@preventive/triage 1.0.0-alpha.74 → 1.0.0-alpha.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/finding-duplicates.js +4 -4
- package/common/finding-filters.js +11 -13
- package/common/managed/roles.ts +6 -0
- package/common/managed/routes.js +4 -3
- package/common/managed/team-app.d.ts +2 -0
- package/common/managed/team-app.js +31 -14
- package/out/activity.js +1 -1
- package/out/{chunk-C6OPCPCA.js → chunk-24LZZYAP.js} +1 -1
- package/out/{chunk-VRAJCPV5.js → chunk-EYTPAODY.js} +2 -2
- package/out/chunk-ITUKKCCK.js +10 -0
- package/out/{chunk-BLPHP4U3.js → chunk-IVDE66N5.js} +1 -1
- package/out/{chunk-VS7RV24Z.js → chunk-MFAB7P3T.js} +2 -2
- package/out/chunk-O6FA2R5G.js +53 -0
- package/out/chunk-OCE6KQGJ.js +40 -0
- package/out/{chunk-YI4D6XVX.js → chunk-RHOQDAU4.js} +1 -1
- package/out/{chunk-2IHCVA3Y.js → chunk-T6EXDRB7.js} +1 -1
- package/out/chunk-UZC7POI4.js +255 -0
- package/out/chunk-WGQ7D5DB.js +1 -0
- package/out/client-managed-import.js +1 -1
- package/out/client-managed.js +30 -30
- package/out/compare.js +4 -4
- package/out/dialogs.js +1 -1
- package/out/graph.js +6 -6
- package/out/index.html +8 -8
- package/out/prism.js +1 -1
- package/out/scan.js +1 -1
- package/out/view.css +1 -1
- package/out/view.js +4 -4
- package/package.json +5 -2
- package/risk/files/characters.js +142 -8
- package/risk/files/hosts.js +4 -3
- package/risk/files/readability.js +18 -13
- package/risk/files/runs-code.js +41 -80
- package/risk/files/script.js +210 -48
- package/risk/index.d.ts +4 -2
- package/risk/npm/assess.js +1 -1
- package/risk/npm/tarball.js +35 -19
- package/server-managed/dependency-review-comments.ts +22 -10
- package/server-managed/http.ts +74 -25
- package/server-managed/locked-packages.ts +62 -5
- package/server-managed/npm-packages.ts +7 -5
- package/server-managed/queue.ts +8 -7
- package/server-managed/repository-browser.ts +6 -3
- package/server-managed/repository-code.ts +3 -2
- package/server-managed/repository-risk-caches.ts +37 -0
- package/server-managed/repository-risk-read.ts +41 -18
- package/server-managed/repository-risk-stasis.ts +61 -0
- package/server-managed/repository-risk-turn.ts +97 -0
- package/server-managed/repository-risk.ts +128 -102
- package/server-managed/scan-downloads.ts +44 -10
- package/server-managed/team-app-summaries.ts +3 -1
- package/server-managed/team-app.ts +4 -2
- package/server-managed/team-reports.ts +8 -3
- package/out/chunk-5YP7P5KA.js +0 -1
- package/out/chunk-74AEKRES.js +0 -10
- package/out/chunk-DQJEVHRE.js +0 -52
- package/out/chunk-ESJZZF2Y.js +0 -255
- package/out/chunk-GV5U7OLP.js +0 -40
package/out/compare.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,b as t,f as n,g as r,j as i,k as a,l as o}from"./chunk-W5PRH5D7.js";import"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import"./chunk-R3NZFXVR.js";import{Ad as s,Bd as c,Be as l,Cd as u,Ce as d,Dd as f,De as p,Ed as m,Ee as h,Eg as g,Fd as _,Fg as v,Gd as y,Ha as b,Hd as x,Ia as S,Id as C,Ja as w,Jd as ee,Ka as T,Kd as E,Ld as D,Le as te,Md as ne,Me as re,Nd as ie,Ne as ae,Od as oe,Oe as se,Pd as ce,Pe as le,Qa as ue,Qc as de,Qd as fe,Qe as pe,Ra as me,Rc as he,Rd as ge,Re as _e,Sa as ve,Sc as O,Sd as ye,Se as be,Ta as xe,Tc as Se,Td as Ce,Te as we,Ua as Te,Uc as Ee,Ud as De,Ue as Oe,Va as ke,Vc as Ae,Vd as je,Wa as Me,Wd as Ne,We as Pe,Xd as Fe,Yd as Ie,Zd as Le,_d as Re,bd as ze,cd as k,cg as Be,dd as Ve,de as He,dg as Ue,ee as We,eg as Ge,fe as Ke,fg as qe,ge as Je,gg as Ye,ha as Xe,hd as Ze,hg as Qe,id as $e,ig as et,jd as tt,jg as nt,kd as rt,kg as it,ld as at,lg as ot,md as st,mg as ct,nc as lt,nd as ut,ng as dt,oc as ft,od as pt,og as A,pc as mt,pd as ht,pg as j,qc as gt,qd as _t,qg as vt,rd as yt,rf as bt,rg as xt,sd as St,sf as Ct,sg as M,tc as wt,u as N,uc as Tt,vd as Et,wd as Dt,xd as P,yd as F,zd as Ot}from"./chunk-
|
|
1
|
+
import{a as e,b as t,f as n,g as r,j as i,k as a,l as o}from"./chunk-W5PRH5D7.js";import"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import"./chunk-R3NZFXVR.js";import{Ad as s,Bd as c,Be as l,Cd as u,Ce as d,Dd as f,De as p,Ed as m,Ee as h,Eg as g,Fd as _,Fg as v,Gd as y,Ha as b,Hd as x,Ia as S,Id as C,Ja as w,Jd as ee,Ka as T,Kd as E,Ld as D,Le as te,Md as ne,Me as re,Nd as ie,Ne as ae,Od as oe,Oe as se,Pd as ce,Pe as le,Qa as ue,Qc as de,Qd as fe,Qe as pe,Ra as me,Rc as he,Rd as ge,Re as _e,Sa as ve,Sc as O,Sd as ye,Se as be,Ta as xe,Tc as Se,Td as Ce,Te as we,Ua as Te,Uc as Ee,Ud as De,Ue as Oe,Va as ke,Vc as Ae,Vd as je,Wa as Me,Wd as Ne,We as Pe,Xd as Fe,Yd as Ie,Zd as Le,_d as Re,bd as ze,cd as k,cg as Be,dd as Ve,de as He,dg as Ue,ee as We,eg as Ge,fe as Ke,fg as qe,ge as Je,gg as Ye,ha as Xe,hd as Ze,hg as Qe,id as $e,ig as et,jd as tt,jg as nt,kd as rt,kg as it,ld as at,lg as ot,md as st,mg as ct,nc as lt,nd as ut,ng as dt,oc as ft,od as pt,og as A,pc as mt,pd as ht,pg as j,qc as gt,qd as _t,qg as vt,rd as yt,rf as bt,rg as xt,sd as St,sf as Ct,sg as M,tc as wt,u as N,uc as Tt,vd as Et,wd as Dt,xd as P,yd as F,zd as Ot}from"./chunk-UZC7POI4.js";import"./chunk-A4BBBHQU.js";import"./chunk-JCIIBLKR.js";import"./chunk-VYYUMYVW.js";import"./chunk-7HP2VYIC.js";import{f as kt}from"./chunk-PQPKHAI5.js";import"./chunk-T6EXDRB7.js";import{Ca as At,ga as I,ha as jt,ia as Mt,ja as Nt,la as Pt,v as Ft,xa as It,za as Lt}from"./chunk-O6FA2R5G.js";import{a as Rt,k as zt,l as L,m as R}from"./chunk-62QT2RXR.js";import{b as Bt}from"./chunk-S5HSDGTP.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{Ga as Vt,K as z,L as Ht,a as B}from"./chunk-OCE6KQGJ.js";import"./chunk-IVDE66N5.js";import{e as Ut}from"./chunk-74JZTGTO.js";import{e as Wt}from"./chunk-IYPY47MC.js";import{d as Gt}from"./chunk-ITUKKCCK.js";import{a as V,d as H}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import{k as Kt,n as qt,r as Jt}from"./chunk-WGQ7D5DB.js";import{a as Yt}from"./chunk-QRKFPLA4.js";import{c as U,g as W,j as Xt}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var Zt=e=>e.toLocaleString(),Qt=(e,t)=>`${e===0?`±`:e>0?`+`:`−`}${t(Math.abs(e))}`,$t=e=>Qt(e,Zt),en=e=>Qt(e,z);function tn(e){return e>0?`up`:e<0?`down`:``}function nn({onlyBase:e,onlyOther:t,changed:n}){return[[`removed`,`−`,e],[`added`,`+`,t],[`repointed`,``,n]].filter(([,,e])=>e.length>0).map(([e,t,n])=>U`<span class="${`bundle-compare-chip ${e===`repointed`?`changed`:e}`}">${t}${n.length.toLocaleString()} ${e} ${n.length===1?`resolution`:`resolutions`}</span>`)}function rn(e,t){if(!t)return``;let n=e/t*100;return`${n>0?`+`:n<0?`−`:`±`}${Math.abs(n).toFixed(1)}%`}var an=(e,t,n,r,i=Zt,a=$t(r))=>U`<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">${e}</span> <span class="bundle-compare-metric-value">${i(t)} → ${i(n)}</span> <span class="${`bundle-compare-metric-delta ${tn(r)}`}">${a}</span></div>`;function on(e){let t=e.totals,n=e.versionUpdates?.totals??{baseDeps:0,otherDeps:0},r=rn(t.byteDelta,t.baseBytes);return U`<div class="bundle-compare-stats">${n.baseDeps>0||n.otherDeps>0?an(`Deps`,n.baseDeps,n.otherDeps,n.otherDeps-n.baseDeps):W} ${an(`Size`,t.baseBytes,t.otherBytes,t.byteDelta,z,U`${en(t.byteDelta)}${r?U`${` `}<span class="bundle-compare-pct">(${r})</span>`:W}`)} ${t.baseLines>0||t.otherLines>0?an(`LoC`,t.baseLines,t.otherLines,t.otherLines-t.baseLines):W}<div class="bundle-compare-files">${an(`Files`,t.baseFiles,t.otherFiles,t.fileDelta)}<div class="bundle-compare-chips">${t.onlyBaseFiles>0?U`<span class="bundle-compare-chip removed">−${t.onlyBaseFiles.toLocaleString()} removed</span>`:W} ${t.onlyOtherFiles>0?U`<span class="bundle-compare-chip added">+${t.onlyOtherFiles.toLocaleString()} added</span>`:W} ${t.changedFiles>0?U`<span class="bundle-compare-chip changed">${t.changedFiles.toLocaleString()} changed${t.renamedFiles>0?` (${t.renamedFiles.toLocaleString()} renamed)`:``}</span>`:W} <span class="bundle-compare-chip unchanged">${t.unchangedFiles.toLocaleString()} unchanged</span> ${e.resolutions?nn(e.resolutions):W}</div></div></div>`}var sn=24;function G(e,t=e=>e.id){return e.map(e=>({id:t(e),integrity:t(e),kind:e.format,format:e.format,detail:e.detail,...e.date&&{date:e.date},...e.dateWarning&&{dateWarning:e.dateWarning},filename:e.name,displayLabel:e.displayLabel,size:`—`,summary:null}))}function cn(e){if(!e)return W;let t=({name:e=``,detail:t=``,detailNote:n=null}={})=>e.length+Math.min(t.length,sn)*.87+(n?3:1),n=(e.choices??[]).reduce((e,n)=>Math.max(e,t(n)),Math.max(`Choose a ${e.noun??`bundle`}\u2026`.length,t(e.widest)));return V({"--compare-select-chars":`${Math.ceil(n)}`})}function ln({source:e,label:t=`Compare`,from:n,to:r,clear:i,swap:a,extras:o=W,comparison:s=null,disabled:c=!1,openLine:l}){let u=e?.noun??`bundle`,d=`${u[0].toUpperCase()}${u.slice(1)}`,f=(t,n)=>e?.select?e.select(t,t.label??n):U`<bundle-selector .bundles="${t.options}" .value="${t.value}" .noun="${u}" .versions="${!!e}" label="${t.label??n}" placeholder="${t.placeholder??`Choose a ${u}\u2026`}" ?disabled="${c}" @bundle-change="${e=>{e.stopPropagation(),t.pick(e.detail.value)}}"></bundle-selector>`;return U`<div class="${e?`bundle-compare-picker is-versions`:`bundle-compare-picker`}" style="${cn(e)}" @compare-open-line="${e=>l?.(e.detail)}"><div class="bundle-compare-select-wrap"><span class="bundle-compare-select-hint">${t}</span> ${f(n,`${d} to compare with`)} ${i?U`<button type="button" class="bundle-compare-clear" aria-label="${i.label??`Clear comparison`}" ?disabled="${c}" @click="${i.run}">×</button>`:W}</div><span class="bundle-compare-arrow" aria-hidden="true">→</span><div class="bundle-compare-select-wrap">${f(r,`${d} to compare`)} ${a?U`<button type="button" class="bundle-compare-swap" ?disabled="${c}" @click="${a}" aria-label="${`Swap the two ${u}s`}"><span class="bundle-compare-swap-icon" aria-hidden="true">↔</span>Swap</button>`:W}</div>${o}${s?e?.badges?.(s.base,s.other,s.files)??W:W}</div>`}function un(e,t=W){return U`<div class="bundle-compare-summary">${on(e)}${t}</div>`}function dn(e,t=W){return U`<header class="bundle-compare-head">${e}${t}</header>`}var fn=4,pn=e=>e?.integrity===`(empty)`,mn=new Map,hn=e=>e.state.status!==`loading`;function gn(e){e.notify?.();for(let t of e.waiting.splice(0))t()}var _n=null,vn=(e,t)=>!!(e.managedId&&t.managedId)||!(!t.npm&&!t.npmPatch||!e.npm&&!pn(e));function yn(e,t,n){if(e.managedId&&t.managedId)return w(e.managedId,t.managedId,{scope:n});if(vn(e,t)){let{name:n,version:r,patch:i}=t.npm??t.npmPatch;return T(n,r,e.npm?.version??`(empty)`,{otherName:e.npm?.name??n,...i?{patch:i}:{},...e.npmPatch?{otherPatch:e.npmPatch.patch}:{}})}return import(`./chunk-HLMQ7QYS.js`).then(r=>(_n=r,r.prepareComparison(e,t,n)))}async function bn(e,t,n,r,i){let a;try{a={status:`ready`,diff:await yn(n,r,i)}}catch(n){if(E(n)){mn.get(e)===t&&mn.delete(e),gn(t);return}if(a={status:`error`,message:n?.message??String(n)},x(n?.status)){let e=C(t.failures);Object.assign(t,{retryAt:Date.now()+e,failures:t.failures+1}),ee(e,()=>{t.notify?.()})}}a.status===`ready`&&(t.failures=0),t.state=a,gn(t),D(mn,fn,hn)}var xn=new WeakMap,Sn=0,Cn=e=>(xn.has(e)||xn.set(e,++Sn),xn.get(e));function wn(e,t,n,r=!1){let i=vn(e,t)?`${e.integrity}\0${t.integrity}\0${n??``}`:`${Cn(e)}\0${Cn(t)}\0${n??``}\0here`;return ne(mn,i,fn,hn,r=>{let a={state:{status:`loading`},notify:r?.notify??null,waiting:[],failures:r?.failures??0};return _n&&!vn(e,t)?a.state={status:`ready`,diff:_n.prepareComparison(e,t,n??``)}:bn(i,a,e,t,n??``),a},e=>!e||r&&e.state.status===`error`||e.retryAt!==void 0&&Date.now()>=e.retryAt)}function Tn(e,t,n,r){let i=wn(e,t,n);return i.notify=oe(r),i.state}function En(e,t,n=null){return new Promise((r,i)=>{let a=(o=!1)=>{let s=wn(e,t,n,o),{state:c}=s;c.status===`loading`?s.waiting.push(()=>a()):c.status===`ready`?r(c.diff):i(Error(c.message))};a(!0)})}function Dn(e,t){let{head:n,from:i,to:a,tail:o}=r(e,t);return U`${n}{<span class="bundle-compare-rename-from">${i}</span> → <span class="bundle-compare-rename-to">${a}</span>}${o}`}var K=(e,t)=>t&&e.startsWith(t)?e.slice(t.length):e;function On({from:e,to:t}){return U`<span class="bundle-compare-rename-from">${e}</span> → <span class="bundle-compare-rename-to">${t}</span>`}function kn(e){let t=new Map;if(!e)return t;for(let n of e.onlyBase)t.set(n.path,{kind:`removed`,basePath:n.basePath,baseBytes:n.bytes,otherBytes:null});for(let n of e.onlyOther)t.set(n.path,{kind:`added`,baseBytes:null,otherBytes:n.bytes});for(let n of e.changed){let e={...n.meta?{meta:n.meta}:{}};t.set(n.path,n.renamedFrom==null?{kind:`changed`,basePath:n.basePath,baseBytes:n.baseBytes,otherBytes:n.otherBytes,...n.modified===!1?{modified:!1}:{},...e}:{kind:`renamed`,basePath:n.basePath,renamedFrom:n.renamedFrom,modified:n.modified,baseBytes:n.baseBytes,otherBytes:n.otherBytes,...e})}return t}function q(e,t,n,{kind:r,basePath:i=n}){let a=r===`added`?``:L(e).get(i),o=r===`removed`?``:L(t).get(n);return r===`repointed`&&(a=o??=a),{before:a,after:o}}var An=new WeakMap,jn=Object.freeze([]);function Mn(e){if(!e)return jn;let t=An.get(e);return t||An.set(e,t=[...e.onlyBase,...e.onlyOther,...e.changed]),t}function Nn(e){return e.baseTarget===null?`added`:e.otherTarget===null?`removed`:`repointed`}function Pn(e,t,n,r=[]){let i=kn(n);if(!n)return i;for(let n of r){if(!i.has(n.parent)){let r=R(L(t).get(n.parent)??L(e).get(n.parent));i.set(n.parent,{kind:`repointed`,baseBytes:r,otherBytes:r})}let r=i.get(n.parent);r.repointed=[...r.repointed??[],n]}return i}function Fn(e,t,n){return[...Pn(e,t,n.files,Mn(n.resolutions))].map(([n,r])=>({path:n,...r,...q(e,t,n,r)}))}function In(e,{maxBytes:t,maxLines:n}){let r=0,i=0;for(let{before:a,after:o}of e)for(let e of[a,o])if(r+=R(e)??0,r>=t||(typeof e==`string`&&e!==``&&(i+=(e.match(/\n/gu)?.length??0)+ +!e.endsWith(`
|
|
2
2
|
`)),i>=n))return!1;return!0}var Ln=3,Rn=20,zn=4;function Bn(e,t,{ignoreWhitespace:n=!1,changes:r=null,marks:i=null}={}){let a=P(e),o=P(t),s=r?.blocks??F(e,t,n),c={a:e!==``&&!e.endsWith(`
|
|
3
3
|
`),b:t!==``&&!t.endsWith(`
|
|
4
4
|
`)};return{a,b:o,blocks:s,...Vn(s,i),noEol:c,words:new Map}}function Vn(e,t){let n=new Set((t??[]).map(({a0:e,a1:t,b0:n,b1:r})=>`${e},${t},${n},${r}`)),r=new Set,i=0,a=0,o=0;return e.forEach(({a0:e,a1:t,b0:s,b1:c},l)=>{n.has(`${e},${t},${s},${c}`)&&t-e===c-s?(r.add(l),o+=c-s):(i+=c-s,a+=t-e)}),{additions:i,deletions:a,renamed:o,marked:r}}function Hn(e,t,{runs:n,otherRuns:r}){let i=(e,t)=>{let n=[],r=P(e);for(let[e,i]of t)for(let t=e;t<Math.min(i,r.length);t++)n.push(t);let i=n.map(e=>r[e]),a=new Set(n),o=e!==``&&!e.endsWith(`
|
|
@@ -16,9 +16,9 @@ import{a as e,b as t,f as n,g as r,j as i,k as a,l as o}from"./chunk-W5PRH5D7.js
|
|
|
16
16
|
Affects files: ${e.length.toLocaleString()}`:`
|
|
17
17
|
Affects files:
|
|
18
18
|
${e.join(`
|
|
19
|
-
`)}`:``,Q=(e,t)=>U`<button type="button" class="bundle-compare-code-action" @click="${t}">${e}</button>`,Ci=(e,t,...n)=>Ut(e,U`<div class="bundle-compare-code-message"><p>${t}</p>${n.map((e,t)=>t?[` `,e]:e)}</div>`),wi=e=>z(e??0),Ti=(e,t,n)=>e===`added`?wi(n):e===`removed`?wi(t):`${wi(t)} \u2192 ${wi(n)}`,Ei=e=>typeof e?.link==`string`?e.link:void 0,Di=(e,t,n=Ei(t))=>n===void 0?`a file`:U`a symlink to <code>${n}</code>${zt(e,n)===null?`, out of the package`:``}`,Oi=({after:e,before:t})=>[e,t].find(e=>typeof e==`string`&&e!==``)??null,ki=(e,t)=>U`<span class="bundle-compare-code-counts" aria-label="${`${e} added, ${t} removed lines`}"><span class="add">+${e.toLocaleString()}</span><span class="del">−${t.toLocaleString()}</span></span>`,Ai=(e,t,n)=>e.hideable??=Jn(t,n,e.blocks),ji=(e,t)=>e.length+t.length>Nr||yi(e)+yi(t)>Mr;function Mi(e){let t=Map.groupBy(e,Nn);return t.size===1&&t.has(`repointed`)?{title:`Repointed ${e.length===1?`import`:`imports`}`,note:`${e.length} repointed ${e.length===1?`import`:`imports`}`}:{title:`Import resolutions`,note:`Import resolutions: ${[`removed`,`added`,`repointed`].filter(e=>t.has(e)).map(e=>`${t.get(e).length} ${e}`).join(`, `)}`}}var Ni=e=>e.kind===`repointed`||e.kind===`renamed`&&!e.modified&&!!e.repointed&&!e.meta,Pi=e=>Array.isArray(e)?e.some(Pi):e?.strings?e.strings.some(e=>e.trim()!==``)||e.values.some(Pi):e!=null&&e!==W&&e!==!1&&e!==``,Fi=new WeakMap;function Ii(e,t){if(Fi.has(e))return Fi.get(e);let n=new Set;for(let e of t)for(let t=e.lastIndexOf(`/`);t>0&&!n.has(e.slice(0,t));t=e.lastIndexOf(`/`,t-1))n.add(e.slice(0,t));return Fi.set(e,n),n}function Li(e){let t=L(e);return Ii(t,t.keys())}function Ri(e,t){for(let n of e.files.values())if(n===t)return!0;for(let n of e.dirs.values())if(Ri(n,t))return!0;return!1}var zi=class extends Xt{static properties={base:{attribute:!1},other:{attribute:!1},files:{attribute:!1},scope:{attribute:!1},resolutions:{attribute:!1},baseAlerts:{attribute:!1},otherAlerts:{attribute:!1},alertTags:{attribute:!1},newHosts:{attribute:!1},newHostTag:{attribute:!1},dependencies:{attribute:!1},openDependency:{attribute:!1},dependencyTags:{attribute:!1},extensions:{attribute:!1},baseName:{},otherName:{},path:{},seek:{attribute:!1},_query:{state:!0},_kinds:{state:!0},_mode:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.base=null,this.other=null,this.files=null,this.scope=``,this.resolutions=[],this._query=``,this._kinds=new Set(Ar.map(e=>e.kind)),this._mode=`files`,this._blocks=new Map,this._found=null,this._rowless=new Map,this._rowlessCount=0,this._aligned=new WeakMap,this._sought=null,this._soughtRow=null,this._open=new Map,this._models=new Map,this._modelCap=Pr,this._counted=new Map,this._countModels=new Map,this._drawnCounts=new Map,this._drawnTotals=new Map,this._spaced=new Map,this._shorter=new Map,this._larges=new Map,this._unrebuilt=new Map,this._expansions=new Map,this._limits=new Map,this._forced=new Set,this._shownPath=null}willUpdate(e){let t=`${this.base?.integrity}|${this.other?.integrity}`;if(t!==this._pair||e.has(`files`)){this._pair=t;for(let e of[this._models,this._spaced,this._shorter,this._unrebuilt,this._larges,this._expansions,this._limits,this._forced])e.clear()}if([`files`,`resolutions`,`base`,`other`].some(t=>e.has(t))){this._entries=Pn(this.base,this.other,this.files,this.resolutions??[]);for(let e of[this._counted,this._countModels,this._drawnCounts,this._drawnTotals,this._blocks,this._rowless])e.clear();this._treeLimit=this.extensions?.treePageSize??1/0,this._sought=this._soughtRow=null,this._soughtSettling=!1}if(e.has(`seek`)&&this.seek&&!Vr.has(this.seek)){Vr.add(this.seek);let{path:e,line:t,query:n}=this.seek,r=this._entries?.get(e),i=r?q(this.base,this.other,e,r).after:null,a=typeof i==`string`?P(i)[t]?.toLowerCase().indexOf(n.toLowerCase())??-1:-1;this._sought={path:e,side:`b`,line:t,at:Math.max(a,0),query:n},this._soughtRow=null,this._soughtSettling=!1}}updated(){if(this._current!==this._shownPath){this._shownPath=this._current;let e=this.querySelector(`.bundle-compare-diff`);e&&(e.scrollTop=0),this.querySelector(`.bundle-compare-code-tree .bundle-code-tree-link.current`)?.scrollIntoView({block:`nearest`})}this._scrollSought()}_scrollSought(){if(this._sought?.path===this._current&&!this._soughtSettling&&(this._sought=null),!this._soughtRow)return;let{path:e,index:t}=this._soughtRow;this._soughtRow=null;let n=[...this.querySelectorAll(`.bundle-compare-diff-table`)].find(t=>t.dataset.path===e)?.children[t];if(!n)return;let r=n.closest(`.bundle-compare-diff`);n.scrollIntoView({block:r&&n.offsetHeight>r.clientHeight/2?`start`:`center`}),n.classList.remove(`is-sought`),n.offsetWidth,n.classList.add(`is-sought`),n.addEventListener(`animationend`,()=>n.classList.remove(`is-sought`),{once:!0})}_shown(e){return this._kinds.has(e.kind)||!!e.modified&&this._kinds.has(`changed`)||!!e.repointed&&this._kinds.has(`repointed`)}_modules(){let[e,t]=[this.base,this.other].map(e=>e?.kind===`stasis`?e.bundle?.modules:null),n={root:this.files?.root,paths:this.files?.basePaths??new Map};return e||t?new Map([...[...e??[]].map(([e,t])=>[i(n,e,Object.keys(t.files??{})),t]),...t??[]]):null}_baseDirs(){let e=this.files?.root?this.files.basePaths:null;return e?Ii(e,e.values()):Li(this.base)}_format(e){let t=this._entries.get(e),n=jt(this.base,t?.basePath??e),r=jt(this.other,e);return[n,r].find(At)??(t?.kind===`removed`?n:r)}_tree(){let e=[this._entries,`${[...this._kinds].join()}:${!!this.extensions?.fullPaths}`];if(this._treeKey?.[0]===e[0]&&this._treeKey[1]===e[1])return this._treeMemo;let t=[...this._entries.keys()],n=this._modules(),r=a(this.files?.root,this.extensions?.fullPaths?``:rt(Ht(t).prefix,n,t)),{prefix:i}=r,o=t.filter(e=>this._shown(this._entries.get(e))),s=tt(o.map(e=>K(e,i)),o,n);return this._treeKey=e,this._treeMemo={prefix:i,root:r,tree:s,shown:o.length,allOrder:_t(s)},this._treeMemo}_select(e){!e||e===this._current||this.extensions?.canSelect?.()===!1||this.dispatchEvent(new CustomEvent(`compare-code-select`,{detail:{path:e},bubbles:!0,composed:!0}))}_reveal(e,t){let n=K(e,t).split(`/`);for(let e=1;e<n.length;e++)this._open.set(n.slice(0,e).join(`/`),!0)}_pathQuery(){return this._query.trim()}_railState(){let{prefix:e,root:t,tree:n,shown:r,allOrder:i}=this._tree(),a=at(n,this._mode===`files`?this._pathQuery():``,e,this.extensions?.fileFilter);return{prefix:e,root:t,tree:n,shown:r,filtered:a,order:a===n?i:a?_t(a):[],allOrder:i}}_renderRail({prefix:e,root:t,tree:n,shown:r,filtered:i,order:a},o){this._countUntil=null,this._treeRemaining=this.extensions?.treePageSize?this._treeLimit:1/0,this._treeTruncated=!1;let s=!!this._pathQuery()||r<=Ir,c=this._mode===`code`?W:i?this._renderTree(i,o,0,s,s?null:ut(i)):U`<div class="bundle-code-search-empty">No changed files match.</div>`,l=new Set([...this._entries.values()].flatMap(e=>[e.kind!==`repointed`&&e.kind,e.modified&&`changed`,e.repointed&&`repointed`])),u=Rr.find(({mode:e})=>e===this._mode),d=this._mode===`files`?this.extensions:null;return U`<aside class="bundle-code-rail"><div class="bundle-code-rail-head"><span class="bundle-code-rail-label">${this.extensions?.railLabel??`Changes`}</span> <span class="bundle-code-rail-count">${this._entries.size.toLocaleString()}</span> <span class="bundle-code-rail-actions">${this.extensions?.copyDiff?U`<button type="button" class="bundle-code-rail-action bundle-code-copy-diff" aria-label="Copy complete diff" data-tooltip="Copy complete diff" @click="${e=>{this._copyDiff(e.currentTarget)}}">${de}</button>`:W} <button type="button" class="bundle-code-rail-action" aria-label="${this.extensions?.collapseLabel??`Collapse directories`}" data-tooltip="Collapse directories" ?disabled="${this._mode!==`files`||!!this._pathQuery()&&!this.extensions?.collapseClearsSearch||n.dirs.size===0}" @click="${()=>this._collapseAll(n)}">${Se}</button></span></div>${t.from?U`<div class="bundle-code-rail-prefix mono" data-tooltip="${`Root moved: ${t.from} \u2192 ${t.to}`}">${On(t)}</div>`:e?U`<div class="bundle-code-rail-prefix mono" data-tooltip-truncated data-tooltip="${e}">${e}</div>`:W}<div class="bundle-compare-code-filter"><label class="bundle-compare-code-search"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/></svg> <input type="search" placeholder="${d?.searchPlaceholder??u.placeholder}" aria-label="${d?.searchLabel??u.placeholder}" spellcheck="false" autocomplete="off" .value="${I(this._query)}" @input="${e=>{this._query=e.target.value,this._treeLimit=this.extensions?.treePageSize??1/0}}"> <span class="bundle-code-search-modes" role="tablist">${Rr.map(({mode:e,label:t,icon:n})=>U`<button type="button" class="${B({"bundle-code-search-mode":!0,active:e===this._mode})}" role="tab" aria-selected="${String(e===this._mode)}" aria-label="${t}" data-tooltip="${t}" @click="${()=>{this._mode=e}}">${n}</button>`)}</span></label> ${this.extensions?.filters??U`<div class="bundle-compare-code-kinds" role="group" aria-label="Show changes">${Ar.filter(({kind:e})=>l.has(e)).map(({kind:e,label:t})=>U`<button type="button" class="${`bundle-compare-code-kind ${e}`}" aria-pressed="${String(this._kinds.has(e))}" data-tooltip="${`${this._kinds.has(e)?`Hide`:`Show`} ${t.toLowerCase()} files`}" @click="${()=>this._toggleKind(e)}">${t.toLowerCase()}</button>`)}</div>`}</div><div class="bundle-code-rail-body bundle-compare-code-tree">${this._mode===`code`?this._renderSearch(a,o,e):c} ${this._mode===`files`&&this._treeTruncated?Q(`Show more files`,()=>{this._treeLimit+=this.extensions.treePageSize,this.requestUpdate()}):W}</div></aside><bundle-code-splitter role="separator" tabindex="0" aria-orientation="vertical" aria-label="Resize file tree" data-tooltip="Drag to resize · double-click to reset"></bundle-code-splitter>`}async _copyDiff(e){try{await navigator.clipboard.writeText(this.extensions.copyDiff())}catch{Pe(`Could not copy the diff to the clipboard.`,{kind:`error`});return}e.classList.add(`copied`),setTimeout(()=>e.classList.remove(`copied`),1e3)}_arrived=0;_renamesAlone=!0;_repaint=()=>{this._arrived++,this.isConnected&&this.requestUpdate()};disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this._countLater),clearTimeout(this._searchLater),this._countLater=this._searchLater=null}render(){let e=this._railState(),t=this._entries.has(this.path)?this.path:e.order[0]??null;t&&t!==this._current&&this._reveal(t,e.prefix),this._current=t,this._order=this.extensions?.filterContent===!1?e.allOrder:e.order;let n=t?U`${this._renderFile(t,this.extensions?.fullPaths?``:e.prefix)}${this.extensions?.fileActions?.(t,!1)??W}`:U`<div class="bundle-code-placeholder">No files differ in this comparison.</div>`;return this._layout(e,t,n)}_layout(e,t,n){return U`<div class="bundle-code-view bundle-compare-code">${this._renderRail(e,t)}<div class="bundle-code-main">${n}</div></div>`}_toggleKind(e){let t=new Set(this._kinds);t.delete(e)||t.add(e),this._kinds=t}_collapseAll(e){this.extensions?.collapseClearsSearch&&(this._query=``),this._treeLimit=this.extensions?.treePageSize??1/0;let t=e=>{for(let n of e.dirs.values())this._open.set(n.path,!1),t(n)};t(e),this.requestUpdate()}_renderSearch(e,t,n){if(!this._query)return U`<div class="bundle-code-search-hint">Type to search the code of the changed files.</div>`;let{files:r,hits:i,truncated:a,unsigned:o}=this._searchResults(e);return r.length===0?U`<div class="bundle-code-search-empty">No matches.</div>`:U`<div class="bundle-code-search-results bundle-compare-search"><div class="bundle-code-search-summary">${i.toLocaleString()} ${i===1?`hit`:`hits`} in ${r.length.toLocaleString()} ${r.length===1?`file`:`files`}${a?`, the first ${lr}`:``}</div>${H(r,e=>e.path,({path:e,hits:r})=>U`<div class="${B({"bundle-code-search-file":!0,current:e===t})}"><button type="button" class="${`bundle-code-search-file-name bundle-compare-code-name ${this._entries.get(e).kind}`}" data-tooltip-truncated data-tooltip="${e}" @click="${()=>this._select(e)}">${K(e,n)}</button> ${o.has(e)?U`<p class="bundle-compare-search-note">${Hr[o.get(e)]}</p>`:W}<ul class="bundle-code-search-hits">${r.map(t=>U`<li class="bundle-code-search-hit"><button type="button" class="bundle-code-search-hit-link" aria-label="${`${Ur[t.sign]?.label??`Line`} ${t.line+1}${t.side===`a`?` of the old text`:``}: ${t.text.trim().slice(0,80)}`}" @click="${()=>this._seek(e,t)}"><span class="bundle-code-search-hit-ln">${t.line+1}</span> <span class="${`bundle-compare-search-sign ${Ur[t.sign]?.name??``}`}" aria-hidden="true">${t.sign??``}</span> <span class="bundle-code-search-hit-text mono">${Ct(t.text,t.ranges)}</span></button></li>`)}</ul></div>`)}</div>`}_searchResults(e){let t=Wr(),r=`${this._query}\0${this._forced.size}\0${t}\0${k.layout}\0${N.bundleSourcePretty}\0${je()}\0${this._rowlessCount}\0${e.join(`\0`)}`;if(this._found?.key===r&&this._found.entries===this._entries)return this._found.result;let i=null,a=!0,o=new Map,s={...mr(e.flatMap(e=>{let n=this._entries.get(e);if(!this._searchable(n))return[];let r=q(this.base,this.other,e,n),{before:i,after:a}=r;if(this._prettyShown(e,n,r)){if(!/\S/u.test(this._query))return[];let n=i!==``&&a!==``&&i!==a;if(n&&this._rowless.get(e)===t)return[];o.set(e,n?`printed`:`numbered`)}return[{path:e,...r}]}),bt(this._query,!1,!1),(e,t,r)=>{if(o.get(e)===`printed`)return null;let s=`${k.ignoreWhitespace}\0${e}`;if(this._blocks.has(s))return this._blocks.get(s);if(!this._forced.has(e)&&ji(t,r))return o.set(e,`large`),null;let c=performance.now();if(i??=c+Lr,c>i)return a=!1,null;let l=k.ignoreWhitespace&&!this._unlisted(e,this._entries.get(e),{before:t,after:r}),u=F(t,r,l&&`leading`);return l&&n(t,r,u)&&(u=F(t,r)),this._blocks.set(s,u),u},{split:k.layout===`split`,align:(e,t,n,r)=>{let i=this._aligned.get(n);return i||this._aligned.set(n,i={a:e,b:t,blocks:n}),or(i,n.indexOf(r))}}),unsigned:o};return a?this._found={key:r,entries:this._entries,result:s}:this._later(`_searchLater`),s}_later(e){this[e]??=setTimeout(()=>{this[e]=null,this.requestUpdate()})}_spent(){let e=performance.now();return this._countUntil??=e+Lr,e<=this._countUntil?!1:(this._later(`_countLater`),!0)}_searchable(e){return e.modified!==!1||Ni(e)}_prettyShown(e,t,n){if(!N.bundleSourcePretty)return!1;let r=this._printing(e,t,n);return!!r?.applies&&r.copies.status!==`error`}_noteRowless(e,t){let n=t?Wr():void 0;this._rowless.get(e)!==n&&(n===void 0?this._rowless.delete(e):this._rowless.set(e,n),this._rowlessCount++)}_seek(e,t){this._sought={path:e,side:t.side,line:t.line,at:t.ranges[0]?.[0]??0,query:this._query},e===this._current?this.requestUpdate():this._select(e,!1)}_soughtLine(e,t,n,r){let{side:i,line:a,at:o,query:s}=this._sought;if(n?.status!==`ready`)return{side:i,line:a};let c=e=>e.replaceAll(/\s+/gu,``),l=P(q(this.base,this.other,e,t)[i===`a`?`before`:`after`]??``),u=l.slice(0,a).reduce((e,t)=>e+c(t).length,0)+c(l[a]?.slice(0,o)??``).length,d=c(s).toLowerCase(),f=(e,t)=>{if(!d)return null;let n=0,r=0,i=0,a=``;for(let o of e)for(let e=0;e<o.length;e+=Br){a+=c(o.slice(e,e+Br)).toLowerCase();for(let e=a.indexOf(d,n);e!==-1;e=a.indexOf(d,n),r++){if(t(r,i+e))return{index:r,start:i+e};n=e+d.length}let s=Math.max(n,a.length-d.length+1);a=a.slice(s),i+=s,n=Math.max(0,n-s)}return null},p=f(l,(e,t)=>t>=u),m=(p&&f(r[i],e=>e===p.index)?.start)??u;for(let e=0;e<r[i].length;e++)if(m-=c(r[i][e]).length,m<0)return{side:i,line:e};return null}_seekRows(e,t,{side:n,line:r},i){let a=t.typeFolds,o=a?a.lineOf[n].indexOf(r):r,s=e=>e.kind===`types`?o===-1&&!!e[n]&&r>=e[n].from&&r<e[n].to:n===`b`?(e.kind===`ctx`||e.kind===`add`)&&e.b===o||e.kind===`change`&&e.right===o:(e.kind===`ctx`||e.kind===`del`)&&e.a===o||e.kind===`change`&&e.left===o,c=this._expansions.get(e)??new Map,l=er(t,c,{split:i}),u=l.findIndex(s);if(u===-1){let r=l.find(e=>e.kind===`fold`&&o>=e[n]&&o<e[n]+e.count);if(r){let a=c.get(r.run)??{},d=o-r[n];c=new Map(c).set(r.run,r.down?{...a,top:(a.top??0)+d+1+zr}:r.up?{...a,bottom:(a.bottom??0)+r.count-d+zr}:{all:!0}),this._expansions.set(e,c),l=er(t,c,{split:i}),u=l.findIndex(s)}}return this._reach(e,u),{rows:l,index:u}}_reach(e,t){return t<(this._limits.get(e)??X)?!1:(this._limits.set(e,Math.ceil((t+1)/X)*X),!0)}_takeTreeRow(e=!1){return this._treeRemaining-->0||(this._treeTruncated=!0,e)}_renderTree(e,t,n,i,a){let o=[...e.dirs.entries()].toSorted(ht),s=[...e.files.entries()].toSorted(([e],[t])=>e.localeCompare(t)),c=o.flatMap(([e,r])=>{let o=st(e,r,n),s=r.package,c=s?.ecosystem===`cargo`||s?.ecosystem===`composer`||s?.ecosystem===`soldeer`,l=this._pathQuery()?!0:this._open.get(r.path)??(i||!!a?.has(r.path)||Ri(r,t)),u=this._baseDirs().has(r.sourcePath)?Li(this.other).has(r.sourcePath)?null:`removed`:`added`;if(!this._takeTreeRow(Ri(r,t)))return[];let d=U`<li class="bundle-code-tree-dir"><details .open="${I(l)}" @toggle="${e=>{let t=e.currentTarget.open;this._open.get(r.path)!==t&&(this._open.set(r.path,t),this.extensions?.treePageSize&&this.requestUpdate())}}"><summary aria-label="${this.extensions?.directoryLabel?.(o.node)??W}"><span class="bundle-code-tree-chevron" aria-hidden="true"></span> ${s||r.dependencyRoot?Nt(s?.ecosystem??r.dependencyRoot):W} <span class="${B({"bundle-code-tree-dirname":!0,"bundle-code-tree-package":!!s,"bundle-code-tree-package-vendored":c,"bundle-compare-code-name":!0,removed:u===`removed`})}" data-tooltip-truncated data-tooltip="${o.node.sourcePath}">${s?U`<span class="bundle-code-tree-package-name">${s.name}</span>${s.version?U`<span class="bundle-code-tree-package-version">${c?`- `:`@`}${s.version}</span>`:W}`:o.names.map((e,t)=>U`${t>0?U`<span class="bundle-code-tree-separator">/</span>`:W}${e}`)} </span>${s?.variant?U`<span class="bundle-code-tree-variant">variant ${s.variant}</span>`:W} <span class="bundle-compare-code-dir-count" data-tooltip="${`${r.fileCount} changed ${r.fileCount===1?`file`:`files`}`}">${this.extensions?.directorySummary?.(o.node)??r.fileCount}</span> ${u?U`<span class="${`bundle-compare-code-letter ${u}`}" data-tooltip="${`${s?`Package`:`Directory`} ${u}`}">${jr[u].letter}</span>`:W}</summary>${l||!this.extensions?.treePageSize?this._renderTree(o.node,t,n+1,i,a):W}</details></li>`;return[{key:r.path,content:d}]}),l=s.flatMap(([e,n])=>{if(!this._takeTreeRow(n===t))return[];let i=this._entries.get(n),{kind:a,repointed:o,renamedFrom:s,modified:c}=i,l=o?Mi(o).note:``;return[{key:n,content:U`<li class="bundle-code-tree-file"><button type="button" class="${B({"bundle-code-tree-link":!0,current:n===t})}" aria-label="${this.extensions?.fileLabel?.(n)??W}" aria-current="${n===t?`true`:W}" @click="${()=>this._select(n)}">${this.extensions?.filePrefix?.(n)??W}${Mt(n,this._format(n))}<span class="${`bundle-code-tree-name bundle-compare-code-name ${a}`}" data-tooltip-truncated data-tooltip="${n}">${e}</span> ${this.extensions?.fileSuffix?.(n)??W} ${s?U`<span class="bundle-compare-code-oldname" data-tooltip-truncated data-tooltip="${`Renamed from ${s}`}">← ${r(s,n,{extension:!1}).from}</span>`:W} ${this._fileTags(n,i,!0)} ${this._treeCounts(n,i)} ${o&&a!==`repointed`?U`<span class="bundle-compare-code-letter repointed" data-tooltip="${l}">R</span>`:W} <span class="${B({"bundle-compare-code-letter":!0,[a]:!0,pure:a===`renamed`&&!c})}" data-tooltip="${a===`repointed`?l:s?`Renamed${c?` and modified`:``} from ${s}`:jr[a].label}">${jr[a].letter}</span></button></li>`}]});return U`<ul class="${B({"bundle-code-tree":!0,root:n===0})}" aria-label="${n===0?this.extensions?.treeLabel??`Changed files`:W}" @keydown="${n===0?pt:W}">${H(c,e=>e.key,e=>e.content)}${H(l,e=>e.key,e=>e.content)}</ul>`}_treeCounts(e,t){if(t.kind===`repointed`)return W;let n=this._lineCounts(e,t),r;if(n===null&&this._counted.has(e)?{published:n,shown:r}=this._largeCounts(e,t):r=n&&this._shownCounts(e,t),!(n||r)||r===void 0)return W;let{additions:i,deletions:a}=r??n,o=!n||n.additions>0||n.deletions>0,s=t.kind===`renamed`,c=r?.renamed>0?`
|
|
19
|
+
`)}`:``,Q=(e,t)=>U`<button type="button" class="bundle-compare-code-action" @click="${t}">${e}</button>`,Ci=(e,t,...n)=>Ut(e,U`<div class="bundle-compare-code-message"><p>${t}</p>${n.map((e,t)=>t?[` `,e]:e)}</div>`),wi=e=>z(e??0),Ti=(e,t,n)=>e===`added`?wi(n):e===`removed`?wi(t):`${wi(t)} \u2192 ${wi(n)}`,Ei=e=>typeof e?.link==`string`?e.link:void 0,Di=(e,t,n=Ei(t))=>n===void 0?`a file`:U`a symlink to <code>${n}</code>${zt(e,n)===null?`, out of the package`:``}`,Oi=({after:e,before:t})=>[e,t].find(e=>typeof e==`string`&&e!==``)??null,ki=(e,t)=>U`<span class="bundle-compare-code-counts" aria-label="${`${e} added, ${t} removed lines`}"><span class="add">+${e.toLocaleString()}</span><span class="del">−${t.toLocaleString()}</span></span>`,Ai=(e,t,n)=>e.hideable??=Jn(t,n,e.blocks),ji=(e,t)=>e.length+t.length>Nr||yi(e)+yi(t)>Mr;function Mi(e){let t=Map.groupBy(e,Nn);return t.size===1&&t.has(`repointed`)?{title:`Repointed ${e.length===1?`import`:`imports`}`,note:`${e.length} repointed ${e.length===1?`import`:`imports`}`}:{title:`Import resolutions`,note:`Import resolutions: ${[`removed`,`added`,`repointed`].filter(e=>t.has(e)).map(e=>`${t.get(e).length} ${e}`).join(`, `)}`}}var Ni=e=>e.kind===`repointed`||e.kind===`renamed`&&!e.modified&&!!e.repointed&&!e.meta,Pi=e=>Array.isArray(e)?e.some(Pi):e?.strings?e.strings.some(e=>e.trim()!==``)||e.values.some(Pi):e!=null&&e!==W&&e!==!1&&e!==``,Fi=new WeakMap;function Ii(e,t){if(Fi.has(e))return Fi.get(e);let n=new Set;for(let e of t)for(let t=e.lastIndexOf(`/`);t>0&&!n.has(e.slice(0,t));t=e.lastIndexOf(`/`,t-1))n.add(e.slice(0,t));return Fi.set(e,n),n}function Li(e){let t=L(e);return Ii(t,t.keys())}function Ri(e,t){for(let n of e.files.values())if(n===t)return!0;for(let n of e.dirs.values())if(Ri(n,t))return!0;return!1}var zi=class extends Xt{static properties={base:{attribute:!1},other:{attribute:!1},files:{attribute:!1},scope:{attribute:!1},resolutions:{attribute:!1},baseAlerts:{attribute:!1},otherAlerts:{attribute:!1},alertTags:{attribute:!1},newHosts:{attribute:!1},newHostTag:{attribute:!1},dependencies:{attribute:!1},openDependency:{attribute:!1},dependencyTags:{attribute:!1},extensions:{attribute:!1},baseName:{},otherName:{},path:{},seek:{attribute:!1},_query:{state:!0},_kinds:{state:!0},_mode:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.base=null,this.other=null,this.files=null,this.scope=``,this.resolutions=[],this._query=``,this._kinds=new Set(Ar.map(e=>e.kind)),this._mode=`files`,this._blocks=new Map,this._found=null,this._rowless=new Map,this._rowlessCount=0,this._aligned=new WeakMap,this._sought=null,this._soughtRow=null,this._open=new Map,this._models=new Map,this._modelCap=Pr,this._counted=new Map,this._countModels=new Map,this._drawnCounts=new Map,this._drawnTotals=new Map,this._spaced=new Map,this._shorter=new Map,this._larges=new Map,this._unrebuilt=new Map,this._expansions=new Map,this._limits=new Map,this._forced=new Set,this._shownPath=null}willUpdate(e){let t=`${this.base?.integrity}|${this.other?.integrity}`;if(t!==this._pair||e.has(`files`)){this._pair=t;for(let e of[this._models,this._spaced,this._shorter,this._unrebuilt,this._larges,this._expansions,this._limits,this._forced])e.clear()}if([`files`,`resolutions`,`base`,`other`].some(t=>e.has(t))){this._entries=Pn(this.base,this.other,this.files,this.resolutions??[]);for(let e of[this._counted,this._countModels,this._drawnCounts,this._drawnTotals,this._blocks,this._rowless])e.clear();this._treeLimit=this.extensions?.treePageSize??1/0,this._sought=this._soughtRow=null,this._soughtSettling=!1}if(e.has(`seek`)&&this.seek&&!Vr.has(this.seek)){Vr.add(this.seek);let{path:e,line:t,query:n}=this.seek,r=this._entries?.get(e),i=r?q(this.base,this.other,e,r).after:null,a=typeof i==`string`?P(i)[t]?.toLowerCase().indexOf(n.toLowerCase())??-1:-1;this._sought={path:e,side:`b`,line:t,at:Math.max(a,0),query:n},this._soughtRow=null,this._soughtSettling=!1}}updated(){if(this._current!==this._shownPath){this._shownPath=this._current;let e=this.querySelector(`.bundle-compare-diff`);e&&(e.scrollTop=0),this.querySelector(`.bundle-compare-code-tree .bundle-code-tree-link.current`)?.scrollIntoView({block:`nearest`})}this._scrollSought()}_scrollSought(){if(this._sought?.path===this._current&&!this._soughtSettling&&(this._sought=null),!this._soughtRow)return;let{path:e,index:t}=this._soughtRow;this._soughtRow=null;let n=[...this.querySelectorAll(`.bundle-compare-diff-table`)].find(t=>t.dataset.path===e)?.children[t];if(!n)return;let r=n.closest(`.bundle-compare-diff`);n.scrollIntoView({block:r&&n.offsetHeight>r.clientHeight/2?`start`:`center`}),n.classList.remove(`is-sought`),n.offsetWidth,n.classList.add(`is-sought`),n.addEventListener(`animationend`,()=>n.classList.remove(`is-sought`),{once:!0})}_shown(e){return this._kinds.has(e.kind)||!!e.modified&&this._kinds.has(`changed`)||!!e.repointed&&this._kinds.has(`repointed`)}_modules(){let[e,t]=[this.base,this.other].map(e=>e?.kind===`stasis`?e.bundle?.modules:null),n={root:this.files?.root,paths:this.files?.basePaths??new Map};return e||t?new Map([...[...e??[]].map(([e,t])=>[i(n,e,Object.keys(t.files??{})),t]),...t??[]]):null}_baseDirs(){let e=this.files?.root?this.files.basePaths:null;return e?Ii(e,e.values()):Li(this.base)}_format(e){let t=this._entries.get(e),n=Mt(this.base,t?.basePath??e),r=Mt(this.other,e);return[n,r].find(jt)??(t?.kind===`removed`?n:r)}_tree(){let e=[this._entries,`${[...this._kinds].join()}:${!!this.extensions?.fullPaths}`];if(this._treeKey?.[0]===e[0]&&this._treeKey[1]===e[1])return this._treeMemo;let t=[...this._entries.keys()],n=this._modules(),r=a(this.files?.root,this.extensions?.fullPaths?``:rt(Ht(t).prefix,n,t)),{prefix:i}=r,o=t.filter(e=>this._shown(this._entries.get(e))),s=tt(o.map(e=>K(e,i)),o,n);return this._treeKey=e,this._treeMemo={prefix:i,root:r,tree:s,shown:o.length,allOrder:_t(s)},this._treeMemo}_select(e){!e||e===this._current||this.extensions?.canSelect?.()===!1||this.dispatchEvent(new CustomEvent(`compare-code-select`,{detail:{path:e},bubbles:!0,composed:!0}))}_reveal(e,t){let n=K(e,t).split(`/`);for(let e=1;e<n.length;e++)this._open.set(n.slice(0,e).join(`/`),!0)}_pathQuery(){return this._query.trim()}_railState(){let{prefix:e,root:t,tree:n,shown:r,allOrder:i}=this._tree(),a=at(n,this._mode===`files`?this._pathQuery():``,e,this.extensions?.fileFilter);return{prefix:e,root:t,tree:n,shown:r,filtered:a,order:a===n?i:a?_t(a):[],allOrder:i}}_renderRail({prefix:e,root:t,tree:n,shown:r,filtered:i,order:a},o){this._countUntil=null,this._treeRemaining=this.extensions?.treePageSize?this._treeLimit:1/0,this._treeTruncated=!1;let s=!!this._pathQuery()||r<=Ir,c=this._mode===`code`?W:i?this._renderTree(i,o,0,s,s?null:ut(i)):U`<div class="bundle-code-search-empty">No changed files match.</div>`,l=new Set([...this._entries.values()].flatMap(e=>[e.kind!==`repointed`&&e.kind,e.modified&&`changed`,e.repointed&&`repointed`])),u=Rr.find(({mode:e})=>e===this._mode),d=this._mode===`files`?this.extensions:null;return U`<aside class="bundle-code-rail"><div class="bundle-code-rail-head"><span class="bundle-code-rail-label">${this.extensions?.railLabel??`Changes`}</span> <span class="bundle-code-rail-count">${this._entries.size.toLocaleString()}</span> <span class="bundle-code-rail-actions">${this.extensions?.copyDiff?U`<button type="button" class="bundle-code-rail-action bundle-code-copy-diff" aria-label="Copy complete diff" data-tooltip="Copy complete diff" @click="${e=>{this._copyDiff(e.currentTarget)}}">${de}</button>`:W} <button type="button" class="bundle-code-rail-action" aria-label="${this.extensions?.collapseLabel??`Collapse directories`}" data-tooltip="Collapse directories" ?disabled="${this._mode!==`files`||!!this._pathQuery()&&!this.extensions?.collapseClearsSearch||n.dirs.size===0}" @click="${()=>this._collapseAll(n)}">${Se}</button></span></div>${t.from?U`<div class="bundle-code-rail-prefix mono" data-tooltip="${`Root moved: ${t.from} \u2192 ${t.to}`}">${On(t)}</div>`:e?U`<div class="bundle-code-rail-prefix mono" data-tooltip-truncated data-tooltip="${e}">${e}</div>`:W}<div class="bundle-compare-code-filter"><label class="bundle-compare-code-search"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/></svg> <input type="search" placeholder="${d?.searchPlaceholder??u.placeholder}" aria-label="${d?.searchLabel??u.placeholder}" spellcheck="false" autocomplete="off" .value="${I(this._query)}" @input="${e=>{this._query=e.target.value,this._treeLimit=this.extensions?.treePageSize??1/0}}"> <span class="bundle-code-search-modes" role="tablist">${Rr.map(({mode:e,label:t,icon:n})=>U`<button type="button" class="${B({"bundle-code-search-mode":!0,active:e===this._mode})}" role="tab" aria-selected="${String(e===this._mode)}" aria-label="${t}" data-tooltip="${t}" @click="${()=>{this._mode=e}}">${n}</button>`)}</span></label> ${this.extensions?.filters??U`<div class="bundle-compare-code-kinds" role="group" aria-label="Show changes">${Ar.filter(({kind:e})=>l.has(e)).map(({kind:e,label:t})=>U`<button type="button" class="${`bundle-compare-code-kind ${e}`}" aria-pressed="${String(this._kinds.has(e))}" data-tooltip="${`${this._kinds.has(e)?`Hide`:`Show`} ${t.toLowerCase()} files`}" @click="${()=>this._toggleKind(e)}">${t.toLowerCase()}</button>`)}</div>`}</div><div class="bundle-code-rail-body bundle-compare-code-tree">${this._mode===`code`?this._renderSearch(a,o,e):c} ${this._mode===`files`&&this._treeTruncated?Q(`Show more files`,()=>{this._treeLimit+=this.extensions.treePageSize,this.requestUpdate()}):W}</div></aside><bundle-code-splitter role="separator" tabindex="0" aria-orientation="vertical" aria-label="Resize file tree" data-tooltip="Drag to resize · double-click to reset"></bundle-code-splitter>`}async _copyDiff(e){try{await navigator.clipboard.writeText(this.extensions.copyDiff())}catch{Pe(`Could not copy the diff to the clipboard.`,{kind:`error`});return}e.classList.add(`copied`),setTimeout(()=>e.classList.remove(`copied`),1e3)}_arrived=0;_renamesAlone=!0;_repaint=()=>{this._arrived++,this.isConnected&&this.requestUpdate()};disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this._countLater),clearTimeout(this._searchLater),this._countLater=this._searchLater=null}render(){let e=this._railState(),t=this._entries.has(this.path)?this.path:e.order[0]??null;t&&t!==this._current&&this._reveal(t,e.prefix),this._current=t,this._order=this.extensions?.filterContent===!1?e.allOrder:e.order;let n=t?U`${this._renderFile(t,this.extensions?.fullPaths?``:e.prefix)}${this.extensions?.fileActions?.(t,!1)??W}`:U`<div class="bundle-code-placeholder">No files differ in this comparison.</div>`;return this._layout(e,t,n)}_layout(e,t,n){return U`<div class="bundle-code-view bundle-compare-code">${this._renderRail(e,t)}<div class="bundle-code-main">${n}</div></div>`}_toggleKind(e){let t=new Set(this._kinds);t.delete(e)||t.add(e),this._kinds=t}_collapseAll(e){this.extensions?.collapseClearsSearch&&(this._query=``),this._treeLimit=this.extensions?.treePageSize??1/0;let t=e=>{for(let n of e.dirs.values())this._open.set(n.path,!1),t(n)};t(e),this.requestUpdate()}_renderSearch(e,t,n){if(!this._query)return U`<div class="bundle-code-search-hint">Type to search the code of the changed files.</div>`;let{files:r,hits:i,truncated:a,unsigned:o}=this._searchResults(e);return r.length===0?U`<div class="bundle-code-search-empty">No matches.</div>`:U`<div class="bundle-code-search-results bundle-compare-search"><div class="bundle-code-search-summary">${i.toLocaleString()} ${i===1?`hit`:`hits`} in ${r.length.toLocaleString()} ${r.length===1?`file`:`files`}${a?`, the first ${lr}`:``}</div>${H(r,e=>e.path,({path:e,hits:r})=>U`<div class="${B({"bundle-code-search-file":!0,current:e===t})}"><button type="button" class="${`bundle-code-search-file-name bundle-compare-code-name ${this._entries.get(e).kind}`}" data-tooltip-truncated data-tooltip="${e}" @click="${()=>this._select(e)}">${K(e,n)}</button> ${o.has(e)?U`<p class="bundle-compare-search-note">${Hr[o.get(e)]}</p>`:W}<ul class="bundle-code-search-hits">${r.map(t=>U`<li class="bundle-code-search-hit"><button type="button" class="bundle-code-search-hit-link" aria-label="${`${Ur[t.sign]?.label??`Line`} ${t.line+1}${t.side===`a`?` of the old text`:``}: ${t.text.trim().slice(0,80)}`}" @click="${()=>this._seek(e,t)}"><span class="bundle-code-search-hit-ln">${t.line+1}</span> <span class="${`bundle-compare-search-sign ${Ur[t.sign]?.name??``}`}" aria-hidden="true">${t.sign??``}</span> <span class="bundle-code-search-hit-text mono">${Ct(t.text,t.ranges)}</span></button></li>`)}</ul></div>`)}</div>`}_searchResults(e){let t=Wr(),r=`${this._query}\0${this._forced.size}\0${t}\0${k.layout}\0${N.bundleSourcePretty}\0${je()}\0${this._rowlessCount}\0${e.join(`\0`)}`;if(this._found?.key===r&&this._found.entries===this._entries)return this._found.result;let i=null,a=!0,o=new Map,s={...mr(e.flatMap(e=>{let n=this._entries.get(e);if(!this._searchable(n))return[];let r=q(this.base,this.other,e,n),{before:i,after:a}=r;if(this._prettyShown(e,n,r)){if(!/\S/u.test(this._query))return[];let n=i!==``&&a!==``&&i!==a;if(n&&this._rowless.get(e)===t)return[];o.set(e,n?`printed`:`numbered`)}return[{path:e,...r}]}),bt(this._query,!1,!1),(e,t,r)=>{if(o.get(e)===`printed`)return null;let s=`${k.ignoreWhitespace}\0${e}`;if(this._blocks.has(s))return this._blocks.get(s);if(!this._forced.has(e)&&ji(t,r))return o.set(e,`large`),null;let c=performance.now();if(i??=c+Lr,c>i)return a=!1,null;let l=k.ignoreWhitespace&&!this._unlisted(e,this._entries.get(e),{before:t,after:r}),u=F(t,r,l&&`leading`);return l&&n(t,r,u)&&(u=F(t,r)),this._blocks.set(s,u),u},{split:k.layout===`split`,align:(e,t,n,r)=>{let i=this._aligned.get(n);return i||this._aligned.set(n,i={a:e,b:t,blocks:n}),or(i,n.indexOf(r))}}),unsigned:o};return a?this._found={key:r,entries:this._entries,result:s}:this._later(`_searchLater`),s}_later(e){this[e]??=setTimeout(()=>{this[e]=null,this.requestUpdate()})}_spent(){let e=performance.now();return this._countUntil??=e+Lr,e<=this._countUntil?!1:(this._later(`_countLater`),!0)}_searchable(e){return e.modified!==!1||Ni(e)}_prettyShown(e,t,n){if(!N.bundleSourcePretty)return!1;let r=this._printing(e,t,n);return!!r?.applies&&r.copies.status!==`error`}_noteRowless(e,t){let n=t?Wr():void 0;this._rowless.get(e)!==n&&(n===void 0?this._rowless.delete(e):this._rowless.set(e,n),this._rowlessCount++)}_seek(e,t){this._sought={path:e,side:t.side,line:t.line,at:t.ranges[0]?.[0]??0,query:this._query},e===this._current?this.requestUpdate():this._select(e,!1)}_soughtLine(e,t,n,r){let{side:i,line:a,at:o,query:s}=this._sought;if(n?.status!==`ready`)return{side:i,line:a};let c=e=>e.replaceAll(/\s+/gu,``),l=P(q(this.base,this.other,e,t)[i===`a`?`before`:`after`]??``),u=l.slice(0,a).reduce((e,t)=>e+c(t).length,0)+c(l[a]?.slice(0,o)??``).length,d=c(s).toLowerCase(),f=(e,t)=>{if(!d)return null;let n=0,r=0,i=0,a=``;for(let o of e)for(let e=0;e<o.length;e+=Br){a+=c(o.slice(e,e+Br)).toLowerCase();for(let e=a.indexOf(d,n);e!==-1;e=a.indexOf(d,n),r++){if(t(r,i+e))return{index:r,start:i+e};n=e+d.length}let s=Math.max(n,a.length-d.length+1);a=a.slice(s),i+=s,n=Math.max(0,n-s)}return null},p=f(l,(e,t)=>t>=u),m=(p&&f(r[i],e=>e===p.index)?.start)??u;for(let e=0;e<r[i].length;e++)if(m-=c(r[i][e]).length,m<0)return{side:i,line:e};return null}_seekRows(e,t,{side:n,line:r},i){let a=t.typeFolds,o=a?a.lineOf[n].indexOf(r):r,s=e=>e.kind===`types`?o===-1&&!!e[n]&&r>=e[n].from&&r<e[n].to:n===`b`?(e.kind===`ctx`||e.kind===`add`)&&e.b===o||e.kind===`change`&&e.right===o:(e.kind===`ctx`||e.kind===`del`)&&e.a===o||e.kind===`change`&&e.left===o,c=this._expansions.get(e)??new Map,l=er(t,c,{split:i}),u=l.findIndex(s);if(u===-1){let r=l.find(e=>e.kind===`fold`&&o>=e[n]&&o<e[n]+e.count);if(r){let a=c.get(r.run)??{},d=o-r[n];c=new Map(c).set(r.run,r.down?{...a,top:(a.top??0)+d+1+zr}:r.up?{...a,bottom:(a.bottom??0)+r.count-d+zr}:{all:!0}),this._expansions.set(e,c),l=er(t,c,{split:i}),u=l.findIndex(s)}}return this._reach(e,u),{rows:l,index:u}}_reach(e,t){return t<(this._limits.get(e)??X)?!1:(this._limits.set(e,Math.ceil((t+1)/X)*X),!0)}_takeTreeRow(e=!1){return this._treeRemaining-->0||(this._treeTruncated=!0,e)}_renderTree(e,t,n,i,a){let o=[...e.dirs.entries()].toSorted(ht),s=[...e.files.entries()].toSorted(([e],[t])=>e.localeCompare(t)),c=o.flatMap(([e,r])=>{let o=st(e,r,n),s=r.package,c=s?.ecosystem===`cargo`||s?.ecosystem===`composer`||s?.ecosystem===`soldeer`,l=this._pathQuery()?!0:this._open.get(r.path)??(i||!!a?.has(r.path)||Ri(r,t)),u=this._baseDirs().has(r.sourcePath)?Li(this.other).has(r.sourcePath)?null:`removed`:`added`;if(!this._takeTreeRow(Ri(r,t)))return[];let d=U`<li class="bundle-code-tree-dir"><details .open="${I(l)}" @toggle="${e=>{let t=e.currentTarget.open;this._open.get(r.path)!==t&&(this._open.set(r.path,t),this.extensions?.treePageSize&&this.requestUpdate())}}"><summary aria-label="${this.extensions?.directoryLabel?.(o.node)??W}"><span class="bundle-code-tree-chevron" aria-hidden="true"></span> ${s||r.dependencyRoot?Pt(s?.ecosystem??r.dependencyRoot):W} <span class="${B({"bundle-code-tree-dirname":!0,"bundle-code-tree-package":!!s,"bundle-code-tree-package-vendored":c,"bundle-compare-code-name":!0,removed:u===`removed`})}" data-tooltip-truncated data-tooltip="${o.node.sourcePath}">${s?U`<span class="bundle-code-tree-package-name">${s.name}</span>${s.version?U`<span class="bundle-code-tree-package-version">${c?`- `:`@`}${s.version}</span>`:W}`:o.names.map((e,t)=>U`${t>0?U`<span class="bundle-code-tree-separator">/</span>`:W}${e}`)} </span>${s?.variant?U`<span class="bundle-code-tree-variant">variant ${s.variant}</span>`:W} <span class="bundle-compare-code-dir-count" data-tooltip="${`${r.fileCount} changed ${r.fileCount===1?`file`:`files`}`}">${this.extensions?.directorySummary?.(o.node)??r.fileCount}</span> ${u?U`<span class="${`bundle-compare-code-letter ${u}`}" data-tooltip="${`${s?`Package`:`Directory`} ${u}`}">${jr[u].letter}</span>`:W}</summary>${l||!this.extensions?.treePageSize?this._renderTree(o.node,t,n+1,i,a):W}</details></li>`;return[{key:r.path,content:d}]}),l=s.flatMap(([e,n])=>{if(!this._takeTreeRow(n===t))return[];let i=this._entries.get(n),{kind:a,repointed:o,renamedFrom:s,modified:c}=i,l=o?Mi(o).note:``;return[{key:n,content:U`<li class="bundle-code-tree-file"><button type="button" class="${B({"bundle-code-tree-link":!0,current:n===t})}" aria-label="${this.extensions?.fileLabel?.(n)??W}" aria-current="${n===t?`true`:W}" @click="${()=>this._select(n)}">${this.extensions?.filePrefix?.(n)??W}${Nt(n,this._format(n))}<span class="${`bundle-code-tree-name bundle-compare-code-name ${a}`}" data-tooltip-truncated data-tooltip="${n}">${e}</span> ${this.extensions?.fileSuffix?.(n)??W} ${s?U`<span class="bundle-compare-code-oldname" data-tooltip-truncated data-tooltip="${`Renamed from ${s}`}">← ${r(s,n,{extension:!1}).from}</span>`:W} ${this._fileTags(n,i,!0)} ${this._treeCounts(n,i)} ${o&&a!==`repointed`?U`<span class="bundle-compare-code-letter repointed" data-tooltip="${l}">R</span>`:W} <span class="${B({"bundle-compare-code-letter":!0,[a]:!0,pure:a===`renamed`&&!c})}" data-tooltip="${a===`repointed`?l:s?`Renamed${c?` and modified`:``} from ${s}`:jr[a].label}">${jr[a].letter}</span></button></li>`}]});return U`<ul class="${B({"bundle-code-tree":!0,root:n===0})}" aria-label="${n===0?this.extensions?.treeLabel??`Changed files`:W}" @keydown="${n===0?pt:W}">${H(c,e=>e.key,e=>e.content)}${H(l,e=>e.key,e=>e.content)}</ul>`}_treeCounts(e,t){if(t.kind===`repointed`)return W;let n=this._lineCounts(e,t),r;if(n===null&&this._counted.has(e)?{published:n,shown:r}=this._largeCounts(e,t):r=n&&this._shownCounts(e,t),!(n||r)||r===void 0)return W;let{additions:i,deletions:a}=r??n,o=!n||n.additions>0||n.deletions>0,s=t.kind===`renamed`,c=r?.renamed>0?`
|
|
20
20
|
\u2248${r.renamed.toLocaleString()} lines differing in renamed names alone, marked`:``,l=n?`
|
|
21
|
-
As published: +${n.additions.toLocaleString()} \u2212${n.deletions.toLocaleString()}`:``,u=r?`${r.aside.join(`, `)}${c}${l}`:null;if(i===0&&a===0){if((s||t.modified===!1)&&!o)return U`<span class="bundle-compare-code-line-counts unchanged" aria-label="No line changes">=</span>`;if(r&&o)return U`<span class="bundle-compare-code-line-counts unchanged" aria-label="${`No line changes with ${r.aside.join(`, `)}`}" data-tooltip="${`No line changes with ${u}`}">≈</span>`}let d=r&&(!n||i!==n.additions||a!==n.deletions);return U`<span class="bundle-compare-code-line-counts" aria-label="${`${i} added, ${a} removed lines`}" data-tooltip="${d?`With ${u}`:W}"><span class="${B({add:!0,empty:s&&i===0})}">+${i.toLocaleString()}</span> <span class="${B({del:!0,empty:t.kind===`added`||s&&a===0})}">−${a.toLocaleString()}</span></span>`}_countingState(e,t){return this._fileState(e,t,!0)}_shownCounts(e,t){if(!(N.bundleSourcePretty||k.ignoreWhitespace||k.ignoreRenames||k.ignoreTypes))return null;let n=`${Jr(e)}\0${this._arrived}\0${this._forced.size}`,r=this._drawnCounts.get(e);if(r?.settings===n)return r.counts;if(this._spent())return;let i=this._countingState(e,t),a=i.model&&Yr(i).length>0?Xr(i.model,i):null;return this._drawnCounts.set(e,{settings:n,counts:a}),a}_lineCounts(e,t){if(this._counted.has(e))return this._counted.get(e);if(this._spent())return null;let{before:n,after:r}=q(this.base,this.other,e,t),i=qn(n,r);return this._counted.set(e,i),i}_noteDrawn(e,t){return t.model&&this._drawnTotals.set(e,{settings:Jr(e),counts:Xr(t.model,t)}),t}_largeCounts(e,t){let n=this._drawnTotals.get(e);if(n?.settings===Jr(e))return n.counts.aside.length===0?{published:n.counts,shown:null}:{published:null,shown:n.counts};let r=k.ignoreTypes?q(this.base,this.other,e,t):null;return{published:null,shown:typeof r?.before==`string`&&typeof r.after==`string`&&Tr(this.base,this.other,e,t,r,this._repaint,this.scope)===!0?{additions:0,deletions:0,renamed:0,aside:[Kr]}:null}}_model(e,t,n,r={},i=k.ignoreWhitespace){return Z(this._models,e,[t,n,r.changes?.blocks??r.marks??null],()=>Bn(t,n,{...r,ignoreWhitespace:i}),this._modelCap)}_counts(e,t,n,r,i){return Z(this._countModels,e,[t,n,r.changes?.blocks??r.marks??null],()=>{let e=r.changes?.blocks??F(t,n,i);return{blocks:e,...Vn(e,r.marks)}})}_fileState(e,t,r=!1){let i=q(this.base,this.other,e,t),a=typeof i.before==`string`&&typeof i.after==`string`,o=a?Tr(this.base,this.other,e,t,i,this._repaint,this.scope):void 0,s=o===!0;if(s&&k.ignoreTypes){let t={a:[],b:[],blocks:[],additions:0,deletions:0,renamed:0,marked:new Set,noEol:{a:!1,b:!1},words:new Map};return r?{pretty:null,hiding:!1,model:t,spacesHidden:!1,typesHidden:!0}:this._noteDrawn(e,{...i,textual:a,large:!1,printing:null,pretty:null,key:null,generated:!1,renamed:!1,warned:[],hiding:!1,changes:null,model:t,whitespace:null,spacesHidden:!1,types:s,typesHidden:!0})}let c=o&&o!==!0?_i(o,i):null,l=!!c&&k.ignoreTypes,u=a&&!l&&(!r||N.bundleSourcePretty)?this._printing(e,t,i):null,d=N.bundleSourcePretty&&u?.applies?u.copies:null,{before:f,after:p}=l?c:d?.status===`ready`?d:i,m=a&&$r(e)&&$r(t.basePath??e)&&[`ready`,`loading`,`error`].includes(d?.status)&&this._generated(e,t,i),h=m&&d.status===`ready`;!r&&a&&this._sought?.path===e&&!this._forced.has(e)&&this._large(e,f,p)&&this._forced.add(e);let g=a&&!this._forced.has(e)&&this._large(e,f,p),{basePath:_=e}=t,v=t=>{let n=h&&!g?fe(this.base,_,i.before,this.other,e,i.after,!1,this._repaint,d.hashes,!r&&this._renamesAlone,this.scope):null,o=n?.status===`ready`&&k.ignoreRenames&&!(n.holds??=Ot(n.before,p,n.blocks))?ci:n,s=o?.status===`ready`,u=s&&k.ignoreRenames,v=s&&!u,y=u&&o.reason===null?ui(o):[],b=s&&o.reason===null?o.marks.length>0||k.ignoreRenames&&o.before!==f:k.ignoreRenames&&m,x=`${di(e,d?.status===`ready`,{...k,ignoreWhitespace:t,ignoreRenames:u,markRenames:v})}${l?`\0types`:``}`,S=u?o.before:f,C=u?t?{}:{changes:{blocks:o.blocks}}:v?{marks:o.marks}:{},w=a&&!g&&(!o||s||!k.ignoreRenames)?r?this._counts(x,S,p,C,t):this._model(x,S,p,C,t):null;return l&&w&&(w.typeFolds=c),{key:x,changes:o,warned:y,renamed:b,hiding:u,shown:S,model:w,ignoreWhitespace:t}},y=this._unlisted(e,t,i),b=v(k.ignoreWhitespace&&!y&&`leading`),x=!!b.ignoreWhitespace&&!!b.model&&(b.model.mixed??=n(b.shown,p,b.model.blocks));x&&(b=v(!1));let{key:S,changes:C,warned:w,renamed:ee,hiding:T,shown:E,model:D}=b;if(u?.map&&d?.status===`ready`&&D&&(Object.hasOwn(D,`listingRefusal`)||(D.listingRefusal=Ie(this.base,this.other,_,e,i,{a:D.a??P(E),b:D.b??P(p),blocks:D.blocks})),D.listingRefusal!==null))return this._unrebuilt.set(`${_}\0${e}`,{status:`error`,message:`Its listings' diff wouldn't show every change: ${D.listingRefusal}`,retry:!1}),this._fileState(e,t,r);if(r)return{pretty:d,hiding:T,model:D,spacesHidden:b.ignoreWhitespace,typesFolded:l};d?.status===`ready`&&D?this._noteRowless(e,D.blocks.length===0):D&&!l&&(this._blocks.set(`${k.ignoreWhitespace}\0${e}`,D.blocks),this._aligned.set(D.blocks,D));let te=D&&!y&&!k.ignoreWhitespace?this._whitespaceHidden(`${e}\0${d?.status===`ready`}\0${T}`,E,p):null,ne=D===null||y?null:x?`mixed`:k.ignoreWhitespace?Ai(D,E,p)?`hideable`:null:te.hides&&!te.mixed?`hideable`:null;return this._sought?.path===e&&(this._soughtSettling=d?.status===`loading`||k.ignoreRenames&&(C?.status===`loading`||C?.status===`error`)),this._noteDrawn(e,{...l?i:{before:E,after:p},textual:a,large:g,printing:u,pretty:d,key:S,generated:m,renamed:ee,warned:w,hiding:T,changes:C,model:D,whitespace:ne,spacesHidden:b.ignoreWhitespace,types:s||!!c,typesFolded:l})}_unlisted(e,{basePath:t=e},{before:n,after:r}){return!Qn(e,r,Qr(this.other,e))||!Qn(t,n,Qr(this.base,t))}_whitespaceHidden(e,t,n){return Z(this._spaced,e,[t,n],()=>$n(t,n),this._modelCap)}_generated(e,{kind:t,basePath:n=e},{before:r,after:i}){return t!==`repointed`&&ce(this.base,this.other)&&ei(this.base,n,r)&&ei(this.other,e,i)}_printing(e,t,n){let{kind:r,basePath:i=e,modified:a}=t,{before:o,after:c}=n;if(r===`repointed`||a===!1||typeof o!=`string`||typeof c!=`string`||o===c)return null;let l=[[`base`,this.base,i,o],[`other`,this.other,e,c]];if(!l.every(([e,,t,n])=>n===``||Ne(this.base,this.other,e,t,n)))return null;let u=l.every(([,,e,t])=>t===``||Et(e)),d=l.every(([,,e,t])=>t===``||s(e)),f=!u&&!d&&l.some(([,e,t,n])=>n!==``&&ei(e,t,n)),p=l.map(([e,,t,n])=>n===``?{status:`ready`,text:n}:Fe(this.base,this.other,e,t,n,this._repaint)),m=this._unrebuilt.get(`${i}\0${e}`)??p.find(e=>e.status===`error`)??p.find(e=>e.status===`loading`)??p.find(e=>e.status===`off`)??{status:`ready`,before:p[0].text,after:p[1].text,hashes:p.map(e=>e.hash)},h=!u&&!d&&!f&&o!==``&&c!==``&&m.status===`ready`&&this._smaller(e,n,m);return{copies:m,json:u,map:d,minified:f,smaller:h,applies:u||d||f||h}}_large(e,t,n){return Z(this._larges,e,[t,n],()=>ji(t,n))}_smaller(e,{before:t,after:n},r){let i=(e,t)=>F(e,t).reduce((e,{a0:t,a1:n,b0:r,b1:i})=>e+n-t+i-r,0);return Z(this._shorter,e,[t,n,r.before,r.after],()=>!ji(t,n)&&!ji(r.before,r.after)&&i(r.before,r.after)<i(t,n))}_fileMessage(e,{kind:t,modified:n,meta:r,basePath:i=e},{before:a,after:o,textual:s,large:c,model:l,pretty:u,hiding:d,warned:f=[],changes:p,whitespace:m,typesHidden:h=!1,typesFolded:g=!1}){let _=kr(r),v=e=>`${e}${_?` ${_}`:``}`,y=v(t===`renamed`?_?`Renamed, its contents the same.`:`Renamed without changes.`:`The contents are the same.`);if(s&&n===!1)return Ci(`same`,y);if(!s&&[a,o].some(e=>Ei(e)!==void 0)){let[n,r]=[t===`added`?`nothing`:Di(i,a),t===`removed`?`nothing`:Di(e,o)];return U`<div class="bundle-compare-code-message">Was ${n}; now ${r}.${_?` ${_}`:``}</div>`}if(!s){let r=[a,o].some(e=>e?.format===`digest`)&&Pt(e),i=r?`Code that isn't text`:`Binary file`;if(t===`changed`&&n===!1)return U`<div class="bundle-compare-code-message">${i}, its bytes the same · ${wi(R(o))}. ${_}</div>`;let s=r?` It is not UTF-8, or holds a NUL, so it is shown as no text, yet node runs it all the same, decoded as UTF-8.`:``;return U`<div class="bundle-compare-code-message">${i} ${t} · ${Ti(t,R(a),R(o))}. A text diff is not available.${s}${_?` ${_}`:``}</div>`}if(c)return Ci(`large`,U`This diff is large (${(yi(a)+yi(o)).toLocaleString()} lines across both sides) and may take a few seconds to compute.`,Q(`Show diff`,()=>{this._forced.add(e),this.requestUpdate()}));let b=Q(`Show renamed names`,()=>this._setRenames(!1)),x=Q(`Show type-only changes`,()=>this._setTypes(!1));if(h)return Ci(`types`,U`Only types changed in this file.${_?` ${_}`:``}`,x);if(p?.status===`loading`&&k.ignoreRenames)return U`<div class="bundle-compare-code-message" aria-busy="true">Hiding renamed names…</div>`;if(p?.status===`error`&&k.ignoreRenames)return Ci(`renames`,U`Couldn't hide renamed names: ${p.message}`,b);if(l.blocks.length>0)return null;let S=u?.status===`ready`&&u.before===u.after,C=!S&&k.ignoreWhitespace&&m===`hideable`,w=!S&&d,ee=[g&&`types`,C&&`whitespace`,w&&`renamed names`].filter(Boolean),T=S?`No actual code changes in this file.`:ee.length>0?`Only ${ee.join(` and `)} changed in this file.`:null;return Ci(`told`,T?v(T):y,f.map(e=>U`<p>${e}</p>`),S?Q(`Show as published`,()=>{Re(!1),this._viewChanged()}):W,g?x:W,C?Q(`Show whitespace changes`,()=>this._setWhitespace(!1)):W,w?b:W)}_fileName(e,t,n,r=W){let i=e=>K(e,n);return U`<span class="${B({"bundle-compare-code-pill":!0,[t.kind]:!0,pure:t.kind===`renamed`&&!t.modified})}">${jr[t.kind].label}</span> ${Mt(e,this._format(e))} <span class="bundle-code-main-path mono" data-tooltip-truncated data-tooltip="${t.renamedFrom?`${t.renamedFrom} \u2192 ${e}`:e}">${t.renamedFrom?Dn(i(t.renamedFrom),i(e)):i(e)}</span> ${r}${this._githubLink(e,t)}${this._fileTags(e,t)}`}_side(e,{kind:t,basePath:n=e}){return t===`removed`?{details:this.base,at:n,alerts:this.baseAlerts}:{details:this.other,at:e,alerts:this.otherAlerts}}_fileTags(e,t,n=!1){if(!n)return U`${this._entryTags(e,t)}${this._alertTags(e,t)}${this._runsTags(e,t)}${this._newHostTags(e,t)}${this._flagTags(e,t)}${this._readability(e,t)}${this._installTags(e,t)}${Dr(t.meta)}`;let r=[this._alertTags(e,t),this._runsTags(e,t),this._newHostTags(e,t),this._flagTags(e,t,!1),this._treeTag(e,t),this._installTags(e,t,!0),Dr(t.meta,!0)];return Pi(r)?r:this._flagTags(e,t)}_githubLink(e,t){let{details:n,at:r}=this._side(e,t),i=yt(n,r);return i?St(i):W}_alertTags(e,t){let{alerts:n,at:r}=this._side(e,t),i=n?.get(r);return i?.length>0&&this.alertTags?this.alertTags(i):W}_newHostTags(e,{kind:t}){let n=t===`removed`?null:this.newHosts?.get(e);return n&&this.newHostTag?this.newHostTag(n):W}_runsTags(e,t){return[[te,re],[ae,se]].map(([n,r])=>{let{was:i,now:a}=this._reads(e,t,n);return t.kind===`removed`?r(i):r(a,i)})}_entryTags(e,t){let{details:n,at:r}=this._side(e,t);return[...Map.groupBy(ri(n).get(r)??[],({label:e})=>e)].map(([e,t])=>U`<span class="${`bundle-compare-code-entry${e===`license`?` is-license`:``}`}" data-tooltip="${t.map(({note:e})=>e).join(` · `)}">${e}</span>`)}_installTags(e,t,n=!1){if(!ii.test(e))return W;let{kind:r,basePath:i=e}=t,{before:a,after:o}=q(this.base,this.other,e,t),s=new Map(r===`added`||a===void 0?[]:oi(this.base,i,a)),c=new Map(r===`removed`||o===void 0?[]:oi(this.other,e,o)),l=[...r===`removed`?s:c].map(([e,t])=>{let n=r===`removed`?t:s.get(e),i=n===void 0?`, new`:n===t?``:`, was: ${n}`;return U`<span class="bundle-compare-code-install" data-tooltip="${`${t}${i}`}">${e}</span>`});if(!n&&r!==`removed`)for(let[e,t]of s)c.has(e)||l.push(U`<span class="bundle-compare-code-install is-dropped" data-tooltip="${`No longer run on install: ${t}`}">${e}</span>`);return l}_reads(e,t,n=c){let{kind:r,basePath:i=e}=t,{before:a,after:o}=q(this.base,this.other,e,t);return{was:r===`added`?null:a===void 0?void 0:n(this.base,i,a),now:r===`removed`||o===void 0?null:n(this.other,e,o)}}_readability(e,t){let{was:n,now:r}=this._reads(e,t),i=e=>U`${f(e)}${m(e)}`,a=!n||!r||It(n)===It(r)&&n.kind===r.kind?i(r??n):U`<span class="bundle-compare-code-readability">${i(n)}<span aria-hidden="true">→</span>${i(r)}</span>`;return U`${_(r??n)}${a}`}_flagTags(e,t,n=!0){let{details:r,at:i}=this._side(e,t);return y(r,i,t.kind===`removed`?t.baseBytes:t.otherBytes,n)}_treeTag(e,t){let{was:n,now:r}=this._reads(e,t),i=r??n;if(!i)return W;let a=i.category!==`map`&&Lt.get(It(i)).mark;return U`${_(i,[`warn`])}${a?f(i,!0):W}`}_fileFigures({kind:e,baseBytes:t,otherBytes:n},r){return U`${r?.blocks.length>(r?.marked?.size??0)?ki(r.additions,r.deletions):W} ${r?.renamed>0?U`<span class="bundle-compare-code-renamed" aria-label="${`${r.renamed} lines differing in renamed names alone`}" data-tooltip="Lines differing in renamed names alone, marked">≈${r.renamed}</span>`:W} <span class="bundle-code-main-stats">${Ti(e,t,n)}</span>`}_highlighted(e,t,n,r=``){if(!n)return null;let i=Rt(t,Qr(e,t),n);if(!i)return null;let a=`${t}${r?`\0${r}`:``}`,o=`${e.integrity}\0${a}`,s=wt(pi,e.integrity)?.get(a);return s?.text===n?s.lines:(mi.has(o)||(mi.add(o),(async()=>{let t=await lt(n,i),r=typeof t==`string`?ft(t):null;(wt(pi,e.integrity)??pi.set(e.integrity,new Map).get(e.integrity)).set(a,{text:n,lines:r?.length===n.split(`
|
|
21
|
+
As published: +${n.additions.toLocaleString()} \u2212${n.deletions.toLocaleString()}`:``,u=r?`${r.aside.join(`, `)}${c}${l}`:null;if(i===0&&a===0){if((s||t.modified===!1)&&!o)return U`<span class="bundle-compare-code-line-counts unchanged" aria-label="No line changes">=</span>`;if(r&&o)return U`<span class="bundle-compare-code-line-counts unchanged" aria-label="${`No line changes with ${r.aside.join(`, `)}`}" data-tooltip="${`No line changes with ${u}`}">≈</span>`}let d=r&&(!n||i!==n.additions||a!==n.deletions);return U`<span class="bundle-compare-code-line-counts" aria-label="${`${i} added, ${a} removed lines`}" data-tooltip="${d?`With ${u}`:W}"><span class="${B({add:!0,empty:s&&i===0})}">+${i.toLocaleString()}</span> <span class="${B({del:!0,empty:t.kind===`added`||s&&a===0})}">−${a.toLocaleString()}</span></span>`}_countingState(e,t){return this._fileState(e,t,!0)}_shownCounts(e,t){if(!(N.bundleSourcePretty||k.ignoreWhitespace||k.ignoreRenames||k.ignoreTypes))return null;let n=`${Jr(e)}\0${this._arrived}\0${this._forced.size}`,r=this._drawnCounts.get(e);if(r?.settings===n)return r.counts;if(this._spent())return;let i=this._countingState(e,t),a=i.model&&Yr(i).length>0?Xr(i.model,i):null;return this._drawnCounts.set(e,{settings:n,counts:a}),a}_lineCounts(e,t){if(this._counted.has(e))return this._counted.get(e);if(this._spent())return null;let{before:n,after:r}=q(this.base,this.other,e,t),i=qn(n,r);return this._counted.set(e,i),i}_noteDrawn(e,t){return t.model&&this._drawnTotals.set(e,{settings:Jr(e),counts:Xr(t.model,t)}),t}_largeCounts(e,t){let n=this._drawnTotals.get(e);if(n?.settings===Jr(e))return n.counts.aside.length===0?{published:n.counts,shown:null}:{published:null,shown:n.counts};let r=k.ignoreTypes?q(this.base,this.other,e,t):null;return{published:null,shown:typeof r?.before==`string`&&typeof r.after==`string`&&Tr(this.base,this.other,e,t,r,this._repaint,this.scope)===!0?{additions:0,deletions:0,renamed:0,aside:[Kr]}:null}}_model(e,t,n,r={},i=k.ignoreWhitespace){return Z(this._models,e,[t,n,r.changes?.blocks??r.marks??null],()=>Bn(t,n,{...r,ignoreWhitespace:i}),this._modelCap)}_counts(e,t,n,r,i){return Z(this._countModels,e,[t,n,r.changes?.blocks??r.marks??null],()=>{let e=r.changes?.blocks??F(t,n,i);return{blocks:e,...Vn(e,r.marks)}})}_fileState(e,t,r=!1){let i=q(this.base,this.other,e,t),a=typeof i.before==`string`&&typeof i.after==`string`,o=a?Tr(this.base,this.other,e,t,i,this._repaint,this.scope):void 0,s=o===!0;if(s&&k.ignoreTypes){let t={a:[],b:[],blocks:[],additions:0,deletions:0,renamed:0,marked:new Set,noEol:{a:!1,b:!1},words:new Map};return r?{pretty:null,hiding:!1,model:t,spacesHidden:!1,typesHidden:!0}:this._noteDrawn(e,{...i,textual:a,large:!1,printing:null,pretty:null,key:null,generated:!1,renamed:!1,warned:[],hiding:!1,changes:null,model:t,whitespace:null,spacesHidden:!1,types:s,typesHidden:!0})}let c=o&&o!==!0?_i(o,i):null,l=!!c&&k.ignoreTypes,u=a&&!l&&(!r||N.bundleSourcePretty)?this._printing(e,t,i):null,d=N.bundleSourcePretty&&u?.applies?u.copies:null,{before:f,after:p}=l?c:d?.status===`ready`?d:i,m=a&&$r(e)&&$r(t.basePath??e)&&[`ready`,`loading`,`error`].includes(d?.status)&&this._generated(e,t,i),h=m&&d.status===`ready`;!r&&a&&this._sought?.path===e&&!this._forced.has(e)&&this._large(e,f,p)&&this._forced.add(e);let g=a&&!this._forced.has(e)&&this._large(e,f,p),{basePath:_=e}=t,v=t=>{let n=h&&!g?fe(this.base,_,i.before,this.other,e,i.after,!1,this._repaint,d.hashes,!r&&this._renamesAlone,this.scope):null,o=n?.status===`ready`&&k.ignoreRenames&&!(n.holds??=Ot(n.before,p,n.blocks))?ci:n,s=o?.status===`ready`,u=s&&k.ignoreRenames,v=s&&!u,y=u&&o.reason===null?ui(o):[],b=s&&o.reason===null?o.marks.length>0||k.ignoreRenames&&o.before!==f:k.ignoreRenames&&m,x=`${di(e,d?.status===`ready`,{...k,ignoreWhitespace:t,ignoreRenames:u,markRenames:v})}${l?`\0types`:``}`,S=u?o.before:f,C=u?t?{}:{changes:{blocks:o.blocks}}:v?{marks:o.marks}:{},w=a&&!g&&(!o||s||!k.ignoreRenames)?r?this._counts(x,S,p,C,t):this._model(x,S,p,C,t):null;return l&&w&&(w.typeFolds=c),{key:x,changes:o,warned:y,renamed:b,hiding:u,shown:S,model:w,ignoreWhitespace:t}},y=this._unlisted(e,t,i),b=v(k.ignoreWhitespace&&!y&&`leading`),x=!!b.ignoreWhitespace&&!!b.model&&(b.model.mixed??=n(b.shown,p,b.model.blocks));x&&(b=v(!1));let{key:S,changes:C,warned:w,renamed:ee,hiding:T,shown:E,model:D}=b;if(u?.map&&d?.status===`ready`&&D&&(Object.hasOwn(D,`listingRefusal`)||(D.listingRefusal=Ie(this.base,this.other,_,e,i,{a:D.a??P(E),b:D.b??P(p),blocks:D.blocks})),D.listingRefusal!==null))return this._unrebuilt.set(`${_}\0${e}`,{status:`error`,message:`Its listings' diff wouldn't show every change: ${D.listingRefusal}`,retry:!1}),this._fileState(e,t,r);if(r)return{pretty:d,hiding:T,model:D,spacesHidden:b.ignoreWhitespace,typesFolded:l};d?.status===`ready`&&D?this._noteRowless(e,D.blocks.length===0):D&&!l&&(this._blocks.set(`${k.ignoreWhitespace}\0${e}`,D.blocks),this._aligned.set(D.blocks,D));let te=D&&!y&&!k.ignoreWhitespace?this._whitespaceHidden(`${e}\0${d?.status===`ready`}\0${T}`,E,p):null,ne=D===null||y?null:x?`mixed`:k.ignoreWhitespace?Ai(D,E,p)?`hideable`:null:te.hides&&!te.mixed?`hideable`:null;return this._sought?.path===e&&(this._soughtSettling=d?.status===`loading`||k.ignoreRenames&&(C?.status===`loading`||C?.status===`error`)),this._noteDrawn(e,{...l?i:{before:E,after:p},textual:a,large:g,printing:u,pretty:d,key:S,generated:m,renamed:ee,warned:w,hiding:T,changes:C,model:D,whitespace:ne,spacesHidden:b.ignoreWhitespace,types:s||!!c,typesFolded:l})}_unlisted(e,{basePath:t=e},{before:n,after:r}){return!Qn(e,r,Qr(this.other,e))||!Qn(t,n,Qr(this.base,t))}_whitespaceHidden(e,t,n){return Z(this._spaced,e,[t,n],()=>$n(t,n),this._modelCap)}_generated(e,{kind:t,basePath:n=e},{before:r,after:i}){return t!==`repointed`&&ce(this.base,this.other)&&ei(this.base,n,r)&&ei(this.other,e,i)}_printing(e,t,n){let{kind:r,basePath:i=e,modified:a}=t,{before:o,after:c}=n;if(r===`repointed`||a===!1||typeof o!=`string`||typeof c!=`string`||o===c)return null;let l=[[`base`,this.base,i,o],[`other`,this.other,e,c]];if(!l.every(([e,,t,n])=>n===``||Ne(this.base,this.other,e,t,n)))return null;let u=l.every(([,,e,t])=>t===``||Et(e)),d=l.every(([,,e,t])=>t===``||s(e)),f=!u&&!d&&l.some(([,e,t,n])=>n!==``&&ei(e,t,n)),p=l.map(([e,,t,n])=>n===``?{status:`ready`,text:n}:Fe(this.base,this.other,e,t,n,this._repaint)),m=this._unrebuilt.get(`${i}\0${e}`)??p.find(e=>e.status===`error`)??p.find(e=>e.status===`loading`)??p.find(e=>e.status===`off`)??{status:`ready`,before:p[0].text,after:p[1].text,hashes:p.map(e=>e.hash)},h=!u&&!d&&!f&&o!==``&&c!==``&&m.status===`ready`&&this._smaller(e,n,m);return{copies:m,json:u,map:d,minified:f,smaller:h,applies:u||d||f||h}}_large(e,t,n){return Z(this._larges,e,[t,n],()=>ji(t,n))}_smaller(e,{before:t,after:n},r){let i=(e,t)=>F(e,t).reduce((e,{a0:t,a1:n,b0:r,b1:i})=>e+n-t+i-r,0);return Z(this._shorter,e,[t,n,r.before,r.after],()=>!ji(t,n)&&!ji(r.before,r.after)&&i(r.before,r.after)<i(t,n))}_fileMessage(e,{kind:t,modified:n,meta:r,basePath:i=e},{before:a,after:o,textual:s,large:c,model:l,pretty:u,hiding:d,warned:f=[],changes:p,whitespace:m,typesHidden:h=!1,typesFolded:g=!1}){let _=kr(r),v=e=>`${e}${_?` ${_}`:``}`,y=v(t===`renamed`?_?`Renamed, its contents the same.`:`Renamed without changes.`:`The contents are the same.`);if(s&&n===!1)return Ci(`same`,y);if(!s&&[a,o].some(e=>Ei(e)!==void 0)){let[n,r]=[t===`added`?`nothing`:Di(i,a),t===`removed`?`nothing`:Di(e,o)];return U`<div class="bundle-compare-code-message">Was ${n}; now ${r}.${_?` ${_}`:``}</div>`}if(!s){let r=[a,o].some(e=>e?.format===`digest`)&&It(e),i=r?`Code that isn't text`:`Binary file`;if(t===`changed`&&n===!1)return U`<div class="bundle-compare-code-message">${i}, its bytes the same · ${wi(R(o))}. ${_}</div>`;let s=r?` It is not UTF-8, or holds a NUL, so it is shown as no text, yet node runs it all the same, decoded as UTF-8.`:``;return U`<div class="bundle-compare-code-message">${i} ${t} · ${Ti(t,R(a),R(o))}. A text diff is not available.${s}${_?` ${_}`:``}</div>`}if(c)return Ci(`large`,U`This diff is large (${(yi(a)+yi(o)).toLocaleString()} lines across both sides) and may take a few seconds to compute.`,Q(`Show diff`,()=>{this._forced.add(e),this.requestUpdate()}));let b=Q(`Show renamed names`,()=>this._setRenames(!1)),x=Q(`Show type-only changes`,()=>this._setTypes(!1));if(h)return Ci(`types`,U`Only types changed in this file.${_?` ${_}`:``}`,x);if(p?.status===`loading`&&k.ignoreRenames)return U`<div class="bundle-compare-code-message" aria-busy="true">Hiding renamed names…</div>`;if(p?.status===`error`&&k.ignoreRenames)return Ci(`renames`,U`Couldn't hide renamed names: ${p.message}`,b);if(l.blocks.length>0)return null;let S=u?.status===`ready`&&u.before===u.after,C=!S&&k.ignoreWhitespace&&m===`hideable`,w=!S&&d,ee=[g&&`types`,C&&`whitespace`,w&&`renamed names`].filter(Boolean),T=S?`No actual code changes in this file.`:ee.length>0?`Only ${ee.join(` and `)} changed in this file.`:null;return Ci(`told`,T?v(T):y,f.map(e=>U`<p>${e}</p>`),S?Q(`Show as published`,()=>{Re(!1),this._viewChanged()}):W,g?x:W,C?Q(`Show whitespace changes`,()=>this._setWhitespace(!1)):W,w?b:W)}_fileName(e,t,n,r=W){let i=e=>K(e,n);return U`<span class="${B({"bundle-compare-code-pill":!0,[t.kind]:!0,pure:t.kind===`renamed`&&!t.modified})}">${jr[t.kind].label}</span> ${Nt(e,this._format(e))} <span class="bundle-code-main-path mono" data-tooltip-truncated data-tooltip="${t.renamedFrom?`${t.renamedFrom} \u2192 ${e}`:e}">${t.renamedFrom?Dn(i(t.renamedFrom),i(e)):i(e)}</span> ${r}${this._githubLink(e,t)}${this._fileTags(e,t)}`}_side(e,{kind:t,basePath:n=e}){return t===`removed`?{details:this.base,at:n,alerts:this.baseAlerts}:{details:this.other,at:e,alerts:this.otherAlerts}}_fileTags(e,t,n=!1){if(!n)return U`${this._entryTags(e,t)}${this._alertTags(e,t)}${this._runsTags(e,t)}${this._newHostTags(e,t)}${this._flagTags(e,t)}${this._readability(e,t)}${this._installTags(e,t)}${Dr(t.meta)}`;let r=[this._alertTags(e,t),this._runsTags(e,t),this._newHostTags(e,t),this._flagTags(e,t,!1),this._treeTag(e,t),this._installTags(e,t,!0),Dr(t.meta,!0)];return Pi(r)?r:this._flagTags(e,t)}_githubLink(e,t){let{details:n,at:r}=this._side(e,t),i=yt(n,r);return i?St(i):W}_alertTags(e,t){let{alerts:n,at:r}=this._side(e,t),i=n?.get(r);return i?.length>0&&this.alertTags?this.alertTags(i):W}_newHostTags(e,{kind:t}){let n=t===`removed`?null:this.newHosts?.get(e);return n&&this.newHostTag?this.newHostTag(n):W}_runsTags(e,t){return[[te,re],[ae,se]].map(([n,r])=>{let{was:i,now:a}=this._reads(e,t,n);return t.kind===`removed`?r(i):r(a,i)})}_entryTags(e,t){let{details:n,at:r}=this._side(e,t);return[...Map.groupBy(ri(n).get(r)??[],({label:e})=>e)].map(([e,t])=>U`<span class="${`bundle-compare-code-entry${e===`license`?` is-license`:``}`}" data-tooltip="${t.map(({note:e})=>e).join(` · `)}">${e}</span>`)}_installTags(e,t,n=!1){if(!ii.test(e))return W;let{kind:r,basePath:i=e}=t,{before:a,after:o}=q(this.base,this.other,e,t),s=new Map(r===`added`||a===void 0?[]:oi(this.base,i,a)),c=new Map(r===`removed`||o===void 0?[]:oi(this.other,e,o)),l=[...r===`removed`?s:c].map(([e,t])=>{let n=r===`removed`?t:s.get(e),i=n===void 0?`, new`:n===t?``:`, was: ${n}`;return U`<span class="bundle-compare-code-install" data-tooltip="${`${t}${i}`}">${e}</span>`});if(!n&&r!==`removed`)for(let[e,t]of s)c.has(e)||l.push(U`<span class="bundle-compare-code-install is-dropped" data-tooltip="${`No longer run on install: ${t}`}">${e}</span>`);return l}_reads(e,t,n=c){let{kind:r,basePath:i=e}=t,{before:a,after:o}=q(this.base,this.other,e,t);return{was:r===`added`?null:a===void 0?void 0:n(this.base,i,a),now:r===`removed`||o===void 0?null:n(this.other,e,o)}}_readability(e,t){let{was:n,now:r}=this._reads(e,t),i=e=>U`${f(e)}${m(e)}`,a=!n||!r||Lt(n)===Lt(r)&&n.kind===r.kind?i(r??n):U`<span class="bundle-compare-code-readability">${i(n)}<span aria-hidden="true">→</span>${i(r)}</span>`;return U`${_(r??n)}${a}`}_flagTags(e,t,n=!0){let{details:r,at:i}=this._side(e,t);return y(r,i,t.kind===`removed`?t.baseBytes:t.otherBytes,n)}_treeTag(e,t){let{was:n,now:r}=this._reads(e,t),i=r??n;if(!i)return W;let a=i.category!==`map`&&At.get(Lt(i)).mark;return U`${_(i,[`warn`])}${a?f(i,!0):W}`}_fileFigures({kind:e,baseBytes:t,otherBytes:n},r){return U`${r?.blocks.length>(r?.marked?.size??0)?ki(r.additions,r.deletions):W} ${r?.renamed>0?U`<span class="bundle-compare-code-renamed" aria-label="${`${r.renamed} lines differing in renamed names alone`}" data-tooltip="Lines differing in renamed names alone, marked">≈${r.renamed}</span>`:W} <span class="bundle-code-main-stats">${Ti(e,t,n)}</span>`}_highlighted(e,t,n,r=``){if(!n)return null;let i=Rt(t,Qr(e,t),n);if(!i)return null;let a=`${t}${r?`\0${r}`:``}`,o=`${e.integrity}\0${a}`,s=wt(pi,e.integrity)?.get(a);return s?.text===n?s.lines:(mi.has(o)||(mi.add(o),(async()=>{let t=await lt(n,i),r=typeof t==`string`?ft(t):null;(wt(pi,e.integrity)??pi.set(e.integrity,new Map).get(e.integrity)).set(a,{text:n,lines:r?.length===n.split(`
|
|
22
22
|
`).length?r:null}),Tt(pi,fi),mi.delete(o),this.isConnected&&this.requestUpdate()})()),null)}_renderFile(e,t){let n=this._entries.get(e),r=this._fileState(e,n),{after:i,before:a,textual:o,model:s}=r,c=Ni(n),l=o&&(!c||s?.blocks.length>0),u=this._order.indexOf(e),d=n.kind===`repointed`&&a===void 0?U`<div class="bundle-compare-code-message">Neither bundle carries this importer's source.</div>`:c&&s?.blocks.length===0?this._renderSource(e,i,n.repointed,r):this._fileMessage(e,n,r)??this._renderDiff(e,n,r);return U`<header class="bundle-code-main-bar bundle-compare-code-bar"><span class="bundle-code-file-nav"><button type="button" class="focus-code-nav-btn" aria-label="Previous file" data-tooltip="Previous file" ?disabled="${u<=0}" @click="${()=>this._select(this._order[u-1])}">${he}</button> <button type="button" class="focus-code-nav-btn" aria-label="Next file" data-tooltip="Next file" ?disabled="${u===-1?this._order.length===0:u>=this._order.length-1}" @click="${()=>this._select(this._order[u+1])}">${O}</button> </span>${this._fileName(e,n,t,U`<button type="button" class="bundle-code-copy-path" data-copy-path="${e}" aria-label="Copy file path">${de}</button>`)} <span class="bundle-code-main-spacer"></span> ${this._fileFigures(n,s)} ${this._toggles(l,bi(r),r.renamed,r.whitespace===`hideable`,r.types)}</header><div class="bundle-compare-diff" tabindex="0" aria-label="${`Changes in ${K(e,t)}`}">${this._dependencyChanges(e)} ${n.repointed?this._renderRepointed(e,n.repointed,Oi(r),o&&!l):W} ${d}</div>`}_toggles(e,t=null,n=!1,r=!1,i=!1){return U`${e?this._hides(n,r,i):W} ${t?U`<button type="button" class="${B({"bundle-compare-code-toggle":!0,"is-loading":t.status===`loading`,"is-error":t.status===`error`,"is-folded":De(t.json)})}" aria-pressed="${String(!!N.bundleSourcePretty)}" aria-busy="${t.status===`loading`?`true`:W}" aria-label="Pretty-print" data-tooltip="${`${Ce(t,t.json)}${Si(t.affects)}`}" @click="${()=>{Le(t.json),this._viewChanged()}}">${ye}</button>`:W} ${e?U`<span class="bundles-overview-sort bundle-compare-code-layout" role="group" aria-label="Diff layout">${[[`unified`,`Unified`],[`split`,`Split`]].map(([e,t])=>U`<button type="button" aria-pressed="${String(k.layout===e)}" @click="${()=>{k.layout=e,this.requestUpdate()}}">${t}</button>`)}</span>`:W}`}_importLines(e,t){let n=new Map;for(let{specifier:r}of e){if(n.has(r))continue;let e=[`'`,`"`,"`"].map(e=>`${e}${r}${e}`);n.set(r,t.flatMap((t,n)=>e.some(e=>t.includes(e))?[n]:[]))}return n}_textSide(e){return L(this.other).has(e)?this.other:this.base}_dependencyChanges(e){if(e!==`package.json`||!this.dependencies)return W;let t={added:[`new`,`New`],changed:[`updated`,`Updated`],removed:[`removed`,`Removed`]},n=Object.keys(t).flatMap(e=>this.dependencies[e].map(t=>[e,t]));if(n.length===0)return W;let r=Object.entries(t).filter(([e])=>this.dependencies[e].length>0).map(([e,[t]])=>`${this.dependencies[e].length} ${t}`),i=Map.groupBy(n.flatMap(([,e])=>e.flags??[]),({label:e})=>e),a=this.openDependency;return U`<section class="bundle-compare-code-deps" aria-label="Dependency changes"><h4>Dependencies <span>${r.join(` · `)}</span>${[...i].map(([e,t])=>U`<span class="bundle-compare-code-deps-flagged">${t.length} ${e}</span>`)}</h4><ul>${n.map(([e,n])=>{let r=U`<span class="bundle-compare-code-dep-range">${e===`changed`?U`${n.from} → <b>${n.to}</b>`:n.range}</span>`,i=U`<span class="bundle-compare-code-dep-name">${n.name}</span>${n.kind?U`<span class="npm-dependency-kind">${n.kind}</span>`:W}${r}${this.dependencyTags?.(n,e)??W}`,o=`${t[e][1]}: ${n.name}`;return U`<li>${a&&n.opens?U`<button type="button" class="${`bundle-compare-code-dep is-${e}`}" aria-label="${o}" @click="${()=>a(n)}">${i}</button>`:U`<span class="${`bundle-compare-code-dep is-${e}`}" aria-label="${o}">${i}</span>`}</li>`})}</ul></section>`}_renderRepointed(e,t,n,r){let i=n?n.split(`
|
|
23
23
|
`):[],a=n?this._highlighted(this._textSide(e),e,n):null,o=this._importLines(t,i),s=e=>e===null?U`<code class="is-none">(none)</code>`:U`<code data-tooltip-truncated data-tooltip="${e||`(empty target)`}">${e||`(empty target)`}</code>`,{title:c}=Mi(t);return U`<section class="bundle-compare-code-repointed" aria-label="${c}"><h4>${c} <b>${t.length}</b></h4><ul>${t.map(e=>{let t=o.get(e.specifier),n=`${e.conditions}${e.platform===null?``:` \xB7 Platform: ${e.platform}`}`;return U`<li><div class="bundle-compare-code-repointed-spec"><code data-tooltip-truncated data-tooltip="${e.specifier}">${e.specifier}</code> <span data-tooltip-truncated data-tooltip="${n}">${n}</span></div><div class="bundle-compare-code-repointed-targets"><span class="before"><span>Before</span>${s(e.baseTarget)}</span> <span aria-hidden="true">→</span> <span class="after"><span>After</span>${s(e.otherTarget)}</span></div>${t.slice(0,Fr).map(t=>this._importLine(t,i[t],a?.[t],e.specifier,r))} ${t.length>Fr?U`<span class="bundle-compare-code-repointed-more">and ${t.length-Fr} more ${t.length-Fr===1?`line`:`lines`}</span>`:W}</li>`})}</ul></section>`}_importLine(e,t,n,r,i){let a=t.length>240?Math.max(0,t.indexOf(r)-80):0;return U`<button type="button" class="bundle-compare-code-repointed-line bundle-compare-diff-table" ?disabled="${!i}" aria-label="${`Go to line ${e+1}`}" @click="${()=>this._goToLine(e+1)}"><span class="diff-num">${e+1}</span> <code>${t.length<=240&&typeof n==`string`?Gt(gt(n,!0)):$e(`${a>0?`…`:``}${t.slice(a,a+240)}${t.length>a+240?`…`:``}`,!0)}</code></button>`}_goToLine(e){this._reach(`${this._current}\0source`,e-1)&&this.requestUpdate(),this.updateComplete.then(()=>this.querySelector(`.bundle-compare-diff [data-line="${e}"]`)?.scrollIntoView({block:`center`}))}_renderSource(e,t,n,{key:r,pretty:i}){let a=this._model(r,t,t),o={model:a,b:this._highlighted(this._textSide(e),e,t,i?.status===`ready`?`pretty`:``)},s=new Set([...this._importLines(n,a.b).values()].flat()),c=`${e}\0source`,l=this._sought?.path===e&&this._sought.key!==r?this._soughtLine(e,this._entries.get(e),i,a):null;this._sought?.path===e&&(this._sought.key=r),l&&l.line<a.b.length&&(this._reach(c,l.line),this._soughtRow={path:e,index:l.line});let u=this._limits.get(c)??X,d=a.b.length>u?a.b.slice(0,u):a.b;return U`<div class="bundle-compare-diff-table single" data-path="${e}" style="${V({"--diff-num-width":`${String(a.b.length).length+1}ch`})}" role="table" aria-label="Source">${H(d,(e,t)=>t,(e,t)=>U`<div class="${B({"diff-row":!0,ctx:!0,"is-import":s.has(t)})}" role="row" data-line="${t+1}"><span class="diff-num">${t+1}</span>${this._codeCell(o,`b`,t,null)}</div>`)}</div>${this._moreRows(c,u,d.length,a.b.length,`lines`)}`}_moreRows(e,t,n,r,i){return r>n?U`<div class="bundle-compare-code-more">${Q(`Show ${Math.min(X,r-n).toLocaleString()} more ${i}`,()=>{this._limits.set(e,t+X),this.requestUpdate()})} <span>${(r-n).toLocaleString()} not shown</span></div>`:W}_hides(e,t,n){let r=[e&&[`Renames`,Gr,k.ignoreRenames,()=>this._setRenames(!k.ignoreRenames)],t&&[`Whitespace`,qr,k.ignoreWhitespace,()=>this._setWhitespace(!k.ignoreWhitespace)],n&&[`Type-only`,Kr,k.ignoreTypes,()=>this._setTypes(!k.ignoreTypes)]].filter(Boolean);return r.length===0?W:U`<span class="bundle-compare-code-hide" role="group" aria-label="Hide"><span class="bundle-compare-code-hide-label" aria-hidden="true">Hide:</span>${r.map(([e,t,n,r])=>U`<mode-switch compact="compact" borderless .checked="${n}" accessible-label="${t}" label="${e}" @click="${r}"></mode-switch>`)}</span>`}_setWhitespace(e){k.ignoreWhitespace=e,this._viewChanged()}_setTypes(e){k.ignoreTypes=e,this._viewChanged()}_setRenames(e){k.ignoreRenames=e,e&&ge(),this._viewChanged()}_viewChanged(){this.requestUpdate(),this.dispatchEvent(new CustomEvent(`compare-view-change`,{bubbles:!0,composed:!0}))}_renderDiff(e,t,{after:n,before:r,key:i,model:a,pretty:o,changes:s,hiding:c,warned:l=[],whitespace:u=null}){let{kind:d,basePath:f=e}=t,p=k.layout===`split`,m=this._sought?.path===e&&this._sought.key!==i?this._soughtLine(e,t,o,a):null;this._sought?.path===e&&(this._sought.key=i);let h=a.typeFolds,g=m?this._seekRows(i,a,m,p):null;g?.index>=0&&(this._soughtRow={path:e,index:g.index+ +!!p});let _=this._expansions.get(i)??new Map,v=g?.rows??er(a,_,{split:p}),y=this._limits.get(i)??X,b=v.length>y?v.slice(0,y):v,x=(e,t)=>e&&h?h.lineOf[t].map(t=>e[t]):e,S={model:a,a:d===`added`?null:x(this._highlighted(this.base,f,r,c?`renamed\0${this.other.integrity}\0${e}`:o?.status===`ready`?`pretty`:``),`a`),b:d===`removed`?null:x(this._highlighted(this.other,e,n,o?.status===`ready`?`pretty`:``),`b`),expand:(e,t)=>{let n=new Map(_);n.set(e,t===`all`?{all:!0}:{...n.get(e),[t]:(n.get(e)?.[t]??0)+Rn}),this._expansions.set(i,n),this.requestUpdate()}},C=h?.lines??{a:a.a.length,b:a.b.length},w=String(Math.max(C.a,C.b,1)).length;return U`${k.ignoreRenames&&s?.reason?U`<p class="bundle-compare-code-note">Renamed names are shown: ${si[s.reason]??s.reason}.</p>`:W} ${u===`mixed`?U`<p class="bundle-compare-code-note">${Zr}</p>`:W} ${l.length>0?U`<p class="bundle-compare-code-note">${l.join(` `)} <button type="button" @click="${()=>this._setRenames(!1)}">Show them marked</button></p>`:W}<div class="${B({"bundle-compare-diff-table":!0,split:p,unified:!p})}" data-path="${e}" style="${V({"--diff-num-width":`${w+1}ch`})}" role="table" aria-label="Diff">${p?U`<div class="diff-row diff-split-head" role="row"><span class="diff-half">Before<strong data-tooltip-truncated data-tooltip="${this.baseName}">${this.baseName}</strong></span> <span class="diff-half">After<strong data-tooltip-truncated data-tooltip="${this.otherName}">${this.otherName}</strong></span></div>`:W} ${H(b,e=>this._rowKey(e),e=>this._row(e,S,p))}</div>${this._moreRows(i,y,b.length,v.length,`rows`)}`}_rowKey(e){return e.kind===`fold`?`f${e.run}:${e.a}`:e.kind===`types`?`t${e.a?.from??``}:${e.b?.from??``}`:e.kind===`change`?`c${e.left??``}:${e.right??``}`:`${e.kind}${e.a??``}:${e.b??``}`}_words(e,t,n){if(t==null||n==null)return null;let r=`${t}:${n}`;return e.words.has(r)||e.words.set(r,ir(e.a[t],e.b[n])),e.words.get(r)}_code(e,t,n,r){let i=r&&!(e.endsWith(`\r`)&&n?.at(-1)?.[1]===e.length);if(typeof t==`string`)return Gt(gt(sr(t,n),i));if(n){let t=cr(e,n);return t.map((e,n)=>{let r=$e(e.text,i&&n===t.length-1);return e.marked?U`<mark class="diff-word">${r}</mark>`:r})}return $e(e,i)}_cell(e,t,n,r,i){return n==null?U`<span class="diff-num"></span><span class="diff-sign"></span><span class="diff-code diff-empty"></span>`:U`<span class="diff-num">${vi(e.model,t,n)}</span><span class="diff-sign">${r}</span>${this._codeCell(e,t,n,i)}`}_types({a:e,b:t}){let{from:n,to:r}=t??e;return U`<div class="diff-row diff-types" role="row"><span>Only types here · ${r-n===1?`line ${n+1}`:`lines ${n+1}\u2013${r}`}${t?``:` before`}</span> ${Q(`Show type-only changes`,()=>this._setTypes(!1))}</div>`}_fold(e,t){let n=`Show ${Rn} more lines`,r=e.count>Rn,i=(n,r,i,a)=>U`<button type="button" aria-label="${r}" data-tooltip="${i}" @click="${()=>t.expand(e.run,n)}"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${a}"></path></svg></button>`;return U`<div class="diff-row diff-fold" role="row"><span class="diff-fold-actions">${r&&e.down?i(`top`,`${n} below`,n,`M8 3v9m-4-4 4 4 4-4`):W} ${r&&e.up?i(`bottom`,`${n} above`,n,`M8 13V4M4 8l4-4 4 4`):W} <button type="button" aria-label="${`Show all ${e.count} unchanged lines`}" data-tooltip="Show all" @click="${()=>t.expand(e.run,`all`)}"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 6 4-4 4 4M4 10l4 4 4-4"></path></svg></button> </span><span class="diff-fold-label">${e.count.toLocaleString()} unchanged ${e.count===1?`line`:`lines`} · ${e.b+1}–${e.b+e.count}</span></div>`}_row(e,t,n){let{model:r}=t;if(e.kind===`fold`)return this._fold(e,t);if(e.kind===`types`)return this._types(e);if(e.kind===`ctx`)return n?U`<div class="diff-row ctx" role="row"><span class="diff-half">${this._cell(t,`a`,e.a,` `,null)}</span> <span class="diff-half">${this._cell(t,`b`,e.b,` `,null)}</span></div>`:U`<div class="diff-row ctx" role="row"><span class="diff-num">${vi(r,`a`,e.a)}</span>${this._cell(t,`b`,e.b,` `,null)}</div>`;let i=r.marked?.has(e.change),a;if(n){let n=e.paired?this._words(r,e.left,e.right):null;a=U`<span class="${B({"diff-half":!0,del:e.left!==null,blank:e.left===null})}">${this._cell(t,`a`,e.left,`−`,n?.a)}</span> <span class="${B({"diff-half":!0,add:e.right!==null,blank:e.right===null})}">${this._cell(t,`b`,e.right,`+`,n?.b)}</span>`}else{let n=e.kind===`del`,[i,o]=n?[`a`,e.a]:[`b`,e.b],s=vi(r,i,o),c=n?this._words(r,e.a,e.pair)?.a:this._words(r,e.pair,e.b)?.b;a=U`<span class="diff-num">${n?s:W}</span><span class="diff-num">${n?W:s}</span><span class="diff-sign">${n?`−`:`+`}</span>${this._codeCell(t,i,o,c)}`}return U`<div class="${`diff-row ${e.kind}${i?` renamed`:``}`}" role="row" data-tooltip="${i?`Renamed names alone`:W}">${a}</div>`}_codeCell(e,t,n,r){let i=e.model[t],a=e[t]?.[n],o=i[n],s=e.model.noEol[t]&&n===i.length-1,c=hi.get(i);c||hi.set(i,c=new Map);let l=c.get(n);return l&&l.markup===a&&l.ranges===r&&l.noEol===s||c.set(n,l={markup:a,ranges:r,noEol:s,drawn:this._code(o,a,r,!s)}),U`<span class="${B({"diff-code":!0,"diff-long":o.length>Ze})}">${l.drawn}${s?U`<span class="diff-no-eol" data-tooltip="No newline at end of file" aria-label="No newline at end of file">⊘</span>`:W}</span>`}};customElements.define(`bundle-compare-code`,zi);var Bi=25e3,Vi=40;function Hi(e,t,n,{resolutions:r=[],max:i=Bi}={}){let a=new Map,o=kn(n);if(o.size*2>=i)return{rows:1/0,models:a};let s=new Set(r.map(e=>e.parent).filter(e=>!o.has(e))),c=r.length*2+s.size;for(let[n,r]of[...o].toSorted(([e],[t])=>e.localeCompare(t))){c++;let{before:o,after:s}=q(e,t,n,r);if(r.modified===!1)c++;else if(typeof o==`string`&&typeof s==`string`){if(ji(o,s))return{rows:1/0,models:a};let e=Bn(o,s);a.set(n,e),c+=Math.max(er(e).length,1)}else c++;if(c>=i)break}return{rows:c,models:a}}var Ui=class extends zi{static properties={...zi.properties,models:{attribute:!1}};constructor(){super(),this.models=null,this._modelCap=1/0,this._fileLimit=Vi}_renamesAlone=!1;willUpdate(e){if(super.willUpdate(e),e.has(`models`))for(let[e,t]of this.models??[]){let n=this._entries.get(e);if(!n)continue;let{before:r,after:i}=q(this.base,this.other,e,n);this._models.set(di(e,!1,{ignoreWhitespace:!1,ignoreRenames:!1}),{inputs:[r,i,null],value:t})}e.has(`files`)&&(this._fileLimit=Vi,this._current=this._picked=null),(e.has(`path`)||e.has(`files`))&&this.path&&this.path!==this._current&&(this._goTo=this.path),e.has(`files`)&&(this._toTop=!0)}updated(){let e=this._goTo&&this._section(this._goTo);if(e)this._picked=this._goTo,e.scrollIntoView({block:`start`});else if(this._toTop){let e=this.querySelector(`.bundle-compare-diff`);e&&(e.scrollTop=0)}this._goTo=null,this._toTop=!1,this._current!==this._shownPath&&(this._shownPath=this._current,this.querySelector(`.bundle-compare-code-tree .bundle-code-tree-link.current`)?.scrollIntoView({block:`nearest`})),this._scrollSought()}_select(e,t=!0){!e||this.extensions?.canSelect?.()===!1||(this._current=this._picked=e,this.requestUpdate(),t&&this.updateComplete.then(()=>this._section(e)?.scrollIntoView({block:`start`})),this.dispatchEvent(new CustomEvent(`compare-code-select`,{detail:{path:e},bubbles:!0,composed:!0})))}_more(){this._fileLimit+=Vi,this.requestUpdate()}_searchable(e){return e.modified!==!1&&e.kind!==`repointed`}_countingState(e,t){return this._states?.get(e)??super._countingState(e,t)}_section(e){return[...this.querySelectorAll(`.bundle-compare-all-file`)].find(t=>t.dataset.path===e)??null}_spy(){this._spying||this.extensions?.canSelect?.()===!1||(this._spying=requestAnimationFrame(()=>{this._spying=0;let e=this.querySelector(`.bundle-compare-diff`);if(!e||this.extensions?.canSelect?.()===!1)return;this._fileLimit<this._order.length&&e.scrollTop+2*e.clientHeight>=e.scrollHeight&&this._more();let{top:t,bottom:n}=e.getBoundingClientRect(),r=this._picked&&this._section(this._picked)?.getBoundingClientRect();if(r&&r.bottom>t&&r.top<n)return;this._picked=null;let i=null;for(let n of e.querySelectorAll(`:scope > .bundle-compare-all-file`)){if(n.getBoundingClientRect().top>t+4)break;i=n}let a=i?.dataset.path??this._order[0]??null;a!==this._current&&(this._current=a,this.requestUpdate(),this.dispatchEvent(new CustomEvent(`compare-code-select`,{detail:{path:a},bubbles:!0,composed:!0})))}))}_fileBody(e,t,n){let r=t.repointed?this._renderRepointed(e,t.repointed,Oi(n),!1):W,i=t.kind===`repointed`||t.kind===`renamed`&&!t.modified&&!!t.repointed&&!t.meta&&!(n.model?.blocks.length>0);return U`${this._dependencyChanges(e)}${r}${i?W:this._fileMessage(e,t,n)??this._renderDiff(e,t,n)}`}_fileContent(e,t,n,r){return U`<header class="bundle-code-main-bar bundle-compare-all-file-head">${this._fileName(e,t,r)} <span class="bundle-code-main-spacer"></span> ${this._fileFigures(t,n.model)}</header>${this._fileBody(e,t,n)}`}render(){let e=this._railState(),t=this.extensions?.fullPaths?``:e.prefix,n=this.extensions?.filterContent===!1?e.allOrder:e.order;this._order=n,this._goTo&&n.includes(this._goTo)&&(this._current=this._goTo),n.includes(this._current)||(this._current=n[0]??null),this._current&&(this._goTo||this._current!==this._shownPath)&&this._reveal(this._current,e.prefix);let r=n.indexOf(this._current);r>=this._fileLimit&&(this._fileLimit=Math.ceil((r+1)/Vi)*Vi);let i=n.map(e=>[e,this._entries.get(e)]),a=i.map(([e,t])=>({path:e,entry:t,file:this._fileState(e,t)})),o=a.reduce((e,{file:t})=>e+(t.model?.additions??0),0),s=a.reduce((e,{file:t})=>e+(t.model?.deletions??0),0);this._states=new Map(a.map(({path:e,file:t})=>[e,t]));let c=a.filter(({file:e})=>bi(e)),l=c.map(({file:e})=>bi(e)),u=l.filter(e=>e.status===`error`),d=u.length>0?{...u[0],failed:u.length,of:l.length}:l.find(e=>e.status===`loading`)??l[0]??null,f=d&&{...d,json:l.some(e=>e.json),affects:c.map(({path:e})=>e)},p=a.some(({file:e})=>e.model?.blocks.length>0||e.whitespace||e.hiding||e.types);return this._layout(e,this._current,U`<header class="bundle-code-main-bar bundle-compare-code-bar"><span class="bundle-compare-all-title">${i.length.toLocaleString()} ${i.length===1?`file`:`files`} changed</span> ${o+s>0?ki(o,s):W} <span class="bundle-code-main-spacer"></span> ${this._toggles(p,f,a.some(({file:e})=>e.renamed),a.some(({file:e})=>e.whitespace===`hideable`),a.some(({file:e})=>e.types))}</header><div class="bundle-compare-diff" tabindex="0" aria-label="Every change" @scroll="${()=>this._spy()}">${i.length===0?U`<div class="bundle-code-placeholder">${this._entries.size===0?`No files differ in this comparison.`:`No changed files match.`}</div>`:H(a.slice(0,this._fileLimit),({path:e})=>e,({path:e,entry:n,file:r})=>U`<section class="bundle-compare-all-file" aria-label="${e}" data-path="${e}">${this.extensions?.fileActions?U`<div class="bundle-compare-file-content">${this._fileContent(e,n,r,t)}</div>${this.extensions.fileActions(e,!0)}`:this._fileContent(e,n,r,t)}</section>`)} ${a.length>this._fileLimit?U`<button type="button" class="bundle-compare-code-action bundle-compare-all-more" @click="${()=>this._more()}">Show more files (${(a.length-this._fileLimit).toLocaleString()} remaining)</button>`:W}</div>`)}};customElements.define(`bundle-compare-all`,Ui);function Wi({base:e,other:t,diff:n,source:r,path:i,seek:a,baseName:o,otherName:s,select:c,extensions:l=null,mode:u,viewChanged:d=null}){let f=Mn(n.resolutions),p=u?null:n.combined??=Hi(e,t,n.files,{resolutions:f});u??=p.rows<Bi?`diff`:`code`;let m=u===`diff`?ke`bundle-compare-all`:ke`bundle-compare-code`;return Me`<${m} .base=${e} .other=${t} .files=${n.files} .scope=${n.scope??``} .resolutions=${f}
|
|
24
24
|
.baseAlerts=${r?.files?.alerts?.(e)??null} .otherAlerts=${r?.files?.alerts?.(t)??null} .alertTags=${r?.files?.alertTags??null}
|
|
@@ -28,4 +28,4 @@ As published: +${n.additions.toLocaleString()} \u2212${n.deletions.toLocaleStrin
|
|
|
28
28
|
@compare-code-select=${e=>{e.stopPropagation(),c(e.detail.path)}}
|
|
29
29
|
@compare-view-change=${e=>{e.stopPropagation(),d?.()}}></${m}>`}var Gi=400,Ki=24,qi=[`removed`,`added`,`changed`],Ji=null,Yi=(e,t,n,r,i=null)=>U`<span class="bundle-compare-ver" aria-label="${e}"><span class="bundle-compare-ver-from">${t}</span> <span class="bundle-compare-ver-arrow" aria-hidden="true">→</span> <span class="${`bundle-compare-ver-to ${r}`}">${n}</span>${i?[` `,U`<span class="${`bundle-compare-ver-dir ${r}`}" aria-hidden="true">${i}</span>`]:W}</span>`,Xi=class extends Xt{static properties={details:{attribute:!1},integrity:{attribute:!1},request:{attribute:!1},source:{attribute:!1},_targetIntegrity:{state:!0},_otherDetails:{state:!0},_status:{state:!0},_scope:{state:!0},_fileSort:{state:!0},_pkgSort:{state:!0},_openSections:{state:!0},_mode:{state:!0},_codePath:{state:!0},_codeSeek:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.details=null,this.integrity=null,this.request=null,this.source=null,this._targetIntegrity=null,this._otherDetails=null,this._status=`idle`,this._scope=``,this._fileSort={removed:`name`,added:`name`,changed:`name`},this._pkgSort={removed:`size`,added:`size`,changed:`size`},this._openSections=new Set,this._mode=`overview`,this._codePath=null,this._codeSeek=null,this._repaint=()=>this.requestUpdate(),this._fitBody=null,this._fitObserver=null}connectedCallback(){super.connectedCallback(),this._fitBody&&this._fitObserver?.observe(this._fitBody)}disconnectedCallback(){super.disconnectedCallback(),this._fitObserver?.disconnect()}willUpdate(e){e.has(`source`)&&this.source&&!e.get(`source`)&&(this._openSections=new Set([...this._openSections,`files`])),(e.has(`_otherDetails`)||e.has(`details`))&&this._status===`ready`&&!o(this._otherDetails,this.details).some(e=>e.id===this._scope)&&(this._scope=``),e.has(`integrity`)&&this._rebase(),(e.has(`request`)||e.has(`integrity`))&&this.integrity&&this.request?.bundle===this.integrity?(this.request.target!==this._targetIntegrity&&this._choose(this.request.target),this._mode=qt(this.request.mode)):e.has(`request`)&&!e.has(`integrity`)&&e.get(`request`)?.bundle===this.integrity&&(this._targetIntegrity&&this._choose(null),this._mode=`overview`)}updated(){let e=this.querySelector(`.bundle-compare-body`);e!==this._fitBody&&typeof ResizeObserver==`function`&&(this._fitObserver??=new ResizeObserver(()=>this._fitLists()),this._fitObserver.disconnect(),e&&this._fitObserver.observe(e),this._fitBody=e),this._fitLists()}_fitLists(){let e=this._fitBody;if(!e)return;let t=getComputedStyle(e),n=e.getBoundingClientRect().top+e.clientTop+parseFloat(t.paddingTop)-e.scrollTop,r=e=>{let t=e.getBoundingClientRect();return t.top-n+e.parentElement.getBoundingClientRect().bottom-t.bottom},i=e.querySelector(`.bundle-compare-rows--fill`);if(i){let t=r(i),n=i.closest(`.bundle-compare-section`);for(let e=n;e;e=e.nextElementSibling){let r=e.matches(`details[open]`)&&e.querySelector(`:scope > summary`),i=e===n?0:r?r.getBoundingClientRect().bottom+parseFloat(getComputedStyle(r).marginBottom)-e.getBoundingClientRect().top:e.getBoundingClientRect().height;t+=i+parseFloat(getComputedStyle(e).marginBottom)}e.style.setProperty(`--compare-fill-around`,`${t}px`)}let a=[...e.querySelectorAll(`.bundle-compare-rows--scroll:not(.bundle-compare-rows--fill)`)];if(a.length===0)return;let o=e.lastElementChild,s=new Map(a.filter(e=>o.contains(e)).map(e=>[e,e.parentElement.getBoundingClientRect().top])),c=Math.max(...s.values()),l=e.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom),u=parseFloat(getComputedStyle(o).marginBottom);for(let e of a)s.get(e)>=c-1?e.style.setProperty(`--compare-rest`,`${l-r(e)-u}px`):e.style.removeProperty(`--compare-rest`)}_rebase(){let e=this._baseKey,t=e&&Ji?.base===e?Ji:null;e&&(Ji=null),t&&(this._mode=t.mode),this._scope=t?t.scope:``,this._codePath=t?t.codePath:null;let n=t?.target||null;this._targetIntegrity=n;let r=n&&!this.source?g(n,e=>!!(e.json||e.bundle)):null;this._otherDetails=r,this._status=r?`ready`:n?`loading`:`idle`,n&&!r&&this._loadOther(n)}get _baseKey(){return this.source?this.source.base:this.integrity}_swap(){let e=this._targetIntegrity;e&&e!==this._baseKey&&this._reopen(e,this._baseKey)}_pickBase(e){!e||e===this._baseKey||(e===this._targetIntegrity?this._swap():this._reopen(e,this._targetIntegrity))}_reopen(e,t){if(!this.source&&!ze(N.bundles??[],this.integrity).some(t=>t.integrity===e))return;if(Ji={base:e,target:t,scope:this._scope,mode:this._mode,codePath:this._codePath},this.source){this.source.open(e,t,this._mode);return}let n=[this._otherDetails,this._baseReady?this.details:null].filter(n=>n&&!n.error&&(n.json||n.bundle)&&[e,t].includes(n.integrity));this.dispatchEvent(new CustomEvent(`bundle-swap`,{bubbles:!0,composed:!0,detail:{integrity:e,target:t,bundles:n,mode:this._mode}}))}_nameFor(e){return this.source?this.source.name(e):(N.bundles??[]).find(t=>t.integrity===e)?.name??`${e.slice(0,15)}\u2026`}_pick(e){this._choose(e),this._notify()}_notify(){this.dispatchEvent(new CustomEvent(`bundle-compare-change`,{bubbles:!0,composed:!0,detail:{base:this.integrity,target:this._targetIntegrity,mode:this._mode}}))}_choose(e){let t=e||null;this._targetIntegrity=t,this._otherDetails=null,this._codePath=null,t?(this._status=`loading`,this._loadOther(t)):(this._status=`idle`,this._scope=``)}async _loadOther(e){let t=this.source?null:ze(N.bundles??[],this.integrity).find(t=>t.integrity===e);if(!this.source&&!t){this._status=`idle`,this._targetIntegrity=null,this._notify();return}let n;try{n=await(this.source?this.source.load(e):v(e,t))}catch(e){if(e.name===`AbortError`)return;if(!this.source)throw e;n={error:e.message}}this._targetIntegrity===e&&(this._otherDetails=n,this._status=`ready`,this.source&&n?.compareId&&n.compareId!==e&&(this._targetIntegrity=n.compareId,this._notify()))}get _baseReady(){return!!(this.details&&this.details.integrity===this.integrity&&(this.details.json||this.details.bundle))}_openFile(e){this._codePath=e,this._mode=`code`,this._notify()}_openLine({path:e,line:t,query:n}){this._codeSeek={path:e,line:t-1,query:n},this._openFile(e)}_group(e,t,n,r,i,a=W,{fill:o=!1,lanes:s=qi,style:c={}}={}){return t.length===0?W:U`<section class="${`bundle-compare-group bundle-compare-${n}`}" style="${V({"--compare-lane":String(s.indexOf(n)+1),...c})}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title" data-tooltip-truncated data-tooltip="${e}">${e}</span> <span class="bundle-compare-group-count">${t.length}</span> ${a}</header><ul class="${o?`bundle-compare-rows bundle-compare-rows--scroll bundle-compare-rows--fill`:`bundle-compare-rows bundle-compare-rows--scroll`}">${H(t,r,i)}</ul></section>`}_sizeCells(e){let t=e=>e==null?`—`:z(e),n=e=>`${e.toLocaleString()} LoC`;return e.delta===void 0?U`<span class="bundle-compare-row-size" data-tooltip="${e.lines>0?n(e.lines):W}">${t(e.bytes)}</span>`:U`<span class="${`bundle-compare-row-delta ${e.delta===null?``:tn(e.delta)}`}" data-tooltip="${`${t(e.baseBytes)} \u2192 ${t(e.otherBytes)}${e.baseLines>0||e.otherLines>0?` \xB7 ${e.baseLines.toLocaleString()} \u2192 ${n(e.otherLines)}`:``}`}">${e.delta===null?`—`:en(e.delta)}</span>`}_sortActions(e,t,n,r=!1,i=this[e][t]){return U`<span class="bundles-overview-sort" role="group" aria-label="${`${t} ${n} order`}">${[[`name`,`Name`],[`size`,`Size`],...r?[[`flags`,`Flags`]]:[]].map(([n,r])=>U`<button type="button" aria-pressed="${String(i===n)}" @click="${()=>{this[e]={...this[e],[t]:n}}}">${r}</button>`)}</span>`}_fileGroup(e,t,n,r,i){let a=this.source?.files,o=n!==`removed`,s=e=>n===`added`?null:{details:this._otherDetails,path:e.basePath??e.path},c=e=>[...o&&a?.flags?a.flags(this.details,e.path,s(e)):[],...Or(e.meta)],l=t.some(e=>c(e).length>0),u=this._fileSort[n]===`flags`&&!l?`name`:this._fileSort[n],d=e=>n===`changed`?Math.abs(e.delta):e.bytes,f=u===`flags`?we(t,c,e=>e.path):t.toSorted((e,t)=>(u===`size`?d(t)-d(e):0)||e.path.localeCompare(t.path));return this._group(e,f,n,e=>e.path,e=>U`<li><button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>this._openFile(e.path)}">${a?a.icon(e.path,[[this._otherDetails,e.basePath??e.path],[this.details,e.path]]):W}<span class="bundle-compare-row-path mono" data-tooltip-truncated data-tooltip="${e.renamedFrom==null?e.path:`${e.renamedFrom} \u2192 ${e.path}`}">${e.renamedFrom==null?r(e.path):Dn(r(e.renamedFrom),r(e.path))}</span>${o?a?.tag?.(this.details,e.path,s(e))??W:W}${Dr(e.meta)}${this._sizeCells(e)}</button></li>`,this._sortActions(`_fileSort`,n,`file`,l,u),{lanes:i})}_pkgGroup(e,t,n,r){let i=this._pkgSort[n],a=e=>{let t=n===`changed`?e.delta:e.bytes;return t==null?-1:Math.abs(t)},o=t.toSorted((e,t)=>(i===`size`?a(t)-a(e):0)||Wt(e.pkg).localeCompare(Wt(t.pkg))),s=n===`changed`?0:Math.min(Ki,Math.max(0,...t.map(e=>e.versions.join(`, `).length)));return this._group(e,o,n,e=>e.pkg,e=>U`<li><div class="bundle-compare-row"><span class="bundle-compare-pkg-dot" style="${V({background:Vt(e.pkg)})}"></span> <span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${Wt(e.pkg)}">${Wt(e.pkg)}</span> ${n===`changed`?this._versionCell(e):s>0?U`<span class="bundle-compare-dep-ver" data-tooltip-truncated data-tooltip="${e.versions.join(`, `)}">${e.versions.join(`, `)}</span>`:W} ${this._sizeCells(n===`changed`?e:{bytes:e.bytes})}</div></li>`,this._sortActions(`_pkgSort`,n,`package`),{fill:!0,lanes:r,style:s>0?{"--compare-version-width":`${s}ch`}:{}})}_versionCell(e){let t=e.otherVersions.join(`, `),n=e.baseVersions.join(`, `);if(e.baseVersions.join()===e.otherVersions.join())return e.baseVersions.length>0?U`<span class="bundle-compare-dep-ver">${n}</span>`:W;let r=e.direction??`changed`,[i,a]=r===`up`?[`↑`,`Upgraded`]:r===`down`?[`↓`,`Downgraded`]:[`±`,`Changed`];return Yi(`${a}: ${n||`none`} to ${t||`none`}`,n||`—`,t||`—`,r,i)}_depGroup(e,t,n,r){let i=n===`changed`?0:Math.min(Ki,Math.max(0,...t.map(e=>e.range.length))),a=e=>U`<span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span> ${this.source?.dependencyTags?.(e,n)??W}${e.kind?U`<span class="npm-dependency-kind">${e.kind}</span>`:W} ${n===`changed`?Yi(`Changed: ${e.from} to ${e.to}`,e.from,e.to,`changed`):U`<span class="bundle-compare-dep-ver" data-tooltip-truncated data-tooltip="${e.range}">${e.range}</span>`}`,o=this.source?.openDependency;return this._group(e,t,n,e=>e.key,e=>U`<li>${o&&e.opens?U`<button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>o(e)}">${a(e)}</button>`:U`<div class="bundle-compare-row">${a(e)}</div>`}</li>`,W,{fill:!0,lanes:r,style:i>0?{"--compare-version-width":`${i}ch`}:{}})}_renderDependencies(e,t,n,r){return r.length===0?W:U`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Dependencies</h3>${this._cols(r,(...e)=>this._depGroup(...e),e,t,n,`dependencies`)}</section>`}_renderPackages(e,t,n,r=qi){return e.removed.length===0&&e.added.length===0&&e.changed.length===0?W:U`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Packages</h3>${this._cols(r,(...e)=>this._pkgGroup(...e),e,t,n,`packages`)}</section>`}_cols(e,t,n,r,i,a){let o=e.map(e=>e===`changed`?`minmax(0, 5fr)`:`minmax(0, 4fr)`).join(` `);return U`<div class="bundle-compare-cols" data-lanes="${e.length}" data-section="${a}" style="${V({"--compare-lanes":o})}">${t(`Removed \xB7 only in ${r}`,n.removed,`removed`,e)} ${t(`Added \xB7 only in ${i}`,n.added,`added`,e)} ${t(`Changed`,n.changed,`changed`,e)}</div>`}_collapsible(e,t,n,r,i=``){let a=this._openSections.has(e);return U`<details class="bundle-compare-section bundle-compare-collapsible" .open="${I(a)}" @toggle="${t=>this._setSection(e,t.currentTarget.open)}"><summary class="bundle-compare-section-head" @click="${t=>{t.preventDefault(),this._setSection(e,!a)}}">${t} <span class="bundle-compare-section-count">${n.toLocaleString()}</span>${i?U`<span class="bundle-compare-section-note" data-tooltip-truncated data-tooltip="${i}">${i}</span>`:W}</summary>${a?r():W}</details>`}_setSection(e,t){if(t===this._openSections.has(e))return;let n=new Set(this._openSections);t?n.add(e):n.delete(e),this._openSections=n}_renderResolutions(e,t,n){if(e.totalChanges===0)return W;let r=[{title:`Removed \xB7 only in ${t}`,rows:e.onlyBase,kind:`removed`},{title:`Added \xB7 only in ${n}`,rows:e.onlyOther,kind:`added`},{title:`Repointed`,rows:e.changed,kind:`changed`}].filter(({rows:e})=>e.length>0).map(e=>({...e,shown:e.rows.slice(0,Gi)})),i=(e,t=``)=>U`<td class="${t}"><code data-tooltip-truncated data-tooltip="${e}">${e}</code></td>`,a=(e,t)=>e===null?U`<td class="bundle-compare-resolution-none"><span>(none)</span></td>`:i(e||`(empty target)`,t),o=e=>`${e.conditions}${e.platform===null?``:` \xB7 Platform: ${e.platform}`}`,s=r.some(({shown:e})=>e.some(e=>o(e)!==`*`));return this._collapsible(`resolutions`,`Import resolutions`,e.totalChanges,()=>r.map(({title:e,rows:t,kind:n,shown:r})=>U`<section class="${`bundle-compare-group bundle-compare-${n} bundle-compare-resolutions`}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title">${e}</span> <span class="bundle-compare-group-count">${t.length}</span></header><table class="${s?``:`bundle-compare-resolutions--no-context`}"><thead><tr><th>File</th><th>Import</th><th>Before</th><th>After</th>${s?U`<th>Conditions</th>`:W}</tr></thead><tbody>${H(r,e=>e.key,e=>{let t=o(e);return U`<tr><td><button type="button" class="bundle-compare-resolution-parent" data-tooltip-truncated data-tooltip="${e.parent}" @click="${()=>this._openFile(e.parent)}">${e.parent}</button></td>${i(e.specifier)} ${a(e.baseTarget,`bundle-compare-resolution-before`)} ${a(e.otherTarget,`bundle-compare-resolution-after`)} ${s?U`<td class="bundle-compare-resolution-context"><span data-tooltip-truncated data-tooltip="${t}">${t}</span></td>`:W}</tr>`})}</tbody></table>${t.length>r.length?U`<div class="bundle-compare-more">and ${(t.length-r.length).toLocaleString()} more…</div>`:W}</section>`))}_comparison(){return Tn(this._otherDetails,this.details,this._scope,this._repaint)}_renderSummary(e){return un(e,U`<div class="bundle-compare-modes" role="tablist" aria-label="Comparison view">${[[`overview`,`Overview`],[`code`,`Code`]].map(([e,t])=>U`<button type="button" role="tab" aria-selected="${String(this._mode===e)}" @click="${()=>{this._mode=e,this._notify()}}">${t}</button>`)}</div>`)}_renderPicker(e,t,n,r){return ln({source:this.source,from:{options:e,value:this._targetIntegrity,pick:e=>this._pick(e)},to:{options:this._baseOptions(),value:this._baseKey,placeholder:this._nameFor(this.integrity),pick:e=>this._pickBase(e)},clear:t?{run:()=>this._pick(null)}:null,swap:t?()=>this._swap():null,extras:n,comparison:r,openLine:e=>this._openLine(e)})}_baseOptions(){if(this.source)return G(this.source.choices??[]);let e=(N.bundles??[]).find(e=>e.integrity===this.integrity),t=ze(N.bundles??[],this.integrity);return this._bundleOptions(e?[e,...t]:t)}_otherOptions(){return this.source?G(this.source.options):this._bundleOptions(ze(N.bundles??[],this.integrity))}_bundleOptions(e){let t=Map.groupBy(e,e=>e.name);return e.map(e=>({id:e.integrity,integrity:e.integrity,kind:e.kind??(e.name.toLowerCase().endsWith(`.map`)?`sourcemap`:`stasis`),summary:e.summary,size:typeof e.size==`number`?z(e.size):`—`,filename:t.get(e.name).length>1?`${e.name} \xB7 ${e.integrity.slice(7,13)}\u2026`:e.name}))}render(){let e=this._otherOptions(),t=!!this._targetIntegrity&&(!!this.source||e.some(e=>e.integrity===this._targetIntegrity)),n=this._baseReady?o(t?this._otherDetails:null,this.details):[],r=n.length>0?U`<bundle-scope-selector .reasons="${n}" .value="${this._scope}" label="Compare scope" @scope-change="${e=>{this._scope=e.detail.value}}"></bundle-scope-selector>`:W,i=t&&this._status===`ready`&&this._otherDetails&&(this._otherDetails.json||this._otherDetails.bundle)&&!this._otherDetails.error,a=this._baseReady&&i?this._comparison():null,s=a?.status===`ready`?a.diff:null,c=s?{base:this._otherDetails,other:this.details,files:s.files}:null,l=e.length>0||this.source?this._renderPicker(e,t,r,c):r,u=s?this._mode:`overview`;return U`<div class="bundle-compare">${dn(l,s?this._renderSummary(s):W)} ${u===`code`?Wi({base:this._otherDetails,other:this.details,diff:s,source:this.source,path:this._codePath,seek:this._codeSeek,baseName:this._nameFor(this._targetIntegrity),otherName:this._nameFor(this.integrity),select:e=>{this._codePath=e}}):U`<div class="bundle-compare-body">${s?this._renderDiff(s):this._empty(e,t,a)}</div>`}</div>`}_empty(e,t,n){let r=U`<strong>${this._nameFor(this.integrity)}</strong>`,i=this.source?.noun??`bundle`,a=(e,t=!1)=>U`<div class="${t?`bundle-compare-empty is-error`:`bundle-compare-empty`}">${e}</div>`;return this._baseReady?this.source&&!t&&(this.source.pending||this.source.error||!this.source.select&&e.length===0)?a(this.source.pending?`Loading ${i}s\u2026`:this.source.error??U`No other ${i}s to compare ${r} with.`,!!this.source.error):e.length===0&&!this.source?a(U`No other bundles to compare with. Drop a second <code>.map</code>, <code>.stasis.code.br</code> or <code>.stasis.tgz</code> bundle to diff against this one.`):t?this._status===`loading`||!this._otherDetails?a(`Comparing…`):this._otherDetails.error?a(`Couldn't read the selected ${i}: ${this._otherDetails.error}`,!0):!this._otherDetails.json&&!this._otherDetails.bundle?a(`The selected ${i} couldn't be parsed.`,!0):n?.status===`error`?a(`Couldn't compare the ${i}s: ${n.message}`,!0):a(`Comparing…`):a(U`Pick a ${i} above to compare ${r} against.`):a(`Loading bundle…`)}_renderDiff(e){let t=this._nameFor(this._targetIntegrity),n=this._nameFor(this.integrity),r={removed:e.files.onlyBase,added:e.files.onlyOther,changed:e.files.changed},i=[...r.removed,...r.added,...r.changed].flatMap(e=>e.renamedFrom==null?[e.path]:[e.path,e.renamedFrom]),o=a(e.files.root,Ht(i).prefix),{prefix:s}=o,c=e=>K(e,s),l=r.removed.length+r.added.length+r.changed.length,u=!e.totals.identical,d=this.source?.dependencies?.(this._otherDetails,this.details)??null,f=qi.filter(t=>(d??e.packageRows)[t].length>0),p=u?qi.filter(e=>r[e].length>0):[],m=p.every(e=>f.includes(e))?f:p,h=u?this.source?.files?.warning?.(this.details,[...r.added,...r.changed].map(e=>e.path)):W;return U`${d?this._renderDependencies(d,t,n,f):this._renderPackages(e.packageRows,t,n,f)} ${h??W} ${e.totals.identical?e.resolutions.totalChanges>0?U`<div class="bundle-compare-caption">File contents are unchanged; import resolutions differ.</div>`:U`<div class="bundle-compare-identical">These two ${this.source?.noun??`bundle`}s carry identical files (${e.totals.unchangedFiles.toLocaleString()} ${e.totals.unchangedFiles===1?`file`:`files`})${o.from?U`, moved <span class="mono">${On(o)}</span>`:``}.</div>`:this._collapsible(`files`,`Files`,l,()=>this._cols(m,(e,t,n,r)=>this._fileGroup(e,t,n,c,r),r,t,n,`files`),o.from?`${o.from} \u2192 ${o.to}`:s)} ${this._renderResolutions(e.resolutions,t,n)}`}};customElements.define(`bundle-compare`,Xi);var Zi=/\p{Cc}/u,Qi=(e,t)=>t===null?`/dev/null`:`${e}/${t}${t.includes(` `)?` `:``}`;function $i({path:e,kind:t,basePath:n=e,modified:r,before:i,after:a}){let o={from:null,to:e,before:``,after:a},s={from:n,to:null,before:i,after:``};return t===`added`?[o]:t===`removed`?[s]:n===e?t===`repointed`||r===!1||i===a?[]:[{from:e,to:e,before:i,after:a}]:[s,o]}var ea=e=>typeof e==`string`&&!mt(e),ta=e=>e===null||!Zi.test(e)&&!mt(e);function na(e){let t=e.flatMap($i);return t.every(({from:e,to:t,before:n,after:r})=>ta(e)&&ta(t)&&ea(n)&&ea(r))?t:null}function ra(e){return e.map(({from:e,to:t,before:n,after:r})=>`--- ${Qi(`a`,e)}
|
|
30
30
|
+++ ${Qi(`b`,t)}
|
|
31
|
-
${kt(n,r)}`).join(``)}var $=e=>e._blocked||e._loading,ia=e=>e._shownReview?.publishedAt!=null,aa=e=>e._error?U`<p class="npm-review-error" role="alert">${e._error}</p>`:W,oa=e=>e._saveBlocked?U`<div class="npm-review-saving" role="status">Saving changes…</div>`:W,sa=e=>[e._continuation?.review,...e._reviews].filter(Boolean).toSorted((e,t)=>+(e.publishedAt!==null)-(t.publishedAt!==null)||(t.publishedAt??t.time)-(e.publishedAt??e.time)),ca=e=>`npm-review-button npm-review-primary npm-review-finalize ${e._allowedVerdicts[0]}`,la=(e,t,n,r,i=Object.keys(Be),a=!1)=>U`<div class="npm-review-verdict-options" role="group" aria-label="Verdict">${Object.entries(a?{"":`Not checked`,...Be}:Be).map(([a,o])=>U`<label class="${`npm-review-verdict-choice ${a||`unchecked`}`}"><input type="radio" name="${e}" aria-label="${o}" value="${a}" .checked="${I(t===a)}" ?disabled="${r||a!==``&&!i.includes(a)}" @change="${()=>n(a)}">${o}</label>`)}</div>`;function ua(e){let t=ia(e),n=e._shownReview,r=e._summary,i=e._canEdit?{label:`Finalize review`,run:()=>e._beginPublish(),disabled:!r.checkedFiles}:!t||!e._writable?null:e._activeReview||e._ownPublished.length===0?{label:`Resume your review`,run:()=>e._resume()}:n.user===e.session?.id?{label:`Revise review`,run:()=>e._change({action:`continue`,reviewId:n.id,revision:n.revision})}:null,a=t&&n.revokedAt===null&&n.user===e.session?.id?U`<dependency-review-copy .text="${n.formatted}"></dependency-review-copy>`:W;return U`<div class="npm-review-summary-actions">${t||e._draftStarted?U`<span class="npm-review-status">${a}${qe(n??{publishedAt:null,revokedAt:null})}</span>`:W}<div class="npm-review-progress-block"><span>${e._unsaved&&(e._saveBlocked||e._error)?U`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>e._openPanel(`unsaved`)}">Unsaved changes</button>`:U`<strong>${r.checkedFiles} of ${r.totalFiles}</strong> files checked`}</span> ${et(r.checkedFiles,r.totalFiles)}</div>${i?U`<button type="button" class="${e._canEdit?ca(e):`npm-review-button`}" ?disabled="${$(e)||i.disabled}" @click="${i.run}">${i.label} ${O}</button>`:W}</div>`}var da=(e,t)=>e.some(e=>e.id===t)?e:[...e,...G([{id:t,name:t,format:`npm`}])];function fa(e,t,n,r,i){if(!r)return null;let a=e.findIndex(e=>e.id===t),o=`patch:${r.slice(0,5)}`;return e.splice(a,1,{...e[a],detail:o,detailNote:i},{...e[a],id:`${t} unpatched`}),{name:n,detail:o,detailNote:i}}function pa(e){let t=e.source??Oe(e.entry),{name:n,version:r}=e.entry.npm,i=!!(e._target&&e._target!==`(empty)`),a=G(t.options,e=>`${n}@${e.id}`),o=i?da(a,e._target):a,s=da(G(t.choices),r),c=`${e._target} unpatched`,l=`${r} unpatched`,u=fa(s,r,`${n}@${r}`,e._patch?.hash,ha(ma(e))),d=fa(o,e._target,e._target,i&&e._basePatch,ha(e._base?.npmPatch?.patch));return dn(ln({source:u||d?{...t,widest:u||d}:t,label:`Review`,disabled:$(e),from:{options:o,value:i?e._target:null,label:`Review base`,pick:t=>{e._navigate(t===c?e._target:t,t===e._target?e._basePatch:null)}},to:{options:s,value:r,label:`Version to review`,pick:t=>{e._navigateTo({view:`npm`,packageName:n,packageSpec:t===l?r:t,bundleTab:`review`,...e._location(e._target,t===r)})}},clear:i?{label:`Clear review base`,run:()=>{e._navigate(`(empty)`)}}:null,openLine:t=>e._openLine(t),comparison:e._base?{base:e._base,other:e._other,files:e._diff.files}:null}),e._base?un(e._diff):W)}var ma=e=>e._patched?.npmPatch?.patch??e._patch,ha=e=>`As pnpm\u2019s patch${e?.path?` ${e.path}`:``} changes it`,ga=e=>e._patch?U`<span class="npm-review-patched" data-tooltip="${`${ha(ma(e))}${ma(e).commit?`, read at ${ma(e).commit.slice(0,7)}`:``}`}">patch:${e._patch.hash}</span>`:W;function _a(e){return U`<div class="npm-review-toolbar"><nav class="npm-review-toolbar-group" aria-label="Review breadcrumbs"><button type="button" class="npm-review-button npm-review-text-button" ?disabled="${$(e)}" @click="${()=>{e._navigateTo({view:`reviews`})}}">My reviews</button> ${O}<button type="button" class="npm-review-button npm-review-text-button npm-review-package" aria-haspopup="dialog" ?disabled="${e._blocked}" @click="${()=>e._openPanel(`reviews`)}"><span>${e.entry.npm.name}@${e.entry.npm.version}</span><span class="npm-review-count">${sa(e).length}</span></button> ${ga(e)}</nav>${ua(e)}</div>`}function va(e,t=e._file,n=!1){let r=e._editorState(t),i=e._shownReview?.entries.find(e=>e.file===t),a=e._nonTextFiles.includes(t),o=!a&&[`accept-with-nits`,`request-changes`,`reject`].includes(r.status);return U`<section class="${`npm-review-decision${n?` npm-review-inline-decision`:``}`}" aria-label="File decision">${e._canEdit?U`${la(`file:${t}`,a?``:r.status,n=>{e._setFileStatus(t,n)},$(e)||a,void 0,!0)} ${a?U`<p class="npm-review-help">Non-text file. Verdicts are not supported yet; this file remains unchecked.</p>`:W} ${o?U`<textarea aria-label="File note" rows="2" maxlength="20000" placeholder="Add a note (optional)…" .value="${I(r.comment)}" ?disabled="${$(e)}" @input="${n=>e._editFile(t,{comment:n.target.value})}" @blur="${()=>{e._saveFile(t)}}"></textarea>`:W}`:U`${n?W:U`<header><strong>File review</strong><span class="npm-review-muted">${ia(e)?`Frozen`:`Read only`}</span></header>`} ${i?.status&&!a?U`${Ge(i.status)}${A(i.comment)}`:U`<p class="npm-review-muted">This file was not reviewed.</p>`} ${e._reviewer||e._loading?W:U`<p class="npm-review-help">${e._writable?`Reviewing needs a team that reviews dependencies, where you manage or have Dependencies.`:`Triage access is required to add a review.`}</p>`}`}</section>`}function ya(e,t,n,r,i,a){return U`<fieldset class="npm-review-team-options"><legend>${t}</legend>${n.map(t=>U`<mode-switch label="${t.name}" .checked="${r.has(t.id)}" .disabled="${$(e)}" @click="${()=>{if($(e))return;let n=new Set(r);n.delete(t.id)||n.add(t.id),i(n)}}"></mode-switch>`)}${a}</fieldset>`}function ba(e,t){let n=e._allowedVerdicts,r=pe(t.entries,e._files,e._nonTextFiles),i=t.entries.filter(t=>t.status&&t.comment.trim()&&!e._nonTextFiles.includes(t.file));return U`<form class="npm-review-publish-form" @submit="${t=>{t.preventDefault(),e._publish()}}"><div class="npm-review-dialog-body"><section class="npm-review-coverage"><div><strong>${r.coverage===`full`?`Full`:`Partial`} review</strong><span>${r.checkedFiles} of ${r.totalFiles} files checked</span></div>${et(r.checkedFiles,r.totalFiles)}<p>${r.totalFiles>r.checkedFiles?U`${r.totalFiles-r.checkedFiles} files not checked. <button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e._unchecked=!0,e._closePanel()}}">View files</button>`:`Every file has a verdict.`}</p>${e._needsPackageJson?U`<p class="npm-review-error">Review ${e._files.includes(`package.json`)?U`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e._closePanel(),e._selectFile(`package.json`)}}">package.json</button>`:`package.json`} before publishing a partial review.</p>`:W}</section>${i.length>0?U`<section aria-label="File notes"><strong>File notes</strong><ul class="npm-review-publish-notes" tabindex="0" aria-label="Saved file notes">${i.map(e=>U`<li>${it(e.file)} ${A(e.comment)}</li>`)}</ul></section>`:W}<div><strong>Final verdict</strong>${la(`final-verdict`,e._finalStatus,t=>{e._finalStatus=t},$(e),n)}</div>${e._securityLimit===`reject`?U`<p class="npm-review-help">Malware detected. Only Reject is available.</p>`:e._securityLimit===`request-changes`?U`<p class="npm-review-help">Critical vulnerabilities detected.</p>`:W} <label>Final note <span class="npm-review-muted">· optional</span><textarea aria-label="Final comment" rows="3" maxlength="20000" .value="${I(e._finalComment)}" placeholder="Summarize your findings or explain what remains…" ?disabled="${$(e)}" @input="${t=>{e._finalComment=t.target.value}}"></textarea></label> ${e._unchangedContinuation?U`<p class="npm-review-help">Change a verdict or note to publish a new review.</p>`:W} ${ya(e,`Publish to teams`,e._teams,e._selectedTeams,t=>{e._selectedTeams=t},e._selectedTeams.size>0?W:U`<p class="npm-review-error">${e._teams.length===0?`No teams you belong to have dependency review enabled.`:`Select at least one team to publish.`}</p>`)} ${aa(e)}</div><footer class="npm-review-dialog-footer"><p>Publishing freezes your verdicts and notes.<br>You can continue in a new review to make changes.</p><button type="submit" class="${ca(e)}" ?disabled="${$(e)||!e._canPublish}">Publish to ${e._selectedTeams.size} ${e._selectedTeams.size===1?`team`:`teams`} ${O}</button></footer></form>`}function xa(e,t){let n=t===e._shownReview,r=t.publishedAt!==null,i=r?t:j(t,e._context)?pe(t.entries,e._files,e._nonTextFiles):{checkedFiles:t.entries.filter(e=>e.status).length,totalFiles:null},a=[e._continuation?.review,...e._reviews].some(n=>n?.publishedAt===null&&n.user===e.session?.id&&j(n,t)),o=t.user===e.session?.id,s=e._teams.filter(e=>!t.teams.some(t=>t.id===e.id)),c=e._additionalTeams.get(t.id)??new Set(s.length===1?s.map(e=>e.id):[]),l=s.filter(e=>c.has(e.id)).map(e=>e.id);return U`<section class="npm-review-entry" aria-current="${String(n)}"><div class="npm-review-history-heading"><strong>${Ye(t)}</strong>${n?U`<span class="npm-review-current">Current</span>`:W}${qe(t)}</div><p class="npm-review-help">${t.basePackage?`${t.basePackage===t.package?t.baseVersion:`${t.basePackage}@${t.baseVersion}`} \u2192 ${t.version}`:`All package files`}</p><div class="npm-review-entry-result">${r?Ge(t.status):W}<span class="dependency-review-coverage"> ${r?U`${nt(i)} · `:W}${i.checkedFiles}${i.totalFiles===null?W:`/${i.totalFiles}`} files checked</span></div><p class="npm-review-help">${t.teams.length>0?`${t.teams.map(e=>e.name).join(`, `)} \xB7 `:``}${Qe(t.publishedAt??t.time)}</p>${A(t.comment)}<div class="npm-review-entry-actions"><button type="button" class="npm-review-button" ?disabled="${$(e)}" @click="${()=>{e._openReview(t)}}">Open ${O}</button> ${r&&o&&!a&&e._reviewer?U`<button type="button" class="npm-review-button" aria-label="Revise in a new draft" ?disabled="${$(e)}" @click="${()=>{e._openReview(t,!0)}}">Revise</button>`:W} ${r&&o&&e._writable&&t.revokedAt===null?U`<button type="button" class="npm-review-button npm-review-danger" ?disabled="${$(e)}" @click="${()=>e._change({action:`revoke`,reviewId:t.id,revision:t.revision})}">Revoke</button>`:W} ${o?U`<dependency-review-copy .text="${t.formatted}"></dependency-review-copy>`:W} ${!r&&o&&e._writable?ct($(e),()=>{e._discard(t)}):W}</div>${r&&o&&e._writable&&t.revokedAt===null&&s.length>0?U`<details class="npm-review-share"><summary>Publish to more teams</summary>${ya(e,`Teams`,s,c,n=>{e._additionalTeams=new Map(e._additionalTeams).set(t.id,n)},U`<button type="button" class="npm-review-button" ?disabled="${$(e)||l.length===0}" @click="${()=>e._change({action:`publish`,reviewId:t.id,revision:t.revision,teamIds:l})}">Publish to more teams</button>`)}</details>`:W} ${t.revokedAt===null?W:U`<p class="npm-review-help">Revoked ${Qe(t.revokedAt)}. Content and team links remain frozen.</p>`}</section>`}function Sa(e){if(!e._panel)return W;let t={publish:`Publish review`,reviews:`Reviews`,unsaved:`Unsaved changes`};return U`<dialog class="npm-review-dialog" aria-label="${t[e._panel]}" @cancel="${t=>{t.preventDefault(),e._closePanel()}}"><button type="button" class="detail-action npm-review-close" aria-label="Close panel" ?disabled="${e._blocked}" @click="${()=>e._closePanel()}">×</button><header class="npm-review-dialog-head"><h2>${t[e._panel]}</h2><p>${e._panel===`reviews`?`${e.entry.npm.name}@${e.entry.npm.version}${e._patch?` (patched)`:``}`:M(e._context)}</p></header>${e._panel===`publish`?ba(e,e._activeReview):U`<div class="${`npm-review-dialog-body${e._panel===`reviews`?` npm-review-entries`:``}`}">${e._panel===`unsaved`?U`${e._dirtyFiles.map(t=>U`<button type="button" class="npm-review-button" @click="${()=>{e._closePanel(),e._selectFile(t)}}">${t} ${O}</button>`)}`:sa(e).map(t=>xa(e,t))} ${e._panel===`reviews`&&sa(e).length===0?U`<p class="npm-review-muted">No reviews yet.</p>`:W}${aa(e)}</div>`} ${oa(e)}</dialog>`}function Ca(e){let t=e._shownReview?.entries,n=e._files,r=e._nonTextFiles;if(e._treeProgress?.entries!==t||e._treeProgress?.files!==n||e._treeProgress?.nonTextFiles!==r){let i=dt(t,r),a=new Map,o=0;for(let t of e._files){let e=t.split(`/`),n=+!!i.get(t)?.status;o+=n;for(let t=1;t<e.length;t++){let r=e.slice(0,t).join(`/`),i=a.get(r)??{total:0,checked:0};i.total++,i.checked+=n,a.set(r,i)}}e._treeProgress={entries:t,files:n,nonTextFiles:r,states:i,directories:a,checked:o}}let{states:i,directories:a,checked:o}=e._treeProgress;return{railLabel:`Files`,treeLabel:`Review files`,collapseLabel:`Collapse folders`,searchLabel:`Find a file`,searchPlaceholder:`Find a file…`,treePageSize:300,filterContent:!1,fullPaths:!0,collapseClearsSearch:!0,canSelect:()=>!e._blocked&&!e._panel,fileFilter:e._unchecked?e=>!i.get(e)?.status:null,fileLabel:e=>`${e}, ${Be[i.get(e)?.status]??`Not reviewed`}`,filePrefix:e=>Ue(i.get(e)?.status),fileSuffix:e=>i.get(e)?.notes?U`<span class="npm-review-note-dot" aria-label="Has notes">•</span>`:W,directoryLabel:e=>{let t=a.get(e.sourcePath);return`${e.sourcePath}, ${t?.checked??0} of ${t?.total??0} checked`},directorySummary:e=>{let t=a.get(e.sourcePath);return`${t?.checked??0}/${t?.total??0}`},filters:U`<div class="npm-review-filters" aria-label="Filter review files"><button type="button" class="npm-review-button" aria-pressed="${String(!e._unchecked)}" @click="${()=>{e._unchecked=!1}}">All ${e._files.length}</button> <button type="button" class="npm-review-button" aria-pressed="${String(!!e._unchecked)}" @click="${()=>{e._unchecked=!0}}">Unchecked ${e._files.length-o}</button></div>`,fileActions:(t,n)=>va(e,t,n),copyDiff:e._unified?.length>0?()=>e._unifiedText??=ra(e._unified):null}}function wa(e){if(!e._base){let t=U`<div class="npm-review-empty" role="${e._baseError?`alert`:`status`}">${e._baseError??`Loading comparison…`} ${e._baseError?U`<button type="button" class="npm-review-button" @click="${()=>{e._baseKey=null,e._loadBase(e._target,e.request?.resume)}}">Retry</button>`:W}</div>`;return e._baseError&&e._basePatch?U`${pa(e)}${t}`:t}return U`${pa(e)}${_a(e)}${e._panel?W:aa(e)} ${Wi({base:e._base,other:e._other,diff:e._diff,source:e.source,path:e._path,seek:e._seek,baseName:e._base.npm?`${e._base.npm.name}@${e._base.npm.version}${e._base.npmPatch?` (patched)`:``}`:`Empty package`,otherName:`${e.entry.npm.name}@${e.entry.npm.version}${e._patch?` (patched)`:``}`,select:t=>e._selectFile(t),extensions:Ca(e),mode:e._mode,viewChanged:()=>e._viewChanged()})} <span class="npm-review-announcement" role="status">${e._notice??``}</span>${e._panel?W:oa(e)}${Sa(e)}`}var Ta={maxLines:5e4,maxBytes:2097152},Ea={integrity:`(empty)`,kind:`sourcemap`,json:{version:3,sources:[],sourcesContent:[]},fileSizes:new Map},Da=(e,t,n=null)=>({ecosystem:`npm`,package:e.npm.name,version:e.npm.version,integrity:e.integrity,patchHash:n?.hash??null,basePackage:t?.npm?.name??null,baseVersion:t?.npm?.version??null,baseIntegrity:t?.npm?t.npmPatch?.integrity??t.integrity:null,basePatchHash:t?.npmPatch?.patch.hash??null}),Oa=(e,t)=>e?`${e}@${t??`latest`}`:`(empty)`,ka=class extends Xt{static properties={entry:{attribute:!1},details:{attribute:!1},request:{attribute:!1},session:{attribute:!1},source:{attribute:!1},_teams:{state:!0},_selectedTeams:{state:!0},_additionalTeams:{state:!0},_reviews:{state:!0},_loading:{state:!0},_error:{state:!0},_saving:{state:!0},_saveBlocked:{state:!0},_file:{state:!0},_seek:{state:!0},_finalStatus:{state:!0},_finalComment:{state:!0},_base:{state:!0},_baseError:{state:!0},_panel:{state:!0},_path:{state:!0},_selectedReview:{state:!0},_unchecked:{state:!0},_notice:{state:!0},_continuation:{state:!0}};createRenderRoot(){return this}constructor(){super(),this._teams=[],this._reviews=[],this._files=[],this._nonTextFiles=[],this._unified=null,this._unifiedText=null,this._selectedTeams=new Set,this._additionalTeams=new Map,this._editors=new Map,this._file=null,this._path=null,this._patch=null,this._patched=null,this._basePatch=null,this._loading=!1,this._saving=!1,this._error=null,this._context=null,this._key=null,this._controller=new AbortController,this._mode=`code`,this._panel=null,this._selectedReview=null,this._unchecked=!1,this._pendingSaves=[],this._saveBlocked=!1}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._cancelSaves(),this._dismissLoading?.(),this._key=null,this._baseKey=null}updated(){let e=this.querySelector(`dialog`);e&&!e.open&&e.showModal(),this._rememberBase()}_rememberBase(){N.bundleDetailsTab!==`review`||N.selectedBundle!==this.entry?.integrity||!this._context||!this._activeReview&&this._ownPublished.length===0&&!this._unsaved||(N.npmReview={bundle:this.entry.integrity,...this._context.basePackage?{reviewPackage:this._context.basePackage,reviewSpec:this._context.baseVersion}:{},...this._patch?{patch:this._patch}:{},...this._context.basePatchHash?{basePatch:this._context.basePatchHash}:{},started:!0,user:this.session?.id})}get _writable(){return[`triage`,`manage`,`admin`].includes(this.session?.role)&&!this.session?.viewer}get _other(){return this._patched??this.details}get _reviewer(){return this._writable&&this._teams.length>0}_ownHere(e){return e.user===this.session?.id&&j(e,this._context)}get _activeReview(){return this._reviews.find(e=>e.publishedAt===null&&this._ownHere(e))??(this._continuation&&this._continuation.review.user===this.session?.id?this._continuation.review:null)}get _ownPublished(){return this._reviews.filter(e=>e.publishedAt!==null&&this._ownHere(e)).toSorted((e,t)=>t.publishedAt-e.publishedAt)}get _shownReview(){return this._selectedReview?this._reviews.find(e=>e.id===this._selectedReview):this._activeReview??this._ownPublished[0]??null}get _canEdit(){return this._reviewer&&!this._selectedReview&&(this._activeReview!==null||this._ownPublished.length===0)}_isDirty(e,t){return!this._nonTextFiles.includes(e)&&(t.comment!==(t.edit?.comment??``)||t.status!==(t.edit?.status??``))}get _dirtyFiles(){return[...this._editors].filter(([e,t])=>this._isDirty(e,t)).map(([e])=>e)}get _blocked(){return this._saving||this._saveBlocked}get _unsaved(){return this._pendingSaves.length>0||this._dirtyFiles.length>0}get _draftStarted(){return this._canEdit&&(this._unsaved||this._activeReview&&!this._continuation||this._continuation&&this._publishRevision!=null&&!this._unchangedContinuation)}get _summary(){return pe(this._shownReview?.entries??[],this._files,this._nonTextFiles)}get _securityLimit(){return this.source?.reviewVerdictLimit?.(this.entry,this._base)??`accept`}get _allowedVerdicts(){let e=new Map((this._shownReview?.entries??[]).map(e=>[e.file,e]));if(this._canEdit)for(let[t,n]of this._editors)e.set(t,{file:t,status:n.status||null});return _e([...e.values()].filter(e=>!this._nonTextFiles.includes(e.file)),this._securityLimit)}get _needsPackageJson(){return be(this._activeReview?.entries??[],this._files,this._nonTextFiles)}get _unchangedContinuation(){let e=this._continuation?.source;return!!(e&&this._finalStatus===e.status&&this._finalComment===e.comment)}get _canPublish(){return this._canEdit&&this._panel===`publish`&&this._activeReview?.revision===this._publishRevision&&this._summary.checkedFiles>0&&!this._needsPackageJson&&!this._unchangedContinuation&&this._selectedTeams.size>0&&!this._unsaved&&this._allowedVerdicts.includes(this._finalStatus)}_location(e,t=!0,n=e===this._target?this._basePatch:null){let r=e&&e!==`(empty)`?l(e):null;return{...r?{reviewPackage:r.name,reviewSpec:r.spec}:{},...t&&this._patch?{patch:this._patch}:{},...r&&n?{basePatch:n}:{}}}_asked(e=this._context){let t=Object.fromEntries(Object.keys(this._context).map(t=>[t,e[t]??null])),n=(e===this._context?null:e.patchSource)??this._patch;return t.patchHash&&n?.repoId!=null?{...t,patchRepoId:n.repoId,patchCommit:n.commit,...n.path==null?{}:{patchPath:n.path}}:t}_navigate(e,t=e===this._target?this._basePatch:null){return this._navigateTo(d(this.entry,`review`,this._location(e,!0,t)))}async _navigateTo(e){if(this._blocked||this._loading)return;let t=this._key,n=this._navigation={};this._unsaved&&!await this._saveAll()||t===this._key&&n===this._navigation&&!this._unsaved&&await Xe?.navigate(e.bundleTab===`review`?{...e,...Ve(N)}:e)}_shownRoute(e=this._base){let t=this._location(Oa(e.npm?.name,e.npm?.version),!0,e.npmPatch?.patch.hash??null);return d(this.entry,`review`,{...t,...Ve(N)})}_viewChanged(){N.bundleDetailsTab!==`review`||N.selectedBundle!==this.entry?.integrity||!this._base||!this._context||Xe?.replaceRoute(this._shownRoute())}_baseKeyOf(e){return JSON.stringify([this.entry.integrity,e,this._patch,this._basePatch,this.session?.id,this.session?.role])}_restart(){this._controller.abort(),this._cancelSaves(),this._controller=new AbortController}async _loadBase(e,t=!1){let n=this._baseKeyOf(e);if(this._baseKey!==n){this._baseKey=n,this._base=null,this._baseError=null,this._key=null,this._restart();try{let r=this._controller.signal,i=this._patch?h(this.entry,this._patch,{signal:r}):Promise.resolve(this.details);i.catch(()=>{});let a=t?await Te(Da(this.entry,null,this._patch),r):null;if(this._baseKey!==n)return;a&&([e,this._basePatch]=[Oa(a.basePackage,a.baseVersion),a.basePatchHash??null]);let o=e===`(empty)`?null:l(e),s=o?await p(o.name,o.spec??`latest`):null,c=s&&this._basePatch?{...await h(s.entry,{hash:this._basePatch},{signal:r}),npm:s.details.npm}:s?.details??Ea,u=await i;if(this._baseKey!==n)return;let d=await En(c,u);if(this._baseKey!==n)return;t&&(a&&vt(a),this._target=e,this.request={bundle:this.entry.integrity,...this._location(e)},this._baseKey=this._baseKeyOf(e)),this._patched=this._patch?u:null,this._base=c,this._ensureContext(c,d)}catch(e){this._baseKey===n&&(this._baseError=e.message)}}}_ensureContext(e,t){let n=Da(this.entry,e,this._patch),r=JSON.stringify([this.session?.id,this.session?.role,n]);if(r===this._key)return;this._restart(),this._context=n,this._diff=t;let i=Fn(e,this._other,this._diff);this._files=_t(tt(i.map(e=>e.path)));let a=new Set(i.filter(e=>!le(e.before,e.after)).map(e=>e.path));this._nonTextFiles=this._files.filter(e=>a.has(e));let o=new Map(i.map(e=>[e.path,e]));if(this._unified=na(this._files.map(e=>o.get(e))),this._unifiedText=null,this._mode=In(i,Ta)?`diff`:`code`,this._key=r,this._teams=[],this._reviews=[],this._selectedTeams=new Set,this._additionalTeams=new Map,this._selectedReview=null,this._continuation=null,this._editors.clear(),this._path=this._files[0]??null,this._panel=null,this._notice=``,this._resetEditor(this._path),this._saving=!1,this._refresh(!0),N.bundleDetailsTab===`review`&&N.selectedBundle===this.entry.integrity){let t=Oa(e.npm?.name,e.npm?.version),n=this._location(t,!0,e.npmPatch?.patch.hash??null);N.npmReview={bundle:this.entry.integrity,...n},this._baseKey=this._baseKeyOf(t),Xe?.replaceRoute(this._shownRoute(e))}}async _refresh(e=!1){let t=this._key;for(;t===this._key&&this._pendingSaves.length>0;)if((await Promise.all(this._pendingSaves.map(e=>e.promise))).some(e=>!e))return;if(t!==this._key)return;this._dismissLoading?.();let n=this._dismissLoading=Pe(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let{reviews:n,teams:r}=await ue({...this._context,allBases:!0},null,null,this._controller.signal);if(t===this._key){let t=this._unsaved;this._reviews=n,this._teams=r,n.some(e=>e.publishedAt===null&&this._ownHere(e))&&(this._continuation=null),this._rememberBase();let i=xt(this._context),a=i&&n.find(e=>e.id===i.review.id);a?.publishedAt!=null&&(i.continueReview?this._continue(a.id,a.revision):this._selectedReview=a.id),this._selectedTeams=new Set(r.filter(t=>e?r.length===1:this._selectedTeams.has(t.id)).map(e=>e.id)),t||this._clearEditors(this._file)}}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_resetEditor(e=null){this._publishRevision=null,this._file=e,this._editorState(e)}_clearEditors(e=this._path){this._editors.clear(),this._resetEditor(e)}_editorState(e){let t=this._canEdit?this._editors.get(e):null;if(!t){let n=this._shownReview?.entries.find(t=>t.file===e&&t.status)??null,r=this._nonTextFiles.includes(e);t={edit:n,revision:this._activeReview?.revision??null,comment:r?``:n?.comment??``,status:r?``:n?.status??``},this._canEdit&&this._editors.set(e,t)}return{...t,dirty:this._isDirty(e,t)}}_editFile(e,t){!this._canEdit||this._blocked||(this._resetEditor(e),Object.assign(this._editors.get(e),t),this.requestUpdate())}_setFileStatus(e,t){if(!(this._blocked||this._nonTextFiles.includes(e)))return this._editFile(e,{status:t,...t?{}:{comment:``}}),this._saveFile(e)}_selectFile(e){this._blocked||!this._files.includes(e)||(this._path=e,this._resetEditor(e))}_openLine({path:e,line:t,query:n}){this._blocked||!this._files.includes(e)||(this._seek={path:e,line:t-1,query:n},this._selectFile(e))}_openPanel(e){this._panel=e}async _openReview(e,t=!1){if(this._blocked||this._loading)return;if(j(e,this._context)){t?this._continue(e.id,e.revision):e.publishedAt===null?this._resume():this._showPublished(e);return}let n=this._key;this._unsaved&&!await this._saveAll()||n!==this._key||(vt(e,t),await this._navigate(Oa(e.basePackage,e.baseVersion),e.basePatchHash??null))}_closePanel(){this._blocked||(this.querySelector(`dialog`)?.close(),this._panel=null)}_showPublished(e){this._selectedReview=e.id,this._panel=null,this._file=this._path}_resume(){this._selectedReview=null,this._panel=null,this._resetEditor(this._path)}async _discard(e){if(this._blocked||this._loading||!this._writable||e.user!==this.session.id||e.publishedAt!==null)return;let t=e===this._activeReview,n=this._key,r=this._controller.signal;this._saving=!0,this._error=null;try{let{confirmed:i}=await Ft({reviewTitle:M(e),signal:r});if(!i||r.aborted||n!==this._key||(await Promise.all(this._pendingSaves.map(e=>e.promise)),r.aborted||n!==this._key||!this._writable)||(e=t?this._activeReview:this._reviews.find(t=>t.id===e.id),!e||e.user!==this.session.id||e.publishedAt!==null))return;let a=e===this._continuation?.review;if(a||await xe(e.id,e.revision,this.session.csrfToken,r),r.aborted||n!==this._key)return;a||(this._reviews=this._reviews.filter(t=>t.id!==e.id)),j(e,this._context)&&(this._continuation=null,this._selectedReview=null,this._clearEditors(),this._finalStatus=null,this._finalComment=``,this._panel=null,this._ownPublished.length===0&&N.npmReview?.bundle===this.entry.integrity&&delete N.npmReview.started),this._notice=`Draft discarded.`}catch(e){n===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n===this._key&&(this._saving=!1)}}_continue(e,t){let n=this._reviews.find(n=>n.id===e&&n.revision===t&&n.publishedAt!==null&&this._ownHere(n));return!n||this._activeReview||!this._reviewer?null:(this._continuation={source:n,review:{...n,publishedAt:null,revokedAt:null,status:null,teams:[]}},this._selectedTeams=new Set(this._teams.length===1?this._teams.map(e=>e.id):[]),this._selectedReview=null,this._panel=null,this._clearEditors(),this._notice=`A new draft will be saved when you make a change.`,this._activeReview)}async _persistContinuation(e){let t=this._continuation,n=this._key,{review:r}=await ue(this._asked(),{action:`continue`,reviewId:t.source.id,revision:t.source.revision},this.session.csrfToken,this._controller.signal);return n!==this._key||this._continuation!==t||e&&this._pendingSaves[0]!==e?null:(this._acceptSave(r,{revision:t.source.revision}),r)}_cancelSaves(){for(let e of this._pendingSaves)clearTimeout(e.timer),e.resolve(null);this._pendingSaves=[],this._saveBlocked=!1}_queueSave(e){let t=this._pendingSaves.findLast(t=>t.change.file===e.file);if(t&&t.change.comment===e.comment&&t.change.status===e.status)return t.promise;let n={change:e,slow:!1};return n.promise=new Promise(e=>{n.resolve=e}),n.timer=setTimeout(()=>{n.slow=!0,this._saveBlocked=!0},3e3),this._pendingSaves.push(n),this.requestUpdate(),this._pendingSaves.length===1&&this._flushSaves(),n.promise}_putReview(e){this._reviews=[...this._reviews.filter(t=>t.id!==e.id),e]}_acceptSave(e,t){this._putReview(e),this._continuation=null;for(let[n,r]of this._editors)r.revision===t.revision&&(r.revision=e.revision,r.edit=e.entries.find(e=>e.file===n&&e.status)??null);for(let{change:n}of this._pendingSaves.slice(1))n.revision===t.revision&&(n.revision=e.revision,n.reviewId=e.id,n.entryId=e.entries.find(e=>e.file===n.file)?.id??null);this._canEdit&&this._resetEditor(this._file),this._notice=`Saved privately.`,this._rememberBase()}async _flushSaves(){for(;this._pendingSaves.length>0;){let e=this._pendingSaves[0];this._error=null;try{if(this._continuation){let t=await this._persistContinuation(e);if(!t||this._pendingSaves[0]!==e)return;Object.assign(e.change,{reviewId:t.id,revision:t.revision,entryId:t.entries.find(t=>t.file===e.change.file)?.id??null})}let{review:t}=await ue(this._asked(),e.change,this.session.csrfToken,this._controller.signal);if(this._pendingSaves[0]!==e)return;this._acceptSave(t,e.change),clearTimeout(e.timer),this._pendingSaves.shift(),e.resolve(t),this._saveBlocked=this._pendingSaves.some(e=>e.slow),this.requestUpdate()}catch(t){if(this._pendingSaves[0]!==e)return;this._cancelSaves(),t.name!==`AbortError`&&(this._error=t.message),this.requestUpdate();return}}}async _change(e){if(this._blocked||this._pendingSaves.length>0||this._loading||!this._writable)return null;if(e.action===`continue`)return this._continue(e.reviewId,e.revision);let t=this._key;this._saving=!0,this._error=null;try{if(e.action===`publish`&&e.finalStatus&&this._continuation){let t=await this._persistContinuation();if(!t)return null;e={...e,reviewId:t.id,revision:t.revision}}let n=this._reviews.find(t=>t.id===e.reviewId)??this._context,{review:r}=await ue(this._asked(n),e,this.session.csrfToken,this._controller.signal);return t===this._key?(this._putReview(r),e.action===`publish`&&e.finalStatus&&j(r,this._context)&&(this._selectedReview=r.id,this._panel=null,this._editors.clear(),this._notice=`Published. Verdicts and notes are now frozen.`),this._rememberBase(),r):null}catch(e){return t===this._key&&e.name!==`AbortError`&&(this._error=e.message),null}finally{t===this._key&&(this._saving=!1)}}_saveFile(e){if(!this._canEdit||this._saving||this._loading)return null;let t=this._editorState(e),n=this._pendingSaves.some(t=>t.change.file===e),r=this._activeReview;return!t.dirty&&!n?r:!t.status&&!t.comment.trim()&&!t.edit?.id&&!n?(this._editors.delete(e),e===this._file&&this._resetEditor(e),r):this._queueSave({action:`save`,reviewId:r?.id??null,revision:t.revision,entryId:t.edit?.id??null,file:e,comment:t.comment,status:this._nonTextFiles.includes(e)?null:t.status||null})}async _saveAll(){let e=this._key;for(;e===this._key&&this._canEdit;){if(this._pendingSaves.length>0){if((await Promise.all(this._pendingSaves.map(e=>e.promise))).some(e=>!e))return!1;continue}let e=this._dirtyFiles;if(e.length===0)return!0;if(!await this._saveFile(e[0]))return!1}return!1}async _beginPublish(){if(!this._canEdit||this._saving||this._loading||this._finalizing||!this._summary.checkedFiles)return;let e=this._key;this._finalizing=!0;try{if(this._unsaved&&!await this._saveAll()||e!==this._key||!this._canEdit||this._unsaved||!this._summary.checkedFiles)return;let t=this._activeReview;if(!t)return;let n=this._allowedVerdicts,r=this._continuation?.source.status;this._finalStatus=n.includes(r)?r:n[0],this._finalComment=t.comment??``,this._publishRevision=t.revision,this._panel=`publish`}finally{this._finalizing=!1}}_publish(){if(this._canPublish)return this._change({action:`publish`,reviewId:this._activeReview.id,revision:this._publishRevision,teamIds:[...this._selectedTeams],finalStatus:this._finalStatus,finalComment:this._finalComment})}render(){if(!this.entry?.npm||!this.details)return W;let e=this.request?.bundle===this.entry.integrity?this.request:{};return this._target=Oa(e.reviewPackage,e.reviewSpec),JSON.stringify(e.patch??null)!==JSON.stringify(this._patch)&&(this._patch=e.patch??null),this._basePatch=e.basePatch??null,this._loadBase(this._target,e.resume),wa(this)}};customElements.define(`npm-review`,ka);var Aa=e=>({view:`npm`,packageName:e.package,packageSpec:e.version,bundleTab:`review`,...e.basePackage===null?{}:{reviewPackage:e.basePackage,reviewSpec:e.baseVersion},...Kt(e.patchHash)&&e.patchSource?{patch:{hash:e.patchHash,...e.patchSource}}:{},...Kt(e.basePatchHash)&&e.basePackage!==null?{basePatch:e.basePatchHash}:{}}),ja=e=>{let t=new Date(e);return U`<time class="dependency-review-date" datetime="${t.toISOString()}" data-tooltip="${t.toLocaleString()}">${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,...t.getFullYear()===new Date().getFullYear()?{}:{year:`numeric`}})} <span>${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}</span></time>`},Ma=class extends Xt{static properties={session:{attribute:!1},team:{attribute:!1},_reviews:{state:!0},_loading:{state:!0},_error:{state:!0},_next:{state:!0},_discarding:{state:!0},_expanded:{state:!0}};constructor(){super(),this._reviews=[],this._next=null,this._expanded=new Set,this._controller=new AbortController}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._dismissLoading?.(),this._key=null}_canDiscard(e){return e.publishedAt===null&&e.user===this.session?.id&&[`triage`,`manage`,`admin`].includes(this.session?.role)}async _discard(e){if(!this._canDiscard(e)||this._discarding||this._loading)return;let t=this._key,n=this._controller.signal;this._discarding=e.id,this._error=null;try{let{confirmed:r}=await Ft({reviewTitle:M(e),signal:n});if(!r||n.aborted||t!==this._key||!this._canDiscard(e)||(await xe(e.id,e.revision,this.session.csrfToken,n),t!==this._key||n.aborted))return;this._reviews=this._reviews.filter(t=>t.id!==e.id)}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{t===this._key&&(this._discarding=null)}}async _load(e=!1){let t=this._key;this._dismissLoading?.();let n=this._dismissLoading=Pe(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let n=e?this._next:null,{reviews:r,next:i}=await(this.team?ve(this.team,n,this._controller.signal):me(n,this._controller.signal));if(t!==this._key)return;this._reviews=[...new Map([...e?this._reviews:[],...r].map(e=>[e.id,e])).values()],this._next=i}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_toggleDetails(e){let t=new Set(this._expanded);t.delete(e)||t.add(e),this._expanded=t}_details(e){let t=e.entries.filter(e=>e.status);return U`<section id="${`review-details-${e.id}`}" class="dependency-review-details" aria-label="${`Details for ${M(e)}`}">${e.comment?U`<div class="dependency-review-final-note" role="note" aria-label="Final note">${A(e.comment)}</div>`:W} ${t.length>0?U`<ul class="dependency-review-entries">${t.map(e=>U`<li>${it(e.file)} ${Ge(e.status)}<div>${A(e.comment)}</div></li>`)}</ul>`:U`<p class="npm-review-muted">No file reviews yet.</p>`}</section>`}_row(e){let t=Aa(e),n=this._expanded.has(e.id),r=e.publishedAt!==null,i=new Set(e.entries.filter(e=>e.status).map(e=>e.file)).size,a=e.entries.filter(e=>e.status&&e.comment.trim()).length+ +!!e.comment.trim(),o=e.teams.filter(e=>e.id!==this.team).map(e=>e.name).join(`, `),s=o&&this.team?`also ${o}`:o,c=n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||!Xe?.active||(n.preventDefault(),vt(e),Xe.navigate(t))};return U`<li class="${`dependency-review-row${n?` is-expanded`:``}${e.revokedAt===null?``:` is-revoked`}`}"><div class="dependency-review-row-main"><a class="dependency-review-title" href="${Jt(t)}" @click="${c}">${Nt(e.ecosystem)} ${e.basePackage!==null&&e.basePackage!==e.package?U`<span>${e.basePackage} ${e.baseVersion} →</span>`:W} <strong>${e.package}</strong> <span>${e.basePackage===e.package?`${e.baseVersion} \u2192 `:``}${e.version}${e.patchHash?U`<span class="dependency-review-patched">patch:${e.patchHash}</span>`:W}</span></a> <span class="dependency-review-result">${r?Ge(e.status):U`<span class="dependency-review-checked">${i} ${i===1?`file`:`files`} checked</span>`}</span> <button type="button" class="dependency-review-coverage" aria-expanded="${n}" aria-controls="${`review-details-${e.id}`}" data-tooltip="${r?`${e.checkedFiles} of ${e.totalFiles} files checked`:W}" @click="${()=>this._toggleDetails(e.id)}">${r?U`${nt(e)} · ${e.checkedFiles}/${e.totalFiles}`:a?ot(a):`No notes`}</button> ${this.team?U`<span class="dependency-review-author">${Ye(e)}</span>`:W} <span class="dependency-review-meta">${r&&s?U`<span class="dependency-review-teams" data-tooltip-truncated data-tooltip="${s}">${s}</span>`:W} ${r&&a>0?U`<span class="dependency-review-note-count">${ot(a)}</span>`:W} ${e.revokedAt===null?W:qe(e)}</span> ${ja(e.publishedAt??e.time)}<div class="dependency-review-row-actions">${this.team?W:U`<dependency-review-copy .text="${e.formatted}"></dependency-review-copy>`} ${this._canDiscard(e)?ct(this._loading||!!this._discarding,()=>this._discard(e)):W} <a class="dependency-review-open" href="${Jt(t)}" @click="${c}" aria-label="${`${r?`Open`:`Continue`} review for ${M(e)}`}"><span aria-hidden="true">→</span></a></div></div>${n?this._details(e):W}</li>`}render(){let e=JSON.stringify([this.session?.id,this.session?.role,this.team??null]);e!==this._key&&(this._controller.abort(),this._controller=new AbortController,this._key=e,this._reviews=[],this._next=null,this._discarding=null,this._expanded=new Set,this._load());let t=this._error?U`<p role="alert">${this._error}</p>`:W,n=!this._loading&&!this._error&&this._reviews.length===0,r=this._next?U`<button type="button" class="npm-review-button" ?disabled="${this._loading||!this.team&&!!this._discarding}" @click="${()=>this._load(!0)}">Load more</button>`:W;return this.team?U`<section class="dependency-review-list is-team">${t} ${n?U`<p class="npm-review-muted">No reviews are published to this team yet.</p>`:W}<ol>${this._reviews.map(e=>this._row(e))}</ol>${r}</section>`:U`<section class="dependency-review-list"><header><h1>My reviews</h1></header><p>Your private work and the reviews you’ve shared with teams.</p>${t} ${n?U`<p>No reviews yet. Open a package’s Review tab to begin.</p>`:W} ${[[`Drafts`,!1],[`Published reviews`,!0]].map(([e,t])=>{let n=this._reviews.filter(e=>e.publishedAt!==null===t);return U`<section class="dependency-review-section"><h2>${e}<span class="npm-review-count">${n.length}</span></h2><ol>${n.map(e=>this._row(e))}</ol>${n.length===0&&!this._loading?U`<p class="npm-review-muted">${t?`No published reviews yet.`:`No drafts.`}</p>`:W}</section>`})} ${r}</section>`}};customElements.define(`dependency-review-list`,Ma);
|
|
31
|
+
${kt(n,r)}`).join(``)}var $=e=>e._blocked||e._loading,ia=e=>e._shownReview?.publishedAt!=null,aa=e=>e._error?U`<p class="npm-review-error" role="alert">${e._error}</p>`:W,oa=e=>e._saveBlocked?U`<div class="npm-review-saving" role="status">Saving changes…</div>`:W,sa=e=>[e._continuation?.review,...e._reviews].filter(Boolean).toSorted((e,t)=>+(e.publishedAt!==null)-(t.publishedAt!==null)||(t.publishedAt??t.time)-(e.publishedAt??e.time)),ca=e=>`npm-review-button npm-review-primary npm-review-finalize ${e._allowedVerdicts[0]}`,la=(e,t,n,r,i=Object.keys(Be),a=!1)=>U`<div class="npm-review-verdict-options" role="group" aria-label="Verdict">${Object.entries(a?{"":`Not checked`,...Be}:Be).map(([a,o])=>U`<label class="${`npm-review-verdict-choice ${a||`unchecked`}`}"><input type="radio" name="${e}" aria-label="${o}" value="${a}" .checked="${I(t===a)}" ?disabled="${r||a!==``&&!i.includes(a)}" @change="${()=>n(a)}">${o}</label>`)}</div>`;function ua(e){let t=ia(e),n=e._shownReview,r=e._summary,i=e._canEdit?{label:`Finalize review`,run:()=>e._beginPublish(),disabled:!r.checkedFiles}:!t||!e._writable?null:e._activeReview||e._ownPublished.length===0?{label:`Resume your review`,run:()=>e._resume()}:n.user===e.session?.id?{label:`Revise review`,run:()=>e._change({action:`continue`,reviewId:n.id,revision:n.revision})}:null,a=t&&n.revokedAt===null&&n.user===e.session?.id?U`<dependency-review-copy .text="${n.formatted}"></dependency-review-copy>`:W;return U`<div class="npm-review-summary-actions">${t||e._draftStarted?U`<span class="npm-review-status">${a}${qe(n??{publishedAt:null,revokedAt:null})}</span>`:W}<div class="npm-review-progress-block"><span>${e._unsaved&&(e._saveBlocked||e._error)?U`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>e._openPanel(`unsaved`)}">Unsaved changes</button>`:U`<strong>${r.checkedFiles} of ${r.totalFiles}</strong> files checked`}</span> ${et(r.checkedFiles,r.totalFiles)}</div>${i?U`<button type="button" class="${e._canEdit?ca(e):`npm-review-button`}" ?disabled="${$(e)||i.disabled}" @click="${i.run}">${i.label} ${O}</button>`:W}</div>`}var da=(e,t)=>e.some(e=>e.id===t)?e:[...e,...G([{id:t,name:t,format:`npm`}])];function fa(e,t,n,r,i){if(!r)return null;let a=e.findIndex(e=>e.id===t),o=`patch:${r.slice(0,5)}`;return e.splice(a,1,{...e[a],detail:o,detailNote:i},{...e[a],id:`${t} unpatched`}),{name:n,detail:o,detailNote:i}}function pa(e){let t=e.source??Oe(e.entry),{name:n,version:r}=e.entry.npm,i=!!(e._target&&e._target!==`(empty)`),a=G(t.options,e=>`${n}@${e.id}`),o=i?da(a,e._target):a,s=da(G(t.choices),r),c=`${e._target} unpatched`,l=`${r} unpatched`,u=fa(s,r,`${n}@${r}`,e._patch?.hash,ha(ma(e))),d=fa(o,e._target,e._target,i&&e._basePatch,ha(e._base?.npmPatch?.patch));return dn(ln({source:u||d?{...t,widest:u||d}:t,label:`Review`,disabled:$(e),from:{options:o,value:i?e._target:null,label:`Review base`,pick:t=>{e._navigate(t===c?e._target:t,t===e._target?e._basePatch:null)}},to:{options:s,value:r,label:`Version to review`,pick:t=>{e._navigateTo({view:`npm`,packageName:n,packageSpec:t===l?r:t,bundleTab:`review`,...e._location(e._target,t===r)})}},clear:i?{label:`Clear review base`,run:()=>{e._navigate(`(empty)`)}}:null,openLine:t=>e._openLine(t),comparison:e._base?{base:e._base,other:e._other,files:e._diff.files}:null}),e._base?un(e._diff):W)}var ma=e=>e._patched?.npmPatch?.patch??e._patch,ha=e=>`As pnpm\u2019s patch${e?.path?` ${e.path}`:``} changes it`,ga=e=>e._patch?U`<span class="npm-review-patched" data-tooltip="${`${ha(ma(e))}${ma(e).commit?`, read at ${ma(e).commit.slice(0,7)}`:``}`}">patch:${e._patch.hash}</span>`:W;function _a(e){return U`<div class="npm-review-toolbar"><nav class="npm-review-toolbar-group" aria-label="Review breadcrumbs"><button type="button" class="npm-review-button npm-review-text-button" ?disabled="${$(e)}" @click="${()=>{e._navigateTo({view:`reviews`})}}">My reviews</button> ${O}<button type="button" class="npm-review-button npm-review-text-button npm-review-package" aria-haspopup="dialog" ?disabled="${e._blocked}" @click="${()=>e._openPanel(`reviews`)}"><span>${e.entry.npm.name}@${e.entry.npm.version}</span><span class="npm-review-count">${sa(e).length}</span></button> ${ga(e)}</nav>${ua(e)}</div>`}function va(e,t=e._file,n=!1){let r=e._editorState(t),i=e._shownReview?.entries.find(e=>e.file===t),a=e._nonTextFiles.includes(t),o=!a&&[`accept-with-nits`,`request-changes`,`reject`].includes(r.status);return U`<section class="${`npm-review-decision${n?` npm-review-inline-decision`:``}`}" aria-label="File decision">${e._canEdit?U`${la(`file:${t}`,a?``:r.status,n=>{e._setFileStatus(t,n)},$(e)||a,void 0,!0)} ${a?U`<p class="npm-review-help">Non-text file. Verdicts are not supported yet; this file remains unchecked.</p>`:W} ${o?U`<textarea aria-label="File note" rows="2" maxlength="20000" placeholder="Add a note (optional)…" .value="${I(r.comment)}" ?disabled="${$(e)}" @input="${n=>e._editFile(t,{comment:n.target.value})}" @blur="${()=>{e._saveFile(t)}}"></textarea>`:W}`:U`${n?W:U`<header><strong>File review</strong><span class="npm-review-muted">${ia(e)?`Frozen`:`Read only`}</span></header>`} ${i?.status&&!a?U`${Ge(i.status)}${A(i.comment)}`:U`<p class="npm-review-muted">This file was not reviewed.</p>`} ${e._reviewer||e._loading?W:U`<p class="npm-review-help">${e._writable?`Reviewing needs a team that reviews dependencies, where you manage or have Dependencies.`:`Triage access is required to add a review.`}</p>`}`}</section>`}function ya(e,t,n,r,i,a){return U`<fieldset class="npm-review-team-options"><legend>${t}</legend>${n.map(t=>U`<mode-switch label="${t.name}" .checked="${r.has(t.id)}" .disabled="${$(e)}" @click="${()=>{if($(e))return;let n=new Set(r);n.delete(t.id)||n.add(t.id),i(n)}}"></mode-switch>`)}${a}</fieldset>`}function ba(e,t){let n=e._allowedVerdicts,r=pe(t.entries,e._files,e._nonTextFiles),i=t.entries.filter(t=>t.status&&t.comment.trim()&&!e._nonTextFiles.includes(t.file));return U`<form class="npm-review-publish-form" @submit="${t=>{t.preventDefault(),e._publish()}}"><div class="npm-review-dialog-body"><section class="npm-review-coverage"><div><strong>${r.coverage===`full`?`Full`:`Partial`} review</strong><span>${r.checkedFiles} of ${r.totalFiles} files checked</span></div>${et(r.checkedFiles,r.totalFiles)}<p>${r.totalFiles>r.checkedFiles?U`${r.totalFiles-r.checkedFiles} files not checked. <button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e._unchecked=!0,e._closePanel()}}">View files</button>`:`Every file has a verdict.`}</p>${e._needsPackageJson?U`<p class="npm-review-error">Review ${e._files.includes(`package.json`)?U`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e._closePanel(),e._selectFile(`package.json`)}}">package.json</button>`:`package.json`} before publishing a partial review.</p>`:W}</section>${i.length>0?U`<section aria-label="File notes"><strong>File notes</strong><ul class="npm-review-publish-notes" tabindex="0" aria-label="Saved file notes">${i.map(e=>U`<li>${it(e.file)} ${A(e.comment)}</li>`)}</ul></section>`:W}<div><strong>Final verdict</strong>${la(`final-verdict`,e._finalStatus,t=>{e._finalStatus=t},$(e),n)}</div>${e._securityLimit===`reject`?U`<p class="npm-review-help">Malware detected. Only Reject is available.</p>`:e._securityLimit===`request-changes`?U`<p class="npm-review-help">Critical vulnerabilities detected.</p>`:W} <label>Final note <span class="npm-review-muted">· optional</span><textarea aria-label="Final comment" rows="3" maxlength="20000" .value="${I(e._finalComment)}" placeholder="Summarize your findings or explain what remains…" ?disabled="${$(e)}" @input="${t=>{e._finalComment=t.target.value}}"></textarea></label> ${e._unchangedContinuation?U`<p class="npm-review-help">Change a verdict or note to publish a new review.</p>`:W} ${ya(e,`Publish to teams`,e._teams,e._selectedTeams,t=>{e._selectedTeams=t},e._selectedTeams.size>0?W:U`<p class="npm-review-error">${e._teams.length===0?`No teams you belong to have dependency review enabled.`:`Select at least one team to publish.`}</p>`)} ${aa(e)}</div><footer class="npm-review-dialog-footer"><p>Publishing freezes your verdicts and notes.<br>You can continue in a new review to make changes.</p><button type="submit" class="${ca(e)}" ?disabled="${$(e)||!e._canPublish}">Publish to ${e._selectedTeams.size} ${e._selectedTeams.size===1?`team`:`teams`} ${O}</button></footer></form>`}function xa(e,t){let n=t===e._shownReview,r=t.publishedAt!==null,i=r?t:j(t,e._context)?pe(t.entries,e._files,e._nonTextFiles):{checkedFiles:t.entries.filter(e=>e.status).length,totalFiles:null},a=[e._continuation?.review,...e._reviews].some(n=>n?.publishedAt===null&&n.user===e.session?.id&&j(n,t)),o=t.user===e.session?.id,s=e._teams.filter(e=>!t.teams.some(t=>t.id===e.id)),c=e._additionalTeams.get(t.id)??new Set(s.length===1?s.map(e=>e.id):[]),l=s.filter(e=>c.has(e.id)).map(e=>e.id);return U`<section class="npm-review-entry" aria-current="${String(n)}"><div class="npm-review-history-heading"><strong>${Ye(t)}</strong>${n?U`<span class="npm-review-current">Current</span>`:W}${qe(t)}</div><p class="npm-review-help">${t.basePackage?`${t.basePackage===t.package?t.baseVersion:`${t.basePackage}@${t.baseVersion}`} \u2192 ${t.version}`:`All package files`}</p><div class="npm-review-entry-result">${r?Ge(t.status):W}<span class="dependency-review-coverage"> ${r?U`${nt(i)} · `:W}${i.checkedFiles}${i.totalFiles===null?W:`/${i.totalFiles}`} files checked</span></div><p class="npm-review-help">${t.teams.length>0?`${t.teams.map(e=>e.name).join(`, `)} \xB7 `:``}${Qe(t.publishedAt??t.time)}</p>${A(t.comment)}<div class="npm-review-entry-actions"><button type="button" class="npm-review-button" ?disabled="${$(e)}" @click="${()=>{e._openReview(t)}}">Open ${O}</button> ${r&&o&&!a&&e._reviewer?U`<button type="button" class="npm-review-button" aria-label="Revise in a new draft" ?disabled="${$(e)}" @click="${()=>{e._openReview(t,!0)}}">Revise</button>`:W} ${r&&o&&e._writable&&t.revokedAt===null?U`<button type="button" class="npm-review-button npm-review-danger" ?disabled="${$(e)}" @click="${()=>e._change({action:`revoke`,reviewId:t.id,revision:t.revision})}">Revoke</button>`:W} ${o?U`<dependency-review-copy .text="${t.formatted}"></dependency-review-copy>`:W} ${!r&&o&&e._writable?ct($(e),()=>{e._discard(t)}):W}</div>${r&&o&&e._writable&&t.revokedAt===null&&s.length>0?U`<details class="npm-review-share"><summary>Publish to more teams</summary>${ya(e,`Teams`,s,c,n=>{e._additionalTeams=new Map(e._additionalTeams).set(t.id,n)},U`<button type="button" class="npm-review-button" ?disabled="${$(e)||l.length===0}" @click="${()=>e._change({action:`publish`,reviewId:t.id,revision:t.revision,teamIds:l})}">Publish to more teams</button>`)}</details>`:W} ${t.revokedAt===null?W:U`<p class="npm-review-help">Revoked ${Qe(t.revokedAt)}. Content and team links remain frozen.</p>`}</section>`}function Sa(e){if(!e._panel)return W;let t={publish:`Publish review`,reviews:`Reviews`,unsaved:`Unsaved changes`};return U`<dialog class="npm-review-dialog" aria-label="${t[e._panel]}" @cancel="${t=>{t.preventDefault(),e._closePanel()}}"><button type="button" class="detail-action npm-review-close" aria-label="Close panel" ?disabled="${e._blocked}" @click="${()=>e._closePanel()}">×</button><header class="npm-review-dialog-head"><h2>${t[e._panel]}</h2><p>${e._panel===`reviews`?`${e.entry.npm.name}@${e.entry.npm.version}${e._patch?` (patched)`:``}`:M(e._context)}</p></header>${e._panel===`publish`?ba(e,e._activeReview):U`<div class="${`npm-review-dialog-body${e._panel===`reviews`?` npm-review-entries`:``}`}">${e._panel===`unsaved`?U`${e._dirtyFiles.map(t=>U`<button type="button" class="npm-review-button" @click="${()=>{e._closePanel(),e._selectFile(t)}}">${t} ${O}</button>`)}`:sa(e).map(t=>xa(e,t))} ${e._panel===`reviews`&&sa(e).length===0?U`<p class="npm-review-muted">No reviews yet.</p>`:W}${aa(e)}</div>`} ${oa(e)}</dialog>`}function Ca(e){let t=e._shownReview?.entries,n=e._files,r=e._nonTextFiles;if(e._treeProgress?.entries!==t||e._treeProgress?.files!==n||e._treeProgress?.nonTextFiles!==r){let i=dt(t,r),a=new Map,o=0;for(let t of e._files){let e=t.split(`/`),n=+!!i.get(t)?.status;o+=n;for(let t=1;t<e.length;t++){let r=e.slice(0,t).join(`/`),i=a.get(r)??{total:0,checked:0};i.total++,i.checked+=n,a.set(r,i)}}e._treeProgress={entries:t,files:n,nonTextFiles:r,states:i,directories:a,checked:o}}let{states:i,directories:a,checked:o}=e._treeProgress;return{railLabel:`Files`,treeLabel:`Review files`,collapseLabel:`Collapse folders`,searchLabel:`Find a file`,searchPlaceholder:`Find a file…`,treePageSize:300,filterContent:!1,fullPaths:!0,collapseClearsSearch:!0,canSelect:()=>!e._blocked&&!e._panel,fileFilter:e._unchecked?e=>!i.get(e)?.status:null,fileLabel:e=>`${e}, ${Be[i.get(e)?.status]??`Not reviewed`}`,filePrefix:e=>Ue(i.get(e)?.status),fileSuffix:e=>i.get(e)?.notes?U`<span class="npm-review-note-dot" aria-label="Has notes">•</span>`:W,directoryLabel:e=>{let t=a.get(e.sourcePath);return`${e.sourcePath}, ${t?.checked??0} of ${t?.total??0} checked`},directorySummary:e=>{let t=a.get(e.sourcePath);return`${t?.checked??0}/${t?.total??0}`},filters:U`<div class="npm-review-filters" aria-label="Filter review files"><button type="button" class="npm-review-button" aria-pressed="${String(!e._unchecked)}" @click="${()=>{e._unchecked=!1}}">All ${e._files.length}</button> <button type="button" class="npm-review-button" aria-pressed="${String(!!e._unchecked)}" @click="${()=>{e._unchecked=!0}}">Unchecked ${e._files.length-o}</button></div>`,fileActions:(t,n)=>va(e,t,n),copyDiff:e._unified?.length>0?()=>e._unifiedText??=ra(e._unified):null}}function wa(e){if(!e._base){let t=U`<div class="npm-review-empty" role="${e._baseError?`alert`:`status`}">${e._baseError??`Loading comparison…`} ${e._baseError?U`<button type="button" class="npm-review-button" @click="${()=>{e._baseKey=null,e._loadBase(e._target,e.request?.resume)}}">Retry</button>`:W}</div>`;return e._baseError&&e._basePatch?U`${pa(e)}${t}`:t}return U`${pa(e)}${_a(e)}${e._panel?W:aa(e)} ${Wi({base:e._base,other:e._other,diff:e._diff,source:e.source,path:e._path,seek:e._seek,baseName:e._base.npm?`${e._base.npm.name}@${e._base.npm.version}${e._base.npmPatch?` (patched)`:``}`:`Empty package`,otherName:`${e.entry.npm.name}@${e.entry.npm.version}${e._patch?` (patched)`:``}`,select:t=>e._selectFile(t),extensions:Ca(e),mode:e._mode,viewChanged:()=>e._viewChanged()})} <span class="npm-review-announcement" role="status">${e._notice??``}</span>${e._panel?W:oa(e)}${Sa(e)}`}var Ta={maxLines:5e4,maxBytes:2097152},Ea={integrity:`(empty)`,kind:`sourcemap`,json:{version:3,sources:[],sourcesContent:[]},fileSizes:new Map},Da=(e,t,n=null)=>({ecosystem:`npm`,package:e.npm.name,version:e.npm.version,integrity:e.integrity,patchHash:n?.hash??null,basePackage:t?.npm?.name??null,baseVersion:t?.npm?.version??null,baseIntegrity:t?.npm?t.npmPatch?.integrity??t.integrity:null,basePatchHash:t?.npmPatch?.patch.hash??null}),Oa=(e,t)=>e?`${e}@${t??`latest`}`:`(empty)`,ka=class extends Xt{static properties={entry:{attribute:!1},details:{attribute:!1},request:{attribute:!1},session:{attribute:!1},source:{attribute:!1},_teams:{state:!0},_selectedTeams:{state:!0},_additionalTeams:{state:!0},_reviews:{state:!0},_loading:{state:!0},_error:{state:!0},_saving:{state:!0},_saveBlocked:{state:!0},_file:{state:!0},_seek:{state:!0},_finalStatus:{state:!0},_finalComment:{state:!0},_base:{state:!0},_baseError:{state:!0},_panel:{state:!0},_path:{state:!0},_selectedReview:{state:!0},_unchecked:{state:!0},_notice:{state:!0},_continuation:{state:!0}};createRenderRoot(){return this}constructor(){super(),this._teams=[],this._reviews=[],this._files=[],this._nonTextFiles=[],this._unified=null,this._unifiedText=null,this._selectedTeams=new Set,this._additionalTeams=new Map,this._editors=new Map,this._file=null,this._path=null,this._patch=null,this._patched=null,this._basePatch=null,this._loading=!1,this._saving=!1,this._error=null,this._context=null,this._key=null,this._controller=new AbortController,this._mode=`code`,this._panel=null,this._selectedReview=null,this._unchecked=!1,this._pendingSaves=[],this._saveBlocked=!1}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._cancelSaves(),this._dismissLoading?.(),this._key=null,this._baseKey=null}updated(){let e=this.querySelector(`dialog`);e&&!e.open&&e.showModal(),this._rememberBase()}_rememberBase(){N.bundleDetailsTab!==`review`||N.selectedBundle!==this.entry?.integrity||!this._context||!this._activeReview&&this._ownPublished.length===0&&!this._unsaved||(N.npmReview={bundle:this.entry.integrity,...this._context.basePackage?{reviewPackage:this._context.basePackage,reviewSpec:this._context.baseVersion}:{},...this._patch?{patch:this._patch}:{},...this._context.basePatchHash?{basePatch:this._context.basePatchHash}:{},started:!0,user:this.session?.id})}get _writable(){return[`triage`,`manage`,`admin`].includes(this.session?.role)&&!this.session?.viewer}get _other(){return this._patched??this.details}get _reviewer(){return this._writable&&this._teams.length>0}_ownHere(e){return e.user===this.session?.id&&j(e,this._context)}get _activeReview(){return this._reviews.find(e=>e.publishedAt===null&&this._ownHere(e))??(this._continuation&&this._continuation.review.user===this.session?.id?this._continuation.review:null)}get _ownPublished(){return this._reviews.filter(e=>e.publishedAt!==null&&this._ownHere(e)).toSorted((e,t)=>t.publishedAt-e.publishedAt)}get _shownReview(){return this._selectedReview?this._reviews.find(e=>e.id===this._selectedReview):this._activeReview??this._ownPublished[0]??null}get _canEdit(){return this._reviewer&&!this._selectedReview&&(this._activeReview!==null||this._ownPublished.length===0)}_isDirty(e,t){return!this._nonTextFiles.includes(e)&&(t.comment!==(t.edit?.comment??``)||t.status!==(t.edit?.status??``))}get _dirtyFiles(){return[...this._editors].filter(([e,t])=>this._isDirty(e,t)).map(([e])=>e)}get _blocked(){return this._saving||this._saveBlocked}get _unsaved(){return this._pendingSaves.length>0||this._dirtyFiles.length>0}get _draftStarted(){return this._canEdit&&(this._unsaved||this._activeReview&&!this._continuation||this._continuation&&this._publishRevision!=null&&!this._unchangedContinuation)}get _summary(){return pe(this._shownReview?.entries??[],this._files,this._nonTextFiles)}get _securityLimit(){return this.source?.reviewVerdictLimit?.(this.entry,this._base)??`accept`}get _allowedVerdicts(){let e=new Map((this._shownReview?.entries??[]).map(e=>[e.file,e]));if(this._canEdit)for(let[t,n]of this._editors)e.set(t,{file:t,status:n.status||null});return _e([...e.values()].filter(e=>!this._nonTextFiles.includes(e.file)),this._securityLimit)}get _needsPackageJson(){return be(this._activeReview?.entries??[],this._files,this._nonTextFiles)}get _unchangedContinuation(){let e=this._continuation?.source;return!!(e&&this._finalStatus===e.status&&this._finalComment===e.comment)}get _canPublish(){return this._canEdit&&this._panel===`publish`&&this._activeReview?.revision===this._publishRevision&&this._summary.checkedFiles>0&&!this._needsPackageJson&&!this._unchangedContinuation&&this._selectedTeams.size>0&&!this._unsaved&&this._allowedVerdicts.includes(this._finalStatus)}_location(e,t=!0,n=e===this._target?this._basePatch:null){let r=e&&e!==`(empty)`?l(e):null;return{...r?{reviewPackage:r.name,reviewSpec:r.spec}:{},...t&&this._patch?{patch:this._patch}:{},...r&&n?{basePatch:n}:{}}}_asked(e=this._context){let t=Object.fromEntries(Object.keys(this._context).map(t=>[t,e[t]??null])),n=(e===this._context?null:e.patchSource)??this._patch;return t.patchHash&&n?.repoId!=null?{...t,patchRepoId:n.repoId,patchCommit:n.commit,...n.path==null?{}:{patchPath:n.path}}:t}_navigate(e,t=e===this._target?this._basePatch:null){return this._navigateTo(d(this.entry,`review`,this._location(e,!0,t)))}async _navigateTo(e){if(this._blocked||this._loading)return;let t=this._key,n=this._navigation={};this._unsaved&&!await this._saveAll()||t===this._key&&n===this._navigation&&!this._unsaved&&await Xe?.navigate(e.bundleTab===`review`?{...e,...Ve(N)}:e)}_shownRoute(e=this._base){let t=this._location(Oa(e.npm?.name,e.npm?.version),!0,e.npmPatch?.patch.hash??null);return d(this.entry,`review`,{...t,...Ve(N)})}_viewChanged(){N.bundleDetailsTab!==`review`||N.selectedBundle!==this.entry?.integrity||!this._base||!this._context||Xe?.replaceRoute(this._shownRoute())}_baseKeyOf(e){return JSON.stringify([this.entry.integrity,e,this._patch,this._basePatch,this.session?.id,this.session?.role])}_restart(){this._controller.abort(),this._cancelSaves(),this._controller=new AbortController}async _loadBase(e,t=!1){let n=this._baseKeyOf(e);if(this._baseKey!==n){this._baseKey=n,this._base=null,this._baseError=null,this._key=null,this._restart();try{let r=this._controller.signal,i=this._patch?h(this.entry,this._patch,{signal:r}):Promise.resolve(this.details);i.catch(()=>{});let a=t?await Te(Da(this.entry,null,this._patch),r):null;if(this._baseKey!==n)return;a&&([e,this._basePatch]=[Oa(a.basePackage,a.baseVersion),a.basePatchHash??null]);let o=e===`(empty)`?null:l(e),s=o?await p(o.name,o.spec??`latest`):null,c=s&&this._basePatch?{...await h(s.entry,{hash:this._basePatch},{signal:r}),npm:s.details.npm}:s?.details??Ea,u=await i;if(this._baseKey!==n)return;let d=await En(c,u);if(this._baseKey!==n)return;t&&(a&&vt(a),this._target=e,this.request={bundle:this.entry.integrity,...this._location(e)},this._baseKey=this._baseKeyOf(e)),this._patched=this._patch?u:null,this._base=c,this._ensureContext(c,d)}catch(e){this._baseKey===n&&(this._baseError=e.message)}}}_ensureContext(e,t){let n=Da(this.entry,e,this._patch),r=JSON.stringify([this.session?.id,this.session?.role,n]);if(r===this._key)return;this._restart(),this._context=n,this._diff=t;let i=Fn(e,this._other,this._diff);this._files=_t(tt(i.map(e=>e.path)));let a=new Set(i.filter(e=>!le(e.before,e.after)).map(e=>e.path));this._nonTextFiles=this._files.filter(e=>a.has(e));let o=new Map(i.map(e=>[e.path,e]));if(this._unified=na(this._files.map(e=>o.get(e))),this._unifiedText=null,this._mode=In(i,Ta)?`diff`:`code`,this._key=r,this._teams=[],this._reviews=[],this._selectedTeams=new Set,this._additionalTeams=new Map,this._selectedReview=null,this._continuation=null,this._editors.clear(),this._path=this._files[0]??null,this._panel=null,this._notice=``,this._resetEditor(this._path),this._saving=!1,this._refresh(!0),N.bundleDetailsTab===`review`&&N.selectedBundle===this.entry.integrity){let t=Oa(e.npm?.name,e.npm?.version),n=this._location(t,!0,e.npmPatch?.patch.hash??null);N.npmReview={bundle:this.entry.integrity,...n},this._baseKey=this._baseKeyOf(t),Xe?.replaceRoute(this._shownRoute(e))}}async _refresh(e=!1){let t=this._key;for(;t===this._key&&this._pendingSaves.length>0;)if((await Promise.all(this._pendingSaves.map(e=>e.promise))).some(e=>!e))return;if(t!==this._key)return;this._dismissLoading?.();let n=this._dismissLoading=Pe(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let{reviews:n,teams:r}=await ue({...this._context,allBases:!0},null,null,this._controller.signal);if(t===this._key){let t=this._unsaved;this._reviews=n,this._teams=r,n.some(e=>e.publishedAt===null&&this._ownHere(e))&&(this._continuation=null),this._rememberBase();let i=xt(this._context),a=i&&n.find(e=>e.id===i.review.id);a?.publishedAt!=null&&(i.continueReview?this._continue(a.id,a.revision):this._selectedReview=a.id),this._selectedTeams=new Set(r.filter(t=>e?r.length===1:this._selectedTeams.has(t.id)).map(e=>e.id)),t||this._clearEditors(this._file)}}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_resetEditor(e=null){this._publishRevision=null,this._file=e,this._editorState(e)}_clearEditors(e=this._path){this._editors.clear(),this._resetEditor(e)}_editorState(e){let t=this._canEdit?this._editors.get(e):null;if(!t){let n=this._shownReview?.entries.find(t=>t.file===e&&t.status)??null,r=this._nonTextFiles.includes(e);t={edit:n,revision:this._activeReview?.revision??null,comment:r?``:n?.comment??``,status:r?``:n?.status??``},this._canEdit&&this._editors.set(e,t)}return{...t,dirty:this._isDirty(e,t)}}_editFile(e,t){!this._canEdit||this._blocked||(this._resetEditor(e),Object.assign(this._editors.get(e),t),this.requestUpdate())}_setFileStatus(e,t){if(!(this._blocked||this._nonTextFiles.includes(e)))return this._editFile(e,{status:t,...t?{}:{comment:``}}),this._saveFile(e)}_selectFile(e){this._blocked||!this._files.includes(e)||(this._path=e,this._resetEditor(e))}_openLine({path:e,line:t,query:n}){this._blocked||!this._files.includes(e)||(this._seek={path:e,line:t-1,query:n},this._selectFile(e))}_openPanel(e){this._panel=e}async _openReview(e,t=!1){if(this._blocked||this._loading)return;if(j(e,this._context)){t?this._continue(e.id,e.revision):e.publishedAt===null?this._resume():this._showPublished(e);return}let n=this._key;this._unsaved&&!await this._saveAll()||n!==this._key||(vt(e,t),await this._navigate(Oa(e.basePackage,e.baseVersion),e.basePatchHash??null))}_closePanel(){this._blocked||(this.querySelector(`dialog`)?.close(),this._panel=null)}_showPublished(e){this._selectedReview=e.id,this._panel=null,this._file=this._path}_resume(){this._selectedReview=null,this._panel=null,this._resetEditor(this._path)}async _discard(e){if(this._blocked||this._loading||!this._writable||e.user!==this.session.id||e.publishedAt!==null)return;let t=e===this._activeReview,n=this._key,r=this._controller.signal;this._saving=!0,this._error=null;try{let{confirmed:i}=await Ft({reviewTitle:M(e),signal:r});if(!i||r.aborted||n!==this._key||(await Promise.all(this._pendingSaves.map(e=>e.promise)),r.aborted||n!==this._key||!this._writable)||(e=t?this._activeReview:this._reviews.find(t=>t.id===e.id),!e||e.user!==this.session.id||e.publishedAt!==null))return;let a=e===this._continuation?.review;if(a||await xe(e.id,e.revision,this.session.csrfToken,r),r.aborted||n!==this._key)return;a||(this._reviews=this._reviews.filter(t=>t.id!==e.id)),j(e,this._context)&&(this._continuation=null,this._selectedReview=null,this._clearEditors(),this._finalStatus=null,this._finalComment=``,this._panel=null,this._ownPublished.length===0&&N.npmReview?.bundle===this.entry.integrity&&delete N.npmReview.started),this._notice=`Draft discarded.`}catch(e){n===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n===this._key&&(this._saving=!1)}}_continue(e,t){let n=this._reviews.find(n=>n.id===e&&n.revision===t&&n.publishedAt!==null&&this._ownHere(n));return!n||this._activeReview||!this._reviewer?null:(this._continuation={source:n,review:{...n,publishedAt:null,revokedAt:null,status:null,teams:[]}},this._selectedTeams=new Set(this._teams.length===1?this._teams.map(e=>e.id):[]),this._selectedReview=null,this._panel=null,this._clearEditors(),this._notice=`A new draft will be saved when you make a change.`,this._activeReview)}async _persistContinuation(e){let t=this._continuation,n=this._key,{review:r}=await ue(this._asked(),{action:`continue`,reviewId:t.source.id,revision:t.source.revision},this.session.csrfToken,this._controller.signal);return n!==this._key||this._continuation!==t||e&&this._pendingSaves[0]!==e?null:(this._acceptSave(r,{revision:t.source.revision}),r)}_cancelSaves(){for(let e of this._pendingSaves)clearTimeout(e.timer),e.resolve(null);this._pendingSaves=[],this._saveBlocked=!1}_queueSave(e){let t=this._pendingSaves.findLast(t=>t.change.file===e.file);if(t&&t.change.comment===e.comment&&t.change.status===e.status)return t.promise;let n={change:e,slow:!1};return n.promise=new Promise(e=>{n.resolve=e}),n.timer=setTimeout(()=>{n.slow=!0,this._saveBlocked=!0},3e3),this._pendingSaves.push(n),this.requestUpdate(),this._pendingSaves.length===1&&this._flushSaves(),n.promise}_putReview(e){this._reviews=[...this._reviews.filter(t=>t.id!==e.id),e]}_acceptSave(e,t){this._putReview(e),this._continuation=null;for(let[n,r]of this._editors)r.revision===t.revision&&(r.revision=e.revision,r.edit=e.entries.find(e=>e.file===n&&e.status)??null);for(let{change:n}of this._pendingSaves.slice(1))n.revision===t.revision&&(n.revision=e.revision,n.reviewId=e.id,n.entryId=e.entries.find(e=>e.file===n.file)?.id??null);this._canEdit&&this._resetEditor(this._file),this._notice=`Saved privately.`,this._rememberBase()}async _flushSaves(){for(;this._pendingSaves.length>0;){let e=this._pendingSaves[0];this._error=null;try{if(this._continuation){let t=await this._persistContinuation(e);if(!t||this._pendingSaves[0]!==e)return;Object.assign(e.change,{reviewId:t.id,revision:t.revision,entryId:t.entries.find(t=>t.file===e.change.file)?.id??null})}let{review:t}=await ue(this._asked(),e.change,this.session.csrfToken,this._controller.signal);if(this._pendingSaves[0]!==e)return;this._acceptSave(t,e.change),clearTimeout(e.timer),this._pendingSaves.shift(),e.resolve(t),this._saveBlocked=this._pendingSaves.some(e=>e.slow),this.requestUpdate()}catch(t){if(this._pendingSaves[0]!==e)return;this._cancelSaves(),t.name!==`AbortError`&&(this._error=t.message),this.requestUpdate();return}}}async _change(e){if(this._blocked||this._pendingSaves.length>0||this._loading||!this._writable)return null;if(e.action===`continue`)return this._continue(e.reviewId,e.revision);let t=this._key;this._saving=!0,this._error=null;try{if(e.action===`publish`&&e.finalStatus&&this._continuation){let t=await this._persistContinuation();if(!t)return null;e={...e,reviewId:t.id,revision:t.revision}}let n=this._reviews.find(t=>t.id===e.reviewId)??this._context,{review:r}=await ue(this._asked(n),e,this.session.csrfToken,this._controller.signal);return t===this._key?(this._putReview(r),e.action===`publish`&&e.finalStatus&&j(r,this._context)&&(this._selectedReview=r.id,this._panel=null,this._editors.clear(),this._notice=`Published. Verdicts and notes are now frozen.`),this._rememberBase(),r):null}catch(e){return t===this._key&&e.name!==`AbortError`&&(this._error=e.message),null}finally{t===this._key&&(this._saving=!1)}}_saveFile(e){if(!this._canEdit||this._saving||this._loading)return null;let t=this._editorState(e),n=this._pendingSaves.some(t=>t.change.file===e),r=this._activeReview;return!t.dirty&&!n?r:!t.status&&!t.comment.trim()&&!t.edit?.id&&!n?(this._editors.delete(e),e===this._file&&this._resetEditor(e),r):this._queueSave({action:`save`,reviewId:r?.id??null,revision:t.revision,entryId:t.edit?.id??null,file:e,comment:t.comment,status:this._nonTextFiles.includes(e)?null:t.status||null})}async _saveAll(){let e=this._key;for(;e===this._key&&this._canEdit;){if(this._pendingSaves.length>0){if((await Promise.all(this._pendingSaves.map(e=>e.promise))).some(e=>!e))return!1;continue}let e=this._dirtyFiles;if(e.length===0)return!0;if(!await this._saveFile(e[0]))return!1}return!1}async _beginPublish(){if(!this._canEdit||this._saving||this._loading||this._finalizing||!this._summary.checkedFiles)return;let e=this._key;this._finalizing=!0;try{if(this._unsaved&&!await this._saveAll()||e!==this._key||!this._canEdit||this._unsaved||!this._summary.checkedFiles)return;let t=this._activeReview;if(!t)return;let n=this._allowedVerdicts,r=this._continuation?.source.status;this._finalStatus=n.includes(r)?r:n[0],this._finalComment=t.comment??``,this._publishRevision=t.revision,this._panel=`publish`}finally{this._finalizing=!1}}_publish(){if(this._canPublish)return this._change({action:`publish`,reviewId:this._activeReview.id,revision:this._publishRevision,teamIds:[...this._selectedTeams],finalStatus:this._finalStatus,finalComment:this._finalComment})}render(){if(!this.entry?.npm||!this.details)return W;let e=this.request?.bundle===this.entry.integrity?this.request:{};return this._target=Oa(e.reviewPackage,e.reviewSpec),JSON.stringify(e.patch??null)!==JSON.stringify(this._patch)&&(this._patch=e.patch??null),this._basePatch=e.basePatch??null,this._loadBase(this._target,e.resume),wa(this)}};customElements.define(`npm-review`,ka);var Aa=e=>({view:`npm`,packageName:e.package,packageSpec:e.version,bundleTab:`review`,...e.basePackage===null?{}:{reviewPackage:e.basePackage,reviewSpec:e.baseVersion},...Kt(e.patchHash)&&e.patchSource?{patch:{hash:e.patchHash,...e.patchSource}}:{},...Kt(e.basePatchHash)&&e.basePackage!==null?{basePatch:e.basePatchHash}:{}}),ja=e=>{let t=new Date(e);return U`<time class="dependency-review-date" datetime="${t.toISOString()}" data-tooltip="${t.toLocaleString()}">${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,...t.getFullYear()===new Date().getFullYear()?{}:{year:`numeric`}})} <span>${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}</span></time>`},Ma=class extends Xt{static properties={session:{attribute:!1},team:{attribute:!1},_reviews:{state:!0},_loading:{state:!0},_error:{state:!0},_next:{state:!0},_discarding:{state:!0},_expanded:{state:!0}};constructor(){super(),this._reviews=[],this._next=null,this._expanded=new Set,this._controller=new AbortController}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._dismissLoading?.(),this._key=null}_canDiscard(e){return e.publishedAt===null&&e.user===this.session?.id&&[`triage`,`manage`,`admin`].includes(this.session?.role)}async _discard(e){if(!this._canDiscard(e)||this._discarding||this._loading)return;let t=this._key,n=this._controller.signal;this._discarding=e.id,this._error=null;try{let{confirmed:r}=await Ft({reviewTitle:M(e),signal:n});if(!r||n.aborted||t!==this._key||!this._canDiscard(e)||(await xe(e.id,e.revision,this.session.csrfToken,n),t!==this._key||n.aborted))return;this._reviews=this._reviews.filter(t=>t.id!==e.id)}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{t===this._key&&(this._discarding=null)}}async _load(e=!1){let t=this._key;this._dismissLoading?.();let n=this._dismissLoading=Pe(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let n=e?this._next:null,{reviews:r,next:i}=await(this.team?ve(this.team,n,this._controller.signal):me(n,this._controller.signal));if(t!==this._key)return;this._reviews=[...new Map([...e?this._reviews:[],...r].map(e=>[e.id,e])).values()],this._next=i}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_toggleDetails(e){let t=new Set(this._expanded);t.delete(e)||t.add(e),this._expanded=t}_details(e){let t=e.entries.filter(e=>e.status);return U`<section id="${`review-details-${e.id}`}" class="dependency-review-details" aria-label="${`Details for ${M(e)}`}">${e.comment?U`<div class="dependency-review-final-note" role="note" aria-label="Final note">${A(e.comment)}</div>`:W} ${t.length>0?U`<ul class="dependency-review-entries">${t.map(e=>U`<li>${it(e.file)} ${Ge(e.status)}<div>${A(e.comment)}</div></li>`)}</ul>`:U`<p class="npm-review-muted">No file reviews yet.</p>`}</section>`}_row(e){let t=Aa(e),n=this._expanded.has(e.id),r=e.publishedAt!==null,i=new Set(e.entries.filter(e=>e.status).map(e=>e.file)).size,a=e.entries.filter(e=>e.status&&e.comment.trim()).length+ +!!e.comment.trim(),o=e.teams.filter(e=>e.id!==this.team).map(e=>e.name).join(`, `),s=o&&this.team?`also ${o}`:o,c=n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||!Xe?.active||(n.preventDefault(),vt(e),Xe.navigate(t))};return U`<li class="${`dependency-review-row${n?` is-expanded`:``}${e.revokedAt===null?``:` is-revoked`}`}"><div class="dependency-review-row-main"><a class="dependency-review-title" href="${Jt(t)}" @click="${c}">${Pt(e.ecosystem)} ${e.basePackage!==null&&e.basePackage!==e.package?U`<span>${e.basePackage} ${e.baseVersion} →</span>`:W} <strong>${e.package}</strong> <span>${e.basePackage===e.package?`${e.baseVersion} \u2192 `:``}${e.version}${e.patchHash?U`<span class="dependency-review-patched">patch:${e.patchHash}</span>`:W}</span></a> <span class="dependency-review-result">${r?Ge(e.status):U`<span class="dependency-review-checked">${i} ${i===1?`file`:`files`} checked</span>`}</span> <button type="button" class="dependency-review-coverage" aria-expanded="${n}" aria-controls="${`review-details-${e.id}`}" data-tooltip="${r?`${e.checkedFiles} of ${e.totalFiles} files checked`:W}" @click="${()=>this._toggleDetails(e.id)}">${r?U`${nt(e)} · ${e.checkedFiles}/${e.totalFiles}`:a?ot(a):`No notes`}</button> ${this.team?U`<span class="dependency-review-author">${Ye(e)}</span>`:W} <span class="dependency-review-meta">${r&&s?U`<span class="dependency-review-teams" data-tooltip-truncated data-tooltip="${s}">${s}</span>`:W} ${r&&a>0?U`<span class="dependency-review-note-count">${ot(a)}</span>`:W} ${e.revokedAt===null?W:qe(e)}</span> ${ja(e.publishedAt??e.time)}<div class="dependency-review-row-actions">${this.team?W:U`<dependency-review-copy .text="${e.formatted}"></dependency-review-copy>`} ${this._canDiscard(e)?ct(this._loading||!!this._discarding,()=>this._discard(e)):W} <a class="dependency-review-open" href="${Jt(t)}" @click="${c}" aria-label="${`${r?`Open`:`Continue`} review for ${M(e)}`}"><span aria-hidden="true">→</span></a></div></div>${n?this._details(e):W}</li>`}render(){let e=JSON.stringify([this.session?.id,this.session?.role,this.team??null]);e!==this._key&&(this._controller.abort(),this._controller=new AbortController,this._key=e,this._reviews=[],this._next=null,this._discarding=null,this._expanded=new Set,this._load());let t=this._error?U`<p role="alert">${this._error}</p>`:W,n=!this._loading&&!this._error&&this._reviews.length===0,r=this._next?U`<button type="button" class="npm-review-button" ?disabled="${this._loading||!this.team&&!!this._discarding}" @click="${()=>this._load(!0)}">Load more</button>`:W;return this.team?U`<section class="dependency-review-list is-team">${t} ${n?U`<p class="npm-review-muted">No reviews are published to this team yet.</p>`:W}<ol>${this._reviews.map(e=>this._row(e))}</ol>${r}</section>`:U`<section class="dependency-review-list"><header><h1>My reviews</h1></header><p>Your private work and the reviews you’ve shared with teams.</p>${t} ${n?U`<p>No reviews yet. Open a package’s Review tab to begin.</p>`:W} ${[[`Drafts`,!1],[`Published reviews`,!0]].map(([e,t])=>{let n=this._reviews.filter(e=>e.publishedAt!==null===t);return U`<section class="dependency-review-section"><h2>${e}<span class="npm-review-count">${n.length}</span></h2><ol>${n.map(e=>this._row(e))}</ol>${n.length===0&&!this._loading?U`<p class="npm-review-muted">${t?`No published reviews yet.`:`No drafts.`}</p>`:W}</section>`})} ${r}</section>`}};customElements.define(`dependency-review-list`,Ma);
|