chamba 0.10.0 → 0.10.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,4 +1,4 @@
1
- import{A as e,D as t,O as n,S as r,c as i,i as a,j as o,n as s,p as c,s as l,t as u,y as d}from"./api-CguEsvNp.js";import{t as f}from"./useNow-Ww-Gffnk.js";import{i as p,n as m,o as h,s as g,t as _}from"./search-DgFnnu-J.js";var v=e(),y=n(),b=s(`reviews`);b.receive;var x=b.credentialsReady,ee=b.onChange,te=b.onSession;b.openOutside;var S=b.deliver,C=b.sayWaiting,w=b.listen;function ne(e){return b.askTheme(e)}var T=u({prefix:`reviews`,label:`Code Reviews`,credentialsReady:x}),E=T.ask;function D(e){return{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}}var O=e=>`review/${encodeURIComponent(e)}`;function re(){return E(`list`)}function ie(e){return E(O(e))}function k(e,t,n){return E(`${O(e)}/hunks?from=${t}&count=${n}`)}function ae(e,t,n,r){let i=new URLSearchParams({name:t,from:String(n),count:String(r)});return E(`${O(e)}/blob?${i.toString()}`)}function oe(){return E(`options`)}async function se(e){let t=new URLSearchParams({kind:e.kind});for(let[n,r]of Object.entries(e))n===`kind`||r===void 0||r===``||t.set(n,String(r));let[n]=(await E(`options?${t.toString()}`)).options;if(n===void 0)throw Error(`that selection holds nothing to review`);return n}function ce(e){return E(`start`,D(e))}function le(e,t,n={}){return E(`${O(e)}/${t}`,D(n))}T.rawUrl;var A=T.fileUrl;function j(e){return e.open?e.messages[e.messages.length-1]?.from===`agent`:!1}var M={undo:`Undo the change`,explain:`Explain in a comment`,comment:`Comment`,"group-comment":`Comment on group`,fix:`Fix`};function N(e){return e!==`undo`}function ue(e){if(e.length===0)return``;let t=[...e].sort((e,t)=>e-t),n=t[0],r=t[t.length-1];return n===void 0||r===void 0?``:n===r?`L${n}`:`L${n}-${r}`}function P(e,t){return`${e}\n${t}`}var F=`ungrouped`,I=`gone`;function L(e){return e.lines===null||e.lines.length===0?null:Math.min(...e.lines)}function de(e){return e.lines===null||e.lines.length===0?`whole hunk`:ue(e.lines)}var fe=[`issue`,`attention`,`info`];function pe(e){return fe.find(t=>e.includes(t))??`info`}function me(e){return[...e].sort((e,t)=>(L(e)??-1)-(L(t)??-1))}function he(e){return e.unseen+e.issues+e.attention+e.threads+e.pending>0}function R(e){return e.unseen+e.issues+e.attention+e.threads+e.pending}function ge(e){let t=[],n=(e,t,n)=>e===1?t:n;if(e.unseen>0&&t.push({kind:`unseen`,count:e.unseen,text:`${n(e.unseen,`hunk`,`hunks`)} not Seen`}),e.attention>0&&t.push({kind:`attention`,count:e.attention,text:`attention ${n(e.attention,`note`,`notes`)} open`}),e.issues>0&&t.push({kind:`issues`,count:e.issues,text:`issue ${n(e.issues,`note`,`notes`)} open`}),e.threads>0){let r=e.unreadReplies>0?`, with ${e.unreadReplies} ${n(e.unreadReplies,`reply`,`replies`)} you have not read`:``;t.push({kind:`threads`,count:e.threads,text:`${n(e.threads,`conversation`,`conversations`)} open${r}`})}return e.pending>0&&t.push({kind:`pending`,count:e.pending,text:`feedback ${n(e.pending,`item`,`items`)} pending, not sent`}),t}function z(e,t){return`${e}\n${t}`}function _e(e,t=new Set){let n=(e.baseline?.entries??[]).map(e=>e.id),r=new Map(n.map((e,t)=>[e,t])),i=new Set(e.marks.marks.map(e=>e.hunk)),a=new Set(e.marks.changed.map(e=>e.hunk).filter(e=>r.has(e))),o=new Set([...e.metadata.groups.map(e=>e.id),F]),s=new Map;for(let t of e.metadata.notes)s.set(t.hunk,[...s.get(t.hunk)??[],t]);let c=new Map;for(let t of e.dismissals.items)c.set(t.hunk,(c.get(t.hunk)??new Set).add(t.key));let l=new Map,u=new Map;for(let[e,t]of s){let n=me(t);l.set(e,n);let r=c.get(e);u.set(e,n.filter(e=>r===void 0||!r.has(e.key)))}let d=new Map,f=new Set,p=[];for(let n of e.threads.threads){let e=n.kind===`hunk`&&n.open&&n.label===`hunk-removed`,i=n.kind===`group`?o.has(n.anchor):r.has(n.anchor)||e;if(e&&p.push(n),!i)continue;let a=z(n.kind,n.anchor);d.set(a,[...d.get(a)??[],n]);for(let e of n.messages)e.from!==`agent`||e.readAt!==null||t.has(e.id)||f.add(e.id)}return{side:e.state.side,order:n,places:r,seen:i,changed:a,open:u,notes:l,aside:c,threads:d,unread:f,gone:p}}function ve(e,t){if(t===null)return[...e.order];let n=new Map;for(let r of t.hunks){let t=e.places.get(r);t!==void 0&&n.set(r,t)}return[...n.keys()].sort((e,t)=>(n.get(e)??0)-(n.get(t)??0))}function ye(e,t){let n=ve(e,t),r=0,i=0,a=0,o=0,s=0;for(let c of n){e.seen.has(c)&&(r+=1),e.changed.has(c)&&(s+=1);for(let t of e.open.get(c)??[])t.kind===`issue`?i+=1:t.kind===`attention`&&(a+=1);t!==null&&(o+=Se(e,z(`hunk`,c)))}return t===null?o=e.unread.size:o+=Se(e,z(`group`,t.id)),{hunks:n.length,seen:r,unseen:n.length-r,issues:i,attention:a,replies:o,changed:s,waiting:be(e,t,n)}}function be(e,t,n){if(e.side===`agent`)return 0;let r=t===null?[...e.threads.keys()]:[...n.map(e=>z(`hunk`,e)),z(`group`,t.id)],i=0;for(let t of r)for(let n of e.threads.get(t)??[])j(n)&&(i+=1);return i}function xe(e){let t={info:0,attention:0,issue:0};for(let n of e.notes.values())for(let e of n)t[e.kind]+=1;return t}function Se(e,t){let n=0;for(let r of e.threads.get(t)??[])for(let t of r.messages)e.unread.has(t.id)&&(n+=1);return n}var B=`.reviews`,Ce=`archive`,we=`pending.json`,Te=`reader-state.json`,Ee=`signature.png`,De=`baseline`,Oe=`baseline.next`,ke=`baseline.gone`,Ae=`diff.patch`,je=`blobs`,Me=`metadata.json`;`${B}${Oe}`,`${B}${ke}`,`${B}${De}${Ae}`,`${B}${De}${je}`,`${B}${De}${Me}`,`${B}${we}`,`${B}${Te}`,`${Ce}${B}${Oe}`,`${Ce}${B}${ke}`,`${Ce}${B}${De}${Ae}`,`${Ce}${B}${De}${je}`,`${Ce}${B}${De}${Me}`,`${Ce}${B}${we}`,`${Ce}${B}${Te}`;var Ne=12;function Pe(e){let t=e=>e.slice(0,Ne);if(e.followed!==null)return`commit ${t(e.followed)}`;if(e.kind===`branch`||e.kind===`other-branch`){let n=e.baseRef??t(e.base),r=`${e.head} against ${n}`;return e.uncommitted?`${r} - includes uncommitted changes`:r}return e.kind===`range`?`${t(e.base)}..${t(e.head)}`:e.kind===`last-commit`?`last commit ${t(e.head)}`:`commit ${t(e.head)}`}var Fe=2e3;function Ie(e){return e.side===`you`&&e.status===`reviewing`}function Le(e){return e.side===`agent`?`Read-only while the agent works on this review.`:e.status===`reviewing`?``:`Read-only: this review is ${e.status}.`}function Re(e){return e.side===`agent`}var ze=600*1e3;function Be(e,t){if(e===null)return!1;let n=new Date(e).getTime();return!Number.isNaN(n)&&t.getTime()-n>ze}function Ve(e){return e===`agent`?`Not grouped yet`:`Ungrouped`}var He=`Hunks that are gone`;function Ue(e,t){let n=e.place.group;return n===`all`?`all`:n!==null&&t.some(e=>e.id===n)?n:t[0]?.id??`all`}function We(e){let t=e.state.agent.groups;return t===null?0:Math.max(0,t-e.metadata.groups.length)}function Ge(e,t){let n=new Set(e.hunks),r=[],i=new Set;for(let a of t){if(a.id===e.id)continue;let t=a.hunks.filter(e=>n.has(e));if(t.length!==0){r.push(a.name);for(let e of t)i.add(e)}}return{count:i.size,groups:r}}function Ke(e){let t=new Map;for(let n of e)for(let e of n.hunks)t.set(e,[...t.get(e)??[],n.name]);return t}function qe(e){let t=e.metadata.groups.map(e=>({id:e.id,name:e.name,narrative:e.narrative,facts:e.facts,hunks:e.hunks}));return e.ungrouped.length>0&&t.push({id:F,name:Ve(e.state.side),narrative:``,facts:[],hunks:e.ungrouped}),t}var V=t(),Je=2*Math.PI*5.5;function Ye(e){return(0,V.jsxs)(`svg`,{className:`rv-ring`,viewBox:`0 0 14 14`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{className:`rv-ring-bg`,cx:`7`,cy:`7`,r:`5.5`}),(0,V.jsx)(`circle`,{className:`rv-ring-fg`,cx:`7`,cy:`7`,r:`5.5`,strokeDasharray:`${(Je*e.part).toFixed(2)} ${Je.toFixed(2)}`})]})}function Xe(e,t){return`${e} ${t}${e===1?``:`s`}`}var Ze=`The agent's notes on this review, whatever their state: dismissed ones count too.`,Qe=`notes-held`;function $e(e){let t=a({className:`rv-infotip`,side:`bottom`}),n=e.review,r=n.baseline,i=e.index,o=e.sections,s=xe(i),l=s.issue+s.attention,u=We(n),f=t=>{let n=e.summary.of(t.id).counts,r=n.hunks>0&&n.unseen===0,i=n.hunks===0;return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`nav-entry rv-gi${r?` is-done`:``}${i?` is-empty`:``}`,"aria-current":t.id===e.group?`true`:void 0,onClick:()=>e.onPick(t.id),children:[(0,V.jsx)(`span`,{className:`nav-entry-name rv-gname`,children:t.name}),(0,V.jsxs)(`span`,{className:`rv-gdots`,children:[n.issues>0&&(0,V.jsx)(`i`,{className:`rv-gdot is-issue`}),n.attention>0&&(0,V.jsx)(`i`,{className:`rv-gdot is-attention`}),n.replies>0&&(0,V.jsx)(`i`,{className:`rv-gdot is-reply`})]}),(0,V.jsx)(`span`,{className:`rv-gright`,children:r?(0,V.jsx)(`span`,{className:`rv-gcheck`,role:`img`,"aria-label":`every hunk seen`,children:`✓`}):(0,V.jsxs)(V.Fragment,{children:[n.seen,` of `,n.hunks,(0,V.jsx)(Ye,{part:n.hunks===0?0:n.seen/n.hunks})]})})]})},t.id)};return(0,V.jsxs)(`nav`,{className:`nav`,"aria-label":`The groups of this review`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`nav-back`,onClick:e.onBack,children:[(0,V.jsx)(c,{size:11}),`Reviews`]}),(0,V.jsxs)(`div`,{className:`nav-title`,children:[(0,V.jsx)(`div`,{className:`nav-title-name`,children:n.state.name}),(0,V.jsx)(`div`,{className:`nav-title-note rv-gnote`,children:r===null?`no baseline`:(0,V.jsxs)(V.Fragment,{children:[Xe(r.totals.files,`file`),` ·`,` `,(0,V.jsxs)(`span`,{className:`rv-plus`,children:[`+`,r.totals.added]}),` `,(0,V.jsxs)(`span`,{className:`rv-minus`,children:[`-`,r.totals.deleted]}),` lines`,(0,V.jsx)(`br`,{}),Xe(r.totals.hunks,`hunk`),` ·`,` `,Xe(n.metadata.groups.length,`group`),l>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`br`,{}),Xe(s.issue,`issue`),` · `,s.attention,` attention`,` `,(0,V.jsxs)(`button`,{type:`button`,className:`rv-info`,"aria-label":`What the counts hold`,"aria-describedby":Qe,...t.anchor,children:[(0,V.jsx)(d,{size:13}),(0,V.jsx)(`span`,{className:`visually-hidden`,id:Qe,children:Ze}),t.says(Ze)]})]})]})})]}),(0,V.jsxs)(`h2`,{className:`nav-head`,children:[(0,V.jsx)(`span`,{children:`Groups`}),(0,V.jsx)(`span`,{className:`nav-head-count`,children:n.metadata.groups.length})]}),(0,V.jsxs)(`ul`,{className:`nav-list`,children:[o.map(f),Array.from({length:u},(e,t)=>`coming-${t}`).map(e=>(0,V.jsx)(`li`,{className:`rv-gwait`,"aria-hidden":`true`,children:(0,V.jsx)(`span`,{className:`rv-skel is-wide`})},e)),u>0&&(0,V.jsxs)(`li`,{className:`visually-hidden`,children:[Xe(u,`more group`),` `,u===1?`is`:`are`,` still being prepared`]}),(0,V.jsx)(`li`,{className:`rv-gsep`,children:(0,V.jsx)(`button`,{type:`button`,className:`nav-entry rv-gi`,"aria-current":e.group===`all`?`true`:void 0,onClick:()=>e.onPick(`all`),children:(0,V.jsx)(`span`,{className:`nav-entry-name rv-gname`,children:`All groups`})})})]})]})}var et=350,tt={"branch-reflog":`base found from the reflog`,"head-reflog":`base found from the reflog`,upstream:`base found from the upstream`,"merge-base":`base found from the merge base`,chosen:`base you chose`,parent:`base is the commit's parent`,range:`base is the start of the range`,root:`base is the repository's first commit`},nt=e=>e.slice(0,7);function rt(e){if(e===null)return``;let t=e.summary,n=t.commits.length;return[`${t.files} file${t.files===1?``:`s`}`,`${t.hunks} hunk${t.hunks===1?``:`s`}`,`${n} commit${n===1?``:`s`}`].join(` - `)}function it(e){if(e===null)return``;let t=e.selection;if(t.kind===`branch`||t.kind===`other-branch`){let e=(t.head.split(`/`).pop()??t.head).replace(/[-_]+/g,` `).trim();return e.charAt(0).toUpperCase()+e.slice(1)}let n=e.summary.commits[0]?.subject??``;return n===``?e.label:n}function at(e){let t=(0,v.useMemo)(()=>{let t=e.offer.options;return{branch:t.find(e=>e.kind===`branch`)??null,last:t.find(e=>e.kind===`last-commit`)??null,others:t.filter(e=>e.kind===`other-branch`)}},[e.offer]),n=t.branch===null?e.offer.notOffered:null,r=e.draft,[i,a]=(0,v.useState)(r?.picked??null),[o,s]=(0,v.useState)(r?.base??null),[c,l]=(0,v.useState)(r?.commit??``),[u,d]=(0,v.useState)(r?.from??``),[f,p]=(0,v.useState)(r?.to??``),[m,h]=(0,v.useState)(r?.other??``),[g,_]=(0,v.useState)(r?.uncommitted??!0),[y,b]=(0,v.useState)(r?.name??``),[x,ee]=(0,v.useState)(r?.named??!1),te=e.onDraft;(0,v.useEffect)(()=>{te({picked:i,base:o,commit:c,from:u,to:f,other:m,uncommitted:g,name:y,named:x})},[i,o,c,u,f,m,g,y,x,te]);let[S,C]=(0,v.useState)(!1),[w,ne]=(0,v.useState)(null),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),re=e=>e===`branch`?t.branch!==null||n!==null:e===`last-commit`?t.last!==null:e!==`other-branch`||t.others.length>0,ie=t.branch===null?`last-commit`:`branch`,k=i!==null&&re(i)?i:ie,ae=t.branch?.selection.head??n?.branch??``,oe=t.branch?.selection.baseRef??t.branch?.selection.base??``,le=o??oe,A=m===``?t.others[0]??null:t.others.find(e=>e.selection.head===m)??null,j=(0,v.useMemo)(()=>{if(k===`branch`)return o===null||o.trim()===``||o===oe?null:{kind:`branch`,base:o.trim(),uncommitted:g};if(k===`commit`)return c.trim()===``?null:{kind:`commit`,commit:c.trim()};if(k===`range`){let e={from:u.trim(),to:f.trim()};return e.from===``||e.to===``?null:{kind:`range`,...e}}return null},[k,o,oe,g,c,u,f]);(0,v.useEffect)(()=>{if(j===null){E(null),O(null);return}let e=!0,t=setTimeout(()=>{se(j).then(t=>{e&&(E(t),O(null))}).catch(t=>{e&&(E(null),O(t.message))})},et);return()=>{e=!1,clearTimeout(t)}},[j]);let M=k===`branch`?j===null?t.branch:T:k===`last-commit`?t.last:k===`other-branch`?A:T,N=it(M),ue=x?y:N,P=e=>{a(e),ne(null)},F=async()=>{if(M!==null){C(!0),ne(null);try{let t=k===`branch`?{kind:`branch`,uncommitted:g,...j===null?{}:{base:le.trim()}}:k===`last-commit`?{kind:`last-commit`}:k===`commit`?{kind:`commit`,commit:c.trim()}:k===`range`?{kind:`range`,from:u.trim(),to:f.trim()}:{kind:`other-branch`,branch:M.selection.head};e.onStarted(await ce({name:ue,selection:t}))}catch(e){ne(e instanceof Error?e.message:`the review was not filed`),C(!1)}}},I=e=>{let t=e?.summary.commits??[],n=t.slice(0,5);return(0,V.jsxs)(`ul`,{className:`rv-commits`,children:[n.map(e=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{className:`rv-mono`,children:nt(e.hash)}),` `,e.subject]},e.hash)),t.length>n.length&&(0,V.jsxs)(`li`,{children:[`+ `,t.length-n.length,` more`]})]})},L=k===`branch`?M:t.branch,de=()=>L===null?n===null?``:`pick a base`:rt(L),fe=()=>{let e=k===`branch`&&D!==null?D:null;if(L!==null){let t=tt[L.selection.baseFoundBy];return e===null?t:`${t} - ${e}`}return e??n?.reason??``},pe=()=>L?.uncommitted.files??t.branch?.uncommitted.files??0,me=(e,t,n,r,i=null)=>(0,V.jsxs)(`label`,{className:`rv-opt${k===e?` is-chosen`:``}`,children:[(0,V.jsx)(`input`,{type:`radio`,className:`rv-radio-input`,name:`rv-what-to-review`,checked:k===e,onChange:()=>P(e)}),(0,V.jsx)(`span`,{className:`rv-radio`,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{className:`rv-opt-title`,children:[(0,V.jsx)(`b`,{children:t}),(0,V.jsx)(`span`,{className:`rv-count`,children:n})]}),r,i]});return(0,V.jsx)(`div`,{className:`rv-screen`,children:(0,V.jsxs)(`div`,{className:`rv-form`,children:[(0,V.jsx)(`h2`,{children:`New review`}),(0,V.jsx)(`p`,{className:`rv-lead`,children:`Pick what to review. The agent in this session prepares it.`}),(0,V.jsxs)(`div`,{className:`rv-form-row`,children:[(0,V.jsx)(`h3`,{children:`What to review`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.reading,onClick:e.onRefresh,children:e.reading?`Reading…`:`Refresh`})]}),(0,V.jsx)(`p`,{className:`rv-lead`,children:`Each option shows what it holds now. The base and the name can be changed before the review starts.`}),(0,V.jsxs)(`div`,{role:`radiogroup`,"aria-label":`What to review`,children:[e.reading&&e.offer.options.length===0&&(0,V.jsxs)(`p`,{className:`rv-opt is-waiting`,"aria-live":`polite`,children:[(0,V.jsx)(`span`,{className:`rv-dot`}),`Reading the repository. The current branch, the last commit and the other branches appear here once they are counted.`]}),(t.branch!==null||n!==null)&&me(`branch`,`Current branch against its base`,de(),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:`rv-opt-detail`,children:[(0,V.jsx)(`span`,{className:`rv-mono`,children:ae}),` against`,` `,(0,V.jsx)(`input`,{className:`rv-mono`,"aria-label":`The base of this branch`,placeholder:n===null?void 0:`base`,value:le,onChange:e=>{s(e.target.value),P(`branch`)}}),` `,(0,V.jsx)(`span`,{children:fe()})]}),pe()>0&&(0,V.jsxs)(`label`,{className:`rv-check`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked)}),` `,`Include uncommitted changes (`,pe(),` files)`]})]}),I(k===`branch`?M:t.branch)),t.last!==null&&me(`last-commit`,`The last commit`,rt(t.last),null,I(t.last)),me(`commit`,`A specific commit`,k===`commit`&&T!==null?rt(T):`pick one`,(0,V.jsxs)(`span`,{className:`rv-opt-detail`,children:[(0,V.jsx)(`input`,{className:`rv-mono`,placeholder:`commit`,"aria-label":`A commit to review`,value:c,onChange:e=>{l(e.target.value),P(`commit`)}}),` `,(0,V.jsx)(`span`,{children:k===`commit`&&D!==null?D:`files, hunks and the commit line appear once a commit is typed`})]}),k===`commit`?I(T):null),me(`range`,`A commit range`,k===`range`&&T!==null?rt(T):`pick two`,(0,V.jsxs)(`span`,{className:`rv-opt-detail`,children:[(0,V.jsx)(`input`,{className:`rv-mono`,placeholder:`from`,"aria-label":`The start of the range`,value:u,onChange:e=>{d(e.target.value),P(`range`)}}),` `,`..`,` `,(0,V.jsx)(`input`,{className:`rv-mono`,placeholder:`to`,"aria-label":`The end of the range`,value:f,onChange:e=>{p(e.target.value),P(`range`)}}),` `,(0,V.jsx)(`span`,{children:k===`range`&&D!==null?D:`the commits in the range are listed here`})]}),k===`range`?I(T):null),t.others.length>0&&me(`other-branch`,`Another branch against its base`,`${t.others.length} branch${t.others.length===1?``:`es`}`,(0,V.jsxs)(`span`,{className:`rv-opt-detail`,children:[(0,V.jsx)(`select`,{"aria-label":`Which branch to review`,value:A?.selection.head??``,onChange:e=>{h(e.target.value),P(`other-branch`)},children:t.others.map(e=>(0,V.jsx)(`option`,{value:e.selection.head,children:e.selection.head},e.selection.head))}),` `,`against`,` `,(0,V.jsx)(`span`,{className:`rv-mono`,children:A?.selection.baseRef??nt(A?.selection.base??``)}),` `,`- `,rt(A)]}),k===`other-branch`?I(A):null)]}),(0,V.jsxs)(`div`,{className:`rv-form-foot`,children:[(0,V.jsx)(`label`,{htmlFor:`rv-name`,children:`Name`}),(0,V.jsx)(`input`,{id:`rv-name`,value:ue,onChange:e=>{ee(!0),b(e.target.value)}})]}),(0,V.jsx)(`p`,{className:`rv-form-note`,children:`Name proposed from the selection. The agent in this session prepares the review as soon as it is started.`}),w!==null&&(0,V.jsx)(`p`,{className:`rv-refused`,children:w}),(0,V.jsxs)(`div`,{className:`rv-form-acts`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-btn`,onClick:e.onCancel,children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-primary`,disabled:M===null||ue.trim()===``||S,onClick:()=>void F(),children:`Start review`})]})]})})}function ot(e){let t=R(e);return`Approved with ${t} ${t===1?`thing`:`things`} left as ${t===1?`it was`:`they were`}`}function st(e){let t=e.left,n=a({className:`rv-tip${e.plain?` is-plain`:``}`,side:`right`});if(t===null||!he(t))return null;let r=ot(t);return(0,V.jsxs)(`span`,{className:`rv-left-mark${e.plain?` is-plain`:``}`,...n.anchor,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`!`}),(0,V.jsx)(`span`,{className:`visually-hidden`,children:r}),n.says((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`b`,{children:r}),(0,V.jsx)(`ul`,{children:ge(t).map(e=>(0,V.jsxs)(`li`,{children:[e.count,` `,e.text]},e.kind))}),(0,V.jsx)(`small`,{children:`Counted at the moment of signing. Acknowledged by the signer.`})]}))]})}function ct(e){if(e===null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString()}function lt(e){return e.relation===null?null:e.relation.relation===`out-of-sync`?{text:`Out of sync`,kind:``}:e.relation.relation===`merged`?{text:`Merged`,kind:`is-merged`}:null}function ut(e){return e.approved===null?``:`${e.approved?`Approved`:`Closed`} ${ct(e.endedAt)}`.trim()}function dt(e){return[e.name,e.branch??``,e.selection,ct(e.endedAt),ut(e)].join(` `)}function ft(e){let t=e.now??new Date,[n,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=(0,v.useMemo)(()=>_(e.archived,a,dt),[e.archived,a]),c=n=>{let r=lt(n),i=n.status===`reviewing`?``:ut(n),a=n.side===`agent`&&n.status===`reviewing`;return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`rv-row nav-row`,"aria-current":n.slug===e.open?`true`:void 0,disabled:n.missing,onClick:()=>e.onOpen(n.slug),children:[(0,V.jsxs)(`span`,{className:`rv-row-top`,children:[(0,V.jsx)(`span`,{className:`rv-row-name`,children:n.name}),r!==null&&(0,V.jsx)(`span`,{className:`rv-row-chip ${r.kind}`.trim(),children:r.text})]}),i===``?(0,V.jsx)(`span`,{className:`rv-bar`,children:(0,V.jsx)(`i`,{style:{width:`${pt(n)}%`}})}):(0,V.jsxs)(`span`,{className:`nav-row-sub`,children:[i,(0,V.jsx)(st,{left:n.leftAsIs,plain:!0})]}),a&&(0,V.jsxs)(`span`,{className:`rv-row-state`,children:[(0,V.jsx)(`span`,{className:`rv-dot`}),n.activity===``?`Awaits agent`:`Awaits agent - ${n.activity}`]}),n.missing&&(0,V.jsx)(`span`,{className:`rv-row-note`,children:`Missing on this branch`}),n.filedBy===`terminal`&&n.status===`reviewing`&&!n.missing&&(0,V.jsxs)(`span`,{className:`rv-row-note`,children:[`Filed from the terminal `,l(n.created,t)]})]})},n.slug)};return(0,V.jsxs)(`nav`,{className:`nav`,"aria-label":`Code reviews`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`nav-new`,"aria-pressed":e.starting,disabled:!e.repository,onClick:e.onStart,children:[(0,V.jsx)(r,{size:12}),`New review`]}),e.error!==null&&(0,V.jsx)(`p`,{className:`nav-note`,children:e.error}),(0,V.jsxs)(`h2`,{className:`nav-head`,children:[(0,V.jsx)(`span`,{children:`Active`}),(0,V.jsx)(`span`,{className:`nav-head-count`,children:e.active.length})]}),e.active.length===0?(0,V.jsx)(`p`,{className:`nav-empty`,children:`none yet`}):(0,V.jsx)(`ul`,{className:`nav-list`,children:e.active.map(c)}),e.archived.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`nav-head`,children:(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>i(e=>!e),children:[(0,V.jsx)(`span`,{children:`Archived`}),(0,V.jsxs)(`span`,{className:`nav-head-count`,children:[e.archived.length,` `,n?`▾`:`▸`]})]})}),n&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`nav-search`,children:(0,V.jsx)(`input`,{type:`search`,"aria-label":`Search the archive`,placeholder:`Search name, branch or date`,value:a,onChange:e=>o(e.target.value)})}),s.length===0?(0,V.jsx)(`p`,{className:`nav-empty`,children:`nothing by that name`}):(0,V.jsx)(`ul`,{className:`nav-list nav-archived`,children:s.map(c)})]})]})]})}function pt(e){return e.progress.total===0?0:Math.round(e.progress.seen/e.progress.total*100)}function mt(e){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(``);return t?(0,V.jsxs)(`div`,{className:`rv-aclose`,children:[(0,V.jsx)(`textarea`,{"aria-label":`Why it is closed without approval`,rows:2,value:r,disabled:e.busy,onChange:e=>i(e.target.value)}),(0,V.jsxs)(`span`,{className:`rv-aclose-acts`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy||r.trim()===``,onClick:()=>e.onClose(r.trim()),children:`Close without approval`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,onClick:()=>n(!1),children:`Cancel`})]})]}):(0,V.jsxs)(`div`,{className:`rv-aclose`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,disabled:e.busy,onClick:()=>n(!0),children:`Close without approval`}),(0,V.jsx)(`span`,{className:`rv-facts`,children:`Opens a box for the reason.`})]})}function ht(e){if(e===null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function gt(e){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t+1),r=e.slice(t+1);return r.length<=12?e:`${n}${r.slice(0,6)}…${r.slice(-4)}`}function _t(e){let t=e.baseline?.resolved;if(t===void 0)return`no baseline`;let n=t.head.slice(0,7);return t.tree?`${n}, includes uncommitted changes`:`${n}, working copy clean`}function vt(e){let t=e.relation?.relation??null;return t===null?`unknown`:t.replaceAll(`-`,` `)}function yt(e){return e===0?`Sign and approve`:`Sign and approve with ${e} ${e===1?`thing`:`things`} left`}function bt(e){let t=e.review,n=t.leftAsIs,r=R(n),i=ge(n),[a,o]=(0,v.useState)(t.configuredName),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=(0,v.useRef)(!1),{onCancel:p}=e;(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&p()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p]);let m=e=>{let t=d.current;if(t===null)return null;let n=t.getBoundingClientRect();return n.width===0||n.height===0?null:{x:(e.clientX-n.left)/n.width*t.width,y:(e.clientY-n.top)/n.height*t.height}},h=(e,t)=>{let n=d.current?.getContext(`2d`)??null,r=m(e);if(!(n===null||r===null)){if(n.strokeStyle=`#e6edf3`,n.lineWidth=2,n.lineCap=`round`,t){n.beginPath(),n.moveTo(r.x,r.y);return}n.lineTo(r.x,r.y),n.stroke(),u(!0)}},g=()=>{let e=d.current,t=e?.getContext(`2d`)??null;e!==null&&t!==null&&t.clearRect(0,0,e.width,e.height),u(!1)},_=()=>{let e=d.current;if(!l||e===null)return null;let t=e.toDataURL(`image/png`);return t.startsWith(`data:image/png;base64,`)?t:null},y=e.busy||a.trim()===``||r>0&&!s;return(0,V.jsx)(`div`,{className:`dialog-shade`,children:(0,V.jsxs)(`form`,{className:`dialog dialog-wide rv-adialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Approve "${t.state.name}"`,onSubmit:t=>{t.preventDefault(),!y&&e.onApprove(a.trim(),_(),r>0)},children:[(0,V.jsxs)(`h2`,{className:`rail-head rv-adialog-head`,children:[(0,V.jsxs)(`span`,{children:[`Approve "`,t.state.name,`"`]}),(0,V.jsx)(`button`,{type:`button`,className:`rv-icon rv-adialog-x`,"aria-label":`Close the dialog`,onClick:e.onCancel,children:`×`})]}),(0,V.jsxs)(`div`,{className:`dialog-body`,children:[(0,V.jsxs)(`div`,{className:`rv-ameta`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Review`}),(0,V.jsx)(`span`,{className:`rv-v`,children:t.state.name})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Feedback loops`}),(0,V.jsx)(`span`,{className:`rv-v`,children:t.loops})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Hunks Seen`}),(0,V.jsxs)(`span`,{className:`rv-v`,children:[t.progress.seen,` of `,t.progress.total]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Fingerprint`}),(0,V.jsx)(`span`,{className:`rv-v rv-mono`,title:t.baseline?.fingerprint??``,children:gt(t.baseline?.fingerprint??``)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Commit`}),(0,V.jsx)(`span`,{className:`rv-v rv-mono`,children:_t(t)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Tree`}),(0,V.jsx)(`span`,{className:`rv-v`,children:vt(t)})]})]}),he(n)?(0,V.jsxs)(`section`,{className:`rv-left`,"aria-label":`Left as it is`,children:[(0,V.jsxs)(`h3`,{children:[(0,V.jsx)(`span`,{className:`rv-left-mark`,"aria-hidden":`true`,children:`!`}),`This approval leaves the following as it is`]}),(0,V.jsx)(`ul`,{children:i.map(t=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`b`,{children:t.count}),(0,V.jsx)(`span`,{children:t.text}),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:()=>e.onGoTo(t.kind),children:`Go to the first`})]},t.kind))}),(0,V.jsxs)(`label`,{className:`rv-left-ack`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:s,disabled:e.busy,onChange:e=>c(e.target.checked)}),(0,V.jsx)(`span`,{children:`I reviewed this change, in the tool or outside it, and I approve it with these left as they are. The record will say so.`})]})]}):(0,V.jsx)(`p`,{className:`rv-left is-clean`,children:`Every hunk is Seen, every conversation is closed, and nothing awaits the agent.`}),(0,V.jsxs)(`div`,{className:`rv-asign`,children:[(0,V.jsxs)(`p`,{className:`rv-field`,children:[(0,V.jsxs)(`label`,{htmlFor:`rv-signer`,children:[`Your name `,(0,V.jsx)(`small`,{children:`from git`})]}),(0,V.jsx)(`input`,{id:`rv-signer`,value:a,disabled:e.busy,onChange:e=>o(e.target.value)})]}),(0,V.jsxs)(`p`,{className:`rv-field`,children:[(0,V.jsxs)(`span`,{className:`rv-label`,children:[`Signature `,(0,V.jsx)(`small`,{children:`optional`})]}),(0,V.jsxs)(`span`,{className:`rv-sig`,children:[(0,V.jsx)(`canvas`,{ref:d,width:520,height:160,"aria-label":`Signature`,onPointerDown:e=>{f.current=!0,e.currentTarget.setPointerCapture?.(e.pointerId),h(e,!0)},onPointerMove:e=>{f.current&&h(e,!1)},onPointerUp:()=>{f.current=!1},onPointerLeave:()=>{f.current=!1}}),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,disabled:!l,onClick:g,children:`clear`})]})]})]})]}),(0,V.jsxs)(`div`,{className:`dialog-acts rv-adialog-acts`,children:[(0,V.jsx)(mt,{busy:e.busy,onClose:e.onClose}),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsxs)(`span`,{className:`rv-facts`,children:[`Approves as of commit `,(t.baseline?.resolved.head??``).slice(0,7)]}),(0,V.jsx)(`button`,{type:`submit`,className:`rv-btn ${r>0?`is-warn`:`is-ok`}`,disabled:y,children:yt(r)})]})]})})}function xt(e){let[t,n]=(0,v.useState)(e.text??``),r=M[e.act],i=ue(e.lines),a=t.trim()!==``||!N(e.act);return(0,V.jsxs)(`form`,{className:`rv-compose`,onSubmit:n=>{n.preventDefault(),!(!a||e.busy)&&e.onWrite(t.trim())},children:[(0,V.jsxs)(`p`,{className:`rv-compose-head`,children:[(0,V.jsx)(`b`,{children:r}),i!==``&&(0,V.jsx)(`span`,{className:`rv-facts`,children:i})]}),(0,V.jsx)(`textarea`,{"aria-label":r,rows:3,value:t,disabled:e.busy,onChange:t=>{n(t.target.value),e.onChange?.(t.target.value)}}),(0,V.jsxs)(`p`,{className:`rv-compose-acts`,children:[(0,V.jsx)(`button`,{type:`submit`,className:`rv-btn is-small is-primary`,disabled:!a||e.busy,children:`Add`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,onClick:e.onCancel,children:`Cancel`})]})]})}function St(e){return e.slice(0,10)}function Ct(e){let t=e.approval,[n,r]=(0,v.useState)(null),i=e.slug,a=t.signature;return(0,v.useEffect)(()=>{if(a===null)return;let e=!0;return A(`${i}/${Ee}`).then(t=>{e&&r(t)}),()=>{e=!1}},[a,i]),(0,V.jsxs)(`div`,{className:`rv-ended`,children:[(0,V.jsxs)(`span`,{className:`rv-ended-how`,children:[t.approved?`Approved`:`Closed`,` `,St(t.at),t.name!==``&&(0,V.jsxs)(V.Fragment,{children:[` by `,(0,V.jsx)(`b`,{children:t.name})]})]}),(0,V.jsx)(st,{left:t.leftAsIs}),n!==null&&(0,V.jsx)(`img`,{src:n,alt:`Signed by ${t.name}`}),!t.approved&&t.reason!==``&&(0,V.jsx)(`span`,{className:`rv-reason`,children:t.reason}),(0,V.jsxs)(`span`,{className:`rv-ended-fact`,children:[`fingerprint `,(0,V.jsx)(`span`,{className:`rv-mono`,children:gt(t.fingerprint)})]}),(0,V.jsxs)(`span`,{className:`rv-ended-fact`,children:[`commit `,(0,V.jsx)(`span`,{className:`rv-mono`,children:t.commit.slice(0,7)}),t.uncommitted&&`, with uncommitted changes`]}),(0,V.jsx)(`span`,{className:`rv-grow`}),!e.filed&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy,onClick:e.onArchive,children:`Archive`})]})}var wt={unseen:{next:`Next unseen`,kind:`Unseen`,spent:`All seen`},issue:{next:`Next issue`,kind:`Issue`,spent:`No issues`},attention:{next:`Next attention`,kind:`Attention`,spent:`No attention`},reply:{next:`Next reply`,kind:`Reply`,spent:`No unread replies`}};function Tt(e){return(0,V.jsx)(`div`,{className:`rv-navrow`,children:e.controls.map(t=>{let n=t.kind,r=wt[n];return t.state===`here`?(0,V.jsxs)(`button`,{type:`button`,className:`rv-nav is-${n}`,onClick:()=>e.onWalk(n),children:[(0,V.jsx)(`span`,{className:`rv-navn`,children:t.count}),r.next]},n):t.state===`across`?(0,V.jsxs)(`button`,{type:`button`,className:`rv-nav is-${n} is-morph`,onClick:()=>e.onWalk(n),children:[(0,V.jsx)(`i`,{className:`rv-navdot`,"aria-hidden":`true`}),r.kind,` in `,(0,V.jsx)(`b`,{children:t.section}),` →`]},n):(0,V.jsxs)(`button`,{type:`button`,className:`rv-nav is-${n} is-done`,disabled:!0,children:[(0,V.jsx)(`span`,{className:`rv-navn`,children:`✓`}),r.spent]},n)})})}function Et(e){let t=[`${e.seen} of ${e.hunks} seen`];return e.issues>0&&t.push(`${e.issues} issue${e.issues===1?``:`s`}`),e.attention>0&&t.push(`${e.attention} attention`),e.replies>0&&t.push(`${e.replies} unread ${e.replies===1?`reply`:`replies`}`),t.join(` · `)}function Dt(e){let t=e.section,n=e.counts,r=n.hunks===0?0:Math.round(n.seen/n.hunks*100),i=e.collapse.collapse>=1,a={"--rv-collapse":e.collapse.collapse,"--rv-fold":`${e.collapse.fold}px`};return(0,V.jsxs)(`div`,{className:`rv-ghead${i?` is-compact`:``}${e.under?` is-under`:``}`,style:a,children:[(0,V.jsxs)(`div`,{className:`rv-gtitle`,children:[(0,V.jsx)(`h3`,{children:t.name}),(0,V.jsx)(`span`,{className:`rv-facts`,children:Et(n)}),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsxs)(`span`,{className:`rv-gacts`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:!e.readable||e.busy||n.unseen===0,onClick:e.onBulk,children:`Mark remaining as Seen`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:!e.readable||e.busy,onClick:e.onComment,children:`Comment`})]})]}),(0,V.jsx)(`div`,{className:`rv-gfold`,children:(0,V.jsxs)(`div`,{className:`rv-gfold-in`,ref:e.fold,children:[t.narrative!==``&&(0,V.jsx)(`p`,{className:`rv-gnarr`,children:t.narrative}),t.facts.length>0&&(0,V.jsx)(`ul`,{className:`rv-gfacts`,children:t.facts.map(e=>(0,V.jsx)(`li`,{children:e},e))}),e.shared.count>0&&(0,V.jsxs)(`p`,{className:`rv-gshared`,children:[e.shared.count,` hunk`,e.shared.count===1?``:`s`,` shared with`,` `,e.shared.groups.join(`, `)]})]})}),e.controls!==null&&(0,V.jsx)(Tt,{controls:e.controls,onWalk:e.onWalk}),(0,V.jsx)(`div`,{className:`rv-gstrip`,children:(0,V.jsx)(`i`,{style:{width:`${r}%`}})})]})}function Ot(e){return(0,V.jsxs)(`div`,{className:`rv-allbar`,children:[(0,V.jsx)(`h3`,{children:`All groups`}),(0,V.jsxs)(`span`,{className:`rv-facts`,children:[e.hunks,` hunk`,e.hunks===1?``:`s`,` in `,e.groups,` group`,e.groups===1?``:`s`]}),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsx)(Tt,{controls:e.controls,onWalk:e.onWalk})]})}function kt(e){if(e.feedHeight<=0)return null;let t=e.collapse*e.fold,n=e.sectionTop-e.feedTop+e.scrollTop,r=e.underHeader?t:0,i=e.targetTop-e.feedTop+e.scrollTop+r;if(e.block===`start`){let n=e.underHeader?e.headerHeight+t:0;return Math.max(0,i-e.pinned-n)}let a=i-(e.feedHeight-e.targetHeight)/2,o=n-e.pinned;return!e.underHeader||a<=o?Math.max(0,a):a<=o+2*e.fold?Math.max(0,(a+o)/2):Math.max(0,a-e.fold)}function At(e){return e.aside?(0,V.jsx)(`button`,{type:`button`,className:`rv-hdot`,"aria-label":`Show the notes put aside`,onClick:e.onShow}):(0,V.jsx)(`i`,{className:`rv-hdot`,"aria-hidden":`true`})}var jt={info:`Info`,attention:`Attention`,issue:`Issue`};function Mt(e){return(0,V.jsx)(V.Fragment,{children:e.notes.map(t=>(0,V.jsxs)(v.Fragment,{children:[(0,V.jsx)(Nt,{note:t,aside:e.aside.has(t.key),shown:e.shown.has(t.key),readable:e.readable,readOnlySaid:e.readOnlySaid,busy:e.busy,onAsk:e.onAsk===null?null:()=>e.onAsk?.(t),onTalk:()=>e.onTalk(t),onComment:()=>e.onComment(t),onDismiss:n=>e.onDismiss(t,n)}),e.box!==null&&e.box.note===t.key&&(0,V.jsx)(`div`,{className:`rv-inote-box`,children:e.box.element})]},t.key))})}function Nt(e){let t=e.note;return(0,V.jsxs)(`div`,{className:`rv-inote${t.kind===`info`?``:` is-${t.kind}`}${e.aside?e.shown?` is-dismissed is-back`:` is-dismissed`:``}`,"data-note":t.key,children:[(0,V.jsxs)(`div`,{className:`rv-inote-top`,children:[(0,V.jsx)(`span`,{className:`rv-note-kind`,children:jt[t.kind]}),(0,V.jsx)(`span`,{className:`rv-note-ln`,children:de(t)})]}),(0,V.jsx)(`div`,{className:`rv-note-txt`,children:t.text}),!e.readable&&(0,V.jsx)(`div`,{className:`rv-note-acts`,children:(0,V.jsx)(`span`,{className:`rv-note-locked`,children:e.readOnlySaid})}),e.readable&&(0,V.jsx)(`div`,{className:`rv-note-acts`,children:e.aside?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`rv-note-dismissed`,children:`dismissed`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,disabled:e.busy,onClick:()=>e.onDismiss(!1),children:`Undo`})]}):(0,V.jsxs)(V.Fragment,{children:[t.kind===`issue`&&e.onAsk!==null&&(0,V.jsx)(`button`,{type:`button`,className:`rv-note-act is-fix`,disabled:e.busy,onClick:e.onAsk,children:`Ask to fix`}),t.kind!==`info`&&(0,V.jsx)(`button`,{type:`button`,className:`rv-note-act`,disabled:e.busy,onClick:e.onTalk,children:`Let's talk`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-note-act`,disabled:e.busy,onClick:e.onComment,children:`Comment`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-note-act`,disabled:e.busy,onClick:()=>e.onDismiss(!0),children:`Dismiss`})]})})]})}function Pt(e){return e.from===`agent`?`Agent`:`You`}function Ft(e){let t=e.thread,n=!e.agentHolds&&j(t);return(0,V.jsxs)(`div`,{className:`rv-thread`,"data-thread":t.id,children:[t.messages.map(t=>{let n=t.from===`agent`&&t.readAt===null,r=Pt(t);return(0,V.jsxs)(`div`,{className:`rv-msg${n?` is-unread`:``}`,"data-message":t.id,children:[(0,V.jsxs)(`span`,{className:`rv-who${t.from===`agent`?` is-agent`:``}`,children:[`${r} - `,ht(t.at),n&&(0,V.jsx)(`span`,{className:`rv-new`,children:`new`})]}),(0,V.jsx)(`div`,{className:`rv-msg-body${t.from===`tool`?` is-tool`:``}`,"data-unread":n?t.id:void 0,ref:n?e.watch:void 0,children:t.text})]},t.id)}),(0,V.jsxs)(`div`,{className:`rv-tf`,children:[t.label===`hunk-removed`&&(0,V.jsx)(`span`,{className:`rv-tag`,children:`hunk removed`}),(0,V.jsx)(`span`,{className:t.open?``:`rv-ok`,children:t.open?n?`Waits on you`:`Waits on the agent`:`Closed${t.closedAt===null?``:` ${ht(t.closedAt)}`}`}),t.open&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:!e.readable||e.busy,onClick:e.onClose,children:`Close thread`})]})]})}var It={dockerfile:`docker`,containerfile:`docker`,makefile:`make`,gnumakefile:`make`},Lt={ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,json:`json`,jsonc:`jsonc`,yaml:`yaml`,yml:`yaml`,toml:`toml`,md:`markdown`,markdown:`markdown`,html:`html`,htm:`html`,css:`css`,scss:`scss`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,py:`python`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,kts:`kotlin`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sql:`sql`,graphql:`graphql`,gql:`graphql`,xml:`xml`,svg:`xml`,mk:`make`,ini:`ini`,cfg:`ini`,diff:`diff`,patch:`diff`};function Rt(e){let t=(e.split(`/`).pop()??``).toLowerCase(),n=t.split(`.`)[0]??``,r=It[t]??It[n];if(r!==void 0)return r;let i=t.lastIndexOf(`.`);return i<=0?null:Lt[t.slice(i+1)]??null}var H=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function zt(e){return Bt(e)}function Bt(e){return Array.isArray(e)?Vt(e):e instanceof RegExp?e:typeof e==`object`?Ht(e):e}function Vt(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Bt(e[n]);return t}function Ht(e){let t={};for(let n in e)t[n]=Bt(e[n]);return t}function Ut(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Wt(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Wt(e.substring(0,e.length-1)):e.substr(~t+1)}var Gt=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Kt=class{static hasCaptures(e){return e===null?!1:(Gt.lastIndex=0,Gt.test(e))}static replaceCaptures(e,t,n){return e.replace(Gt,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function qt(e,t){return e<t?-1:+(e>t)}function Jt(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=qt(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function Yt(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Xt(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var Zt=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Qt=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(rn(e),t)}static createFromParsedTheme(e,t){return on(e,t)}_cachedMatchRoot=new Zt(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>en(e.parent,t.parentScopes));return n?new nn(n.fontStyle,n.foreground,n.background):null}},$t=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function en(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!tn(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function tn(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var nn=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function rn(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&Yt(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&Yt(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new an(l,u,e,o,s,c)}}return n}var an=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},U=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(U||{});function on(e,t){e.sort((e,t)=>{let n=qt(e.scope,t.scope);return n!==0||(n=Jt(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new sn(t),o=new nn(n,a.getId(r),a.getId(i)),s=new un(new ln(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new Qt(a,o,s)}var sn=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},cn=Object.freeze([]),ln=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||cn,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},un=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),ln.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(Jt(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new ln(e,t,n,r,i))}},dn=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=pn(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function fn(e){return e}function pn(e){return e}function mn(e,t){let n=[],r=gn(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(hn(i)){let e=[];do e.push(i),i=r.next();while(hn(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function hn(e){return!!e&&!!e.match(/[\w\.:]+/)}function gn(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function _n(e){typeof e.dispose==`function`&&e.dispose()}var vn=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},yn=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},bn=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},xn=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new vn(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new bn;for(let n of e)Sn(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof vn){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Sn(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof vn?wn({baseGrammar:a,selfGrammar:i},r):Cn(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new vn(e))}function Cn(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Tn([r],t,n)}}function wn(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Tn(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Tn(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Tn(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Ut({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Tn(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=jn(i);switch(a.kind){case 0:wn({...t,selfGrammar:t.baseGrammar},n);break;case 1:wn(t,n);break;case 2:Cn(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?Cn(a.ruleName,i,n):wn(i,n)}else a.kind===4?n.add(new yn(a.scopeName,a.ruleName)):n.add(new vn(a.scopeName));break}}}var En=class{kind=0},Dn=class{kind=1},On=class{constructor(e){this.ruleName=e}kind=2},kn=class{constructor(e){this.scopeName=e}kind=3},An=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function jn(e){if(e===`$base`)return new En;if(e===`$self`)return new Dn;let t=e.indexOf(`#`);return t===-1?new kn(e):t===0?new On(e.substring(1)):new An(e.substring(0,t),e.substring(t+1))}var Mn=/\\(\d+)/,Nn=/\\(\d+)/g,Pn=-1,Fn=-2;function In(e){return e}function Ln(e){return e}var Rn=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Kt.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Kt.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Wt(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Kt.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Kt.replaceCaptures(this._contentName,e,t)}},zn=class extends Rn{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Bn=class extends Rn{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Gn(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Kn,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Vn=class extends Rn{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Kn,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Hn=class extends Rn{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new Gn(i,this.id),this.beginCaptures=a,this._end=new Gn(o||`￿`,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Kn;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Un=class extends Rn{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new Gn(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Gn(o,Fn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Kn;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Kn,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||`￿`),this._cachedCompiledWhilePatterns}},Wn=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new zn(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Bn(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Ut({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Vn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Un(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Hn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=jn(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Vn||e instanceof Hn||e instanceof Un)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Gn=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=Mn.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return Nn.lastIndex=0,this.source.replace(Nn,(e,t)=>Xt(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=`￿`,t[i+1]=`￿`,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=`￿`,t[i+1]=`G`,n[i+1]=`￿`,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Kn=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new qn(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new qn(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},qn=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
1
+ import{A as e,D as t,O as n,S as r,c as i,i as a,j as o,n as s,p as c,s as l,t as u,y as d}from"./api-CguEsvNp.js";import{t as f}from"./useNow-Ww-Gffnk.js";import{i as p,n as m,o as h,s as g,t as _}from"./search-DgFnnu-J.js";var v=e(),y=n(),b=s(`reviews`);b.receive;var x=b.credentialsReady,ee=b.onChange,S=b.onSession;b.openOutside;var C=b.deliver,te=b.sayWaiting,w=b.listen;function ne(e){return b.askTheme(e)}var T=u({prefix:`reviews`,label:`Code Reviews`,credentialsReady:x}),E=T.ask;function D(e){return{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}}var O=e=>`review/${encodeURIComponent(e)}`;function k(){return E(`list`)}function re(e){return E(O(e))}function ie(e,t,n){return E(`${O(e)}/hunks?from=${t}&count=${n}`)}function ae(e,t,n,r){let i=new URLSearchParams({name:t,from:String(n),count:String(r)});return E(`${O(e)}/blob?${i.toString()}`)}function A(){return E(`options`)}async function oe(e){let t=new URLSearchParams({kind:e.kind});for(let[n,r]of Object.entries(e))n===`kind`||r===void 0||r===``||t.set(n,String(r));let[n]=(await E(`options?${t.toString()}`)).options;if(n===void 0)throw Error(`that selection holds nothing to review`);return n}function se(e){return E(`start`,D(e))}function ce(e,t,n={}){return E(`${O(e)}/${t}`,D(n))}T.rawUrl;var le=T.fileUrl;function j(e){return e.open?e.messages[e.messages.length-1]?.from===`agent`:!1}var M={undo:`Undo the change`,explain:`Explain in a comment`,comment:`Comment`,"group-comment":`Comment on group`,fix:`Fix`};function N(e){return e!==`undo`}function P(e){if(e.length===0)return``;let t=[...e].sort((e,t)=>e-t),n=t[0],r=t[t.length-1];return n===void 0||r===void 0?``:n===r?`L${n}`:`L${n}-${r}`}function ue(e,t){return`${e}\n${t}`}var F=`ungrouped`,I=`gone`;function de(e){return e.lines===null||e.lines.length===0?null:Math.min(...e.lines)}function fe(e){return e.lines===null||e.lines.length===0?`whole hunk`:P(e.lines)}var pe=[`issue`,`attention`,`info`];function me(e){return pe.find(t=>e.includes(t))??`info`}function he(e){return[...e].sort((e,t)=>(de(e)??-1)-(de(t)??-1))}function ge(e){return e.unseen+e.issues+e.attention+e.threads+e.pending>0}function L(e){return e.unseen+e.issues+e.attention+e.threads+e.pending}function R(e){let t=[],n=(e,t,n)=>e===1?t:n;if(e.unseen>0&&t.push({kind:`unseen`,count:e.unseen,text:`${n(e.unseen,`hunk`,`hunks`)} not Seen`}),e.attention>0&&t.push({kind:`attention`,count:e.attention,text:`attention ${n(e.attention,`note`,`notes`)} open`}),e.issues>0&&t.push({kind:`issues`,count:e.issues,text:`issue ${n(e.issues,`note`,`notes`)} open`}),e.threads>0){let r=e.unreadReplies>0?`, with ${e.unreadReplies} ${n(e.unreadReplies,`reply`,`replies`)} you have not read`:``;t.push({kind:`threads`,count:e.threads,text:`${n(e.threads,`conversation`,`conversations`)} open${r}`})}return e.pending>0&&t.push({kind:`pending`,count:e.pending,text:`feedback ${n(e.pending,`item`,`items`)} pending, not sent`}),t}function z(e,t){return`${e}\n${t}`}function _e(e,t=new Set){let n=(e.baseline?.entries??[]).map(e=>e.id),r=new Map(n.map((e,t)=>[e,t])),i=new Set(e.marks.marks.map(e=>e.hunk)),a=new Set(e.marks.changed.map(e=>e.hunk).filter(e=>r.has(e))),o=new Set([...e.metadata.groups.map(e=>e.id),F]),s=new Map;for(let t of e.metadata.notes)s.set(t.hunk,[...s.get(t.hunk)??[],t]);let c=new Map;for(let t of e.dismissals.items)c.set(t.hunk,(c.get(t.hunk)??new Set).add(t.key));let l=new Map,u=new Map;for(let[e,t]of s){let n=he(t);l.set(e,n);let r=c.get(e);u.set(e,n.filter(e=>r===void 0||!r.has(e.key)))}let d=new Map,f=new Set,p=[];for(let n of e.threads.threads){let e=n.kind===`hunk`&&n.open&&n.label===`hunk-removed`,i=n.kind===`group`?o.has(n.anchor):r.has(n.anchor)||e;if(e&&p.push(n),!i)continue;let a=z(n.kind,n.anchor);d.set(a,[...d.get(a)??[],n]);for(let e of n.messages)e.from!==`agent`||e.readAt!==null||t.has(e.id)||f.add(e.id)}return{side:e.state.side,order:n,places:r,seen:i,changed:a,open:u,notes:l,aside:c,threads:d,unread:f,gone:p}}function ve(e,t){if(t===null)return[...e.order];let n=new Map;for(let r of t.hunks){let t=e.places.get(r);t!==void 0&&n.set(r,t)}return[...n.keys()].sort((e,t)=>(n.get(e)??0)-(n.get(t)??0))}function ye(e,t){let n=ve(e,t),r=0,i=0,a=0,o=0,s=0;for(let c of n){e.seen.has(c)&&(r+=1),e.changed.has(c)&&(s+=1);for(let t of e.open.get(c)??[])t.kind===`issue`?i+=1:t.kind===`attention`&&(a+=1);t!==null&&(o+=Se(e,z(`hunk`,c)))}return t===null?o=e.unread.size:o+=Se(e,z(`group`,t.id)),{hunks:n.length,seen:r,unseen:n.length-r,issues:i,attention:a,replies:o,changed:s,waiting:be(e,t,n)}}function be(e,t,n){if(e.side===`agent`)return 0;let r=t===null?[...e.threads.keys()]:[...n.map(e=>z(`hunk`,e)),z(`group`,t.id)],i=0;for(let t of r)for(let n of e.threads.get(t)??[])j(n)&&(i+=1);return i}function xe(e){let t={info:0,attention:0,issue:0};for(let n of e.notes.values())for(let e of n)t[e.kind]+=1;return t}function Se(e,t){let n=0;for(let r of e.threads.get(t)??[])for(let t of r.messages)e.unread.has(t.id)&&(n+=1);return n}var B=`.reviews`,Ce=`archive`,we=`pending.json`,Te=`reader-state.json`,Ee=`signature.png`,De=`baseline`,Oe=`baseline.next`,ke=`baseline.gone`,Ae=`diff.patch`,je=`blobs`,Me=`metadata.json`;`${B}${Oe}`,`${B}${ke}`,`${B}${De}${Ae}`,`${B}${De}${je}`,`${B}${De}${Me}`,`${B}${we}`,`${B}${Te}`,`${Ce}${B}${Oe}`,`${Ce}${B}${ke}`,`${Ce}${B}${De}${Ae}`,`${Ce}${B}${De}${je}`,`${Ce}${B}${De}${Me}`,`${Ce}${B}${we}`,`${Ce}${B}${Te}`;var Ne=12;function Pe(e){let t=e=>e.slice(0,Ne);if(e.followed!==null)return`commit ${t(e.followed)}`;if(e.kind===`branch`||e.kind===`other-branch`){let n=e.baseRef??t(e.base),r=`${e.head} against ${n}`;return e.uncommitted?`${r} - includes uncommitted changes`:r}return e.kind===`range`?`${t(e.base)}..${t(e.head)}`:e.kind===`last-commit`?`last commit ${t(e.head)}`:`commit ${t(e.head)}`}var Fe=2e3;function Ie(e){return e.side===`you`&&e.status===`reviewing`}function Le(e){return e.side===`agent`?`Read-only while the agent works on this review.`:e.status===`reviewing`?``:`Read-only: this review is ${e.status}.`}function Re(e){return e.side===`agent`}var ze=600*1e3;function Be(e,t){if(e===null)return!1;let n=new Date(e).getTime();return!Number.isNaN(n)&&t.getTime()-n>ze}function Ve(e){return e===`agent`?`Not grouped yet`:`Ungrouped`}var He=`Hunks that are gone`;function Ue(e,t){let n=e.place.group;return n===`all`?`all`:n!==null&&t.some(e=>e.id===n)?n:t[0]?.id??`all`}function We(e){let t=e.state.agent.groups;return t===null?0:Math.max(0,t-e.metadata.groups.length)}function Ge(e,t){let n=new Set(e.hunks),r=[],i=new Set;for(let a of t){if(a.id===e.id)continue;let t=a.hunks.filter(e=>n.has(e));if(t.length!==0){r.push(a.name);for(let e of t)i.add(e)}}return{count:i.size,groups:r}}function Ke(e){let t=new Map;for(let n of e)for(let e of n.hunks)t.set(e,[...t.get(e)??[],n.name]);return t}function qe(e){let t=e.metadata.groups.map(e=>({id:e.id,name:e.name,narrative:e.narrative,facts:e.facts,hunks:e.hunks}));return e.ungrouped.length>0&&t.push({id:F,name:Ve(e.state.side),narrative:``,facts:[],hunks:e.ungrouped}),t}var V=t(),Je=2*Math.PI*5.5;function Ye(e){return(0,V.jsxs)(`svg`,{className:`rv-ring`,viewBox:`0 0 14 14`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{className:`rv-ring-bg`,cx:`7`,cy:`7`,r:`5.5`}),(0,V.jsx)(`circle`,{className:`rv-ring-fg`,cx:`7`,cy:`7`,r:`5.5`,strokeDasharray:`${(Je*e.part).toFixed(2)} ${Je.toFixed(2)}`})]})}function Xe(e,t){return`${e} ${t}${e===1?``:`s`}`}var Ze=`The agent's notes on this review, whatever their state: dismissed ones count too.`,Qe=`notes-held`;function $e(e){let t=a({className:`rv-infotip`,side:`bottom`}),n=e.review,r=n.baseline,i=e.index,o=e.sections,s=xe(i),l=s.issue+s.attention,u=We(n),f=t=>{let n=e.summary.of(t.id).counts,r=n.hunks>0&&n.unseen===0,i=n.hunks===0;return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`nav-entry rv-gi${r?` is-done`:``}${i?` is-empty`:``}`,"aria-current":t.id===e.group?`true`:void 0,onClick:()=>e.onPick(t.id),children:[(0,V.jsx)(`span`,{className:`nav-entry-name rv-gname`,children:t.name}),(0,V.jsxs)(`span`,{className:`rv-gdots`,children:[n.issues>0&&(0,V.jsx)(`i`,{className:`rv-gdot is-issue`}),n.attention>0&&(0,V.jsx)(`i`,{className:`rv-gdot is-attention`}),n.replies>0&&(0,V.jsx)(`i`,{className:`rv-gdot is-reply`})]}),(0,V.jsx)(`span`,{className:`rv-gright`,children:r?(0,V.jsx)(`span`,{className:`rv-gcheck`,role:`img`,"aria-label":`every hunk seen`,children:`✓`}):(0,V.jsxs)(V.Fragment,{children:[n.seen,` of `,n.hunks,(0,V.jsx)(Ye,{part:n.hunks===0?0:n.seen/n.hunks})]})})]})},t.id)};return(0,V.jsxs)(`nav`,{className:`nav`,"aria-label":`The groups of this review`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`nav-back`,onClick:e.onBack,children:[(0,V.jsx)(c,{size:11}),`Reviews`]}),(0,V.jsxs)(`div`,{className:`nav-title`,children:[(0,V.jsx)(`div`,{className:`nav-title-name`,children:n.state.name}),(0,V.jsx)(`div`,{className:`nav-title-note rv-gnote`,children:r===null?`no baseline`:(0,V.jsxs)(V.Fragment,{children:[Xe(r.totals.files,`file`),` ·`,` `,(0,V.jsxs)(`span`,{className:`rv-plus`,children:[`+`,r.totals.added]}),` `,(0,V.jsxs)(`span`,{className:`rv-minus`,children:[`-`,r.totals.deleted]}),` lines`,(0,V.jsx)(`br`,{}),Xe(r.totals.hunks,`hunk`),` ·`,` `,Xe(n.metadata.groups.length,`group`),l>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`br`,{}),Xe(s.issue,`issue`),` · `,s.attention,` attention`,` `,(0,V.jsxs)(`button`,{type:`button`,className:`rv-info`,"aria-label":`What the counts hold`,"aria-describedby":Qe,...t.anchor,children:[(0,V.jsx)(d,{size:13}),(0,V.jsx)(`span`,{className:`visually-hidden`,id:Qe,children:Ze}),t.says(Ze)]})]})]})})]}),(0,V.jsxs)(`h2`,{className:`nav-head`,children:[(0,V.jsx)(`span`,{children:`Groups`}),(0,V.jsx)(`span`,{className:`nav-head-count`,children:n.metadata.groups.length})]}),(0,V.jsxs)(`ul`,{className:`nav-list`,children:[o.map(f),Array.from({length:u},(e,t)=>`coming-${t}`).map(e=>(0,V.jsx)(`li`,{className:`rv-gwait`,"aria-hidden":`true`,children:(0,V.jsx)(`span`,{className:`rv-skel is-wide`})},e)),u>0&&(0,V.jsxs)(`li`,{className:`visually-hidden`,children:[Xe(u,`more group`),` `,u===1?`is`:`are`,` still being prepared`]}),(0,V.jsx)(`li`,{className:`rv-gsep`,children:(0,V.jsx)(`button`,{type:`button`,className:`nav-entry rv-gi`,"aria-current":e.group===`all`?`true`:void 0,onClick:()=>e.onPick(`all`),children:(0,V.jsx)(`span`,{className:`nav-entry-name rv-gname`,children:`All groups`})})})]})]})}var et=350,tt={"branch-reflog":`base found from the reflog`,"head-reflog":`base found from the reflog`,upstream:`base found from the upstream`,"merge-base":`base found from the merge base`,chosen:`base you chose`,parent:`base is the commit's parent`,range:`base is the start of the range`,root:`base is the repository's first commit`},nt=e=>e.slice(0,7);function rt(e){if(e===null)return``;let t=e.summary,n=t.commits.length;return[`${t.files} file${t.files===1?``:`s`}`,`${t.hunks} hunk${t.hunks===1?``:`s`}`,`${n} commit${n===1?``:`s`}`].join(` - `)}function it(e){if(e===null)return``;let t=e.selection;if(t.kind===`branch`||t.kind===`other-branch`){let e=(t.head.split(`/`).pop()??t.head).replace(/[-_]+/g,` `).trim();return e.charAt(0).toUpperCase()+e.slice(1)}let n=e.summary.commits[0]?.subject??``;return n===``?e.label:n}function at(e){let t=(0,v.useMemo)(()=>{let t=e.offer.options;return{branch:t.find(e=>e.kind===`branch`)??null,last:t.find(e=>e.kind===`last-commit`)??null,others:t.filter(e=>e.kind===`other-branch`)}},[e.offer]),n=t.branch===null?e.offer.notOffered:null,r=e.draft,[i,a]=(0,v.useState)(r?.picked??null),[o,s]=(0,v.useState)(r?.base??null),[c,l]=(0,v.useState)(r?.commit??``),[u,d]=(0,v.useState)(r?.from??``),[f,p]=(0,v.useState)(r?.to??``),[m,h]=(0,v.useState)(r?.other??``),[g,_]=(0,v.useState)(r?.uncommitted??!0),[y,b]=(0,v.useState)(r?.extend??!1),[x,ee]=(0,v.useState)(r?.name??``),[S,C]=(0,v.useState)(r?.named??!1),te=e.onDraft;(0,v.useEffect)(()=>{te({picked:i,base:o,commit:c,from:u,to:f,other:m,uncommitted:g,extend:y,name:x,named:S})},[i,o,c,u,f,m,g,y,x,S,te]);let[w,ne]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),[k,re]=(0,v.useState)(null),ie=e=>e===`branch`?t.branch!==null||n!==null:e===`last-commit`?t.last!==null:e!==`other-branch`||t.others.length>0,ae=t.branch===null?`last-commit`:`branch`,A=i!==null&&ie(i)?i:ae,ce=t.branch?.selection.head??n?.branch??``,le=t.branch?.selection.baseRef??t.branch?.selection.base??``,j=o??le,M=m===``?t.others[0]??null:t.others.find(e=>e.selection.head===m)??null,N=(0,v.useMemo)(()=>{if(A===`branch`)return o===null||o.trim()===``||o===le?null:{kind:`branch`,base:o.trim(),uncommitted:g};if(A===`commit`)return c.trim()===``?null:{kind:`commit`,commit:c.trim()};if(A===`range`){let e={from:u.trim(),to:f.trim()};return e.from===``||e.to===``?null:{kind:`range`,...e}}return null},[A,o,le,g,c,u,f]);(0,v.useEffect)(()=>{if(N===null){O(null),re(null);return}let e=!0,t=setTimeout(()=>{oe(N).then(t=>{e&&(O(t),re(null))}).catch(t=>{e&&(O(null),re(t.message))})},et);return()=>{e=!1,clearTimeout(t)}},[N]);let P=A===`branch`?N===null?t.branch:D:A===`last-commit`?t.last:A===`other-branch`?M:D,ue=it(P),F=S?x:ue,I=e=>{a(e),E(null)},de=async()=>{if(P!==null){ne(!0),E(null);try{let t=pe(A)!==null&&y,n=A===`branch`?{kind:`branch`,uncommitted:g,...N===null?{}:{base:j.trim()}}:A===`last-commit`?{kind:`last-commit`,extend:t}:A===`commit`?{kind:`commit`,commit:c.trim(),extend:t}:A===`range`?{kind:`range`,from:u.trim(),to:f.trim(),extend:t}:{kind:`other-branch`,branch:P.selection.head};e.onStarted(await se({name:F,selection:n}))}catch(e){E(e instanceof Error?e.message:`the review was not filed`),ne(!1)}}},fe=e=>{let t=e?.summary.commits??[],n=t.slice(0,5);return(0,V.jsxs)(`ul`,{className:`rv-commits`,children:[n.map(e=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{className:`rv-mono`,children:nt(e.hash)}),` `,e.subject]},e.hash)),t.length>n.length&&(0,V.jsxs)(`li`,{children:[`+ `,t.length-n.length,` more`]})]})},pe=e=>A!==e||P===null||!P.extendable?null:(0,V.jsxs)(`label`,{className:`rv-check`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked)}),` `,`Include commits made on top of it during the review`]}),me=A===`branch`?P:t.branch,he=()=>me===null?n===null?``:`pick a base`:rt(me),ge=()=>{let e=A===`branch`&&k!==null?k:null;if(me!==null){let t=tt[me.selection.baseFoundBy];return e===null?t:`${t} - ${e}`}return e??n?.reason??``},L=()=>me?.uncommitted.files??t.branch?.uncommitted.files??0,R=(e,t,n,r,i=null)=>(0,V.jsxs)(`label`,{className:`rv-opt${A===e?` is-chosen`:``}`,children:[(0,V.jsx)(`input`,{type:`radio`,className:`rv-radio-input`,name:`rv-what-to-review`,checked:A===e,onChange:()=>I(e)}),(0,V.jsx)(`span`,{className:`rv-radio`,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{className:`rv-opt-title`,children:[(0,V.jsx)(`b`,{children:t}),(0,V.jsx)(`span`,{className:`rv-count`,children:n})]}),r,i]});return(0,V.jsx)(`div`,{className:`rv-screen`,children:(0,V.jsxs)(`div`,{className:`rv-form`,children:[(0,V.jsx)(`h2`,{children:`New review`}),(0,V.jsx)(`p`,{className:`rv-lead`,children:`Pick what to review. The agent in this session prepares it.`}),(0,V.jsxs)(`div`,{className:`rv-form-row`,children:[(0,V.jsx)(`h3`,{children:`What to review`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.reading,onClick:e.onRefresh,children:e.reading?`Reading…`:`Refresh`})]}),(0,V.jsx)(`p`,{className:`rv-lead`,children:`Each option shows what it holds now. The base and the name can be changed before the review starts.`}),(0,V.jsxs)(`div`,{role:`radiogroup`,"aria-label":`What to review`,children:[e.reading&&e.offer.options.length===0&&(0,V.jsxs)(`p`,{className:`rv-opt is-waiting`,"aria-live":`polite`,children:[(0,V.jsx)(`span`,{className:`rv-dot`}),`Reading the repository. The current branch, the last commit and the other branches appear here once they are counted.`]}),(t.branch!==null||n!==null)&&R(`branch`,`Current branch against its base`,he(),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:`rv-opt-detail`,children:[(0,V.jsx)(`span`,{className:`rv-mono`,children:ce}),` against`,` `,(0,V.jsx)(`input`,{className:`rv-mono`,"aria-label":`The base of this branch`,placeholder:n===null?void 0:`base`,value:j,onChange:e=>{s(e.target.value),I(`branch`)}}),` `,(0,V.jsx)(`span`,{children:ge()})]}),L()>0&&(0,V.jsxs)(`label`,{className:`rv-check`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked)}),` `,`Include uncommitted changes (`,L(),` files)`]})]}),fe(A===`branch`?P:t.branch)),t.last!==null&&R(`last-commit`,`The last commit`,rt(t.last),pe(`last-commit`),fe(t.last)),R(`commit`,`A specific commit`,A===`commit`&&D!==null?rt(D):`pick one`,(0,V.jsxs)(`span`,{className:`rv-opt-detail`,children:[(0,V.jsx)(`input`,{className:`rv-mono`,placeholder:`commit`,"aria-label":`A commit to review`,value:c,onChange:e=>{l(e.target.value),I(`commit`)}}),` `,(0,V.jsx)(`span`,{children:A===`commit`&&k!==null?k:`the commit alone; where it is HEAD, a box offers to include commits made on top during the review`}),pe(`commit`)]}),A===`commit`?fe(D):null),R(`range`,`A commit range`,A===`range`&&D!==null?rt(D):`pick two`,(0,V.jsxs)(`span`,{className:`rv-opt-detail`,children:[(0,V.jsx)(`input`,{className:`rv-mono`,placeholder:`from`,"aria-label":`The start of the range`,value:u,onChange:e=>{d(e.target.value),I(`range`)}}),` `,`..`,` `,(0,V.jsx)(`input`,{className:`rv-mono`,placeholder:`to`,"aria-label":`The end of the range`,value:f,onChange:e=>{p(e.target.value),I(`range`)}}),` `,(0,V.jsx)(`span`,{children:A===`range`&&k!==null?k:`from is excluded and to is included, as in git; X^..X reviews the one commit X`}),pe(`range`)]}),A===`range`?fe(D):null),t.others.length>0&&R(`other-branch`,`Another branch against its base`,`${t.others.length} branch${t.others.length===1?``:`es`}`,(0,V.jsxs)(`span`,{className:`rv-opt-detail`,children:[(0,V.jsx)(`select`,{"aria-label":`Which branch to review`,value:M?.selection.head??``,onChange:e=>{h(e.target.value),I(`other-branch`)},children:t.others.map(e=>(0,V.jsx)(`option`,{value:e.selection.head,children:e.selection.head},e.selection.head))}),` `,`against`,` `,(0,V.jsx)(`span`,{className:`rv-mono`,children:M?.selection.baseRef??nt(M?.selection.base??``)}),` `,`- `,rt(M)]}),A===`other-branch`?fe(M):null)]}),(0,V.jsxs)(`div`,{className:`rv-form-foot`,children:[(0,V.jsx)(`label`,{htmlFor:`rv-name`,children:`Name`}),(0,V.jsx)(`input`,{id:`rv-name`,value:F,onChange:e=>{C(!0),ee(e.target.value)}})]}),(0,V.jsx)(`p`,{className:`rv-form-note`,children:`Name proposed from the selection. The agent in this session prepares the review as soon as it is started.`}),T!==null&&(0,V.jsx)(`p`,{className:`rv-refused`,children:T}),(0,V.jsxs)(`div`,{className:`rv-form-acts`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-btn`,onClick:e.onCancel,children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-primary`,disabled:P===null||F.trim()===``||w,onClick:()=>void de(),children:`Start review`})]})]})})}function ot(e){let t=L(e);return`Approved with ${t} ${t===1?`thing`:`things`} left as ${t===1?`it was`:`they were`}`}function st(e){let t=e.left,n=a({className:`rv-tip${e.plain?` is-plain`:``}`,side:`right`});if(t===null||!ge(t))return null;let r=ot(t);return(0,V.jsxs)(`span`,{className:`rv-left-mark${e.plain?` is-plain`:``}`,...n.anchor,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`!`}),(0,V.jsx)(`span`,{className:`visually-hidden`,children:r}),n.says((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`b`,{children:r}),(0,V.jsx)(`ul`,{children:R(t).map(e=>(0,V.jsxs)(`li`,{children:[e.count,` `,e.text]},e.kind))}),(0,V.jsx)(`small`,{children:`Counted at the moment of signing. Acknowledged by the signer.`})]}))]})}function ct(e){if(e===null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString()}function lt(e){return e.relation===null?null:e.relation.relation===`out-of-sync`?{text:`Out of sync`,kind:``}:e.relation.relation===`merged`?{text:`Merged`,kind:`is-merged`}:null}function ut(e){return e.approved===null?``:`${e.approved?`Approved`:`Closed`} ${ct(e.endedAt)}`.trim()}function dt(e){return[e.name,e.branch??``,e.selection,ct(e.endedAt),ut(e)].join(` `)}function ft(e){let t=e.now??new Date,[n,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=(0,v.useMemo)(()=>_(e.archived,a,dt),[e.archived,a]),c=n=>{let r=lt(n),i=n.status===`reviewing`?``:ut(n),a=n.side===`agent`&&n.status===`reviewing`;return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`rv-row nav-row`,"aria-current":n.slug===e.open?`true`:void 0,disabled:n.missing,onClick:()=>e.onOpen(n.slug),children:[(0,V.jsxs)(`span`,{className:`rv-row-top`,children:[(0,V.jsx)(`span`,{className:`rv-row-name`,children:n.name}),r!==null&&(0,V.jsx)(`span`,{className:`rv-row-chip ${r.kind}`.trim(),children:r.text})]}),i===``?(0,V.jsx)(`span`,{className:`rv-bar`,children:(0,V.jsx)(`i`,{style:{width:`${pt(n)}%`}})}):(0,V.jsxs)(`span`,{className:`nav-row-sub`,children:[i,(0,V.jsx)(st,{left:n.leftAsIs,plain:!0})]}),a&&(0,V.jsxs)(`span`,{className:`rv-row-state`,children:[(0,V.jsx)(`span`,{className:`rv-dot`}),n.activity===``?`Awaits agent`:`Awaits agent - ${n.activity}`]}),n.missing&&(0,V.jsx)(`span`,{className:`rv-row-note`,children:`Missing on this branch`}),n.filedBy===`terminal`&&n.status===`reviewing`&&!n.missing&&(0,V.jsxs)(`span`,{className:`rv-row-note`,children:[`Filed from the terminal `,l(n.created,t)]})]})},n.slug)};return(0,V.jsxs)(`nav`,{className:`nav`,"aria-label":`Code reviews`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`nav-new`,"aria-pressed":e.starting,disabled:!e.repository,onClick:e.onStart,children:[(0,V.jsx)(r,{size:12}),`New review`]}),e.error!==null&&(0,V.jsx)(`p`,{className:`nav-note`,children:e.error}),(0,V.jsxs)(`h2`,{className:`nav-head`,children:[(0,V.jsx)(`span`,{children:`Active`}),(0,V.jsx)(`span`,{className:`nav-head-count`,children:e.active.length})]}),e.active.length===0?(0,V.jsx)(`p`,{className:`nav-empty`,children:`none yet`}):(0,V.jsx)(`ul`,{className:`nav-list`,children:e.active.map(c)}),e.archived.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`nav-head`,children:(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>i(e=>!e),children:[(0,V.jsx)(`span`,{children:`Archived`}),(0,V.jsxs)(`span`,{className:`nav-head-count`,children:[e.archived.length,` `,n?`▾`:`▸`]})]})}),n&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`nav-search`,children:(0,V.jsx)(`input`,{type:`search`,"aria-label":`Search the archive`,placeholder:`Search name, branch or date`,value:a,onChange:e=>o(e.target.value)})}),s.length===0?(0,V.jsx)(`p`,{className:`nav-empty`,children:`nothing by that name`}):(0,V.jsx)(`ul`,{className:`nav-list nav-archived`,children:s.map(c)})]})]})]})}function pt(e){return e.progress.total===0?0:Math.round(e.progress.seen/e.progress.total*100)}function mt(e){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(``);return t?(0,V.jsxs)(`div`,{className:`rv-aclose`,children:[(0,V.jsx)(`textarea`,{"aria-label":`Why it is closed without approval`,rows:2,value:r,disabled:e.busy,onChange:e=>i(e.target.value)}),(0,V.jsxs)(`span`,{className:`rv-aclose-acts`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy||r.trim()===``,onClick:()=>e.onClose(r.trim()),children:`Close without approval`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,onClick:()=>n(!1),children:`Cancel`})]})]}):(0,V.jsxs)(`div`,{className:`rv-aclose`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,disabled:e.busy,onClick:()=>n(!0),children:`Close without approval`}),(0,V.jsx)(`span`,{className:`rv-facts`,children:`Opens a box for the reason.`})]})}function ht(e){if(e===null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function gt(e){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t+1),r=e.slice(t+1);return r.length<=12?e:`${n}${r.slice(0,6)}…${r.slice(-4)}`}function _t(e){let t=e.baseline?.resolved;if(t===void 0)return`no baseline`;let n=t.head.slice(0,7);return t.tree?`${n}, includes uncommitted changes`:`${n}, working copy clean`}function vt(e){let t=e.relation?.relation??null;return t===null?`unknown`:t.replaceAll(`-`,` `)}function yt(e){return e===0?`Sign and approve`:`Sign and approve with ${e} ${e===1?`thing`:`things`} left`}function bt(e){let t=e.review,n=t.leftAsIs,r=L(n),i=R(n),[a,o]=(0,v.useState)(t.configuredName),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=(0,v.useRef)(!1),{onCancel:p}=e;(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&p()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p]);let m=e=>{let t=d.current;if(t===null)return null;let n=t.getBoundingClientRect();return n.width===0||n.height===0?null:{x:(e.clientX-n.left)/n.width*t.width,y:(e.clientY-n.top)/n.height*t.height}},h=(e,t)=>{let n=d.current?.getContext(`2d`)??null,r=m(e);if(!(n===null||r===null)){if(n.strokeStyle=`#e6edf3`,n.lineWidth=2,n.lineCap=`round`,t){n.beginPath(),n.moveTo(r.x,r.y);return}n.lineTo(r.x,r.y),n.stroke(),u(!0)}},g=()=>{let e=d.current,t=e?.getContext(`2d`)??null;e!==null&&t!==null&&t.clearRect(0,0,e.width,e.height),u(!1)},_=()=>{let e=d.current;if(!l||e===null)return null;let t=e.toDataURL(`image/png`);return t.startsWith(`data:image/png;base64,`)?t:null},y=e.busy||a.trim()===``||r>0&&!s;return(0,V.jsx)(`div`,{className:`dialog-shade`,children:(0,V.jsxs)(`form`,{className:`dialog dialog-wide rv-adialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Approve "${t.state.name}"`,onSubmit:t=>{t.preventDefault(),!y&&e.onApprove(a.trim(),_(),r>0)},children:[(0,V.jsxs)(`h2`,{className:`rail-head rv-adialog-head`,children:[(0,V.jsxs)(`span`,{children:[`Approve "`,t.state.name,`"`]}),(0,V.jsx)(`button`,{type:`button`,className:`rv-icon rv-adialog-x`,"aria-label":`Close the dialog`,onClick:e.onCancel,children:`×`})]}),(0,V.jsxs)(`div`,{className:`dialog-body`,children:[(0,V.jsxs)(`div`,{className:`rv-ameta`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Review`}),(0,V.jsx)(`span`,{className:`rv-v`,children:t.state.name})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Feedback loops`}),(0,V.jsx)(`span`,{className:`rv-v`,children:t.loops})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Hunks Seen`}),(0,V.jsxs)(`span`,{className:`rv-v`,children:[t.progress.seen,` of `,t.progress.total]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Fingerprint`}),(0,V.jsx)(`span`,{className:`rv-v rv-mono`,title:t.baseline?.fingerprint??``,children:gt(t.baseline?.fingerprint??``)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Commit`}),(0,V.jsx)(`span`,{className:`rv-v rv-mono`,children:_t(t)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`rv-k`,children:`Tree`}),(0,V.jsx)(`span`,{className:`rv-v`,children:vt(t)})]})]}),ge(n)?(0,V.jsxs)(`section`,{className:`rv-left`,"aria-label":`Left as it is`,children:[(0,V.jsxs)(`h3`,{children:[(0,V.jsx)(`span`,{className:`rv-left-mark`,"aria-hidden":`true`,children:`!`}),`This approval leaves the following as it is`]}),(0,V.jsx)(`ul`,{children:i.map(t=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`b`,{children:t.count}),(0,V.jsx)(`span`,{children:t.text}),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:()=>e.onGoTo(t.kind),children:`Go to the first`})]},t.kind))}),(0,V.jsxs)(`label`,{className:`rv-left-ack`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:s,disabled:e.busy,onChange:e=>c(e.target.checked)}),(0,V.jsx)(`span`,{children:`I reviewed this change, in the tool or outside it, and I approve it with these left as they are. The record will say so.`})]})]}):(0,V.jsx)(`p`,{className:`rv-left is-clean`,children:`Every hunk is Seen, every conversation is closed, and nothing awaits the agent.`}),(0,V.jsxs)(`div`,{className:`rv-asign`,children:[(0,V.jsxs)(`p`,{className:`rv-field`,children:[(0,V.jsxs)(`label`,{htmlFor:`rv-signer`,children:[`Your name `,(0,V.jsx)(`small`,{children:`from git`})]}),(0,V.jsx)(`input`,{id:`rv-signer`,value:a,disabled:e.busy,onChange:e=>o(e.target.value)})]}),(0,V.jsxs)(`p`,{className:`rv-field`,children:[(0,V.jsxs)(`span`,{className:`rv-label`,children:[`Signature `,(0,V.jsx)(`small`,{children:`optional`})]}),(0,V.jsxs)(`span`,{className:`rv-sig`,children:[(0,V.jsx)(`canvas`,{ref:d,width:520,height:160,"aria-label":`Signature`,onPointerDown:e=>{f.current=!0,e.currentTarget.setPointerCapture?.(e.pointerId),h(e,!0)},onPointerMove:e=>{f.current&&h(e,!1)},onPointerUp:()=>{f.current=!1},onPointerLeave:()=>{f.current=!1}}),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,disabled:!l,onClick:g,children:`clear`})]})]})]})]}),(0,V.jsxs)(`div`,{className:`dialog-acts rv-adialog-acts`,children:[(0,V.jsx)(mt,{busy:e.busy,onClose:e.onClose}),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsxs)(`span`,{className:`rv-facts`,children:[`Approves as of commit `,(t.baseline?.resolved.head??``).slice(0,7)]}),(0,V.jsx)(`button`,{type:`submit`,className:`rv-btn ${r>0?`is-warn`:`is-ok`}`,disabled:y,children:yt(r)})]})]})})}function xt(e){let[t,n]=(0,v.useState)(e.text??``),r=M[e.act],i=P(e.lines),a=t.trim()!==``||!N(e.act);return(0,V.jsxs)(`form`,{className:`rv-compose`,onSubmit:n=>{n.preventDefault(),!(!a||e.busy)&&e.onWrite(t.trim())},children:[(0,V.jsxs)(`p`,{className:`rv-compose-head`,children:[(0,V.jsx)(`b`,{children:r}),i!==``&&(0,V.jsx)(`span`,{className:`rv-facts`,children:i})]}),(0,V.jsx)(`textarea`,{"aria-label":r,rows:3,value:t,disabled:e.busy,onChange:t=>{n(t.target.value),e.onChange?.(t.target.value)}}),(0,V.jsxs)(`p`,{className:`rv-compose-acts`,children:[(0,V.jsx)(`button`,{type:`submit`,className:`rv-btn is-small is-primary`,disabled:!a||e.busy,children:`Add`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,onClick:e.onCancel,children:`Cancel`})]})]})}function St(e){return e.slice(0,10)}function Ct(e){let t=e.approval,[n,r]=(0,v.useState)(null),i=e.slug,a=t.signature;return(0,v.useEffect)(()=>{if(a===null)return;let e=!0;return le(`${i}/${Ee}`).then(t=>{e&&r(t)}),()=>{e=!1}},[a,i]),(0,V.jsxs)(`div`,{className:`rv-ended`,children:[(0,V.jsxs)(`span`,{className:`rv-ended-how`,children:[t.approved?`Approved`:`Closed`,` `,St(t.at),t.name!==``&&(0,V.jsxs)(V.Fragment,{children:[` by `,(0,V.jsx)(`b`,{children:t.name})]})]}),(0,V.jsx)(st,{left:t.leftAsIs}),n!==null&&(0,V.jsx)(`img`,{src:n,alt:`Signed by ${t.name}`}),!t.approved&&t.reason!==``&&(0,V.jsx)(`span`,{className:`rv-reason`,children:t.reason}),(0,V.jsxs)(`span`,{className:`rv-ended-fact`,children:[`fingerprint `,(0,V.jsx)(`span`,{className:`rv-mono`,children:gt(t.fingerprint)})]}),(0,V.jsxs)(`span`,{className:`rv-ended-fact`,children:[`commit `,(0,V.jsx)(`span`,{className:`rv-mono`,children:t.commit.slice(0,7)}),t.uncommitted&&`, with uncommitted changes`]}),(0,V.jsx)(`span`,{className:`rv-grow`}),!e.filed&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy,onClick:e.onArchive,children:`Archive`})]})}var wt={unseen:{next:`Next unseen`,kind:`Unseen`,spent:`All seen`},issue:{next:`Next issue`,kind:`Issue`,spent:`No issues`},attention:{next:`Next attention`,kind:`Attention`,spent:`No attention`},reply:{next:`Next reply`,kind:`Reply`,spent:`No unread replies`}};function Tt(e){return(0,V.jsx)(`div`,{className:`rv-navrow`,children:e.controls.map(t=>{let n=t.kind,r=wt[n];return t.state===`here`?(0,V.jsxs)(`button`,{type:`button`,className:`rv-nav is-${n}`,onClick:()=>e.onWalk(n),children:[(0,V.jsx)(`span`,{className:`rv-navn`,children:t.count}),r.next]},n):t.state===`across`?(0,V.jsxs)(`button`,{type:`button`,className:`rv-nav is-${n} is-morph`,onClick:()=>e.onWalk(n),children:[(0,V.jsx)(`i`,{className:`rv-navdot`,"aria-hidden":`true`}),r.kind,` in `,(0,V.jsx)(`b`,{children:t.section}),` →`]},n):(0,V.jsxs)(`button`,{type:`button`,className:`rv-nav is-${n} is-done`,disabled:!0,children:[(0,V.jsx)(`span`,{className:`rv-navn`,children:`✓`}),r.spent]},n)})})}function Et(e){let t=[`${e.seen} of ${e.hunks} seen`];return e.issues>0&&t.push(`${e.issues} issue${e.issues===1?``:`s`}`),e.attention>0&&t.push(`${e.attention} attention`),e.replies>0&&t.push(`${e.replies} unread ${e.replies===1?`reply`:`replies`}`),t.join(` · `)}function Dt(e){let t=e.section,n=e.counts,r=n.hunks===0?0:Math.round(n.seen/n.hunks*100),i=e.collapse.collapse>=1,a={"--rv-collapse":e.collapse.collapse,"--rv-fold":`${e.collapse.fold}px`};return(0,V.jsxs)(`div`,{className:`rv-ghead${i?` is-compact`:``}${e.under?` is-under`:``}`,style:a,children:[(0,V.jsxs)(`div`,{className:`rv-gtitle`,children:[(0,V.jsx)(`h3`,{children:t.name}),(0,V.jsx)(`span`,{className:`rv-facts`,children:Et(n)}),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsxs)(`span`,{className:`rv-gacts`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:!e.readable||e.busy||n.unseen===0,onClick:e.onBulk,children:`Mark remaining as Seen`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:!e.readable||e.busy,onClick:e.onComment,children:`Comment`})]})]}),(0,V.jsx)(`div`,{className:`rv-gfold`,children:(0,V.jsxs)(`div`,{className:`rv-gfold-in`,ref:e.fold,children:[t.narrative!==``&&(0,V.jsx)(`p`,{className:`rv-gnarr`,children:t.narrative}),t.facts.length>0&&(0,V.jsx)(`ul`,{className:`rv-gfacts`,children:t.facts.map(e=>(0,V.jsx)(`li`,{children:e},e))}),e.shared.count>0&&(0,V.jsxs)(`p`,{className:`rv-gshared`,children:[e.shared.count,` hunk`,e.shared.count===1?``:`s`,` shared with`,` `,e.shared.groups.join(`, `)]})]})}),e.controls!==null&&(0,V.jsx)(Tt,{controls:e.controls,onWalk:e.onWalk}),(0,V.jsx)(`div`,{className:`rv-gstrip`,children:(0,V.jsx)(`i`,{style:{width:`${r}%`}})})]})}function Ot(e){return(0,V.jsxs)(`div`,{className:`rv-allbar`,children:[(0,V.jsx)(`h3`,{children:`All groups`}),(0,V.jsxs)(`span`,{className:`rv-facts`,children:[e.hunks,` hunk`,e.hunks===1?``:`s`,` in `,e.groups,` group`,e.groups===1?``:`s`]}),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsx)(Tt,{controls:e.controls,onWalk:e.onWalk})]})}function kt(e){if(e.feedHeight<=0)return null;let t=e.collapse*e.fold,n=e.sectionTop-e.feedTop+e.scrollTop,r=e.underHeader?t:0,i=e.targetTop-e.feedTop+e.scrollTop+r;if(e.block===`start`){let n=e.underHeader?e.headerHeight+t:0;return Math.max(0,i-e.pinned-n)}let a=i-(e.feedHeight-e.targetHeight)/2,o=n-e.pinned;return!e.underHeader||a<=o?Math.max(0,a):a<=o+2*e.fold?Math.max(0,(a+o)/2):Math.max(0,a-e.fold)}function At(e){return e.aside?(0,V.jsx)(`button`,{type:`button`,className:`rv-hdot`,"aria-label":`Show the notes put aside`,onClick:e.onShow}):(0,V.jsx)(`i`,{className:`rv-hdot`,"aria-hidden":`true`})}var jt={info:`Info`,attention:`Attention`,issue:`Issue`};function Mt(e){return(0,V.jsx)(V.Fragment,{children:e.notes.map(t=>(0,V.jsxs)(v.Fragment,{children:[(0,V.jsx)(Nt,{note:t,aside:e.aside.has(t.key),shown:e.shown.has(t.key),readable:e.readable,readOnlySaid:e.readOnlySaid,busy:e.busy,onAsk:e.onAsk===null?null:()=>e.onAsk?.(t),onTalk:()=>e.onTalk(t),onComment:()=>e.onComment(t),onDismiss:n=>e.onDismiss(t,n)}),e.box!==null&&e.box.note===t.key&&(0,V.jsx)(`div`,{className:`rv-inote-box`,children:e.box.element})]},t.key))})}function Nt(e){let t=e.note;return(0,V.jsxs)(`div`,{className:`rv-inote${t.kind===`info`?``:` is-${t.kind}`}${e.aside?e.shown?` is-dismissed is-back`:` is-dismissed`:``}`,"data-note":t.key,children:[(0,V.jsxs)(`div`,{className:`rv-inote-top`,children:[(0,V.jsx)(`span`,{className:`rv-note-kind`,children:jt[t.kind]}),(0,V.jsx)(`span`,{className:`rv-note-ln`,children:fe(t)})]}),(0,V.jsx)(`div`,{className:`rv-note-txt`,children:t.text}),!e.readable&&(0,V.jsx)(`div`,{className:`rv-note-acts`,children:(0,V.jsx)(`span`,{className:`rv-note-locked`,children:e.readOnlySaid})}),e.readable&&(0,V.jsx)(`div`,{className:`rv-note-acts`,children:e.aside?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`rv-note-dismissed`,children:`dismissed`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,disabled:e.busy,onClick:()=>e.onDismiss(!1),children:`Undo`})]}):(0,V.jsxs)(V.Fragment,{children:[t.kind===`issue`&&e.onAsk!==null&&(0,V.jsx)(`button`,{type:`button`,className:`rv-note-act is-fix`,disabled:e.busy,onClick:e.onAsk,children:`Ask to fix`}),t.kind!==`info`&&(0,V.jsx)(`button`,{type:`button`,className:`rv-note-act`,disabled:e.busy,onClick:e.onTalk,children:`Let's talk`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-note-act`,disabled:e.busy,onClick:e.onComment,children:`Comment`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-note-act`,disabled:e.busy,onClick:()=>e.onDismiss(!0),children:`Dismiss`})]})})]})}function Pt(e){return e.from===`agent`?`Agent`:`You`}function Ft(e){let t=e.thread,n=!e.agentHolds&&j(t);return(0,V.jsxs)(`div`,{className:`rv-thread`,"data-thread":t.id,children:[t.messages.map(t=>{let n=t.from===`agent`&&t.readAt===null,r=Pt(t);return(0,V.jsxs)(`div`,{className:`rv-msg${n?` is-unread`:``}`,"data-message":t.id,children:[(0,V.jsxs)(`span`,{className:`rv-who${t.from===`agent`?` is-agent`:``}`,children:[`${r} - `,ht(t.at),n&&(0,V.jsx)(`span`,{className:`rv-new`,children:`new`})]}),(0,V.jsx)(`div`,{className:`rv-msg-body${t.from===`tool`?` is-tool`:``}`,"data-unread":n?t.id:void 0,ref:n?e.watch:void 0,children:t.text})]},t.id)}),(0,V.jsxs)(`div`,{className:`rv-tf`,children:[t.label===`hunk-removed`&&(0,V.jsx)(`span`,{className:`rv-tag`,children:`hunk removed`}),(0,V.jsx)(`span`,{className:t.open?``:`rv-ok`,children:t.open?n?`Waits on you`:`Waits on the agent`:`Closed${t.closedAt===null?``:` ${ht(t.closedAt)}`}`}),t.open&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:!e.readable||e.busy,onClick:e.onClose,children:`Close thread`})]})]})}var It={dockerfile:`docker`,containerfile:`docker`,makefile:`make`,gnumakefile:`make`},Lt={ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,json:`json`,jsonc:`jsonc`,yaml:`yaml`,yml:`yaml`,toml:`toml`,md:`markdown`,markdown:`markdown`,html:`html`,htm:`html`,css:`css`,scss:`scss`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,py:`python`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,kts:`kotlin`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sql:`sql`,graphql:`graphql`,gql:`graphql`,xml:`xml`,svg:`xml`,mk:`make`,ini:`ini`,cfg:`ini`,diff:`diff`,patch:`diff`};function Rt(e){let t=(e.split(`/`).pop()??``).toLowerCase(),n=t.split(`.`)[0]??``,r=It[t]??It[n];if(r!==void 0)return r;let i=t.lastIndexOf(`.`);return i<=0?null:Lt[t.slice(i+1)]??null}var H=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function zt(e){return Bt(e)}function Bt(e){return Array.isArray(e)?Vt(e):e instanceof RegExp?e:typeof e==`object`?Ht(e):e}function Vt(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Bt(e[n]);return t}function Ht(e){let t={};for(let n in e)t[n]=Bt(e[n]);return t}function Ut(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Wt(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Wt(e.substring(0,e.length-1)):e.substr(~t+1)}var Gt=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Kt=class{static hasCaptures(e){return e===null?!1:(Gt.lastIndex=0,Gt.test(e))}static replaceCaptures(e,t,n){return e.replace(Gt,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function qt(e,t){return e<t?-1:+(e>t)}function Jt(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=qt(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function Yt(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Xt(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var Zt=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Qt=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(rn(e),t)}static createFromParsedTheme(e,t){return on(e,t)}_cachedMatchRoot=new Zt(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>en(e.parent,t.parentScopes));return n?new nn(n.fontStyle,n.foreground,n.background):null}},$t=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function en(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!tn(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function tn(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var nn=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function rn(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&Yt(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&Yt(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new an(l,u,e,o,s,c)}}return n}var an=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},U=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(U||{});function on(e,t){e.sort((e,t)=>{let n=qt(e.scope,t.scope);return n!==0||(n=Jt(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new sn(t),o=new nn(n,a.getId(r),a.getId(i)),s=new un(new ln(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new Qt(a,o,s)}var sn=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},cn=Object.freeze([]),ln=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||cn,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},un=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),ln.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(Jt(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new ln(e,t,n,r,i))}},dn=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=pn(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function fn(e){return e}function pn(e){return e}function mn(e,t){let n=[],r=gn(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(hn(i)){let e=[];do e.push(i),i=r.next();while(hn(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function hn(e){return!!e&&!!e.match(/[\w\.:]+/)}function gn(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function _n(e){typeof e.dispose==`function`&&e.dispose()}var vn=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},yn=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},bn=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},xn=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new vn(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new bn;for(let n of e)Sn(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof vn){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Sn(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof vn?wn({baseGrammar:a,selfGrammar:i},r):Cn(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new vn(e))}function Cn(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Tn([r],t,n)}}function wn(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Tn(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Tn(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Tn(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Ut({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Tn(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=jn(i);switch(a.kind){case 0:wn({...t,selfGrammar:t.baseGrammar},n);break;case 1:wn(t,n);break;case 2:Cn(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?Cn(a.ruleName,i,n):wn(i,n)}else a.kind===4?n.add(new yn(a.scopeName,a.ruleName)):n.add(new vn(a.scopeName));break}}}var En=class{kind=0},Dn=class{kind=1},On=class{constructor(e){this.ruleName=e}kind=2},kn=class{constructor(e){this.scopeName=e}kind=3},An=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function jn(e){if(e===`$base`)return new En;if(e===`$self`)return new Dn;let t=e.indexOf(`#`);return t===-1?new kn(e):t===0?new On(e.substring(1)):new An(e.substring(0,t),e.substring(t+1))}var Mn=/\\(\d+)/,Nn=/\\(\d+)/g,Pn=-1,Fn=-2;function In(e){return e}function Ln(e){return e}var Rn=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Kt.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Kt.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Wt(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Kt.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Kt.replaceCaptures(this._contentName,e,t)}},zn=class extends Rn{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Bn=class extends Rn{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Gn(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Kn,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Vn=class extends Rn{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Kn,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Hn=class extends Rn{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new Gn(i,this.id),this.beginCaptures=a,this._end=new Gn(o||`￿`,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Kn;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Un=class extends Rn{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new Gn(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Gn(o,Fn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Kn;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Kn,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||`￿`),this._cachedCompiledWhilePatterns}},Wn=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new zn(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Bn(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Ut({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Vn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Un(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Hn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=jn(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Vn||e instanceof Hn||e instanceof Un)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Gn=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=Mn.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return Nn.lastIndex=0,this.source.replace(Nn,(e,t)=>Xt(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=`￿`,t[i+1]=`￿`,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=`￿`,t[i+1]=`G`,n[i+1]=`￿`,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Kn=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new qn(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new qn(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},qn=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
2
2
  `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Jn=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Yn=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Jn(e,8),this._embeddedLanguagesMatcher=new Xn(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Jn(0,0);_getBasicScopeAttributes=new Zt(e=>new Jn(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Xn=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>Xt(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var Zn=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Qn(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=$n(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new Zn(i,!0);f()}return new Zn(i,!1);function f(){let o=er(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===Pn){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),ar(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof Hn){let r=o;ar(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof Un){let r=o;ar(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(ar(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function $n(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof Un&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=ir(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==Fn){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),ar(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function er(e,t,n,r,i,a){let o=tr(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=nr(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function tr(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=rr(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function nr(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=rr(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function rr(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function ir(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function ar(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));Qn(e,p,n&&d.start===0,d.start,f,i,!1,0),_n(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new or(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var or=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function sr(e,t,n,r,i,a,o,s){return new dr(e,t,n,r,i,a,o,s)}function cr(e,t,n,r,i){let a=mn(t,lr),o=Wn.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function lr(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(ur(t[r],e))return n=r+1,!0;return!1})}function ur(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var dr=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new Yn(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=fr(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=mn(e,lr);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)cr(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&cr(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(In(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Ln(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=fr(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=Wn.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===mr.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=dn.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?pr.createRootAndLookUpScopeName(a,r,this):pr.createRoot(`unknown`,r),t=new mr(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
3
3
  `;let a=this.createOnigString(e),o=a.content.length,s=new gr(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Qn(this,a,i,0,t,s,!0,r);return _n(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function fr(e,t){return e=zt(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var pr=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=$t.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new $t(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new $t(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),dn.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},mr=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?pr.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Ln(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=pr.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,In(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,pr.fromExtension(r,n.contentNameScopesList))}},hr=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):mn(e,lr).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>mn(e,lr).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},gr=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=dn.set(n,0,fn(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=dn.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},_r=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,sr(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},vr=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new _r(Qt.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Qt.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new hr(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new xn(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},yr=mr.NULL;function br(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function xr(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Sr(e){return Array.isArray(e)?e:[e]}async function Cr(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function wr(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function Tr(e){return e===`ansi`||wr(e)}function Er(e){return e===`none`}function Dr(e){return Er(e)}var Or=/(\r?\n)/g;function kr(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(Or),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var Ar={light:`#333333`,dark:`#bbbbbb`},jr={light:`#fffffe`,dark:`#1e1e1e`},Mr=`__shiki_resolved`;function Nr(e){if(e?.[Mr])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?Ar.light:Ar.dark,n||=t.type===`light`?jr.light:jr.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,Mr,{enumerable:!1,writable:!1,value:!0}),t}async function Pr(e){return[...new Set((await Promise.all(e.filter(e=>!Tr(e)).map(async e=>await Cr(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function Fr(e){return(await Promise.all(e.map(async e=>Dr(e)?null:Nr(await Cr(e))))).filter(e=>!!e)}function Ir(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new H(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var Lr=class extends vr{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=Nr(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Qt.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Ir(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new H(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},Rr=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},zr=0;function Br(e){zr+=1,e.warnings!==!1&&zr>=10&&zr%10==0&&console.warn(`[Shiki] ${zr} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new H("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Nr),i=new Lr(new Rr(e.engine,n),r,n,e.langAlias),a;function o(t){return Ir(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new H(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new H(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await Pr(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await Fr(e))}function g(){if(t)throw new H(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--zr)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function Vr(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Fr(e.themes||[]),Pr(e.langs||[]),e.engine]);return Br({...e,themes:t,langs:n,engine:r})}var Hr=new WeakMap;function Ur(e,t){Hr.set(e,t)}function Wr(e){return Hr.get(e)}var Gr=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(Sr(n).map(e=>[e,yr])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Kr(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Kr(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function qr(e,t){if(!(e instanceof Gr))throw new H(`Invalid grammar state`);return e.getInternalStack(t)}var Jr=/,/,Yr=/ /;function Xr(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(wr(e.resolveLangAlias(n.lang||`text`))||Er(r))return kr(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new H(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new H(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return Qr(t,o,i,a,n)}function Zr(...e){if(e.length===2)return Wr(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(wr(i)||Er(a))throw new H(`Plain language does not have grammar state`);if(i===`ansi`)throw new H(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new Gr($r(n,c,o,s,r).stateStack,c.name,o.name)}function Qr(e,t,n,r,i){let a=$r(e,t,n,r,i),o=new Gr(a.stateStack,t.name,n.name);return Ur(a.tokens,o),a.tokens}function $r(e,t,n,r,i){let a=br(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=kr(e),u=i.grammarState?qr(i.grammarState,n.name)??yr:i.grammarContextCode==null?yr:$r(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,d=[],f=[];for(let e=0,i=l.length;e<i;e++){let[i,p]=l[e];if(i===``){d=[],f.push([]);continue}if(o>0&&i.length>=o){d=[],f.push([{content:i,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;c&&c!==`tokenType`&&(m=t.tokenizeLine(i,u,s),h=m.tokens,g=0);let _=t.tokenizeLine2(i,u,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:i.length;if(t===o)continue;let s=_.tokens[2*e+1],l=xr(r[dn.getForeground(s)],a),u=dn.getFontStyle(s),f={content:i.substring(t,o),offset:p+t,color:l,fontStyle:u};if(c===`tokenType`)f.type=dn.getTokenType(s);else if(c){let e=[];if(c!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(Jr).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(Yr))})}f.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=i.substring(t.startIndex,t.endIndex);r+=n.length,f.explanation.push({content:n,scopes:c===`scopeName`?ei(t.scopes):ti(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function ei(e){return e.map(e=>({scopeName:e}))}function ti(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:ii(e,i,t.slice(0,r))}}return n}function ni(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function ri(e,t,n){if(!ni(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)ni(e[r],n[i])&&--r,--i;return r===-1}function ii(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(ri(e,t,n)){r.push(a);break}return r}function ai(e,t,n,r=Xr){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:Wr(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=oi(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new Gr(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&Ur(s,c),s}function oi(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var si=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],ci=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ci.prototype.normal={},ci.prototype.property={},ci.prototype.space=void 0;function li(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new ci(n,r,t)}function ui(e){return e.toLowerCase()}var W=class{constructor(e,t){this.attribute=t,this.property=e}};W.prototype.attribute=``,W.prototype.booleanish=!1,W.prototype.boolean=!1,W.prototype.commaOrSpaceSeparated=!1,W.prototype.commaSeparated=!1,W.prototype.defined=!1,W.prototype.mustUseProperty=!1,W.prototype.number=!1,W.prototype.overloadedBoolean=!1,W.prototype.property=``,W.prototype.spaceSeparated=!1,W.prototype.space=void 0;var di=o({boolean:()=>G,booleanish:()=>K,commaOrSpaceSeparated:()=>hi,commaSeparated:()=>mi,number:()=>q,overloadedBoolean:()=>pi,spaceSeparated:()=>J}),fi=0,G=gi(),K=gi(),pi=gi(),q=gi(),J=gi(),mi=gi(),hi=gi();function gi(){return 2**++fi}var _i=Object.keys(di),vi=class extends W{constructor(e,t,n,r){let i=-1;if(super(e,t),yi(this,`space`,r),typeof n==`number`)for(;++i<_i.length;){let e=_i[i];yi(this,_i[i],(n&di[e])===di[e])}}};vi.prototype.defined=!0;function yi(e,t,n){n&&(e[t]=n)}function bi(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new vi(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ui(r)]=r,n[ui(a.attribute)]=r}return new ci(t,n,e.space)}var xi=bi({properties:{ariaActiveDescendant:null,ariaAtomic:K,ariaAutoComplete:null,ariaBusy:K,ariaChecked:K,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:J,ariaCurrent:null,ariaDescribedBy:J,ariaDetails:null,ariaDisabled:K,ariaDropEffect:J,ariaErrorMessage:null,ariaExpanded:K,ariaFlowTo:J,ariaGrabbed:K,ariaHasPopup:null,ariaHidden:K,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:J,ariaLevel:q,ariaLive:null,ariaModal:K,ariaMultiLine:K,ariaMultiSelectable:K,ariaOrientation:null,ariaOwns:J,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:K,ariaReadOnly:K,ariaRelevant:null,ariaRequired:K,ariaRoleDescription:J,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:K,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Si(e,t){return t in e?e[t]:t}function Ci(e,t){return Si(e,t.toLowerCase())}var wi=bi({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:mi,acceptCharset:J,accessKey:J,action:null,allow:null,allowFullScreen:G,allowPaymentRequest:G,allowUserMedia:G,alpha:G,alt:null,as:null,async:G,autoCapitalize:null,autoComplete:J,autoFocus:G,autoPlay:G,blocking:J,capture:null,charSet:null,checked:G,cite:null,className:J,closedBy:null,colorSpace:null,cols:q,colSpan:q,command:null,commandFor:null,content:null,contentEditable:K,controls:G,controlsList:J,coords:q|mi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:G,defer:G,dir:null,dirName:null,disabled:G,download:pi,draggable:K,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:G,formTarget:null,headers:J,height:q,hidden:pi,high:q,href:null,hrefLang:null,htmlFor:J,httpEquiv:J,id:null,imageSizes:null,imageSrcSet:null,inert:G,inputMode:null,integrity:null,is:null,isMap:G,itemId:null,itemProp:J,itemRef:J,itemScope:G,itemType:J,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:G,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:G,muted:G,name:null,nonce:null,noModule:G,noValidate:G,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:G,optimum:q,pattern:null,ping:J,placeholder:null,playsInline:G,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:G,referrerPolicy:null,rel:J,required:G,reversed:G,rows:q,rowSpan:q,sandbox:J,scope:null,scoped:G,seamless:G,selected:G,shadowRootClonable:G,shadowRootCustomElementRegistry:G,shadowRootDelegatesFocus:G,shadowRootMode:null,shadowRootSerializable:G,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:K,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:G,useMap:null,value:K,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:J,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:G,declare:G,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:G,noHref:G,noShade:G,noWrap:G,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:K,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:G,disablePictureInPicture:G,disableRemotePlayback:G,exportParts:mi,part:J,prefix:null,property:null,results:q,security:null,unselectable:null},space:`html`,transform:Ci}),Ti=bi({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:hi,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:J,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:G,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mi,g2:mi,glyphName:mi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:hi,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:J,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:hi,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:hi,rev:hi,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:hi,requiredFeatures:hi,requiredFonts:hi,requiredFormats:hi,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:hi,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:hi,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:hi,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Si}),Ei=bi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Di=bi({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Ci}),Oi=bi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),ki=/[A-Z]/g,Ai=/-[a-z]/g,ji=/^data[-\w.:]+$/i;function Mi(e,t){let n=ui(t),r=t,i=W;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ji.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Ai,Pi);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Ai.test(e)){let n=e.replace(ki,Ni);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=vi}return new i(r,t)}function Ni(e){return`-`+e.toLowerCase()}function Pi(e){return e.charAt(1).toUpperCase()}var Fi=li([xi,wi,Ei,Di,Oi],`html`),Ii=li([xi,Ti,Ei,Di,Oi],`svg`),Li={}.hasOwnProperty;function Ri(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&Li.call(t,e)){let n=String(t[e]);i=Li.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var zi=/["&'<>`]/g,Bi=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Vi=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Hi=/[|\\{}()[\]^$+*?.]/g,Ui=new WeakMap;function Wi(e,t){if(e=e.replace(t.subset?Gi(t.subset):zi,r),t.subset||t.escapeOnly)return e;return e.replace(Bi,n).replace(Vi,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function Gi(e){let t=Ui.get(e);return t||(t=Ki(e),Ui.set(e,t)),t}function Ki(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(Hi,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var qi=/[\dA-Fa-f]/;function Ji(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!qi.test(String.fromCharCode(t))?r:r+`;`}var Yi=/\d/;function Xi(e,t,n){let r=`&#`+String(e);return n&&t&&!Yi.test(String.fromCharCode(t))?r:r+`;`}var Zi=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),Qi={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:`‌`,zwj:`‍`,lrm:`‎`,rlm:`‏`,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},$i=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],ea={}.hasOwnProperty,ta={},na;for(na in Qi)ea.call(Qi,na)&&(ta[Qi[na]]=na);var ra=/[^\dA-Za-z]/;function ia(e,t,n,r){let i=String.fromCharCode(e);if(ea.call(ta,i)){let e=ta[i],a=`&`+e;return n&&Zi.includes(e)&&!$i.includes(e)&&(!r||t&&t!==61&&ra.test(String.fromCharCode(t)))?a:a+`;`}return``}function aa(e,t,n){let r=Ji(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=ia(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=Xi(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function oa(e,t){return Wi(e,Object.assign({format:aa},t))}var sa=/^>|^->|<!--|-->|--!>|<!-$/g,ca=[`>`],la=[`<`,`>`];function ua(e,t,n,r){return r.settings.bogusComments?`<?`+oa(e.value,Object.assign({},r.settings.characterReferences,{subset:ca}))+`>`:`<!--`+e.value.replace(sa,i)+`-->`;function i(e){return oa(e,Object.assign({},r.settings.characterReferences,{subset:la}))}}function da(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}function fa(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function pa(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}function ma(e){return e.join(` `).trim()}var ha=/[ \t\n\f\r]/g;function ga(e){return typeof e==`object`?e.type===`text`&&_a(e.value):_a(e)}function _a(e){return e.replace(ha,``)===``}var Y=ba(1),va=ba(-1),ya=[];function ba(e){return t;function t(t,n,r){let i=t?t.children:ya,a=(n||0)+e,o=i[a];if(!r)for(;o&&ga(o);)a+=e,o=i[a];return o}}var xa={}.hasOwnProperty;function Sa(e){return t;function t(t,n,r){return xa.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var Ca=Sa({body:Ea,caption:wa,colgroup:wa,dd:Aa,dt:ka,head:wa,html:Ta,li:Oa,optgroup:Ma,option:Na,p:Da,rp:ja,rt:ja,tbody:Fa,td:Ra,tfoot:Ia,th:Ra,thead:Pa,tr:La});function wa(e,t,n){let r=Y(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&ga(r.value.charAt(0)))}function Ta(e,t,n){let r=Y(n,t);return!r||r.type!==`comment`}function Ea(e,t,n){let r=Y(n,t);return!r||r.type!==`comment`}function Da(e,t,n){let r=Y(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`))}function Oa(e,t,n){let r=Y(n,t);return!r||r.type===`element`&&r.tagName===`li`}function ka(e,t,n){let r=Y(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function Aa(e,t,n){let r=Y(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function ja(e,t,n){let r=Y(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function Ma(e,t,n){let r=Y(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function Na(e,t,n){let r=Y(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function Pa(e,t,n){let r=Y(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function Fa(e,t,n){let r=Y(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function Ia(e,t,n){return!Y(n,t)}function La(e,t,n){let r=Y(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function Ra(e,t,n){let r=Y(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var za=Sa({body:Ha,colgroup:Ua,head:Va,html:Ba,tbody:Wa});function Ba(e){let t=Y(e,-1);return!t||t.type!==`comment`}function Va(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function Ha(e){let t=Y(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&ga(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function Ua(e,t,n){let r=va(n,t),i=Y(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&Ca(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function Wa(e,t,n){let r=va(n,t),i=Y(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&Ca(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}var Ga={name:[[`
4
4
  \f\r &/=>`.split(``),`
@@ -150,4 +150,4 @@ XID_Start XIDS`.split(/\s/).map(e=>[Ec(e),e])),vl=new Map([[`s`,Z(383)],[Z(383),
150
150
  ]`:`(?>\r
151
151
  ?|[
152
152
  \v\f…\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${Z(e.codePointAt(0)-1)}${Z(e.codePointAt(2)+1)}-\u{10FFFF}`),n($(Kl(`[${e}]`),t))}else n($(ql(Kl(xl.get(u)),l),t));else if(c===`property`)_l.has(Ec(u))||(e.key=`sc`);else if(c===`space`)n(Jl(vc(`space`,{negate:l}),t));else if(c===`word`)n($(ql(Kl(hl),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=dc({flags:c});e.body[0].body=o(),i($(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&Hs(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(Q`Uses "\K" in a way that's unsupported`);let o=fc({behind:!0});o.body[0].body=a(),i($(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n($(fc({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=dc();t.body[0].body.push(e.body),e.body=$(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=Bl(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(Q`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Gl(n)&&(n=Il(n,t),e.ref=n)}},Ol={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=Jl(Pl(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&sl(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=sl(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=ol(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?Pl(0):Nl(o,r.groupOriginByCopy,null),l=c;if(!s){let e=Ll(Fl(o,e=>e.type===`Group`&&!!e.flags)),t=e?ol(r.globalFlags,e):r.globalFlags;jl(t,r.currentFlags)||(l=dc({flags:Rl(t)}),l.body[0].body.push(c))}n($(l,t),{traverse:!s})}},kl={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>Ml(t,e));i.length?i.length>1?n($(dc({atomic:!0,body:i.reverse().map(e=>tc({body:[rc(e.number)]}))}),t)):e.ref=i[0].number:n($(fc({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=ic();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Al(e){kc(e,{"*"({node:e,parent:t}){e.parent=t}})}function jl(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Ml(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=zl(n.parent);for(let r of t){if(r===n)break;if(r===e||Vl(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function Nl(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=Nl(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function Pl(e){let t=_c(e);return t.isRecursive=!0,t}function Fl(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Il(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function Ll(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Rl({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function zl(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Bl(e){let t=e.find(e=>e.kind===`search_start`||Wl(e,{negate:!1})||!Hl(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=Bl(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function Vl(e,t){let n=zl(e)??[];for(let e of n)if(e===t||Vl(e,t))return!0;return!1}function Hl({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function Ul(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function Wl(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&Hs(e.body[0],{type:`Assertion`,kind:`search_start`})}function Gl(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Kl(e,t){let n=Gs(e,{...t,unicodePropertyMap:_l}).body;return n.length>1||n[0].body.length>1?dc({body:n}):n[0].body[0]}function ql(e,t){return e.negate=t,e}function Jl(e,t){return e.parent=t,e}function $(e,t){return Al(e),e.parent=t,e}function Yl(e,t){let n=fl(t),r=cl(n.target,`ES2024`),i=cl(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];kc(e,Xl,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,ll(Zl[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&sl(f._captureTransfers,e.transferTo,[]).push(t)}),f}var Xl={"*":{enter({node:e},t){if(lu(e)){let n=t.getCurrentModI();t.pushModI(e.flags?ol({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){lu(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){ru(Z(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),iu(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&Tl.has(e.value)&&t.setHasCasedChar()}},Zl={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?Q`\B`:Q`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=Z(e),r=au(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&ru(n)){let e=gl(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);il.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(du)&&(o=[ac(45),...o.filter(e=>!du(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||il.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=dc(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=tc({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(il.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=au(n,i),o=au(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&ou(iu(e)).forEach(e=>{s.add(Array.isArray(e)?`${au(e[0],i)}-${au(e[1],i)}`:au(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:Q`[^\n]`;if(e===`digit`)return t?Q`\D`:Q`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&Tl.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Q`\P`:Q`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?Q`\W`:Q`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=ol(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${su(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+cu(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:Q`\g<${t}&R=${r}>`}},Ql=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),$l=new Set([`-`,`\\`,`]`,`^`,`[`]),eu=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),tu=new Map([[9,Q`\t`],[10,Q`\n`],[11,Q`\v`],[12,Q`\f`],[13,Q`\r`],[8232,Q`\u2028`],[8233,Q`\u2029`],[65279,Q`\uFEFF`]]),nu=/^\p{Cased}$/u;function ru(e){return nu.test(e)}function iu(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=Z(e);if(!ru(t))continue;let o=gl(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function au(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(tu.has(e))return tu.get(e);if(e<32||e>126&&e<160||e>262143||t&&uu(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?eu:$l:Ql,a=Z(e);return(i.has(a)?`\\`:``)+a}function ou(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function su(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function cu({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function lu({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function uu(e){return e>47&&e<58}function du({type:e,value:t}){return e===`Character`&&t===45}var fu=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=mu(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(pu(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=hu(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function pu(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function mu(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)sl(n,t,{}).transferTo=e;return n}function hu(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function gu(e,t){let n=_u(e,t);return n.options?new fu(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function _u(e,t){let n=fl(t),r=El(Gs(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:_l}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Yl(r,n),a=Qc(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=Hc(Gc(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function vu(e,t){return gu(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function yu(e={}){let t={target:`auto`,cache:new Map,...e};return t.regexConstructor||=e=>vu(e,{target:t.target}),{createScanner(e){return new Qo(e,t)},createString(e){return{content:e}}}}var bu=``+new URL(`c-BNa-DeUl.json`,import.meta.url).href,xu=``+new URL(`cpp-B-T4NRoH.json`,import.meta.url).href,Su=``+new URL(`csharp-BbxHChhA.json`,import.meta.url).href,Cu=``+new URL(`css-CWCxuwmz.json`,import.meta.url).href,wu=``+new URL(`diff-B-2N89g8.json`,import.meta.url).href,Tu=``+new URL(`docker-DWTvYW26.json`,import.meta.url).href,Eu=``+new URL(`go-B2hyYeNg.json`,import.meta.url).href,Du=``+new URL(`graphql-Z6Id2aNO.json`,import.meta.url).href,Ou=``+new URL(`html-BtzvlIfu.json`,import.meta.url).href,ku=``+new URL(`ini-Bn3Twap1.json`,import.meta.url).href,Au=``+new URL(`java-C7t2dwLO.json`,import.meta.url).href,ju=``+new URL(`javascript-DuC2v0C0.json`,import.meta.url).href,Mu=``+new URL(`json-CwdkWeV5.json`,import.meta.url).href,Nu=``+new URL(`jsonc-MYWDbTU3.json`,import.meta.url).href,Pu=``+new URL(`jsx-Cn8EZuIC.json`,import.meta.url).href,Fu=``+new URL(`kotlin-CFNOz1gw.json`,import.meta.url).href,Iu=``+new URL(`make-BVnlFCcl.json`,import.meta.url).href,Lu=``+new URL(`markdown-B4Xk2WM_.json`,import.meta.url).href,Ru=``+new URL(`php-CAQzQmmI.json`,import.meta.url).href,zu=``+new URL(`python-CYQee8m4.json`,import.meta.url).href,Bu=``+new URL(`ruby-D7R58tus.json`,import.meta.url).href,Vu=``+new URL(`rust-BFBbFiei.json`,import.meta.url).href,Hu=``+new URL(`scss-TQRhBkPG.json`,import.meta.url).href,Uu=``+new URL(`shellscript-DieAkC4W.json`,import.meta.url).href,Wu=``+new URL(`sql-Bxd030LV.json`,import.meta.url).href,Gu=``+new URL(`toml-ChrKGzsV.json`,import.meta.url).href,Ku=``+new URL(`tsx-D2e90MFw.json`,import.meta.url).href,qu=``+new URL(`typescript-DonXQ_n1.json`,import.meta.url).href,Ju=``+new URL(`xml-B17r2RXF.json`,import.meta.url).href,Yu={typescript:qu,tsx:Ku,javascript:ju,jsx:Pu,json:Mu,jsonc:Nu,yaml:``+new URL(`yaml-CKn4h1zy.json`,import.meta.url).href,toml:Gu,markdown:Lu,html:Ou,css:Cu,scss:Hu,shellscript:Uu,docker:Tu,python:zu,go:Eu,rust:Vu,java:Au,kotlin:Fu,c:bu,cpp:xu,csharp:Su,ruby:Bu,php:Ru,sql:Wu,graphql:Du,xml:Ju,make:Iu,ini:ku,diff:wu};function Xu(e){return[{scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:e.comment}},{scope:[`constant`,`constant.numeric`,`constant.language`,`support.constant`,`variable.other.constant`,`variable.language`],settings:{foreground:e.constant}},{scope:[`entity`,`entity.name.function`,`support.function`,`meta.function-call`],settings:{foreground:e.entity}},{scope:[`keyword`,`storage`,`storage.type`,`keyword.operator`,`punctuation.definition.keyword`],settings:{foreground:e.keyword}},{scope:[`string`,`string.quoted`,`punctuation.definition.string`,`support.type.property-name`],settings:{foreground:e.string}},{scope:[`variable`,`support.type`,`support.class`,`entity.name.type`,`entity.name.class`],settings:{foreground:e.variable}},{scope:[`entity.name.tag`,`entity.other.attribute-name`,`support.type.property-name.json`],settings:{foreground:e.tag}},{scope:[`markup.heading`,`entity.name.section`],settings:{foreground:e.heading}},{scope:[`markup.inserted`,`markup.inserted.diff`],settings:{foreground:e.inserted}},{scope:[`markup.deleted`,`markup.deleted.diff`],settings:{foreground:e.deleted}}]}var Zu={name:`reviews-dark`,type:`dark`,colors:{"editor.foreground":`#e6edf3`,"editor.background":`#0d1117`},tokenColors:Xu({comment:`#8b949e`,constant:`#79c0ff`,entity:`#d2a8ff`,keyword:`#ff7b72`,string:`#a5d6ff`,variable:`#ffa657`,tag:`#7ee787`,heading:`#79c0ff`,inserted:`#7ee787`,deleted:`#ffa198`})},Qu={name:`reviews-light`,type:`light`,colors:{"editor.foreground":`#1f2328`,"editor.background":`#ffffff`},tokenColors:Xu({comment:`#6e7781`,constant:`#0550ae`,entity:`#8250df`,keyword:`#cf222e`,string:`#0a3069`,variable:`#953800`,tag:`#116329`,heading:`#0550ae`,inserted:`#116329`,deleted:`#82071e`})},$u=null,ed=new Map,td={dark:`reviews-dark`,light:`reviews-light`};function nd(){return $u??=Xo({themes:[Zu,Qu],langs:[],engine:yu()}),$u}function rd(e,t){return fetch(Yu[t]).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(async n=>(await e.loadLanguage({...n,name:t}),!0)).catch(()=>!1)}async function id(e){let t=await nd(),n=ed.get(e);return n===void 0&&(n=rd(t,e),ed.set(e,n)),await n?t:null}function ad(e,t,n,r,i){let{tokens:a}=e.codeToTokens(t.join(`
153
- `),{lang:n,theme:td[r],grammarState:i});return{rows:a.map(e=>e.map(e=>({text:e.content,color:e.color??``,at:e.offset}))),state:a.length===0?i:e.getLastGrammarState(a)}}function od(e,t){let n=`${e??``}\n${t}`,[r,i]=(0,v.useState)({of:n,hunks:new Map,failure:null}),a=(0,v.useRef)(new Set),o=(0,v.useRef)(new Set),s=(0,v.useRef)([]);r.of!==n&&(s.current=[...a.current],a.current=new Set,o.current=new Set,i({of:n,hunks:new Map,failure:null}));let c=(0,v.useCallback)(r=>{if(e===null||r<0)return;let s=Math.floor(r/50);if(a.current.has(s))return;let c=a.current,l=o.current;c.add(s),k(e,s*50,50).then(e=>{if(e.fingerprint!==t){c.delete(s);return}i(t=>{if(t.of!==n)return t;let r=new Map(t.hunks);for(let t of e.hunks)r.set(t.id,t);return{...t,hunks:r}})}).catch(e=>{c.delete(s),l.add(s),i(t=>t.of===n?{...t,failure:e.message}:t)})},[e,t,n]);(0,v.useEffect)(()=>{c(0);for(let e of s.current)c(e*50);s.current=[]},[c]);let l=(0,v.useCallback)(()=>{let e=[...o.current];o.current=new Set,i(e=>e.of===n?{...e,failure:null}:e);for(let t of e)c(t*50)},[c,n]);return{hunks:r.hunks,need:c,failure:r.failure,retry:l}}function sd(e,t){let n=(0,v.useRef)(t);n.current=t;let r=(0,v.useRef)(e);r.current=e;let i=(0,v.useRef)(e=>e.dataset[r.current.attribute]),a=(0,v.useRef)(null);return a.current===null&&typeof IntersectionObserver==`function`&&(a.current=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=i.current(t.target);e!==void 0&&n.current(e)}},{rootMargin:e.margin})),(0,v.useEffect)(()=>{let e=a.current;return()=>e?.disconnect()},[]),(0,v.useCallback)(e=>{if(e===null)return;let t=a.current;if(t===null){let t=i.current(e);r.current.atMount&&t!==void 0&&n.current(t);return}return t.observe(e),()=>t.unobserve(e)},[])}function cd(e){return sd({attribute:`index`,margin:`400px 0px`,atMount:!0},t=>{let n=Number(t);Number.isFinite(n)&&e(n)})}function ld(e){return sd({attribute:`unread`,margin:`0px`,atMount:!1},e)}function ud(e){let t={old:[],new:[]},n=[];for(let r of e)r.on!==`new`&&t.old.push(r.text),r.on!==`old`&&t.new.push(r.text),n.push(r.on===`old`?{side:`old`,at:t.old.length-1}:{side:`new`,at:t.new.length-1});return{lines:t,from:n}}function dd(e,t,n,r){let[i,a]=(0,v.useState)({of:``,rows:[]}),[o,s]=(0,v.useState)(!1),c=Rt(e),l=(0,v.useRef)(t);l.current=t;let u=sd({attribute:`hunk`,margin:`200px 0px`,atMount:!0},()=>s(!0));(0,v.useEffect)(()=>{if(c===null||!o)return;let e=l.current,t=ud(e),i=[`old`,`new`].filter(e=>t.from.some(t=>t.side===e)),s=!0,u;return a({of:n,rows:e.map(()=>null)}),id(c).then(e=>{if(!s||e===null)return;let o=(l,d,f)=>{if(!s)return;let p=i[l];if(p===void 0)return;let m=t.lines[p],h=ad(e,m.slice(d,d+100),c,r,f);a(e=>{if(e.of!==n)return e;let r=[...e.rows];return t.from.forEach((e,t)=>{if(e.side!==p)return;let n=h.rows[e.at-d];e.at>=d&&n!==void 0&&(r[t]=n)}),{of:n,rows:r}}),d+100<m.length?u=setTimeout(()=>o(l,d+100,h.state),0):l+1<i.length&&(u=setTimeout(()=>o(l+1,0,void 0),0))};o(0,0,void 0)}),()=>{s=!1,clearTimeout(u)}},[c,n,r,o]);let d=i.of===n?i.rows:[];return(0,v.useMemo)(()=>({ref:u,rows:d}),[u,d])}var fd=[5,10],pd=1e5,md=[`undo`,`explain`,`talk`,`comment`];function hd(e){let t=e.lastIndexOf(`/`);return t===-1?{dir:``,name:e}:{dir:e.slice(0,t+1),name:e.slice(t+1)}}var gd=2;function _d(e){let t=e.filter(e=>e.lines!==null&&e.lines.length>0).map(e=>({kind:e.kind,note:e.key,first:Math.min(...e.lines),last:Math.max(...e.lines)})).sort((e,t)=>e.first-t.first||t.last-e.last),n=Array.from({length:gd},()=>0),r=new Map;for(let e of t){let t=n.findIndex(t=>t<e.first),i=t===-1?0:t;n[i]=Math.max(n[i]??0,e.last);for(let t=e.first;t<=e.last;t+=1){let n=r.get(t)??[];n.push({lane:i,kind:e.kind,note:e.note,first:t===e.first,last:t===e.last}),r.set(t,n)}}return r}function vd(e){return(0,V.jsx)(`span`,{style:{color:e.color},children:e.text},e.at)}function yd(e){return e===`info`?``:` is-${e}`}function bd(e,t){let n=(e.lines??[]).filter(e=>t.has(e));return n.length===0?null:Math.min(...n)}function xd(e,t){let n=Math.min(e,t),r=Math.max(e,t);return Array.from({length:r-n+1},(e,t)=>n+t)}function Sd(e){let{file:t,hunk:n}=e,r=e.entry.id,i=t=>e.onAct({act:`mark`,hunk:r,seen:t}),a=t=>e.onAct({act:`comment`,hunk:r,kind:`talk`,text:``,lines:t}),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(new Set),[y,b]=(0,v.useState)(e.draft?.act??null),[x,ee]=(0,v.useState)(e.draft?.note??null),[te,S]=(0,v.useState)(()=>{let t=e.draft?.lines??[];return t.length===0?null:{from:Math.min(...t),to:Math.max(...t)}}),C=e.draft;(0,v.useEffect)(()=>{C===null||y!==null||(b(C.act),ee(C.note),S(C.lines.length===0?null:{from:Math.min(...C.lines),to:Math.max(...C.lines)}))},[C,y]);let w=(t,n,r,i)=>{b(t),ee(i),S(n.length===0?null:{from:Math.min(...n),to:Math.max(...n)}),e.onDraft({act:t,lines:n,text:r,note:i})},ne=()=>{b(null),ee(null),e.onDraft(null)},T=e.entry.id,E=(0,v.useRef)(n?.header??``);n!==null&&E.current!==n.header&&(E.current=n.header,s([]),l([]),d(null));let D=t?.newBlob??null,O=te===null?[]:xd(te.from,te.to),re=n===null?[]:[...o.map(e=>({text:e,on:`both`})),...n.lines.map(e=>({text:e.text,on:e.kind===`add`?`new`:e.kind===`remove`?`old`:`both`})),...c.map(e=>({text:e,on:`both`}))],ie=n===null?``:`${T}|${n.header}|${o.length}|${c.length}`,k=dd(n?.path??``,re,ie,e.theme),oe=(0,v.useCallback)(async(t,r)=>{if(n===null||D===null)return;let i=n.newStart-o.length,a=n.newStart+n.newLines-1+c.length,u=t===`above`?Math.max(1,i-(r??i-1)):a+1,f=t===`above`?i-u:r??pd;if(!(f<=0))try{let n=await ae(e.slug,D,u,f);if(d(n.total),n.lines.length===0)return;t===`above`?s(e=>[...n.lines,...e]):l(e=>[...e,...n.lines])}catch(e){p(e instanceof Error?e.message:`that context could not be read`)}},[o.length,c.length,D,n,e.slug]),se=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ce=e=>{S(t=>t===null?{from:e,to:e}:xd(t.from,t.to).includes(e)?null:{from:t.from,to:e})};if(n===null)return(0,V.jsxs)(`section`,{className:`rv-hunk rv-waiting`,"data-index":e.index,"data-hunk":T,"data-key":e.cardKey,ref:e.watch,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{className:`rv-skel is-narrow`}),(0,V.jsx)(`span`,{className:`rv-skel is-wide`}),(0,V.jsx)(`span`,{className:`rv-skel is-half`})]});let{dir:le,name:A}=hd(n.path),j=n.header===``?`the whole file`:n.header,N=_d(e.notes),ue=yd(pe(e.notes.map(e=>e.kind))),P=new Set;for(let e=n.newStart-o.length;e<n.newStart;e+=1)P.add(e);for(let e of n.lines)e.newLine!==null&&P.add(e.newLine);for(let e=0;e<c.length;e+=1)P.add(n.newStart+n.newLines+e);let F=e.notes.filter(e=>bd(e,P)===null),I=new Map;for(let t of e.notes){let e=bd(t,P);e!==null&&I.set(e,[...I.get(e)??[],t])}let L=F.length>0?` is-note${ue}`:``,de=F.some(t=>e.aside.has(t.key)),fe=()=>y===null?null:(0,V.jsx)(xt,{act:y,lines:O,text:e.draft?.text??``,busy:e.busy,onChange:t=>e.onDraft({act:y,lines:O,text:t,note:x}),onWrite:t=>{ne(),S(null),e.onAct({act:`comment`,hunk:r,kind:y,text:t,lines:O})},onCancel:ne}),me=y!==null&&x!==null&&e.notes.some(e=>e.key===x)?x:null,he=t=>(0,V.jsx)(Mt,{notes:t,aside:e.aside,shown:g,readable:e.readable,readOnlySaid:e.readOnlySaid,busy:e.busy,onAsk:e=>w(`fix`,e.lines??[],e.text,e.key),onTalk:e=>a(e.lines??[]),onComment:e=>w(`comment`,e.lines??[],``,e.key),onDismiss:(t,n)=>e.onAct({act:`dismiss`,hunk:r,key:t.key,on:n}),box:me!==null&&t.some(e=>e.key===me)?{note:me,element:fe()}:null});if(e.seen&&!e.open)return(0,V.jsxs)(`div`,{className:`rv-folded${F.length>0||N.size>0?` is-note${ue}`:``}`,"data-hunk":T,"data-key":e.cardKey,children:[(0,V.jsx)(`span`,{className:`rv-ok`,"aria-hidden":`true`,children:`✓`}),(0,V.jsx)(`span`,{children:`Seen`}),(0,V.jsx)(`span`,{className:`rv-mono`,children:n.path}),(0,V.jsx)(`span`,{className:`rv-mono`,children:j}),e.notes.length>0&&(0,V.jsxs)(`span`,{className:`rv-fnotes`,children:[e.notes.length,` note`,e.notes.length===1?``:`s`]}),(0,V.jsx)(`span`,{className:`rv-grow`}),e.changed&&(0,V.jsx)(`span`,{className:`rv-changed`,children:`Changed since you saw it`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:()=>e.onOpen(!0),children:`Expand`})]});let R=n.newStart-o.length,ge=n.newStart+n.newLines-1+c.length,z=D!==null&&R>1,_e=D!==null&&(u===null||ge<u),ve=(t,n,r)=>{let i=t.kind===`add`?` is-add`:t.kind===`remove`?` is-del`:``,a=k.rows[r]??null,o=t.newLine===null?[]:N.get(t.newLine)??[],s=o.length===0?``:` is-note${yd(pe(o.map(e=>e.kind)))}`,c=t.newLine!==null&&O.includes(t.newLine),l=t.newLine===null?[]:I.get(t.newLine)??[];return(0,V.jsxs)(v.Fragment,{children:[l.length>0&&he(l),(0,V.jsxs)(`div`,{className:`rv-l${i}${s}${c?` is-picked`:``}`,"data-line":t.newLine??void 0,"data-old":t.oldLine??void 0,children:[o.map(n=>{let r=`rv-nl is-lane${n.lane}${yd(n.kind)}${n.first?` is-first`:``}${n.last?` is-last`:``}`;return e.aside.has(n.note)?(0,V.jsx)(`button`,{type:`button`,className:r,"data-note":n.note,"aria-label":`Show the note put aside on line ${t.newLine}`,onClick:()=>se(n.note)},n.lane):(0,V.jsx)(`i`,{className:r,"data-note":n.note,"aria-hidden":`true`},n.lane)}),(0,V.jsx)(`span`,{className:`rv-ln`,children:t.oldLine??``}),t.newLine===null?(0,V.jsx)(`span`,{className:`rv-ln`}):(0,V.jsx)(`button`,{type:`button`,className:`rv-ln`,"aria-label":`Line ${t.newLine}`,"aria-pressed":c,onClick:()=>ce(t.newLine),children:t.newLine}),(0,V.jsxs)(`span`,{children:[t.kind===`add`?`+`:t.kind===`remove`?`-`:` `,a===null?t.text:a.map(e=>vd(e))]})]})]},n)},ye=(e,t,r)=>ve({kind:`context`,text:e,oldLine:t-(n.newStart-n.oldStart),newLine:t,noNewline:!1},`c${t}`,r),be=e=>(0,V.jsxs)(`div`,{className:`rv-expand`,children:[fd.map(t=>(0,V.jsxs)(`button`,{type:`button`,className:`rv-link`,onClick:()=>void oe(e,t),children:[`+`,t]},t)),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:()=>void oe(e,null),children:`whole file`})]});return(0,V.jsxs)(`section`,{className:`rv-hunk${e.readable?``:` is-dim`}`,"data-hunk":T,"data-key":e.cardKey,"data-index":e.index,ref:k.ref,children:[(0,V.jsxs)(`div`,{className:`rv-fh${L}`,children:[F.length>0&&(0,V.jsx)(At,{aside:de,onShow:()=>{for(let t of F)e.aside.has(t.key)&&se(t.key)}}),(0,V.jsxs)(`span`,{className:`rv-path rv-mono`,children:[le!==``&&(0,V.jsx)(`i`,{children:le}),A]}),(0,V.jsx)(`span`,{className:`rv-mono`,children:j}),e.also.length>0&&(0,V.jsxs)(`span`,{className:`rv-also`,children:[`also in `,e.also.map(e=>`"${e}"`).join(`, `)]}),(0,V.jsx)(`span`,{className:`rv-grow`}),e.changed&&(0,V.jsx)(`span`,{className:`rv-changed`,children:`Changed since you saw it`}),(o.length>0||c.length>0)&&(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:()=>{s([]),l([])},children:`Back to the hunk`}),e.readable&&!e.fileRead&&(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,disabled:e.busy,onClick:()=>e.onAct({act:`bulk`,kind:`file`,id:e.file?.key??``}),children:`Mark file Seen`}),e.seen&&e.readable?(0,V.jsxs)(`button`,{type:`button`,className:`rv-state is-seen`,disabled:e.busy,"aria-label":`Mark as not seen`,onClick:()=>i(!1),children:[(0,V.jsx)(`span`,{className:`rv-state-on`,children:`✓ Seen`}),(0,V.jsx)(`span`,{className:`rv-state-off`,children:`Not seen`})]}):(0,V.jsx)(`span`,{className:`rv-state${e.seen?` is-seen`:``}`,children:e.seen?`✓ Seen`:`pending`}),e.seen&&(0,V.jsx)(`button`,{type:`button`,className:`rv-icon`,"aria-label":`Fold this hunk`,onClick:()=>e.onOpen(!1),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M3 10l5-5 5 5`})})})]}),F.length>0&&he(F),(0,V.jsxs)(`div`,{className:`rv-diff`,children:[z&&be(`above`),o.map((e,t)=>ye(e,R+t,t)),(0,V.jsx)(`div`,{className:`rv-hd`,children:j}),n.lines.map((e,t)=>ve(e,`${e.oldLine??`x`}-${e.newLine??`x`}`,o.length+t)),c.map((e,t)=>ye(e,n.newStart+n.newLines+t,o.length+n.lines.length+t)),_e&&be(`below`)]}),f!==null&&(0,V.jsx)(`p`,{className:`rv-trouble`,children:f}),me===null&&fe(),e.threads.map(t=>(0,V.jsx)(Ft,{thread:t,readable:e.readable,agentHolds:e.agentHolds,busy:e.busy,onClose:()=>e.onAct({act:`close-thread`,thread:t.id}),watch:e.watchReply},t.id)),e.readable&&(0,V.jsxs)(V.Fragment,{children:[m&&(0,V.jsxs)(`div`,{className:`rv-fabmenu`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-seen`,disabled:e.busy,onClick:()=>{h(!1),i(!e.seen)},children:e.seen?`Not seen`:`✓ Seen`}),(0,V.jsx)(`hr`,{}),md.map(t=>t===`talk`?(0,V.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>{h(!1),a(O),S(null)},children:`Let's talk`},t):(0,V.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>{h(!1),w(t,O,``,null)},children:M[t]},t))]}),(0,V.jsx)(`button`,{type:`button`,className:`rv-fab`,"aria-expanded":m,"aria-label":`Act on ${n.path} ${j}`,onClick:()=>h(e=>!e),children:m?`×`:`+`})]})]})}var Cd={binary:`binary`,generated:`generated`,oversize:`too large to read as a diff`,text:`whole file`};function wd(e,t){let[n,r]=(0,v.useState)({old:null,new:null}),i=t?.oldBlob??null,a=t?.newBlob??null;return(0,v.useEffect)(()=>{let t=!0,n=t=>t===null?Promise.resolve(null):A(`${e}/${je}/${t}`);return Promise.all([n(i),n(a)]).then(([e,n])=>{t&&r({old:e,new:n})}),()=>{t=!1}},[e,i,a]),n}function Td(e){let{file:t,hunk:n}=e,r=e.entry.id,a=wd(e.slug,t),[o,s]=(0,v.useState)(new Set),c=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[l,u]=(0,v.useState)(e.draft?.act??null),[d,f]=(0,v.useState)(e.draft?.note??null),h=e.draft;(0,v.useEffect)(()=>{h===null||l!==null||(u(h.act),f(h.note))},[h,l]);let g=(t,n,r)=>{u(t),f(n.key),e.onDraft({act:t,lines:n.lines??[],text:r,note:n.key})},_=()=>{u(null),f(null),e.onDraft(null)},y=e.draft?.lines??[],b=n?.path??t?.path??e.entry.id,x=Math.max(t?.oldBytes??0,t?.newBytes??0)>m,ee=p(b)===`image`&&!x;if(n===null)return(0,V.jsx)(`div`,{className:`rv-nt-row rv-waiting`,"data-index":e.index,"data-hunk":e.entry.id,"data-key":e.cardKey,ref:e.watch,children:(0,V.jsx)(`span`,{className:`rv-mono`,children:b})});let te=t===null||t.added===0&&t.deleted===0?``:`+${t.added} -${t.deleted}`,S=[t?.oldBytes??null,t?.newBytes??null].filter(e=>e!==null).map(i).join(` → `);return(0,V.jsxs)(`div`,{className:`rv-nt-row`,"data-hunk":e.entry.id,"data-key":e.cardKey,"data-index":e.index,children:[(0,V.jsxs)(`div`,{className:`rv-nt-head${e.notes.length>0?` is-note`:``}`,children:[e.notes.length>0&&(0,V.jsx)(At,{aside:e.notes.some(t=>e.aside.has(t.key)),onShow:()=>{for(let t of e.notes)e.aside.has(t.key)&&c(t.key)}}),(0,V.jsx)(`span`,{className:`rv-mono`,children:b}),(0,V.jsxs)(`span`,{className:`rv-facts`,children:[Cd[t?.category??`text`],te===``?``:` - ${te}`,S===``?``:` - ${S}`,x?` - too large to show`:``]}),(0,V.jsx)(`span`,{className:`rv-grow`}),e.seen?(0,V.jsx)(`span`,{className:`rv-ok`,children:`✓ Seen`}):e.readable&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy,onClick:()=>e.onAct({act:`mark`,hunk:r,seen:!0}),children:`Mark Seen`})]}),e.notes.length>0&&(0,V.jsx)(Mt,{notes:e.notes,aside:e.aside,shown:o,readable:e.readable,readOnlySaid:e.readOnlySaid,busy:e.busy,onAsk:e=>g(`fix`,e,e.text),onTalk:t=>e.onAct({act:`comment`,hunk:r,kind:`talk`,text:``,lines:t.lines??[]}),onComment:e=>g(`comment`,e,``),onDismiss:(t,n)=>e.onAct({act:`dismiss`,hunk:r,key:t.key,on:n}),box:l!==null&&d!==null?{note:d,element:(0,V.jsx)(xt,{act:l,lines:y,text:e.draft?.text??``,busy:e.busy,onChange:t=>e.onDraft({act:l,lines:y,text:t,note:d}),onWrite:t=>{_(),e.onAct({act:`comment`,hunk:r,kind:l,text:t,lines:y})},onCancel:_})}:null}),ee&&(0,V.jsxs)(`div`,{className:`rv-nt-images`,children:[a.old!==null&&(0,V.jsxs)(`figure`,{children:[(0,V.jsx)(`img`,{src:a.old,alt:`${b} before`}),(0,V.jsx)(`figcaption`,{children:`before`})]}),a.new!==null&&(0,V.jsxs)(`figure`,{children:[(0,V.jsx)(`img`,{src:a.new,alt:`${b} after`}),(0,V.jsx)(`figcaption`,{children:`after`})]})]})]})}var Ed={collapse:0,fold:0};function Dd(e,t,n){let[r,i]=(0,v.useState)(Ed),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(0);return(0,v.useEffect)(()=>{if(a===null||typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(e=>{for(let t of e)c(Math.round(t.contentRect.height))});return e.observe(a),()=>e.disconnect()},[a]),(0,v.useEffect)(()=>{let r=e.current;if(r===null||s===0){i(Ed);return}let a=0,o=()=>{a=0;let e=t.current;if(e===null)return;let o=r.getBoundingClientRect().top+n-e.getBoundingClientRect().top,c=Math.min(1,Math.max(0,o/s));i(e=>e.fold===s&&Math.abs(e.collapse-c)*s<1?e:{collapse:c,fold:s})},c=()=>{a===0&&(a=requestAnimationFrame(o))};return o(),r.addEventListener(`scroll`,c,{passive:!0}),()=>{r.removeEventListener(`scroll`,c),a!==0&&cancelAnimationFrame(a)}},[e,t,n,s]),[r,o]}var Od=new Set;function kd(e){let t=e.kit,n=e.section,r=`group:${n.id}`,i=t.drafts.get(r)??null,a=i!==null,o=(0,v.useRef)(null),[s,c]=Dd(t.feed,o,e.pinned),l=t.summary.of(n.id).counts,u=t.index.threads.get(z(`group`,n.id))??[],d=ve(t.index,n).flatMap(e=>{let n=t.entryOf.get(e);return n===void 0?[]:[n]}),f=d.filter(e=>t.files[e.file]?.category===`text`),p=d.filter(e=>t.files[e.file]?.category!==`text`),m=(e,r)=>{let i=`${n.id}-${e.id}`,a=t.seen.has(e.id),o=`hunk:${e.id}`,s=t.opened.has(e.id)||t.drafts.has(o),c={cardKey:i,slug:t.review.slug,entry:e,file:t.files[e.file]??null,hunk:t.pages.get(e.id)??null,seen:a,busy:t.busy,readable:t.readable,readOnlySaid:t.readOnlySaid,agentHolds:t.agentHolds,onAct:t.onAct,index:t.order.get(e.id)??0,watch:t.watch,notes:t.index.notes.get(e.id)??[],aside:t.index.aside.get(e.id)??Od};return r?(0,V.jsx)(Td,{...c,draft:t.drafts.get(o)??null,onDraft:e=>t.onDraft(o,e)},i):(0,V.jsx)(Sd,{...c,theme:t.theme,fileRead:t.entries.every(n=>n.file!==e.file||t.seen.has(n.id)),changed:t.index.changed.has(e.id),also:(t.summary.holders().get(e.id)??[]).filter(e=>e!==n.name),open:s,onOpen:n=>t.onOpen(e.id,n),draft:t.drafts.get(o)??null,onDraft:e=>t.onDraft(o,e),threads:t.index.threads.get(z(`hunk`,e.id))??[],watchReply:t.watchReply},i)};return(0,V.jsxs)(`div`,{className:`rv-section`,"data-section":n.id,ref:o,children:[(0,V.jsx)(Dt,{section:n,counts:l,shared:t.summary.shared(n.id),collapse:s,fold:c,under:e.pinned>0,controls:e.controls,onWalk:e.onWalk,readable:t.readable,busy:t.busy,onBulk:()=>t.onAct({act:`bulk`,kind:`group`,id:n.id}),onComment:()=>t.onDraft(r,{act:`group-comment`,lines:[],text:``,note:null})}),(a||u.length>0)&&(0,V.jsxs)(`div`,{className:`rv-gtalk`,children:[a&&(0,V.jsx)(xt,{act:`group-comment`,lines:[],text:i?.text??``,busy:t.busy,onChange:e=>t.onDraft(r,{act:`group-comment`,lines:[],text:e,note:null}),onWrite:e=>{t.onDraft(r,null),t.onAct({act:`group-comment`,group:n.id,text:e})},onCancel:()=>t.onDraft(r,null)}),u.map(e=>(0,V.jsx)(Ft,{thread:e,readable:t.readable,agentHolds:t.agentHolds,busy:t.busy,onClose:()=>t.onAct({act:`close-thread`,thread:e.id}),watch:t.watchReply},e.id))]}),f.map(e=>m(e,!1)),p.length>0&&(0,V.jsxs)(`details`,{className:`rv-nt`,children:[(0,V.jsxs)(`summary`,{children:[`Non-textual (`,p.length,`)`,(0,V.jsx)(`span`,{className:`rv-nt-names`,children:p.map(e=>t.files[e.file]?.path??``).join(`, `)})]}),p.map(e=>m(e,!0))]})]})}var Ad=1200;function jd(e){return e.replace(/["\\]/g,e=>`\\${e}`)}function Md(e){let t=e.review,n=e.index,r=t.baseline,i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(!1),c=(0,v.useRef)(null),l=r?.entries??[],u=n.places,d=(0,v.useMemo)(()=>new Map(l.map(e=>[e.id,e])),[l]),f=r?.files??[],p=e.sections,m=e.group===`all`,h=p.filter(t=>m||t.id===e.group),g=Ie(t.state),_=Le(t.state),y=Re(t.state),b={review:t,index:n,summary:e.summary,entries:l,entryOf:d,files:f,order:u,pages:e.hunks,seen:n.seen,readable:g,readOnlySaid:_,agentHolds:y,busy:e.busy,theme:e.theme,opened:e.opened,drafts:e.drafts,feed:i,watch:e.watch,watchReply:e.watchReply,onAct:e.onAct,onOpen:e.onOpen,onDraft:e.onDraft},x=t=>n.seen.has(t)&&!e.opened.has(t)&&!e.drafts.has(`hunk:${t}`),ee=e=>{let t=i.current;if(t===null)return null;let r=t.querySelector(`[data-section="${jd(e.section)}"]`)??t;if(e.message!==null)return r.querySelector(`[data-message="${jd(e.message)}"]`);if(e.hunk===null)return r===t?null:r;let a=r.querySelector(`[data-hunk="${jd(e.hunk)}"]`);if(a===null||e.note===null)return a;let o=a.querySelector(`[data-note="${jd(e.note)}"]`);if(o!==null)return o;let s=(n.notes.get(e.hunk)??[]).find(t=>t.key===e.note),c=s===void 0?null:L(s);return(c===null?null:a.querySelector(`[data-line="${c}"]`))??a},te=(e,t)=>{let n=i.current,r=e.closest(`.rv-section`),a=r?.querySelector(`.rv-ghead`)??null;if(n===null||r===null||a===null)return null;let o=n.getBoundingClientRect(),s=e.getBoundingClientRect();return kt({scrollTop:n.scrollTop,feedTop:o.top,feedHeight:o.height,pinned:a.classList.contains(`is-under`)?44:0,sectionTop:r.getBoundingClientRect().top,headerHeight:a.getBoundingClientRect().height,fold:Number.parseFloat(a.style.getPropertyValue(`--rv-fold`))||0,collapse:Number.parseFloat(a.style.getPropertyValue(`--rv-collapse`))||0,targetTop:s.top,targetHeight:s.height,underHeader:e!==r&&!a.contains(e),block:t})},S=e=>{let t=c.current;t!==null&&(clearTimeout(t.timer),t.element.classList.remove(`is-landed`)),e.classList.add(`is-landed`),c.current={element:e,timer:setTimeout(()=>{e.classList.remove(`is-landed`),c.current=null},Ad)}},C=t=>{let n=t.hunk;if(n!==null){let t=u.get(n);if(t!==void 0&&e.need(t),!e.hunks.has(n))return!1;if(x(n))return e.onOpen(n,!0),!1}let r=ee(t);if(r===null)return!1;let a=r.closest(`details`);a!==null&&!a.open&&(a.open=!0);let o=t.note===null&&t.message===null,s=te(r,o?`start`:`center`),c=i.current;return s!==null&&c!==null&&typeof c.scrollTo==`function`?c.scrollTo({top:s}):typeof r.scrollIntoView==`function`&&r.scrollIntoView({block:o?`start`:`center`}),S(r),!0},w=(0,v.useRef)(C);w.current=C;let ne=e.want,T=e.hunks,E=e.onLanded,D=e.opened;(0,v.useEffect)(()=>{ne!==null&&w.current(ne.target)&&E()},[ne,T,D,E]);let O=e.startAt;(0,v.useEffect)(()=>{s.current||T.size===0||i.current===null||(s.current=!0,i.current.scrollTop=O)},[T.size,O]),(0,v.useEffect)(()=>()=>{let e=c.current;e!==null&&clearTimeout(e.timer)},[]);let re=e.summary.of(e.scope).controls,ie=m?e.coming:0,k=m?n.gone:[],ae=[{kind:`groups`,held:h.length,draw:()=>h.map(t=>(0,V.jsx)(kd,{section:t,kit:b,controls:m?null:re,onWalk:e.onWalk,pinned:m?44:0},t.id))},{kind:`coming`,held:ie,draw:()=>Array.from({length:ie},(e,t)=>`coming-${t}`).map(e=>(0,V.jsx)(`div`,{className:`rv-section`,children:(0,V.jsxs)(`div`,{className:`rv-ghead is-skel`,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{className:`rv-skel is-narrow`}),(0,V.jsx)(`span`,{className:`rv-skel is-wide`})]})},e))},{kind:`gone`,held:k.length,draw:()=>(0,V.jsxs)(`section`,{className:`rv-gcard`,"data-section":I,children:[(0,V.jsxs)(`div`,{className:`rv-gcard-top`,children:[(0,V.jsx)(`h3`,{children:He}),(0,V.jsxs)(`span`,{className:`rv-facts`,children:[k.length,` thread`,k.length===1?``:`s`]})]}),(0,V.jsx)(`p`,{children:`The hunk each of these was about is no longer in the change. Close it once it is settled.`}),k.map(t=>(0,V.jsx)(Ft,{thread:t,readable:g,agentHolds:y,busy:e.busy,onClose:()=>e.onAct({act:`close-thread`,thread:t.id}),watch:e.watchReply},t.id))]})}],oe=ae.every(e=>e.held===0);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`rv-feed`,ref:i,onScroll:t=>{let n=t.currentTarget;o(n.scrollTop>n.clientHeight),e.onScroll(n.scrollTop)},children:(0,V.jsx)(`div`,{className:`rv-fgrid`,children:(0,V.jsxs)(`div`,{className:`rv-fmain${m?` is-all`:``}`,children:[m&&(0,V.jsx)(Ot,{hunks:n.order.length,groups:t.metadata.groups.length,controls:re,onWalk:e.onWalk}),ae.map(e=>(0,V.jsx)(v.Fragment,{children:e.held===0?null:e.draw()},e.kind)),oe&&(0,V.jsx)(`p`,{className:`rv-facts`,children:r===null?`This review has no baseline to draw.`:`Nothing is grouped yet, and nothing is left to read.`})]})})}),a&&(0,V.jsx)(`button`,{type:`button`,className:`rv-totop`,"aria-label":`Scroll to top`,onClick:()=>i.current?.scrollTo({top:0}),children:`↑`})]})}function Nd(e){let[t,n]=(0,v.useState)(!1),r=e.openAsked??0;(0,v.useEffect)(()=>{r>0&&n(!0)},[r]);let i=e.items.length;return i===0?null:(0,V.jsxs)(`aside`,{className:`rv-send${t?` is-open`:``}`,"aria-label":`Pending feedback`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[!t&&(0,V.jsxs)(`button`,{type:`button`,className:`rv-sendpill`,onClick:()=>n(!0),children:[`Send to agent`,(0,V.jsx)(`span`,{className:`rv-n`,children:i})]}),t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`rv-send-head`,children:`Pending feedback`}),e.items.map(t=>(0,V.jsxs)(`div`,{className:`rv-si`,children:[(0,V.jsx)(`b`,{children:M[t.act]}),(0,V.jsx)(`span`,{className:`rv-f`,children:e.whereOf(t)}),(0,V.jsx)(`span`,{className:`rv-q`,children:t.text}),(0,V.jsxs)(`span`,{className:`rv-si-ctl`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Edit ${M[t.act]}`,disabled:!e.readable||e.busy,onClick:()=>e.onEdit(t),children:`✎`}),(0,V.jsx)(`button`,{type:`button`,"aria-label":`Remove ${M[t.act]}`,disabled:!e.readable||e.busy,onClick:()=>e.onRemove(t),children:`×`})]})]},t.id)),(0,V.jsxs)(`p`,{className:`rv-send-foot`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`rv-btn is-primary`,disabled:!e.readable||e.busy,onClick:e.onSend,children:[`Send to agent (`,i,`)`]}),(0,V.jsx)(`small`,{children:`The agent works while you wait, and this review turns read-only`})]})]})]})}function Pd(e){let t=e=>e!==null&&e!==`ungrouped`;return{groups:e.metadata.groups.length,notes:e.metadata.notes.length,aside:e.dismissals.items.length,talk:e.threads.threads.filter(e=>e.kind===`group`&&t(e.anchor)).length,unsent:e.pending.items.filter(e=>t(e.group)).length}}function Fd(e,t){return`${e} ${t}${e===1?``:`s`}`}function Id(e){let t=[];e.groups>0&&t.push(`The agent's ${Fd(e.groups,`group`)}`),e.notes>0&&t.push(`The agent's ${Fd(e.notes,`note`)}`),e.aside>0&&t.push(`The ${Fd(e.aside,`note`)} you put aside`);let n=[];return e.talk>0&&n.push(Fd(e.talk,`conversation`)),e.unsent>0&&n.push(Fd(e.unsent,`unsent comment`)),n.length>0&&t.push(`Your ${n.join(` and `)} on whole groups`),t.length===0&&t.push(`Nothing yet: the agent has not written anything.`),t}function Ld(e){let t=e.review,n=Pd(t),[r,i]=(0,v.useState)(``),{onCancel:a}=e;return(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),(0,V.jsx)(`div`,{className:`dialog-shade`,children:(0,V.jsxs)(`form`,{className:`dialog rv-rdialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Reset the review of "${t.state.name}"`,onSubmit:t=>{t.preventDefault(),!e.busy&&e.onReset(r.trim())},children:[(0,V.jsxs)(`h2`,{className:`rail-head rv-adialog-head`,children:[(0,V.jsx)(`span`,{children:`Reset the review`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-icon rv-adialog-x`,"aria-label":`Close the dialog`,onClick:e.onCancel,children:`×`})]}),(0,V.jsxs)(`div`,{className:`dialog-body`,children:[(0,V.jsx)(`p`,{className:`rv-rsays`,children:`The agent reads the change again and groups and notes it from nothing.`}),(0,V.jsxs)(`div`,{className:`rv-rgoes`,children:[(0,V.jsx)(`h4`,{children:`Deleted`}),(0,V.jsx)(`ul`,{children:Id(n).map(e=>(0,V.jsx)(`li`,{children:e},e))}),(0,V.jsx)(`h4`,{children:`Kept`}),(0,V.jsxs)(`ul`,{children:[(0,V.jsx)(`li`,{children:`Your Seen marks`}),(0,V.jsx)(`li`,{children:`Everything you wrote on a hunk`})]})]}),(0,V.jsxs)(`label`,{htmlFor:`rv-instruction`,children:[`An instruction to the agent `,(0,V.jsx)(`small`,{children:`optional`})]}),(0,V.jsx)(`textarea`,{id:`rv-instruction`,value:r,disabled:e.busy,maxLength:Fe,placeholder:`What to look for this time, if anything`,onChange:e=>i(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`dialog-acts rv-adialog-acts`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy,onClick:e.onCancel,children:`Cancel`}),(0,V.jsx)(`button`,{type:`submit`,className:`rv-btn is-small is-warn`,disabled:e.busy,children:`Reset`})]})]})})}function Rd(e,t){let n=(0,v.useRef)(t);n.current=t;let r=(0,v.useRef)(null),i=(0,v.useRef)(!1),a=(0,v.useCallback)(()=>{r.current=null,!(!i.current||e===null)&&(i.current=!1,le(e,`place`,n.current()).catch(()=>{}))},[e]),o=(0,v.useCallback)(()=>{i.current=!0,r.current===null&&(r.current=setTimeout(a,500))},[a]);return(0,v.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current),r.current=null,a()},[a]),o}var zd=[`unseen`,`issue`,`attention`,`reply`];function Bd(e){return`${e.section}\n${e.hunk??``}\n${e.note??``}\n${e.message??``}`}function Vd(e,t){return{section:e,hunk:t,note:null,message:null}}function Hd(e,t){let n=[],r=(e,t,r)=>{n.push({key:Bd(t),kind:e,target:t,open:r})};for(let n of e.threads.get(z(`group`,t.id))??[])for(let i of n.messages)i.from===`agent`&&r(`reply`,{section:t.id,hunk:null,note:null,message:i.id},e.unread.has(i.id));for(let n of ve(e,t)){r(`unseen`,Vd(t.id,n),!e.seen.has(n));let i=new Set((e.open.get(n)??[]).map(e=>P(e.hunk,e.key)));for(let a of e.notes.get(n)??[])a.kind!==`info`&&r(a.kind,{section:t.id,hunk:n,note:a.key,message:null},i.has(P(a.hunk,a.key)));for(let i of e.threads.get(z(`hunk`,n))??[])for(let a of i.messages)a.from===`agent`&&r(`reply`,{section:t.id,hunk:n,note:null,message:a.id},e.unread.has(a.id))}return n}function Ud(e){let t=[];for(let n of e.gone)for(let r of n.messages){if(r.from!==`agent`)continue;let n={section:I,hunk:null,note:null,message:r.id};t.push({key:Bd(n),kind:`reply`,target:n,open:e.unread.has(r.id)})}return t}function Wd(e,t){return[...t.flatMap(t=>e.of(t)),...e.gone()]}function Gd(e,t,n){let r=e.length;if(r===0)return null;let i=n===null?-1:e.findIndex(e=>e.key===n);for(let n=1;n<=r;n+=1){let a=e[(i+n+r)%r];if(a!==void 0&&a.kind===t&&a.open)return a}return null}function Kd(e,t){for(let n of t){if((e.threads.get(z(`group`,n.id))??[]).some(e=>e.open))return{section:n.id,hunk:null,note:null,message:null};for(let t of ve(e,n))if((e.threads.get(z(`hunk`,t))??[]).some(e=>e.open))return Vd(n.id,t)}return e.gone.length===0?null:{section:I,hunk:null,note:null,message:null}}function qd(e,t,n,r){let i=t.findIndex(e=>e.id===n),a=i===-1?[...t]:[...t.slice(i+1),...t.slice(0,i)];for(let t of a){let n=Gd(e.of(t),r,null);if(n!==null)return{section:t.id,name:t.name,place:n}}let o=Gd(e.gone(),r,null);return o===null?null:{section:I,name:He,place:o}}function Jd(e){let t=e.state;return t.status===`approved`||t.status===`archived`&&e.approval?.approved?{text:`Approved`,kind:`is-ended`}:t.status===`closed`||t.status===`archived`?{text:`Closed`,kind:`is-ended`}:t.side===`agent`?null:e.ready?{text:`Ready for approval`,kind:`is-ready`}:{text:`Awaits you`,kind:`is-you`}}function Yd(e,t){let n=e.state,r=[Pe(n.selection)],i=n.selection.kind===`last-commit`||n.selection.kind===`commit`,a=e.baseline?.commits[0]?.subject??``;return i&&a!==``&&r.push(a),n.filedBy===`terminal`&&r.push(`filed from the terminal ${l(n.created,t)}`),r.join(` - `)}function Xd(e,t){return`${(e===``?`Working on the review`:e).replace(/[.;\s]+$/,``)}${t===`prepare`?`; code changes are best avoided meanwhile`:``}.`}function Zd(e,t){let n=new Date(e);return Number.isNaN(n.getTime())||n.toDateString()===t.toDateString()?``:n.toLocaleDateString([],{month:`short`,day:`numeric`})}function Qd(e){let t=e.review,n=t.state,r=t.baseline,[i,a]=(0,v.useState)(0),[o,s]=(0,v.useState)(!1),[c,u]=(0,v.useState)(null),d=e.group,[p,m]=(0,v.useState)(new Set(t.place.expanded)),[h,g]=(0,v.useState)(()=>new Map(t.place.drafts.map(e=>[e.anchor,e]))),[_,y]=(0,v.useState)(()=>{for(let e of t.place.drafts){if(!e.anchor.startsWith(`pending:`))continue;let n=t.pending.items.find(t=>`pending:${t.id}`===e.anchor);if(n!==void 0)return n}return null}),b=n.side===`agent`&&n.status===`reviewing`,x=t.slug.startsWith(`${Ce}/`),ee=f(b,e.now),te=Jd(t),S=t.relation,C=S!==null&&S.relation===`out-of-sync`?S:null,w=S!==null&&S.relation===`merged`?S:null,ne=(0,v.useRef)(t.place.scroll),T=od(t.slug,r?.fingerprint??``),E=cd(T.need),D=e.passed,O=Rd(x?null:t.slug,()=>({scroll:ne.current,expanded:[...p],group:d,read:[...D],drafts:[...h.values()]})),re=(e,t)=>{g(n=>{let r=new Map(n);return t===null?r.delete(e):r.set(e,{anchor:e,...t}),r}),O()},ie=ld(t=>{D.has(t)||(e.onPassed(t),O())}),k=(0,v.useRef)(d);(0,v.useEffect)(()=>{k.current!==d&&(k.current=d,O())},[d,O]);let ae=t.pending.items;(0,v.useEffect)(()=>{let e=new Set(ae.map(e=>`pending:${e.id}`)),t=[...h.keys()].filter(t=>t.startsWith(`pending:`)&&!e.has(t));t.length>0&&(g(e=>{let n=new Map(e);for(let e of t)n.delete(e);return n}),O()),y(e=>e===null||ae.some(t=>t.id===e.id)?e:null)},[ae,h,O]);let oe=b&&Be(n.agent.lastPostAt,ee),se=Xd(n.agent.activity,n.agent.act),ce=t.metadata.groups,le=e.index,A=e.sections,j=d===`all`?null:d,M=(0,v.useRef)({group:d,key:null});M.current.group!==d&&(M.current={group:d,key:null});let N=Ie(n),ue=t=>{let n=t.section===`gone`?`all`:t.section,r=d===`all`?d:n;r!==d&&e.onPickGroup(r),M.current={group:r,key:Bd(t)},u({target:t})};return(0,V.jsxs)(`div`,{className:`rv-screen`,children:[(0,V.jsxs)(`div`,{className:`rv-head`,children:[(0,V.jsx)(`h2`,{children:n.name}),(0,V.jsx)(`span`,{className:`rv-head-what`,children:Yd(t,ee)}),(0,V.jsx)(`span`,{className:`rv-grow`}),N&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small is-quiet`,disabled:e.busy,onClick:()=>s(!0),children:`Reset`}),te!==null&&(0,V.jsx)(`span`,{className:`rv-chip ${te.kind}`,children:te.text})]}),t.approval!==null&&(0,V.jsx)(Ct,{approval:t.approval,slug:t.slug,filed:x,busy:e.busy,onArchive:()=>e.onAct({act:`archive`})}),b&&(0,V.jsxs)(`div`,{className:`rv-agentbar`,children:[(0,V.jsx)(`b`,{children:`Awaits agent`}),(0,V.jsxs)(`span`,{className:`rv-say`,children:[se,n.agent.instruction!==``&&(0,V.jsxs)(`span`,{className:`rv-asked`,children:[` You asked: `,n.agent.instruction]}),n.agent.lastPostAt!==null&&(0,V.jsxs)(V.Fragment,{children:[` Last post ${ht(n.agent.lastPostAt)}, `,(0,V.jsx)(`span`,{className:oe?`rv-late`:void 0,children:l(n.agent.lastPostAt,ee)}),`.`]})]}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small is-primary`,disabled:e.busy,onClick:()=>e.onAct({act:`stop`}),children:`Stop the agent and review now`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small is-outline`,disabled:e.busy,onClick:()=>e.onAct({act:`ask`}),children:`Ask the agent to continue`})]}),!b&&C!==null&&(0,V.jsxs)(`div`,{className:`rv-banner`,children:[(0,V.jsx)(`b`,{children:`Out of sync`}),(0,V.jsx)(`span`,{children:`The tree is out of sync with the baseline.`}),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy||!N,title:N?void 0:Le(n),onClick:()=>e.onAct({act:`sync`}),children:`Sync`})]}),!b&&w!==null&&(0,V.jsxs)(`div`,{className:`rv-banner is-merged`,children:[(0,V.jsx)(`b`,{children:`Merged`}),(0,V.jsx)(`span`,{children:w.mergedAs===null?`This branch was merged.`:`This branch was merged as ${w.mergedAs}.`}),(0,V.jsx)(`span`,{className:`rv-grow`}),w.mergedAs!==null&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy||!N,title:N?void 0:Le(n),onClick:()=>e.onAct({act:`follow`}),children:`Follow the merge`})]}),t.error!==null&&(0,V.jsxs)(`div`,{className:`rv-banner`,children:[(0,V.jsx)(`b`,{children:`Not all there`}),(0,V.jsx)(`span`,{children:t.error}),N&&!t.ready&&(0,V.jsx)(mt,{busy:e.busy,onClose:t=>e.onAct({act:`close`,reason:t})})]}),(0,V.jsxs)(`div`,{className:`rv-body`,children:[(0,V.jsx)(Md,{review:t,index:le,summary:e.summary,sections:A,group:d,scope:j,hunks:T.hunks,need:T.need,watch:E,watchReply:ie,want:c,onLanded:()=>u(null),onWalk:t=>{let n=e.summary.of(j),r=Gd(n.places,t,M.current.key);if(r!==null){ue(r.target);return}let i=n.crossing(t);i!==null&&ue(i.place.target)},opened:p,onOpen:(e,t)=>{m(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),O()},drafts:h,onDraft:re,busy:e.busy,onAct:e.onAct,startAt:t.place.scroll,theme:e.theme,onScroll:e=>{ne.current=e,O()},coming:We(t)}),(0,V.jsx)(Nd,{items:t.pending.items,whereOf:e=>{if(e.group!==null){let t=ce.find(t=>t.id===e.group);return t===void 0?`the group`:t.name}let t=(r?.entries??[]).find(t=>t.id===e.hunk);if(t===void 0)return e.label===`hunk-removed`?`a hunk that is gone`:e.hunk??``;let n=r?.files[t.file]?.path??``,i=/^@@ (-\d+)/.exec(t.header);return i===null?n:`${n} @@ ${i[1]}`},readable:N,busy:e.busy,onEdit:e=>{y(e),re(`pending:${e.id}`,{act:e.act,lines:[],text:e.text,note:null})},onRemove:n=>e.onAct({act:`pending`,items:t.pending.items.filter(e=>e.id!==n.id)}),onSend:()=>e.onAct({act:`send`}),openAsked:i})]}),e.approving&&N&&(0,V.jsx)(bt,{review:t,busy:e.busy,onApprove:(t,n,r)=>{e.onApproving(!1),e.onAct({act:`approve`,name:t,signature:n,acknowledged:r})},onClose:t=>{e.onApproving(!1),e.onAct({act:`close`,reason:t})},onCancel:()=>e.onApproving(!1),onGoTo:t=>{if(e.onApproving(!1),t===`pending`){a(e=>e+1);return}if(t===`threads`){let e=Kd(le,A);e!==null&&ue(e);return}let n={unseen:`unseen`,issues:`issue`,attention:`attention`,unreadReplies:`reply`}[t];if(n===void 0)return;let r=Gd(e.summary.of(null).places,n,null);r!==null&&ue(r.target)}}),o&&N&&(0,V.jsx)(Ld,{review:t,busy:e.busy,onReset:t=>{s(!1),e.onAct({act:`reset`,instruction:t})},onCancel:()=>s(!1)}),_!==null&&N&&(0,V.jsx)(`div`,{className:`rv-editing`,children:(0,V.jsx)(xt,{act:_.act,lines:[],text:h.get(`pending:${_.id}`)?.text??_.text,busy:e.busy,onChange:e=>re(`pending:${_.id}`,{act:_.act,lines:[],text:e,note:null}),onWrite:n=>{let r=_;y(null),re(`pending:${r.id}`,null),e.onAct({act:`pending`,items:t.pending.items.map(e=>e.id===r.id?{...e,text:n}:e)})},onCancel:()=>{re(`pending:${_.id}`,null),y(null)}})}),T.failure!==null&&(0,V.jsxs)(`p`,{className:`notice notice-failure`,children:[T.failure,` `,(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:T.retry,children:`Try again`})]}),e.openLog&&(0,V.jsx)(`div`,{className:`rv-log`,children:[...n.log].reverse().map(e=>(0,V.jsxs)(`p`,{children:[(0,V.jsxs)(`b`,{children:[Zd(e.at,ee),` `,ht(e.at)]}),` `,e.said]},`${e.at}-${e.said}`))})]})}var $d=`approve-left`;function ef(e){let t=e===1;return`${e} thing${t?``:`s`} still need${t?`s`:``} your attention. Open to see ${t?`it`:`them`}.`}function tf(e){let t=[];return e.issues>0&&t.push({kind:`is-issue`,text:`${e.issues} issue${e.issues===1?``:`s`}`}),e.attention>0&&t.push({kind:`is-attention`,text:`${e.attention} attention`}),e.replies>0&&t.push({kind:`is-reply`,text:`${e.replies} unread ${e.replies===1?`reply`:`replies`}`}),e.waiting>0&&t.push({kind:`is-you`,text:`${e.waiting} wait${e.waiting===1?`s`:``} on you`}),e.changed>0&&t.push({kind:`is-changed`,text:`${e.changed} changed since seen`}),t}function nf(e){let t=a({className:`rv-tip`,side:`top`}),n=e.review,r=n.state,i=e.summary.of(null).counts,o=i.hunks===0?0:Math.round(i.seen/i.hunks*100),s=Ie(r),c=R(n.leftAsIs);return(0,V.jsxs)(`div`,{className:`workspace-foot rv-status`,children:[(0,V.jsxs)(`span`,{className:`rv-loops`,title:`Agent-human feedback loops`,children:[(0,V.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,children:[(0,V.jsx)(`path`,{d:`M13 8a5 5 0 0 0-8.5-3.5M3 8a5 5 0 0 0 8.5 3.5`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,V.jsx)(`path`,{d:`M4.5 1.5v3h3M11.5 14.5v-3h-3`,strokeWidth:`1.5`,strokeLinecap:`round`})]}),n.loops]}),(0,V.jsx)(`span`,{className:`rv-prog`,title:`${i.seen} of ${i.hunks} hunks seen`,children:(0,V.jsx)(`i`,{style:{width:`${o}%`}})}),tf(i).map(e=>(0,V.jsxs)(`span`,{className:`rv-fact ${e.kind}`,children:[(0,V.jsx)(`i`,{"aria-hidden":`true`}),e.text]},e.kind)),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsxs)(`button`,{type:`button`,className:`rv-log-toggle`,"aria-expanded":e.openLog,onClick:()=>e.onOpenLog(!e.openLog),children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,children:e.openLog?`▾`:`▸`}),`Activity (`,r.log.length,`)`]}),s&&(0,V.jsxs)(`button`,{type:`button`,className:`rv-btn is-small is-ok rv-approve`,disabled:e.busy,"aria-describedby":c>0?$d:void 0,onClick:e.onApprove,...t.anchor,children:[`Approve...`,c>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`rv-abadge is-warn`,"aria-hidden":`true`,children:`!`}),(0,V.jsx)(`span`,{className:`visually-hidden`,id:$d,"aria-hidden":`true`,children:ef(c)}),t.says(ef(c))]})]})]})}var rf={unseen:`unseen`,issue:`issues`,attention:`attention`,reply:`replies`},af={count:0,groups:[]};function of(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Map,i=null,a=t=>{let n=r.get(t.id);if(n!==void 0)return n;let i=Hd(e,t);return r.set(t.id,i),i},o={of:a,gone:()=>(i??=Ud(e),i)},s=null,c=()=>(s??=Wd(o,t),s),l=null,u=()=>(l??=e.gone.reduce((t,n)=>t+n.messages.filter(t=>t.from===`agent`&&e.unread.has(t.id)).length,0),l),d=e=>{let n=t.findIndex(t=>t.id===e);return n===-1?t:[...t.slice(n+1),...t.slice(0,n)]},f=(e,t)=>{let n=rf[t];for(let t of d(e))if(h(t.id).counts[n]>0)return t.name;return t===`reply`&&u()>0?He:null},p=(e,t,n)=>{let r=e.counts[rf[n]];if(r>0)return{kind:n,state:`here`,count:r};if(t===null)return{kind:n,state:`nowhere`};let i=f(t,n);return i===null?{kind:n,state:`nowhere`}:{kind:n,state:`across`,section:i}},m=new Map,h=r=>{let i=r===null?``:`group\n${r}`,s=m.get(i);if(s!==void 0)return s;let l=r===null?null:n.get(r)??{id:r,name:r,hunks:[]},u=new Map,d=null,f={counts:ye(e,l),get places(){return l===null?c():a(l)},crossing:e=>l===null?null:(u.has(e)||u.set(e,qd(o,t,l.id,e)),u.get(e)??null),get controls(){return d??=zd.map(e=>p(f,r,e)),d}};return m.set(i,f),f},g=null,_=null;return{of:h,holders:()=>(g??=Ke(t),g),shared:e=>(_??=new Map(t.map(e=>[e.id,Ge(e,t)])),_.get(e)??af)}}var sf={open:null,starting:!1,form:null};function cf(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)({options:[],notOffered:null}),[f,p]=(0,v.useState)(!1),[m,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(null),[x,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(new Set),[D,O]=(0,v.useState)(!1),[k,ae]=(0,v.useState)(!1),se=(0,v.useRef)(null),ce=h({onSession:te,askTheme:ne}),A=(0,v.useRef)(new Map),j=(0,v.useRef)(null),M=(0,v.useRef)(sf),N=(0,v.useRef)(null),[ue,P]=(0,v.useState)(0),F=(0,v.useCallback)(()=>{re().then(e=>{t(e),r(null)}).catch(e=>r(e.message))},[]),I=(0,v.useCallback)(e=>{if(e===null){s(null);return}ie(e).then(s).catch(e=>{s(null),b(e.message)})},[]);(0,v.useEffect)(F,[F]),(0,v.useEffect)(()=>I(i),[i,I]),(0,v.useEffect)(()=>ee(()=>{F(),I(i)}),[i,F,I]),(0,v.useEffect)(()=>{let e=()=>{document.visibilityState!==`hidden`&&(F(),I(i))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[i,F,I]),(0,v.useEffect)(()=>{e!==null&&C(e.awaitingYou,e.any)},[e]);let L=(0,v.useCallback)(async(e,t,n)=>{for(let t of e){let e=await S({event:t.event,detail:t.detail,path:t.path});e.ok||b(`No agent was told: ${e.error}`)}if(!t)return;let r=await S({event:`review`,detail:n});r.ok||b(`No agent was told: ${r.error}`)},[]),de=(0,v.useCallback)(async(e,t,n={})=>{_(!0),b(null);try{let r=await le(e,t,n);r.review!==null&&(s(r.review),r.review.slug!==e&&a(r.review.slug),F(),await L(r.typed,r.command,r.review.state.name))}catch(e){b(e instanceof Error?e.message:`that act was refused`)}finally{_(!1)}},[F,L]),fe=(0,v.useCallback)((e,t)=>{if(t.act===`ask`){L([],!0,e.state.name);return}let{act:n,...r}=t;de(e.slug,n,r)},[de,L]),pe=(0,v.useCallback)(()=>{p(!0),oe().then(d).catch(e=>b(e.message)).finally(()=>p(!1))},[]),me=(0,v.useCallback)(()=>{N.current=null,l(!0),a(null),b(null),pe()},[pe]);(0,v.useEffect)(()=>{M.current={open:i,starting:c}},[i,c]);let he=(0,v.useCallback)(e=>{if(j.current===e)return;let t=M.current,n=e===null?void 0:A.current.get(e);if(j.current===null&&n===void 0){j.current=e;return}j.current!==null&&A.current.set(j.current,{...t,form:N.current}),j.current=e;let r=n??sf;M.current=r,N.current=r.form,a(r.open),l(r.starting),P(e=>e+1),b(null),r.starting&&pe()},[pe]);(0,v.useEffect)(()=>te(e=>he(e.sid)),[he]);let R=o!==null&&o.slug===i?o:null,ge=(0,v.useMemo)(()=>R===null?null:_e(R,T),[R,T]),z=(0,v.useMemo)(()=>R===null?[]:qe(R),[R]),ve=(0,v.useMemo)(()=>ge===null?null:of(ge,z),[ge,z]);R===null?se.current=null:se.current!==R.slug&&(se.current=R.slug,x!==null&&w(null),T.size>0&&E(new Set),D&&O(!1),k&&ae(!1));let ye=(x===null||x!==`all`&&!z.some(e=>e.id===x)?null:x)??(R===null?`all`:Ue(R,z)),be=(0,v.useCallback)(e=>{N.current=null,l(!1),a(e.slug),F(),L([],e.command,e.state.name)},[F,L]);return e===null?(0,V.jsx)(`p`,{className:`notice notice-failure`,children:n??`Waiting for the pane to hand over…`}):(0,V.jsxs)(`div`,{className:`workspace is-alone is-review${R!==null&&ge!==null&&ve!==null?` has-foot`:``}`,children:[R===null||ge===null||ve===null?(0,V.jsx)(ft,{active:e.active,archived:e.archived,open:i,onOpen:e=>{l(!1),a(e)},starting:c,onStart:me,repository:e.repository,error:e.error}):(0,V.jsx)($e,{review:R,index:ge,summary:ve,sections:z,group:ye,onPick:w,onBack:()=>a(null)}),(0,V.jsxs)(`div`,{className:`stage${R===null?``:` has-bar`}`,"data-theme":ce.theme,children:[(0,V.jsx)(g,{theme:ce.theme,kept:ce.kept,onToggle:ce.toggle}),y!==null&&(0,V.jsx)(`p`,{className:`notice notice-failure`,children:y}),c?(0,V.jsx)(at,{offer:u,reading:f,onRefresh:pe,draft:N.current,onDraft:e=>{N.current=e},onCancel:()=>{N.current=null,l(!1)},onStarted:be},ue):R===null||ge===null||ve===null?(0,V.jsx)(`div`,{className:`doc`,children:(0,V.jsx)(`p`,{className:`notice`,children:i===null?`Nothing is open. Pick a review on the left.`:`Reading the review…`})}):(0,V.jsx)(Qd,{review:R,index:ge,summary:ve,sections:z,busy:m,theme:ce.theme,group:ye,onPickGroup:w,passed:T,onPassed:e=>E(t=>t.has(e)?t:new Set([...t,e])),onAct:e=>fe(R,e),openLog:D,approving:k,onApproving:ae},R.slug)]}),R!==null&&ge!==null&&ve!==null&&(0,V.jsx)(nf,{review:R,summary:ve,openLog:D,onOpenLog:O,onApprove:()=>ae(!0),busy:m})]})}w();var lf=document.getElementById(`root`);lf&&(0,y.createRoot)(lf).render((0,V.jsx)(v.StrictMode,{children:(0,V.jsx)(cf,{})}));
153
+ `),{lang:n,theme:td[r],grammarState:i});return{rows:a.map(e=>e.map(e=>({text:e.content,color:e.color??``,at:e.offset}))),state:a.length===0?i:e.getLastGrammarState(a)}}function od(e,t){let n=`${e??``}\n${t}`,[r,i]=(0,v.useState)({of:n,hunks:new Map,failure:null}),a=(0,v.useRef)(new Set),o=(0,v.useRef)(new Set),s=(0,v.useRef)([]);r.of!==n&&(s.current=[...a.current],a.current=new Set,o.current=new Set,i({of:n,hunks:new Map,failure:null}));let c=(0,v.useCallback)(r=>{if(e===null||r<0)return;let s=Math.floor(r/50);if(a.current.has(s))return;let c=a.current,l=o.current;c.add(s),ie(e,s*50,50).then(e=>{if(e.fingerprint!==t){c.delete(s);return}i(t=>{if(t.of!==n)return t;let r=new Map(t.hunks);for(let t of e.hunks)r.set(t.id,t);return{...t,hunks:r}})}).catch(e=>{c.delete(s),l.add(s),i(t=>t.of===n?{...t,failure:e.message}:t)})},[e,t,n]);(0,v.useEffect)(()=>{c(0);for(let e of s.current)c(e*50);s.current=[]},[c]);let l=(0,v.useCallback)(()=>{let e=[...o.current];o.current=new Set,i(e=>e.of===n?{...e,failure:null}:e);for(let t of e)c(t*50)},[c,n]);return{hunks:r.hunks,need:c,failure:r.failure,retry:l}}function sd(e,t){let n=(0,v.useRef)(t);n.current=t;let r=(0,v.useRef)(e);r.current=e;let i=(0,v.useRef)(e=>e.dataset[r.current.attribute]),a=(0,v.useRef)(null);return a.current===null&&typeof IntersectionObserver==`function`&&(a.current=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=i.current(t.target);e!==void 0&&n.current(e)}},{rootMargin:e.margin})),(0,v.useEffect)(()=>{let e=a.current;return()=>e?.disconnect()},[]),(0,v.useCallback)(e=>{if(e===null)return;let t=a.current;if(t===null){let t=i.current(e);r.current.atMount&&t!==void 0&&n.current(t);return}return t.observe(e),()=>t.unobserve(e)},[])}function cd(e){return sd({attribute:`index`,margin:`400px 0px`,atMount:!0},t=>{let n=Number(t);Number.isFinite(n)&&e(n)})}function ld(e){return sd({attribute:`unread`,margin:`0px`,atMount:!1},e)}function ud(e){let t={old:[],new:[]},n=[];for(let r of e)r.on!==`new`&&t.old.push(r.text),r.on!==`old`&&t.new.push(r.text),n.push(r.on===`old`?{side:`old`,at:t.old.length-1}:{side:`new`,at:t.new.length-1});return{lines:t,from:n}}function dd(e,t,n,r){let[i,a]=(0,v.useState)({of:``,rows:[]}),[o,s]=(0,v.useState)(!1),c=Rt(e),l=(0,v.useRef)(t);l.current=t;let u=sd({attribute:`hunk`,margin:`200px 0px`,atMount:!0},()=>s(!0));(0,v.useEffect)(()=>{if(c===null||!o)return;let e=l.current,t=ud(e),i=[`old`,`new`].filter(e=>t.from.some(t=>t.side===e)),s=!0,u;return a({of:n,rows:e.map(()=>null)}),id(c).then(e=>{if(!s||e===null)return;let o=(l,d,f)=>{if(!s)return;let p=i[l];if(p===void 0)return;let m=t.lines[p],h=ad(e,m.slice(d,d+100),c,r,f);a(e=>{if(e.of!==n)return e;let r=[...e.rows];return t.from.forEach((e,t)=>{if(e.side!==p)return;let n=h.rows[e.at-d];e.at>=d&&n!==void 0&&(r[t]=n)}),{of:n,rows:r}}),d+100<m.length?u=setTimeout(()=>o(l,d+100,h.state),0):l+1<i.length&&(u=setTimeout(()=>o(l+1,0,void 0),0))};o(0,0,void 0)}),()=>{s=!1,clearTimeout(u)}},[c,n,r,o]);let d=i.of===n?i.rows:[];return(0,v.useMemo)(()=>({ref:u,rows:d}),[u,d])}var fd=[5,10],pd=1e5,md=[`undo`,`explain`,`talk`,`comment`];function hd(e){let t=e.lastIndexOf(`/`);return t===-1?{dir:``,name:e}:{dir:e.slice(0,t+1),name:e.slice(t+1)}}var gd=2;function _d(e){let t=e.filter(e=>e.lines!==null&&e.lines.length>0).map(e=>({kind:e.kind,note:e.key,first:Math.min(...e.lines),last:Math.max(...e.lines)})).sort((e,t)=>e.first-t.first||t.last-e.last),n=Array.from({length:gd},()=>0),r=new Map;for(let e of t){let t=n.findIndex(t=>t<e.first),i=t===-1?0:t;n[i]=Math.max(n[i]??0,e.last);for(let t=e.first;t<=e.last;t+=1){let n=r.get(t)??[];n.push({lane:i,kind:e.kind,note:e.note,first:t===e.first,last:t===e.last}),r.set(t,n)}}return r}function vd(e){return(0,V.jsx)(`span`,{style:{color:e.color},children:e.text},e.at)}function yd(e){return e===`info`?``:` is-${e}`}function bd(e,t){let n=(e.lines??[]).filter(e=>t.has(e));return n.length===0?null:Math.min(...n)}function xd(e,t){let n=Math.min(e,t),r=Math.max(e,t);return Array.from({length:r-n+1},(e,t)=>n+t)}function Sd(e){let{file:t,hunk:n}=e,r=e.entry.id,i=t=>e.onAct({act:`mark`,hunk:r,seen:t}),a=t=>e.onAct({act:`comment`,hunk:r,kind:`talk`,text:``,lines:t}),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(new Set),[y,b]=(0,v.useState)(e.draft?.act??null),[x,ee]=(0,v.useState)(e.draft?.note??null),[S,C]=(0,v.useState)(()=>{let t=e.draft?.lines??[];return t.length===0?null:{from:Math.min(...t),to:Math.max(...t)}}),te=e.draft;(0,v.useEffect)(()=>{te===null||y!==null||(b(te.act),ee(te.note),C(te.lines.length===0?null:{from:Math.min(...te.lines),to:Math.max(...te.lines)}))},[te,y]);let w=(t,n,r,i)=>{b(t),ee(i),C(n.length===0?null:{from:Math.min(...n),to:Math.max(...n)}),e.onDraft({act:t,lines:n,text:r,note:i})},ne=()=>{b(null),ee(null),e.onDraft(null)},T=e.entry.id,E=(0,v.useRef)(n?.header??``);n!==null&&E.current!==n.header&&(E.current=n.header,s([]),l([]),d(null));let D=t?.newBlob??null,O=S===null?[]:xd(S.from,S.to),k=n===null?[]:[...o.map(e=>({text:e,on:`both`})),...n.lines.map(e=>({text:e.text,on:e.kind===`add`?`new`:e.kind===`remove`?`old`:`both`})),...c.map(e=>({text:e,on:`both`}))],re=n===null?``:`${T}|${n.header}|${o.length}|${c.length}`,ie=dd(n?.path??``,k,re,e.theme),A=(0,v.useCallback)(async(t,r)=>{if(n===null||D===null)return;let i=n.newStart-o.length,a=n.newStart+n.newLines-1+c.length,u=t===`above`?Math.max(1,i-(r??i-1)):a+1,f=t===`above`?i-u:r??pd;if(!(f<=0))try{let n=await ae(e.slug,D,u,f);if(d(n.total),n.lines.length===0)return;t===`above`?s(e=>[...n.lines,...e]):l(e=>[...e,...n.lines])}catch(e){p(e instanceof Error?e.message:`that context could not be read`)}},[o.length,c.length,D,n,e.slug]),oe=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},se=e=>{C(t=>t===null?{from:e,to:e}:xd(t.from,t.to).includes(e)?null:{from:t.from,to:e})};if(n===null)return(0,V.jsxs)(`section`,{className:`rv-hunk rv-waiting`,"data-index":e.index,"data-hunk":T,"data-key":e.cardKey,ref:e.watch,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{className:`rv-skel is-narrow`}),(0,V.jsx)(`span`,{className:`rv-skel is-wide`}),(0,V.jsx)(`span`,{className:`rv-skel is-half`})]});let{dir:ce,name:le}=hd(n.path),j=n.header===``?`the whole file`:n.header,N=_d(e.notes),P=yd(me(e.notes.map(e=>e.kind))),ue=new Set;for(let e=n.newStart-o.length;e<n.newStart;e+=1)ue.add(e);for(let e of n.lines)e.newLine!==null&&ue.add(e.newLine);for(let e=0;e<c.length;e+=1)ue.add(n.newStart+n.newLines+e);let F=e.notes.filter(e=>bd(e,ue)===null),I=new Map;for(let t of e.notes){let e=bd(t,ue);e!==null&&I.set(e,[...I.get(e)??[],t])}let de=F.length>0?` is-note${P}`:``,fe=F.some(t=>e.aside.has(t.key)),pe=()=>y===null?null:(0,V.jsx)(xt,{act:y,lines:O,text:e.draft?.text??``,busy:e.busy,onChange:t=>e.onDraft({act:y,lines:O,text:t,note:x}),onWrite:t=>{ne(),C(null),e.onAct({act:`comment`,hunk:r,kind:y,text:t,lines:O})},onCancel:ne}),he=y!==null&&x!==null&&e.notes.some(e=>e.key===x)?x:null,ge=t=>(0,V.jsx)(Mt,{notes:t,aside:e.aside,shown:g,readable:e.readable,readOnlySaid:e.readOnlySaid,busy:e.busy,onAsk:e=>w(`fix`,e.lines??[],e.text,e.key),onTalk:e=>a(e.lines??[]),onComment:e=>w(`comment`,e.lines??[],``,e.key),onDismiss:(t,n)=>e.onAct({act:`dismiss`,hunk:r,key:t.key,on:n}),box:he!==null&&t.some(e=>e.key===he)?{note:he,element:pe()}:null});if(e.seen&&!e.open)return(0,V.jsxs)(`div`,{className:`rv-folded${F.length>0||N.size>0?` is-note${P}`:``}`,"data-hunk":T,"data-key":e.cardKey,children:[(0,V.jsx)(`span`,{className:`rv-ok`,"aria-hidden":`true`,children:`✓`}),(0,V.jsx)(`span`,{children:`Seen`}),(0,V.jsx)(`span`,{className:`rv-mono`,children:n.path}),(0,V.jsx)(`span`,{className:`rv-mono`,children:j}),e.notes.length>0&&(0,V.jsxs)(`span`,{className:`rv-fnotes`,children:[e.notes.length,` note`,e.notes.length===1?``:`s`]}),(0,V.jsx)(`span`,{className:`rv-grow`}),e.changed&&(0,V.jsx)(`span`,{className:`rv-changed`,children:`Changed since you saw it`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:()=>e.onOpen(!0),children:`Expand`})]});let L=n.newStart-o.length,R=n.newStart+n.newLines-1+c.length,z=D!==null&&L>1,_e=D!==null&&(u===null||R<u),ve=(t,n,r)=>{let i=t.kind===`add`?` is-add`:t.kind===`remove`?` is-del`:``,a=ie.rows[r]??null,o=t.newLine===null?[]:N.get(t.newLine)??[],s=o.length===0?``:` is-note${yd(me(o.map(e=>e.kind)))}`,c=t.newLine!==null&&O.includes(t.newLine),l=t.newLine===null?[]:I.get(t.newLine)??[];return(0,V.jsxs)(v.Fragment,{children:[l.length>0&&ge(l),(0,V.jsxs)(`div`,{className:`rv-l${i}${s}${c?` is-picked`:``}`,"data-line":t.newLine??void 0,"data-old":t.oldLine??void 0,children:[o.map(n=>{let r=`rv-nl is-lane${n.lane}${yd(n.kind)}${n.first?` is-first`:``}${n.last?` is-last`:``}`;return e.aside.has(n.note)?(0,V.jsx)(`button`,{type:`button`,className:r,"data-note":n.note,"aria-label":`Show the note put aside on line ${t.newLine}`,onClick:()=>oe(n.note)},n.lane):(0,V.jsx)(`i`,{className:r,"data-note":n.note,"aria-hidden":`true`},n.lane)}),(0,V.jsx)(`span`,{className:`rv-ln`,children:t.oldLine??``}),t.newLine===null?(0,V.jsx)(`span`,{className:`rv-ln`}):(0,V.jsx)(`button`,{type:`button`,className:`rv-ln`,"aria-label":`Line ${t.newLine}`,"aria-pressed":c,onClick:()=>se(t.newLine),children:t.newLine}),(0,V.jsxs)(`span`,{children:[t.kind===`add`?`+`:t.kind===`remove`?`-`:` `,a===null?t.text:a.map(e=>vd(e))]})]})]},n)},ye=(e,t,r)=>ve({kind:`context`,text:e,oldLine:t-(n.newStart-n.oldStart),newLine:t,noNewline:!1},`c${t}`,r),be=e=>(0,V.jsxs)(`div`,{className:`rv-expand`,children:[fd.map(t=>(0,V.jsxs)(`button`,{type:`button`,className:`rv-link`,onClick:()=>void A(e,t),children:[`+`,t]},t)),(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:()=>void A(e,null),children:`whole file`})]});return(0,V.jsxs)(`section`,{className:`rv-hunk${e.readable?``:` is-dim`}`,"data-hunk":T,"data-key":e.cardKey,"data-index":e.index,ref:ie.ref,children:[(0,V.jsxs)(`div`,{className:`rv-fh${de}`,children:[F.length>0&&(0,V.jsx)(At,{aside:fe,onShow:()=>{for(let t of F)e.aside.has(t.key)&&oe(t.key)}}),(0,V.jsxs)(`span`,{className:`rv-path rv-mono`,children:[ce!==``&&(0,V.jsx)(`i`,{children:ce}),le]}),(0,V.jsx)(`span`,{className:`rv-mono`,children:j}),e.also.length>0&&(0,V.jsxs)(`span`,{className:`rv-also`,children:[`also in `,e.also.map(e=>`"${e}"`).join(`, `)]}),(0,V.jsx)(`span`,{className:`rv-grow`}),e.changed&&(0,V.jsx)(`span`,{className:`rv-changed`,children:`Changed since you saw it`}),(o.length>0||c.length>0)&&(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:()=>{s([]),l([])},children:`Back to the hunk`}),e.readable&&!e.fileRead&&(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,disabled:e.busy,onClick:()=>e.onAct({act:`bulk`,kind:`file`,id:e.file?.key??``}),children:`Mark file Seen`}),e.seen&&e.readable?(0,V.jsxs)(`button`,{type:`button`,className:`rv-state is-seen`,disabled:e.busy,"aria-label":`Mark as not seen`,onClick:()=>i(!1),children:[(0,V.jsx)(`span`,{className:`rv-state-on`,children:`✓ Seen`}),(0,V.jsx)(`span`,{className:`rv-state-off`,children:`Not seen`})]}):(0,V.jsx)(`span`,{className:`rv-state${e.seen?` is-seen`:``}`,children:e.seen?`✓ Seen`:`pending`}),e.seen&&(0,V.jsx)(`button`,{type:`button`,className:`rv-icon`,"aria-label":`Fold this hunk`,onClick:()=>e.onOpen(!1),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M3 10l5-5 5 5`})})})]}),F.length>0&&ge(F),(0,V.jsxs)(`div`,{className:`rv-diff`,children:[z&&be(`above`),o.map((e,t)=>ye(e,L+t,t)),(0,V.jsx)(`div`,{className:`rv-hd`,children:j}),n.lines.map((e,t)=>ve(e,`${e.oldLine??`x`}-${e.newLine??`x`}`,o.length+t)),c.map((e,t)=>ye(e,n.newStart+n.newLines+t,o.length+n.lines.length+t)),_e&&be(`below`)]}),f!==null&&(0,V.jsx)(`p`,{className:`rv-trouble`,children:f}),he===null&&pe(),e.threads.map(t=>(0,V.jsx)(Ft,{thread:t,readable:e.readable,agentHolds:e.agentHolds,busy:e.busy,onClose:()=>e.onAct({act:`close-thread`,thread:t.id}),watch:e.watchReply},t.id)),e.readable&&(0,V.jsxs)(V.Fragment,{children:[m&&(0,V.jsxs)(`div`,{className:`rv-fabmenu`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-seen`,disabled:e.busy,onClick:()=>{h(!1),i(!e.seen)},children:e.seen?`Not seen`:`✓ Seen`}),(0,V.jsx)(`hr`,{}),md.map(t=>t===`talk`?(0,V.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>{h(!1),a(O),C(null)},children:`Let's talk`},t):(0,V.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>{h(!1),w(t,O,``,null)},children:M[t]},t))]}),(0,V.jsx)(`button`,{type:`button`,className:`rv-fab`,"aria-expanded":m,"aria-label":`Act on ${n.path} ${j}`,onClick:()=>h(e=>!e),children:m?`×`:`+`})]})]})}var Cd={binary:`binary`,generated:`generated`,oversize:`too large to read as a diff`,text:`whole file`};function wd(e,t){let[n,r]=(0,v.useState)({old:null,new:null}),i=t?.oldBlob??null,a=t?.newBlob??null;return(0,v.useEffect)(()=>{let t=!0,n=t=>t===null?Promise.resolve(null):le(`${e}/${je}/${t}`);return Promise.all([n(i),n(a)]).then(([e,n])=>{t&&r({old:e,new:n})}),()=>{t=!1}},[e,i,a]),n}function Td(e){let{file:t,hunk:n}=e,r=e.entry.id,a=wd(e.slug,t),[o,s]=(0,v.useState)(new Set),c=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[l,u]=(0,v.useState)(e.draft?.act??null),[d,f]=(0,v.useState)(e.draft?.note??null),h=e.draft;(0,v.useEffect)(()=>{h===null||l!==null||(u(h.act),f(h.note))},[h,l]);let g=(t,n,r)=>{u(t),f(n.key),e.onDraft({act:t,lines:n.lines??[],text:r,note:n.key})},_=()=>{u(null),f(null),e.onDraft(null)},y=e.draft?.lines??[],b=n?.path??t?.path??e.entry.id,x=Math.max(t?.oldBytes??0,t?.newBytes??0)>m,ee=p(b)===`image`&&!x;if(n===null)return(0,V.jsx)(`div`,{className:`rv-nt-row rv-waiting`,"data-index":e.index,"data-hunk":e.entry.id,"data-key":e.cardKey,ref:e.watch,children:(0,V.jsx)(`span`,{className:`rv-mono`,children:b})});let S=t===null||t.added===0&&t.deleted===0?``:`+${t.added} -${t.deleted}`,C=[t?.oldBytes??null,t?.newBytes??null].filter(e=>e!==null).map(i).join(` → `);return(0,V.jsxs)(`div`,{className:`rv-nt-row`,"data-hunk":e.entry.id,"data-key":e.cardKey,"data-index":e.index,children:[(0,V.jsxs)(`div`,{className:`rv-nt-head${e.notes.length>0?` is-note`:``}`,children:[e.notes.length>0&&(0,V.jsx)(At,{aside:e.notes.some(t=>e.aside.has(t.key)),onShow:()=>{for(let t of e.notes)e.aside.has(t.key)&&c(t.key)}}),(0,V.jsx)(`span`,{className:`rv-mono`,children:b}),(0,V.jsxs)(`span`,{className:`rv-facts`,children:[Cd[t?.category??`text`],S===``?``:` - ${S}`,C===``?``:` - ${C}`,x?` - too large to show`:``]}),(0,V.jsx)(`span`,{className:`rv-grow`}),e.seen?(0,V.jsx)(`span`,{className:`rv-ok`,children:`✓ Seen`}):e.readable&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy,onClick:()=>e.onAct({act:`mark`,hunk:r,seen:!0}),children:`Mark Seen`})]}),e.notes.length>0&&(0,V.jsx)(Mt,{notes:e.notes,aside:e.aside,shown:o,readable:e.readable,readOnlySaid:e.readOnlySaid,busy:e.busy,onAsk:e=>g(`fix`,e,e.text),onTalk:t=>e.onAct({act:`comment`,hunk:r,kind:`talk`,text:``,lines:t.lines??[]}),onComment:e=>g(`comment`,e,``),onDismiss:(t,n)=>e.onAct({act:`dismiss`,hunk:r,key:t.key,on:n}),box:l!==null&&d!==null?{note:d,element:(0,V.jsx)(xt,{act:l,lines:y,text:e.draft?.text??``,busy:e.busy,onChange:t=>e.onDraft({act:l,lines:y,text:t,note:d}),onWrite:t=>{_(),e.onAct({act:`comment`,hunk:r,kind:l,text:t,lines:y})},onCancel:_})}:null}),ee&&(0,V.jsxs)(`div`,{className:`rv-nt-images`,children:[a.old!==null&&(0,V.jsxs)(`figure`,{children:[(0,V.jsx)(`img`,{src:a.old,alt:`${b} before`}),(0,V.jsx)(`figcaption`,{children:`before`})]}),a.new!==null&&(0,V.jsxs)(`figure`,{children:[(0,V.jsx)(`img`,{src:a.new,alt:`${b} after`}),(0,V.jsx)(`figcaption`,{children:`after`})]})]})]})}var Ed={collapse:0,fold:0};function Dd(e,t,n){let[r,i]=(0,v.useState)(Ed),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(0);return(0,v.useEffect)(()=>{if(a===null||typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(e=>{for(let t of e)c(Math.round(t.contentRect.height))});return e.observe(a),()=>e.disconnect()},[a]),(0,v.useEffect)(()=>{let r=e.current;if(r===null||s===0){i(Ed);return}let a=0,o=()=>{a=0;let e=t.current;if(e===null)return;let o=r.getBoundingClientRect().top+n-e.getBoundingClientRect().top,c=Math.min(1,Math.max(0,o/s));i(e=>e.fold===s&&Math.abs(e.collapse-c)*s<1?e:{collapse:c,fold:s})},c=()=>{a===0&&(a=requestAnimationFrame(o))};return o(),r.addEventListener(`scroll`,c,{passive:!0}),()=>{r.removeEventListener(`scroll`,c),a!==0&&cancelAnimationFrame(a)}},[e,t,n,s]),[r,o]}var Od=new Set;function kd(e){let t=e.kit,n=e.section,r=`group:${n.id}`,i=t.drafts.get(r)??null,a=i!==null,o=(0,v.useRef)(null),[s,c]=Dd(t.feed,o,e.pinned),l=t.summary.of(n.id).counts,u=t.index.threads.get(z(`group`,n.id))??[],d=ve(t.index,n).flatMap(e=>{let n=t.entryOf.get(e);return n===void 0?[]:[n]}),f=d.filter(e=>t.files[e.file]?.category===`text`),p=d.filter(e=>t.files[e.file]?.category!==`text`),m=(e,r)=>{let i=`${n.id}-${e.id}`,a=t.seen.has(e.id),o=`hunk:${e.id}`,s=t.opened.has(e.id)||t.drafts.has(o),c={cardKey:i,slug:t.review.slug,entry:e,file:t.files[e.file]??null,hunk:t.pages.get(e.id)??null,seen:a,busy:t.busy,readable:t.readable,readOnlySaid:t.readOnlySaid,agentHolds:t.agentHolds,onAct:t.onAct,index:t.order.get(e.id)??0,watch:t.watch,notes:t.index.notes.get(e.id)??[],aside:t.index.aside.get(e.id)??Od};return r?(0,V.jsx)(Td,{...c,draft:t.drafts.get(o)??null,onDraft:e=>t.onDraft(o,e)},i):(0,V.jsx)(Sd,{...c,theme:t.theme,fileRead:t.entries.every(n=>n.file!==e.file||t.seen.has(n.id)),changed:t.index.changed.has(e.id),also:(t.summary.holders().get(e.id)??[]).filter(e=>e!==n.name),open:s,onOpen:n=>t.onOpen(e.id,n),draft:t.drafts.get(o)??null,onDraft:e=>t.onDraft(o,e),threads:t.index.threads.get(z(`hunk`,e.id))??[],watchReply:t.watchReply},i)};return(0,V.jsxs)(`div`,{className:`rv-section`,"data-section":n.id,ref:o,children:[(0,V.jsx)(Dt,{section:n,counts:l,shared:t.summary.shared(n.id),collapse:s,fold:c,under:e.pinned>0,controls:e.controls,onWalk:e.onWalk,readable:t.readable,busy:t.busy,onBulk:()=>t.onAct({act:`bulk`,kind:`group`,id:n.id}),onComment:()=>t.onDraft(r,{act:`group-comment`,lines:[],text:``,note:null})}),(a||u.length>0)&&(0,V.jsxs)(`div`,{className:`rv-gtalk`,children:[a&&(0,V.jsx)(xt,{act:`group-comment`,lines:[],text:i?.text??``,busy:t.busy,onChange:e=>t.onDraft(r,{act:`group-comment`,lines:[],text:e,note:null}),onWrite:e=>{t.onDraft(r,null),t.onAct({act:`group-comment`,group:n.id,text:e})},onCancel:()=>t.onDraft(r,null)}),u.map(e=>(0,V.jsx)(Ft,{thread:e,readable:t.readable,agentHolds:t.agentHolds,busy:t.busy,onClose:()=>t.onAct({act:`close-thread`,thread:e.id}),watch:t.watchReply},e.id))]}),f.map(e=>m(e,!1)),p.length>0&&(0,V.jsxs)(`details`,{className:`rv-nt`,children:[(0,V.jsxs)(`summary`,{children:[`Non-textual (`,p.length,`)`,(0,V.jsx)(`span`,{className:`rv-nt-names`,children:p.map(e=>t.files[e.file]?.path??``).join(`, `)})]}),p.map(e=>m(e,!0))]})]})}var Ad=1200;function jd(e){return e.replace(/["\\]/g,e=>`\\${e}`)}function Md(e){let t=e.review,n=e.index,r=t.baseline,i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(!1),c=(0,v.useRef)(null),l=r?.entries??[],u=n.places,d=(0,v.useMemo)(()=>new Map(l.map(e=>[e.id,e])),[l]),f=r?.files??[],p=e.sections,m=e.group===`all`,h=p.filter(t=>m||t.id===e.group),g=Ie(t.state),_=Le(t.state),y=Re(t.state),b={review:t,index:n,summary:e.summary,entries:l,entryOf:d,files:f,order:u,pages:e.hunks,seen:n.seen,readable:g,readOnlySaid:_,agentHolds:y,busy:e.busy,theme:e.theme,opened:e.opened,drafts:e.drafts,feed:i,watch:e.watch,watchReply:e.watchReply,onAct:e.onAct,onOpen:e.onOpen,onDraft:e.onDraft},x=t=>n.seen.has(t)&&!e.opened.has(t)&&!e.drafts.has(`hunk:${t}`),ee=e=>{let t=i.current;if(t===null)return null;let r=t.querySelector(`[data-section="${jd(e.section)}"]`)??t;if(e.message!==null)return r.querySelector(`[data-message="${jd(e.message)}"]`);if(e.hunk===null)return r===t?null:r;let a=r.querySelector(`[data-hunk="${jd(e.hunk)}"]`);if(a===null||e.note===null)return a;let o=a.querySelector(`[data-note="${jd(e.note)}"]`);if(o!==null)return o;let s=(n.notes.get(e.hunk)??[]).find(t=>t.key===e.note),c=s===void 0?null:de(s);return(c===null?null:a.querySelector(`[data-line="${c}"]`))??a},S=(e,t)=>{let n=i.current,r=e.closest(`.rv-section`),a=r?.querySelector(`.rv-ghead`)??null;if(n===null||r===null||a===null)return null;let o=n.getBoundingClientRect(),s=e.getBoundingClientRect();return kt({scrollTop:n.scrollTop,feedTop:o.top,feedHeight:o.height,pinned:a.classList.contains(`is-under`)?44:0,sectionTop:r.getBoundingClientRect().top,headerHeight:a.getBoundingClientRect().height,fold:Number.parseFloat(a.style.getPropertyValue(`--rv-fold`))||0,collapse:Number.parseFloat(a.style.getPropertyValue(`--rv-collapse`))||0,targetTop:s.top,targetHeight:s.height,underHeader:e!==r&&!a.contains(e),block:t})},C=e=>{let t=c.current;t!==null&&(clearTimeout(t.timer),t.element.classList.remove(`is-landed`)),e.classList.add(`is-landed`),c.current={element:e,timer:setTimeout(()=>{e.classList.remove(`is-landed`),c.current=null},Ad)}},te=t=>{let n=t.hunk;if(n!==null){let t=u.get(n);if(t!==void 0&&e.need(t),!e.hunks.has(n))return!1;if(x(n))return e.onOpen(n,!0),!1}let r=ee(t);if(r===null)return!1;let a=r.closest(`details`);a!==null&&!a.open&&(a.open=!0);let o=t.note===null&&t.message===null,s=S(r,o?`start`:`center`),c=i.current;return s!==null&&c!==null&&typeof c.scrollTo==`function`?c.scrollTo({top:s}):typeof r.scrollIntoView==`function`&&r.scrollIntoView({block:o?`start`:`center`}),C(r),!0},w=(0,v.useRef)(te);w.current=te;let ne=e.want,T=e.hunks,E=e.onLanded,D=e.opened;(0,v.useEffect)(()=>{ne!==null&&w.current(ne.target)&&E()},[ne,T,D,E]);let O=e.startAt;(0,v.useEffect)(()=>{s.current||T.size===0||i.current===null||(s.current=!0,i.current.scrollTop=O)},[T.size,O]),(0,v.useEffect)(()=>()=>{let e=c.current;e!==null&&clearTimeout(e.timer)},[]);let k=e.summary.of(e.scope).controls,re=m?e.coming:0,ie=m?n.gone:[],ae=[{kind:`groups`,held:h.length,draw:()=>h.map(t=>(0,V.jsx)(kd,{section:t,kit:b,controls:m?null:k,onWalk:e.onWalk,pinned:m?44:0},t.id))},{kind:`coming`,held:re,draw:()=>Array.from({length:re},(e,t)=>`coming-${t}`).map(e=>(0,V.jsx)(`div`,{className:`rv-section`,children:(0,V.jsxs)(`div`,{className:`rv-ghead is-skel`,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{className:`rv-skel is-narrow`}),(0,V.jsx)(`span`,{className:`rv-skel is-wide`})]})},e))},{kind:`gone`,held:ie.length,draw:()=>(0,V.jsxs)(`section`,{className:`rv-gcard`,"data-section":I,children:[(0,V.jsxs)(`div`,{className:`rv-gcard-top`,children:[(0,V.jsx)(`h3`,{children:He}),(0,V.jsxs)(`span`,{className:`rv-facts`,children:[ie.length,` thread`,ie.length===1?``:`s`]})]}),(0,V.jsx)(`p`,{children:`The hunk each of these was about is no longer in the change. Close it once it is settled.`}),ie.map(t=>(0,V.jsx)(Ft,{thread:t,readable:g,agentHolds:y,busy:e.busy,onClose:()=>e.onAct({act:`close-thread`,thread:t.id}),watch:e.watchReply},t.id))]})}],A=ae.every(e=>e.held===0);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`rv-feed`,ref:i,onScroll:t=>{let n=t.currentTarget;o(n.scrollTop>n.clientHeight),e.onScroll(n.scrollTop)},children:(0,V.jsx)(`div`,{className:`rv-fgrid`,children:(0,V.jsxs)(`div`,{className:`rv-fmain${m?` is-all`:``}`,children:[m&&(0,V.jsx)(Ot,{hunks:n.order.length,groups:t.metadata.groups.length,controls:k,onWalk:e.onWalk}),ae.map(e=>(0,V.jsx)(v.Fragment,{children:e.held===0?null:e.draw()},e.kind)),A&&(0,V.jsx)(`p`,{className:`rv-facts`,children:r===null?`This review has no baseline to draw.`:`Nothing is grouped yet, and nothing is left to read.`})]})})}),a&&(0,V.jsx)(`button`,{type:`button`,className:`rv-totop`,"aria-label":`Scroll to top`,onClick:()=>i.current?.scrollTo({top:0}),children:`↑`})]})}function Nd(e){let[t,n]=(0,v.useState)(!1),r=e.openAsked??0;(0,v.useEffect)(()=>{r>0&&n(!0)},[r]);let i=e.items.length;return i===0?null:(0,V.jsxs)(`aside`,{className:`rv-send${t?` is-open`:``}`,"aria-label":`Pending feedback`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[!t&&(0,V.jsxs)(`button`,{type:`button`,className:`rv-sendpill`,onClick:()=>n(!0),children:[`Send to agent`,(0,V.jsx)(`span`,{className:`rv-n`,children:i})]}),t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`rv-send-head`,children:`Pending feedback`}),e.items.map(t=>(0,V.jsxs)(`div`,{className:`rv-si`,children:[(0,V.jsx)(`b`,{children:M[t.act]}),(0,V.jsx)(`span`,{className:`rv-f`,children:e.whereOf(t)}),(0,V.jsx)(`span`,{className:`rv-q`,children:t.text}),(0,V.jsxs)(`span`,{className:`rv-si-ctl`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Edit ${M[t.act]}`,disabled:!e.readable||e.busy,onClick:()=>e.onEdit(t),children:`✎`}),(0,V.jsx)(`button`,{type:`button`,"aria-label":`Remove ${M[t.act]}`,disabled:!e.readable||e.busy,onClick:()=>e.onRemove(t),children:`×`})]})]},t.id)),(0,V.jsxs)(`p`,{className:`rv-send-foot`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`rv-btn is-primary`,disabled:!e.readable||e.busy,onClick:e.onSend,children:[`Send to agent (`,i,`)`]}),(0,V.jsx)(`small`,{children:`The agent works while you wait, and this review turns read-only`})]})]})]})}function Pd(e){let t=e=>e!==null&&e!==`ungrouped`;return{groups:e.metadata.groups.length,notes:e.metadata.notes.length,aside:e.dismissals.items.length,talk:e.threads.threads.filter(e=>e.kind===`group`&&t(e.anchor)).length,unsent:e.pending.items.filter(e=>t(e.group)).length}}function Fd(e,t){return`${e} ${t}${e===1?``:`s`}`}function Id(e){let t=[];e.groups>0&&t.push(`The agent's ${Fd(e.groups,`group`)}`),e.notes>0&&t.push(`The agent's ${Fd(e.notes,`note`)}`),e.aside>0&&t.push(`The ${Fd(e.aside,`note`)} you put aside`);let n=[];return e.talk>0&&n.push(Fd(e.talk,`conversation`)),e.unsent>0&&n.push(Fd(e.unsent,`unsent comment`)),n.length>0&&t.push(`Your ${n.join(` and `)} on whole groups`),t.length===0&&t.push(`Nothing yet: the agent has not written anything.`),t}function Ld(e){let t=e.review,n=Pd(t),[r,i]=(0,v.useState)(``),{onCancel:a}=e;return(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),(0,V.jsx)(`div`,{className:`dialog-shade`,children:(0,V.jsxs)(`form`,{className:`dialog rv-rdialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Reset the review of "${t.state.name}"`,onSubmit:t=>{t.preventDefault(),!e.busy&&e.onReset(r.trim())},children:[(0,V.jsxs)(`h2`,{className:`rail-head rv-adialog-head`,children:[(0,V.jsx)(`span`,{children:`Reset the review`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-icon rv-adialog-x`,"aria-label":`Close the dialog`,onClick:e.onCancel,children:`×`})]}),(0,V.jsxs)(`div`,{className:`dialog-body`,children:[(0,V.jsx)(`p`,{className:`rv-rsays`,children:`The agent reads the change again and groups and notes it from nothing.`}),(0,V.jsxs)(`div`,{className:`rv-rgoes`,children:[(0,V.jsx)(`h4`,{children:`Deleted`}),(0,V.jsx)(`ul`,{children:Id(n).map(e=>(0,V.jsx)(`li`,{children:e},e))}),(0,V.jsx)(`h4`,{children:`Kept`}),(0,V.jsxs)(`ul`,{children:[(0,V.jsx)(`li`,{children:`Your Seen marks`}),(0,V.jsx)(`li`,{children:`Everything you wrote on a hunk`})]})]}),(0,V.jsxs)(`label`,{htmlFor:`rv-instruction`,children:[`An instruction to the agent `,(0,V.jsx)(`small`,{children:`optional`})]}),(0,V.jsx)(`textarea`,{id:`rv-instruction`,value:r,disabled:e.busy,maxLength:Fe,placeholder:`What to look for this time, if anything`,onChange:e=>i(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`dialog-acts rv-adialog-acts`,children:[(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy,onClick:e.onCancel,children:`Cancel`}),(0,V.jsx)(`button`,{type:`submit`,className:`rv-btn is-small is-warn`,disabled:e.busy,children:`Reset`})]})]})})}function Rd(e,t){let n=(0,v.useRef)(t);n.current=t;let r=(0,v.useRef)(null),i=(0,v.useRef)(!1),a=(0,v.useCallback)(()=>{r.current=null,!(!i.current||e===null)&&(i.current=!1,ce(e,`place`,n.current()).catch(()=>{}))},[e]),o=(0,v.useCallback)(()=>{i.current=!0,r.current===null&&(r.current=setTimeout(a,500))},[a]);return(0,v.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current),r.current=null,a()},[a]),o}var zd=[`unseen`,`issue`,`attention`,`reply`];function Bd(e){return`${e.section}\n${e.hunk??``}\n${e.note??``}\n${e.message??``}`}function Vd(e,t){return{section:e,hunk:t,note:null,message:null}}function Hd(e,t){let n=[],r=(e,t,r)=>{n.push({key:Bd(t),kind:e,target:t,open:r})};for(let n of e.threads.get(z(`group`,t.id))??[])for(let i of n.messages)i.from===`agent`&&r(`reply`,{section:t.id,hunk:null,note:null,message:i.id},e.unread.has(i.id));for(let n of ve(e,t)){r(`unseen`,Vd(t.id,n),!e.seen.has(n));let i=new Set((e.open.get(n)??[]).map(e=>ue(e.hunk,e.key)));for(let a of e.notes.get(n)??[])a.kind!==`info`&&r(a.kind,{section:t.id,hunk:n,note:a.key,message:null},i.has(ue(a.hunk,a.key)));for(let i of e.threads.get(z(`hunk`,n))??[])for(let a of i.messages)a.from===`agent`&&r(`reply`,{section:t.id,hunk:n,note:null,message:a.id},e.unread.has(a.id))}return n}function Ud(e){let t=[];for(let n of e.gone)for(let r of n.messages){if(r.from!==`agent`)continue;let n={section:I,hunk:null,note:null,message:r.id};t.push({key:Bd(n),kind:`reply`,target:n,open:e.unread.has(r.id)})}return t}function Wd(e,t){return[...t.flatMap(t=>e.of(t)),...e.gone()]}function Gd(e,t,n){let r=e.length;if(r===0)return null;let i=n===null?-1:e.findIndex(e=>e.key===n);for(let n=1;n<=r;n+=1){let a=e[(i+n+r)%r];if(a!==void 0&&a.kind===t&&a.open)return a}return null}function Kd(e,t){for(let n of t){if((e.threads.get(z(`group`,n.id))??[]).some(e=>e.open))return{section:n.id,hunk:null,note:null,message:null};for(let t of ve(e,n))if((e.threads.get(z(`hunk`,t))??[]).some(e=>e.open))return Vd(n.id,t)}return e.gone.length===0?null:{section:I,hunk:null,note:null,message:null}}function qd(e,t,n,r){let i=t.findIndex(e=>e.id===n),a=i===-1?[...t]:[...t.slice(i+1),...t.slice(0,i)];for(let t of a){let n=Gd(e.of(t),r,null);if(n!==null)return{section:t.id,name:t.name,place:n}}let o=Gd(e.gone(),r,null);return o===null?null:{section:I,name:He,place:o}}function Jd(e){let t=e.state;return t.status===`approved`||t.status===`archived`&&e.approval?.approved?{text:`Approved`,kind:`is-ended`}:t.status===`closed`||t.status===`archived`?{text:`Closed`,kind:`is-ended`}:t.side===`agent`?null:e.ready?{text:`Ready for approval`,kind:`is-ready`}:{text:`Awaits you`,kind:`is-you`}}function Yd(e,t){let n=e.state,r=[Pe(n.selection)],i=n.selection.kind===`last-commit`||n.selection.kind===`commit`,a=e.baseline?.commits[0]?.subject??``;return i&&a!==``&&r.push(a),n.filedBy===`terminal`&&r.push(`filed from the terminal ${l(n.created,t)}`),r.join(` - `)}function Xd(e,t){return`${(e===``?`Working on the review`:e).replace(/[.;\s]+$/,``)}${t===`prepare`?`; code changes are best avoided meanwhile`:``}.`}function Zd(e,t){let n=new Date(e);return Number.isNaN(n.getTime())||n.toDateString()===t.toDateString()?``:n.toLocaleDateString([],{month:`short`,day:`numeric`})}function Qd(e){let t=e.review,n=t.state,r=t.baseline,[i,a]=(0,v.useState)(0),[o,s]=(0,v.useState)(!1),[c,u]=(0,v.useState)(null),d=e.group,[p,m]=(0,v.useState)(new Set(t.place.expanded)),[h,g]=(0,v.useState)(()=>new Map(t.place.drafts.map(e=>[e.anchor,e]))),[_,y]=(0,v.useState)(()=>{for(let e of t.place.drafts){if(!e.anchor.startsWith(`pending:`))continue;let n=t.pending.items.find(t=>`pending:${t.id}`===e.anchor);if(n!==void 0)return n}return null}),b=n.side===`agent`&&n.status===`reviewing`,x=t.slug.startsWith(`${Ce}/`),ee=f(b,e.now),S=Jd(t),C=t.relation,te=C!==null&&C.relation===`out-of-sync`?C:null,w=C!==null&&C.relation===`merged`?C:null,ne=(0,v.useRef)(t.place.scroll),T=od(t.slug,r?.fingerprint??``),E=cd(T.need),D=e.passed,O=Rd(x?null:t.slug,()=>({scroll:ne.current,expanded:[...p],group:d,read:[...D],drafts:[...h.values()]})),k=(e,t)=>{g(n=>{let r=new Map(n);return t===null?r.delete(e):r.set(e,{anchor:e,...t}),r}),O()},re=ld(t=>{D.has(t)||(e.onPassed(t),O())}),ie=(0,v.useRef)(d);(0,v.useEffect)(()=>{ie.current!==d&&(ie.current=d,O())},[d,O]);let ae=t.pending.items;(0,v.useEffect)(()=>{let e=new Set(ae.map(e=>`pending:${e.id}`)),t=[...h.keys()].filter(t=>t.startsWith(`pending:`)&&!e.has(t));t.length>0&&(g(e=>{let n=new Map(e);for(let e of t)n.delete(e);return n}),O()),y(e=>e===null||ae.some(t=>t.id===e.id)?e:null)},[ae,h,O]);let A=b&&Be(n.agent.lastPostAt,ee),oe=Xd(n.agent.activity,n.agent.act),se=t.metadata.groups,ce=e.index,le=e.sections,j=d===`all`?null:d,M=(0,v.useRef)({group:d,key:null});M.current.group!==d&&(M.current={group:d,key:null});let N=Ie(n),P=t=>{let n=t.section===`gone`?`all`:t.section,r=d===`all`?d:n;r!==d&&e.onPickGroup(r),M.current={group:r,key:Bd(t)},u({target:t})};return(0,V.jsxs)(`div`,{className:`rv-screen`,children:[(0,V.jsxs)(`div`,{className:`rv-head`,children:[(0,V.jsx)(`h2`,{children:n.name}),(0,V.jsx)(`span`,{className:`rv-head-what`,children:Yd(t,ee)}),(0,V.jsx)(`span`,{className:`rv-grow`}),N&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small is-quiet`,disabled:e.busy,onClick:()=>s(!0),children:`Reset`}),S!==null&&(0,V.jsx)(`span`,{className:`rv-chip ${S.kind}`,children:S.text})]}),t.approval!==null&&(0,V.jsx)(Ct,{approval:t.approval,slug:t.slug,filed:x,busy:e.busy,onArchive:()=>e.onAct({act:`archive`})}),b&&(0,V.jsxs)(`div`,{className:`rv-agentbar`,children:[(0,V.jsx)(`b`,{children:`Awaits agent`}),(0,V.jsxs)(`span`,{className:`rv-say`,children:[oe,n.agent.instruction!==``&&(0,V.jsxs)(`span`,{className:`rv-asked`,children:[` You asked: `,n.agent.instruction]}),n.agent.lastPostAt!==null&&(0,V.jsxs)(V.Fragment,{children:[` Last post ${ht(n.agent.lastPostAt)}, `,(0,V.jsx)(`span`,{className:A?`rv-late`:void 0,children:l(n.agent.lastPostAt,ee)}),`.`]})]}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small is-primary`,disabled:e.busy,onClick:()=>e.onAct({act:`stop`}),children:`Stop the agent and review now`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small is-outline`,disabled:e.busy,onClick:()=>e.onAct({act:`ask`}),children:`Ask the agent to continue`})]}),!b&&te!==null&&(0,V.jsxs)(`div`,{className:`rv-banner`,children:[(0,V.jsx)(`b`,{children:`Out of sync`}),(0,V.jsx)(`span`,{children:`The tree is out of sync with the baseline.`}),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy||!N,title:N?void 0:Le(n),onClick:()=>e.onAct({act:`sync`}),children:`Sync`})]}),!b&&w!==null&&(0,V.jsxs)(`div`,{className:`rv-banner is-merged`,children:[(0,V.jsx)(`b`,{children:`Merged`}),(0,V.jsx)(`span`,{children:w.mergedAs===null?`This branch was merged.`:`This branch was merged as ${w.mergedAs}.`}),(0,V.jsx)(`span`,{className:`rv-grow`}),w.mergedAs!==null&&(0,V.jsx)(`button`,{type:`button`,className:`rv-btn is-small`,disabled:e.busy||!N,title:N?void 0:Le(n),onClick:()=>e.onAct({act:`follow`}),children:`Follow the merge`})]}),t.error!==null&&(0,V.jsxs)(`div`,{className:`rv-banner`,children:[(0,V.jsx)(`b`,{children:`Not all there`}),(0,V.jsx)(`span`,{children:t.error}),N&&!t.ready&&(0,V.jsx)(mt,{busy:e.busy,onClose:t=>e.onAct({act:`close`,reason:t})})]}),(0,V.jsxs)(`div`,{className:`rv-body`,children:[(0,V.jsx)(Md,{review:t,index:ce,summary:e.summary,sections:le,group:d,scope:j,hunks:T.hunks,need:T.need,watch:E,watchReply:re,want:c,onLanded:()=>u(null),onWalk:t=>{let n=e.summary.of(j),r=Gd(n.places,t,M.current.key);if(r!==null){P(r.target);return}let i=n.crossing(t);i!==null&&P(i.place.target)},opened:p,onOpen:(e,t)=>{m(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),O()},drafts:h,onDraft:k,busy:e.busy,onAct:e.onAct,startAt:t.place.scroll,theme:e.theme,onScroll:e=>{ne.current=e,O()},coming:We(t)}),(0,V.jsx)(Nd,{items:t.pending.items,whereOf:e=>{if(e.group!==null){let t=se.find(t=>t.id===e.group);return t===void 0?`the group`:t.name}let t=(r?.entries??[]).find(t=>t.id===e.hunk);if(t===void 0)return e.label===`hunk-removed`?`a hunk that is gone`:e.hunk??``;let n=r?.files[t.file]?.path??``,i=/^@@ (-\d+)/.exec(t.header);return i===null?n:`${n} @@ ${i[1]}`},readable:N,busy:e.busy,onEdit:e=>{y(e),k(`pending:${e.id}`,{act:e.act,lines:[],text:e.text,note:null})},onRemove:n=>e.onAct({act:`pending`,items:t.pending.items.filter(e=>e.id!==n.id)}),onSend:()=>e.onAct({act:`send`}),openAsked:i})]}),e.approving&&N&&(0,V.jsx)(bt,{review:t,busy:e.busy,onApprove:(t,n,r)=>{e.onApproving(!1),e.onAct({act:`approve`,name:t,signature:n,acknowledged:r})},onClose:t=>{e.onApproving(!1),e.onAct({act:`close`,reason:t})},onCancel:()=>e.onApproving(!1),onGoTo:t=>{if(e.onApproving(!1),t===`pending`){a(e=>e+1);return}if(t===`threads`){let e=Kd(ce,le);e!==null&&P(e);return}let n={unseen:`unseen`,issues:`issue`,attention:`attention`,unreadReplies:`reply`}[t];if(n===void 0)return;let r=Gd(e.summary.of(null).places,n,null);r!==null&&P(r.target)}}),o&&N&&(0,V.jsx)(Ld,{review:t,busy:e.busy,onReset:t=>{s(!1),e.onAct({act:`reset`,instruction:t})},onCancel:()=>s(!1)}),_!==null&&N&&(0,V.jsx)(`div`,{className:`rv-editing`,children:(0,V.jsx)(xt,{act:_.act,lines:[],text:h.get(`pending:${_.id}`)?.text??_.text,busy:e.busy,onChange:e=>k(`pending:${_.id}`,{act:_.act,lines:[],text:e,note:null}),onWrite:n=>{let r=_;y(null),k(`pending:${r.id}`,null),e.onAct({act:`pending`,items:t.pending.items.map(e=>e.id===r.id?{...e,text:n}:e)})},onCancel:()=>{k(`pending:${_.id}`,null),y(null)}})}),T.failure!==null&&(0,V.jsxs)(`p`,{className:`notice notice-failure`,children:[T.failure,` `,(0,V.jsx)(`button`,{type:`button`,className:`rv-link`,onClick:T.retry,children:`Try again`})]}),e.openLog&&(0,V.jsx)(`div`,{className:`rv-log`,children:[...n.log].reverse().map(e=>(0,V.jsxs)(`p`,{children:[(0,V.jsxs)(`b`,{children:[Zd(e.at,ee),` `,ht(e.at)]}),` `,e.said]},`${e.at}-${e.said}`))})]})}var $d=`approve-left`;function ef(e){let t=e===1;return`${e} thing${t?``:`s`} still need${t?`s`:``} your attention. Open to see ${t?`it`:`them`}.`}function tf(e){let t=[];return e.issues>0&&t.push({kind:`is-issue`,text:`${e.issues} issue${e.issues===1?``:`s`}`}),e.attention>0&&t.push({kind:`is-attention`,text:`${e.attention} attention`}),e.replies>0&&t.push({kind:`is-reply`,text:`${e.replies} unread ${e.replies===1?`reply`:`replies`}`}),e.waiting>0&&t.push({kind:`is-you`,text:`${e.waiting} wait${e.waiting===1?`s`:``} on you`}),e.changed>0&&t.push({kind:`is-changed`,text:`${e.changed} changed since seen`}),t}function nf(e){let t=a({className:`rv-tip`,side:`top`}),n=e.review,r=n.state,i=e.summary.of(null).counts,o=i.hunks===0?0:Math.round(i.seen/i.hunks*100),s=Ie(r),c=L(n.leftAsIs);return(0,V.jsxs)(`div`,{className:`workspace-foot rv-status`,children:[(0,V.jsxs)(`span`,{className:`rv-loops`,title:`Agent-human feedback loops`,children:[(0,V.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,children:[(0,V.jsx)(`path`,{d:`M13 8a5 5 0 0 0-8.5-3.5M3 8a5 5 0 0 0 8.5 3.5`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,V.jsx)(`path`,{d:`M4.5 1.5v3h3M11.5 14.5v-3h-3`,strokeWidth:`1.5`,strokeLinecap:`round`})]}),n.loops]}),(0,V.jsx)(`span`,{className:`rv-prog`,title:`${i.seen} of ${i.hunks} hunks seen`,children:(0,V.jsx)(`i`,{style:{width:`${o}%`}})}),tf(i).map(e=>(0,V.jsxs)(`span`,{className:`rv-fact ${e.kind}`,children:[(0,V.jsx)(`i`,{"aria-hidden":`true`}),e.text]},e.kind)),(0,V.jsx)(`span`,{className:`rv-grow`}),(0,V.jsxs)(`button`,{type:`button`,className:`rv-log-toggle`,"aria-expanded":e.openLog,onClick:()=>e.onOpenLog(!e.openLog),children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,children:e.openLog?`▾`:`▸`}),`Activity (`,r.log.length,`)`]}),s&&(0,V.jsxs)(`button`,{type:`button`,className:`rv-btn is-small is-ok rv-approve`,disabled:e.busy,"aria-describedby":c>0?$d:void 0,onClick:e.onApprove,...t.anchor,children:[`Approve...`,c>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`rv-abadge is-warn`,"aria-hidden":`true`,children:`!`}),(0,V.jsx)(`span`,{className:`visually-hidden`,id:$d,"aria-hidden":`true`,children:ef(c)}),t.says(ef(c))]})]})]})}var rf={unseen:`unseen`,issue:`issues`,attention:`attention`,reply:`replies`},af={count:0,groups:[]};function of(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Map,i=null,a=t=>{let n=r.get(t.id);if(n!==void 0)return n;let i=Hd(e,t);return r.set(t.id,i),i},o={of:a,gone:()=>(i??=Ud(e),i)},s=null,c=()=>(s??=Wd(o,t),s),l=null,u=()=>(l??=e.gone.reduce((t,n)=>t+n.messages.filter(t=>t.from===`agent`&&e.unread.has(t.id)).length,0),l),d=e=>{let n=t.findIndex(t=>t.id===e);return n===-1?t:[...t.slice(n+1),...t.slice(0,n)]},f=(e,t)=>{let n=rf[t];for(let t of d(e))if(h(t.id).counts[n]>0)return t.name;return t===`reply`&&u()>0?He:null},p=(e,t,n)=>{let r=e.counts[rf[n]];if(r>0)return{kind:n,state:`here`,count:r};if(t===null)return{kind:n,state:`nowhere`};let i=f(t,n);return i===null?{kind:n,state:`nowhere`}:{kind:n,state:`across`,section:i}},m=new Map,h=r=>{let i=r===null?``:`group\n${r}`,s=m.get(i);if(s!==void 0)return s;let l=r===null?null:n.get(r)??{id:r,name:r,hunks:[]},u=new Map,d=null,f={counts:ye(e,l),get places(){return l===null?c():a(l)},crossing:e=>l===null?null:(u.has(e)||u.set(e,qd(o,t,l.id,e)),u.get(e)??null),get controls(){return d??=zd.map(e=>p(f,r,e)),d}};return m.set(i,f),f},g=null,_=null;return{of:h,holders:()=>(g??=Ke(t),g),shared:e=>(_??=new Map(t.map(e=>[e.id,Ge(e,t)])),_.get(e)??af)}}var sf={open:null,starting:!1,form:null};function cf(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)({options:[],notOffered:null}),[f,p]=(0,v.useState)(!1),[m,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(null),[x,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(new Set),[D,O]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(!1),oe=(0,v.useRef)(null),se=h({onSession:S,askTheme:ne}),le=(0,v.useRef)(new Map),j=(0,v.useRef)(null),M=(0,v.useRef)(sf),N=(0,v.useRef)(null),[P,ue]=(0,v.useState)(0),F=(0,v.useCallback)(()=>{k().then(e=>{t(e),r(null)}).catch(e=>r(e.message))},[]),I=(0,v.useCallback)(e=>{if(e===null){s(null);return}re(e).then(s).catch(e=>{s(null),b(e.message)})},[]);(0,v.useEffect)(F,[F]),(0,v.useEffect)(()=>I(i),[i,I]),(0,v.useEffect)(()=>ee(()=>{F(),I(i)}),[i,F,I]),(0,v.useEffect)(()=>{let e=()=>{document.visibilityState!==`hidden`&&(F(),I(i))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[i,F,I]),(0,v.useEffect)(()=>{e!==null&&te(e.awaitingYou,e.any)},[e]);let de=(0,v.useCallback)(async(e,t,n)=>{for(let t of e){let e=await C({event:t.event,detail:t.detail,path:t.path});e.ok||b(`No agent was told: ${e.error}`)}if(!t)return;let r=await C({event:`review`,detail:n});r.ok||b(`No agent was told: ${r.error}`)},[]),fe=(0,v.useCallback)(async(e,t,n={})=>{_(!0),b(null);try{let r=await ce(e,t,n);r.review!==null&&(s(r.review),r.review.slug!==e&&a(r.review.slug),F(),await de(r.typed,r.command,r.review.state.name))}catch(e){b(e instanceof Error?e.message:`that act was refused`)}finally{_(!1)}},[F,de]),pe=(0,v.useCallback)((e,t)=>{if(t.act===`ask`){de([],!0,e.state.name);return}let{act:n,...r}=t;fe(e.slug,n,r)},[fe,de]),me=(0,v.useCallback)(()=>{p(!0),A().then(d).catch(e=>b(e.message)).finally(()=>p(!1))},[]),he=(0,v.useCallback)(()=>{N.current=null,l(!0),a(null),b(null),me()},[me]);(0,v.useEffect)(()=>{M.current={open:i,starting:c}},[i,c]);let ge=(0,v.useCallback)(e=>{if(j.current===e)return;let t=M.current,n=e===null?void 0:le.current.get(e);if(j.current===null&&n===void 0){j.current=e;return}j.current!==null&&le.current.set(j.current,{...t,form:N.current}),j.current=e;let r=n??sf;M.current=r,N.current=r.form,a(r.open),l(r.starting),ue(e=>e+1),b(null),r.starting&&me()},[me]);(0,v.useEffect)(()=>S(e=>ge(e.sid)),[ge]);let L=o!==null&&o.slug===i?o:null,R=(0,v.useMemo)(()=>L===null?null:_e(L,T),[L,T]),z=(0,v.useMemo)(()=>L===null?[]:qe(L),[L]),ve=(0,v.useMemo)(()=>R===null?null:of(R,z),[R,z]);L===null?oe.current=null:oe.current!==L.slug&&(oe.current=L.slug,x!==null&&w(null),T.size>0&&E(new Set),D&&O(!1),ie&&ae(!1));let ye=(x===null||x!==`all`&&!z.some(e=>e.id===x)?null:x)??(L===null?`all`:Ue(L,z)),be=(0,v.useCallback)(e=>{N.current=null,l(!1),a(e.slug),F(),de([],e.command,e.state.name)},[F,de]);return e===null?(0,V.jsx)(`p`,{className:`notice notice-failure`,children:n??`Waiting for the pane to hand over…`}):(0,V.jsxs)(`div`,{className:`workspace is-alone is-review${L!==null&&R!==null&&ve!==null?` has-foot`:``}`,children:[L===null||R===null||ve===null?(0,V.jsx)(ft,{active:e.active,archived:e.archived,open:i,onOpen:e=>{l(!1),a(e)},starting:c,onStart:he,repository:e.repository,error:e.error}):(0,V.jsx)($e,{review:L,index:R,summary:ve,sections:z,group:ye,onPick:w,onBack:()=>a(null)}),(0,V.jsxs)(`div`,{className:`stage${L===null?``:` has-bar`}`,"data-theme":se.theme,children:[(0,V.jsx)(g,{theme:se.theme,kept:se.kept,onToggle:se.toggle}),y!==null&&(0,V.jsx)(`p`,{className:`notice notice-failure`,children:y}),c?(0,V.jsx)(at,{offer:u,reading:f,onRefresh:me,draft:N.current,onDraft:e=>{N.current=e},onCancel:()=>{N.current=null,l(!1)},onStarted:be},P):L===null||R===null||ve===null?(0,V.jsx)(`div`,{className:`doc`,children:(0,V.jsx)(`p`,{className:`notice`,children:i===null?`Nothing is open. Pick a review on the left.`:`Reading the review…`})}):(0,V.jsx)(Qd,{review:L,index:R,summary:ve,sections:z,busy:m,theme:se.theme,group:ye,onPickGroup:w,passed:T,onPassed:e=>E(t=>t.has(e)?t:new Set([...t,e])),onAct:e=>pe(L,e),openLog:D,approving:ie,onApproving:ae},L.slug)]}),L!==null&&R!==null&&ve!==null&&(0,V.jsx)(nf,{review:L,summary:ve,openLog:D,onOpenLog:O,onApprove:()=>ae(!0),busy:m})]})}w();var lf=document.getElementById(`root`);lf&&(0,y.createRoot)(lf).render((0,V.jsx)(v.StrictMode,{children:(0,V.jsx)(cf,{})}));