@preventive/triage 1.0.0-alpha.61 → 1.0.0-alpha.63
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/out/activity.js +3 -3
- package/out/brotli-fallback.js +1 -1
- package/out/{chunk-BNH52UHC.js → chunk-24AKGEH3.js} +2 -2
- package/out/chunk-4ISO5F7Y.js +1 -1
- package/out/{chunk-W6VOKW2N.js → chunk-65PLAG3I.js} +2 -2
- package/out/{chunk-JJK5OZG2.js → chunk-7GJNLCXF.js} +6 -6
- package/out/{chunk-OFZYEWBH.js → chunk-BZP3CT2V.js} +16 -16
- package/out/{chunk-QCOGVL37.js → chunk-DCBXCBLL.js} +2 -2
- package/out/chunk-E3LFSUDJ.js +1 -1
- package/out/{chunk-BRO77PQY.js → chunk-F3UI65ZI.js} +2 -2
- package/out/chunk-FAG6E5RC.js +3 -0
- package/out/chunk-HAZKDK4M.js +1 -1
- package/out/chunk-IZ6MYRYB.js +1 -1
- package/out/{chunk-B3FNMHOE.js → chunk-K2QJLP3E.js} +1 -1
- package/out/chunk-NXATZJQ2.js +1 -1
- package/out/{chunk-GRGIZOTP.js → chunk-OGNTXZYM.js} +1 -1
- package/out/chunk-QRKFPLA4.js +2 -2
- package/out/{chunk-ZQNEWVGG.js → chunk-QVKFY4FA.js} +1 -1
- package/out/chunk-TOXMUOIW.js +2 -2
- package/out/chunk-WL3SPQB4.js +1 -0
- package/out/chunk-WMFDQS2L.js +2 -2
- package/out/chunk-Y5ZHFNBD.js +1 -1
- package/out/client-managed-import.js +1 -1
- package/out/client-managed.js +6 -6
- package/out/client-sync.js +3 -3
- package/out/compare.js +4 -4
- package/out/dialogs.js +11 -11
- package/out/graph.js +5 -5
- package/out/index.html +5 -5
- package/out/prism.js +2 -2
- package/out/scan.js +2 -2
- package/out/terminal.js +146 -144
- package/out/view.js +5 -5
- package/package.json +15 -15
- package/risk/files/runs-code.js +2 -2
- package/server-e2e/static.ts +1 -1
- package/server-managed/bundle-build.ts +8 -4
- package/server-managed/http.ts +2 -2
- package/server-managed/type-only.ts +21 -1
- package/strip-types-loader.js +13 -10
- package/out/chunk-OIERSXON.js +0 -1
- package/out/chunk-W3QFV4SP.js +0 -3
package/out/chunk-TOXMUOIW.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as e,e as t}from"./chunk-PAD2JHZT.js";import{A as n,B as r,C as i,E as a,F as o,G as s,H as c,M as l,O as u,Q as ee,S as d,a as f,d as p,e as m,f as te,i as ne,m as h,n as g,o as re,p as ie,q as _,r as v,u as ae,v as oe,x as y,z as se}from"./chunk-UCP3JRE2.js";import"./chunk-ZQHLECTI.js";import"./chunk-PXK7EU4V.js";import{d as b,e as ce,f as x,g as le,h as S,i as C,j as ue,l as de,m as fe}from"./chunk-JMG5DXII.js";import"./chunk-OOJM4CTU.js";function w(e,t=new Set){if(t.has(e))return;t.add(e);let{parent:n}=e;if(n===void 0)return;let r=w(n,t);return r===void 0?n.bundleDependencies?.includes(e.folder)||e.edgesIn.some(e=>w(e.from,t)===n)?n:void 0:r}var pe=({parent:e})=>e!==void 0&&(e.bundleDependencies!==void 0||pe(e)),me=e=>pe(e)?w(e):void 0;function he(e,t){let n=me(e);return n!==void 0&&n!==t}function ge(e,t){let n=me(e);if(e.inBundle!==(n!==void 0))throw new b(n===void 0?`set, where nothing bundles it`:`expected true, as ${S(n.location)} bundles it`,C(e.where,`inBundle`));let{resolution:r}=e;if(n===void 0||n===t){if(r===void 0)throw new b(`expected where it comes from, resolved or an integrity`,e.where)}else if(r!==void 0){let t=r.type===`git`||r.tarball!==void 0?`resolved`:`integrity`;throw new b(`npm takes it from the tarball of ${S(n.location)}, and from nothing else`,C(e.where,t))}}function _e(e){let t=e.get(``);for(let n of e.values())n.kind===`package`&&ge(n,t)}var T=e=>e?.endsWith(`.git`)?e.slice(0,-4):e;function E(e,t,n){let r=T(t);return e&&r?{user:e,project:r,committish:n}:void 0}var ve=e=>t=>{let[,n,r,i]=t.pathname.split(`/`,4);return i===e?void 0:E(n,r,t.hash.slice(1))},D={__proto__:null,github:{protocols:[`git:`,`http:`,`git+ssh:`,`git+https:`,`ssh:`,`https:`],domain:`github.com`,extract:e=>{let[,t,n,r,i]=e.pathname.split(`/`,5);if(!(r&&r!==`tree`))return E(t,n,r?i:e.hash.slice(1))}},bitbucket:{protocols:[`git+ssh:`,`git+https:`,`ssh:`,`https:`],domain:`bitbucket.org`,extract:ve(`get`)},gitlab:{protocols:[`git+ssh:`,`git+https:`,`ssh:`,`https:`],domain:`gitlab.com`,extract:e=>{let t=e.pathname.slice(1);if(t.includes(`/-/`)||t.includes(`/archive.tar.gz`))return;let n=t.split(`/`),r=n.pop();return E(n.join(`/`),r,e.hash.slice(1))}},gist:{protocols:[`git:`,`git+ssh:`,`git+https:`,`ssh:`,`https:`],domain:`gist.github.com`,extract:e=>{let[,t,n,r]=e.pathname.split(`/`,4);if(r!==`raw`&&(t||n))return{user:n?t:null,project:T(n||t),committish:e.hash.slice(1)}}},sourcehut:{protocols:[`git+ssh:`,`https:`],domain:`git.sr.ht`,extract:ve(`archive`)}},ye=new Map(Object.entries(D).map(([e,t])=>[t.domain,e])),be=new Map(Object.keys(D).map(e=>[`${e}:`,e])),xe=new Set([`git+ssh:`,`ssh:`,`git+https:`,`git:`,`http:`,`https:`,`git+http:`,...be.keys()]);function Se(e){let t=e.indexOf(`#`),n=e=>e===-1||t>-1&&e>t,r=e.indexOf(`/`);return n(e.search(/\s/u))&&r>0&&(t>-1?e[t-1]!==`/`:!e.endsWith(`/`))&&!e.startsWith(`.`)&&n(e.indexOf(`@`))&&n(e.indexOf(`:`))&&n(e.indexOf(`/`,r+1))}var O=(e,t,n)=>{let r=e.indexOf(n);return e.lastIndexOf(t,r>-1?r:1/0)};function Ce(e){let t=e.indexOf(`:`);if(xe.has(e.slice(0,t+1))||e.slice(t,t+3)===`://`)return e;let n=e.indexOf(`@`);return n>-1?n>t?`git+ssh://${e}`:e:`${e.slice(0,t+1)}//${e.slice(t+1)}`}function we(e){let t=e,n=O(t,`:`,`#`);return n>O(t,`@`,`#`)&&(t=`${t.slice(0,n)}/${t.slice(n+1)}`),O(t,`:`,`#`)===-1&&!t.includes(`//`)&&(t=`git+ssh://${t}`),t}var k=e=>e&&decodeURIComponent(e);function Te(e){let t=e.pathname.startsWith(`/`)?e.pathname.slice(1):e.pathname,n=t.indexOf(`@`);n>-1&&(t=t.slice(n+1));let r=t.lastIndexOf(`/`),i=T(k(t.slice(r+1)));return{user:r>-1&&k(t.slice(0,r))||null,project:i,committish:k(e.hash.slice(1))||null}}function A(e){if(!e)return;let t=Ce(Se(e)?`github:${e}`:e),n=URL.parse(t)??URL.parse(we(t));if(n===null)return;let r=be.get(n.protocol),i=r??ye.get(n.hostname.replace(/^www\./u,``));if(i!==void 0)try{if(r!==void 0)return{type:i,...Te(n)};if(!D[i].protocols.includes(n.protocol))return;let e=D[i].extract(n);return e===void 0?void 0:{type:i,user:k(e.user),project:k(e.project),committish:k(e.committish)||null}}catch(e){if(e instanceof URIError)return;throw e}}function Ee({type:e,user:t,project:n,committish:r},i){let a=i&&r?`#${r}`:``;return e===`gist`?`git@${D[e].domain}:${n}.git${a}`:`git@${D[e].domain}:${t}/${n}.git${a}`}var De=/^(?:[Gg][Ii][Tt]\+)?[A-Za-z]+:/u,Oe=/^[^@]+@[^.:]+\.[^:]+:.+$/iu,j=/\.(?:tgz|tar\.gz|tar)$/iu,ke=e=>j.test(e),M=/^git(?:\+(?:https?|rsync|ftp|ssh))?:/u,N=(e,t)=>new b(`${S(e)} is ${t}`);function Ae(e,t){let n=j.test(e)?`file`:`directory`;if(/^file:/iu.test(e)&&!e.startsWith(`file:`))throw N(e,`a path whose "file:" npm reads in another case otherwise`);let r=e.startsWith(`file:`)?e.slice(5):e;if(/^(?:[/~]|[A-Za-z]:)/u.test(r))throw N(e,`a path from the root, a drive or the home directory, which a lockfile does not hold`);return{type:n,path:o(t,r)}}function P(e,t){let n={committish:null,range:null};for(let r of t?t.split(`::`):[]){let[t,i]=r.includes(`:`)?r.split(`:`):[void 0,r];if(t===`path`)throw N(e,`a subdirectory of a repository, which is not supported`);if(t!==void 0&&t!==`semver`)throw N(e,`a git spec with ${S(t)}, which npm passes over`);if(n.committish!==null||n.range!==null)throw N(e,`a git spec with two refs or ranges, which npm refuses`);t===void 0?n.committish=i:n.range=je(e,i)}return n}var je=(e,t)=>x(()=>decodeURIComponent(t),()=>{throw N(e,`a git spec npm cannot decode`)});function Me(e){let t=e.startsWith(`git+ssh:`)?/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/iu.exec(e):null;if(t!==null&&!/:\d+(?:\/|$)/u.test(t[1]))return{type:`git`,hosted:void 0,fetchSpec:t[1],...P(e,t[2])};let n=URL.parse(e);if(n===null)throw N(e,`not a URL npm reads`);if(n.protocol===`http:`||n.protocol===`https:`)return{type:`remote`,url:e};if(!M.test(n.protocol))throw N(e,`of a protocol npm does not read, ${S(n.protocol)}`);let r=P(e,n.hash.slice(1));return n.hash=``,{type:`git`,hosted:void 0,fetchSpec:n.href.replace(/^git\+/u,``),...r}}function Ne(e,t,n){let r=t.trim();if(n===void 0)return{type:`registry`,name:e,fetchSpec:r,kind:void 0};let i=`tag`;if(n.valid(r,!0)===null?n.validRange(r,!0)!==null&&(i=`range`):i=`version`,i===`tag`&&encodeURIComponent(r)!==r)throw N(t,`a tag npm refuses, of a character a URL escapes`);return{type:`registry`,name:e,fetchSpec:r,kind:i}}function F(e,t,n,r){if(/^(?:file:|[.]|~\/|\/|[A-Za-z]:)/iu.test(t))return Ae(t,n);if(/^npm:/iu.test(t))return Fe(t,n,r);let i=A(t);return i===void 0?De.test(t)?Me(t):t.includes(`/`)||j.test(t)?Ae(t,n):Ne(e,t,r):{type:`git`,hosted:i,fetchSpec:void 0,...P(t,i.committish)}}function Pe(e,t,n){let r=e.indexOf(`@`,1),i=r>0?e.slice(0,r):e;return De.test(e)?F(void 0,e,t,n):Oe.test(e)?F(void 0,`git+ssh://${e}`,t,n):!i.startsWith(`@`)&&(i.includes(`/`)||j.test(i))?F(void 0,e,t,n):F(y(i,void 0),r>0&&e.slice(r+1)||`*`,t,n)}function Fe(e,t,n){let r=Pe(e.slice(4),t,n);if(r.type===`alias`)throw N(e,`an alias of an alias, which npm refuses`);if(r.type!==`registry`||r.name===void 0)throw N(e,`an alias of no package of the registry, which npm refuses`);return{type:`alias`,sub:r}}var I=(e,t,n,r)=>F(e,t||`*`,n,r),Ie=e=>F(void 0,e,`.`,void 0),L=[`dev`,`optional`,`devOptional`,`peer`],Le=[`name`,`version`,`dependencies`,`optionalDependencies`,`peerDependencies`,`peerDependenciesMeta`,`bundleDependencies`,`acceptDependencies`,`funding`,`engines`,`os`,`cpu`,`libc`,`license`,`hasInstallScript`,`bin`,`deprecated`,`workspaces`,...L],Re={link:[`link`,`resolved`],importer:[...Le,`devDependencies`],package:[...Le,`resolved`,`integrity`,`inBundle`]},ze={hasShrinkwrap:`a shrinkwrap of its own, which is not supported`,extraneous:`nothing leads to it, and npm prunes it rather than install it`};function R(e,t){if(typeof e==`object`&&e&&Object.keys(e).length===0)throw new b(`expected what npm writes, which leaves an empty ${Array.isArray(e)?`sequence`:`mapping`} out`,t);return e}var Be=e=>(t,n)=>ie(R(t,n),n,e),z=(e,t)=>_(R(e,t),t,y),Ve=(e,t)=>y(g(e,t),t),He=(e,t)=>re(R(e,t),t,y),B=(e,t)=>re(R(e,t),t),V=e=>(t,n)=>Array.isArray(t)?B(t,n):e(t,n),Ue=Be((e,t,n)=>(y(n,t),{optional:h(m(e,t),`optional`,t,ne)??!1}));function We(e,t){return typeof e==`string`?g(e,t):(m(R(e,t),t),{type:h(e,`type`,t,g),url:h(e,`url`,t,g)})}var Ge=(e,t)=>Array.isArray(e)?R(e,t).map((e,n)=>We(e,`${t}[${n}]`)):We(e,t);function Ke(e,t,i){if(!n(i)||/[/:]/u.test(i))throw new b(`${S(i)} is not the name of a bin, as npm writes one`,t);if(!r(g(e,t).replace(/\/$/u,``)))throw new b(`${S(e)} is not a path within the package, as npm writes a bin's`,t);return e}var qe=V((e,t)=>(m(R(e,t),t,[`packages`,`nohoist`]),h(e,`nohoist`,t,B),B(e.packages,C(t,`packages`)))),Je={__proto__:null,dependencies:z,optionalDependencies:z,peerDependencies:z,devDependencies:(e,t)=>_(e,t,y),peerDependenciesMeta:Ue,acceptDependencies:z,bundleDependencies:He,funding:Ge,engines:V((e,t)=>_(R(e,t),t)),os:B,cpu:B,libc:B,license:V(g),bin:Be(Ke),deprecated:g,workspaces:qe};function Ye(e,t){let n=Object.fromEntries(L.map(n=>[n,v(e[n],C(t,n))]));if(n.devOptional&&(n.dev||n.optional))throw new b(`set beside dev or optional, where npm leaves it out`,C(t,`devOptional`));return n}var Xe=(e,t)=>u(e,t)&&e;function Ze(e,t,n,r){if(e.startsWith(`file:`)){if(!ke(e))throw new b(`${S(e)} is a directory, which npm packs again at every install: not supported`,r);i(e.slice(5),r);return}if(!ee(e))throw new b(`${S(e)} is not an http(s) URL, a file: tarball or a git URL`,r);if(A(e)!==void 0)throw new b(`${S(e)} is a repository to npm, which it reads as one on a git host`,r);d(e,t,n,r)}function Qe(e,t,n,r){let i=C(t,`resolved`),a=h(e,`resolved`,t,g),o=h(e,`integrity`,t,Xe);if(a===void 0)return o===void 0?void 0:{type:`tarball`,tarball:void 0,integrity:o};if(M.test(a)){if(o!==void 0)throw new b(`an integrity, which npm does not check for a git repository`,C(t,`integrity`));let e=a.lastIndexOf(`#`);if(e===-1||!c(a.slice(e+1)))throw new b(`expected a full commit hash after the "#" of ${S(a)}`,i);return{type:`git`,repo:l(a.slice(0,e),i),commit:a.slice(e+1)}}if(Ze(a,n,r,i),o===void 0)throw new b(`expected an integrity, which npm checks the tarball with`,t);return{type:`tarball`,tarball:a,integrity:o}}function $e(e){let t=e.split(`/`),n=t.at(-1);return t.at(-2)?.startsWith(`@`)?`${t.at(-2)}/${n}`:n}function et(e,t){if(m(e,t,Re.link,ze),e.link!==!0)throw p(`true`,e.link,C(t,`link`));return e.resolved===``?``:i(e.resolved,C(t,`resolved`))}function tt(e,t,n,r){m(e,t,Re[n],ze);let i=Object.create(null);for(let[n,r]of Object.entries(Je))i[n]=h(e,n,t,r);if(n===`importer`&&r!==void 0&&i.bundleDependencies!==void 0)throw new b(`a bundle of a directory, which is not supported`,C(t,`bundleDependencies`));let a=h(e,`name`,t,Ve);if(a!==void 0&&a===r)throw new b(`the name of its folder, which npm leaves out`,C(t,`name`));let o=h(e,`version`,t,n===`package`?se:g);if(n===`package`&&o===void 0&&!M.test(e.resolved??``))throw new b(`expected a version, which only a package from a git repository is read without`,C(t,`version`));let s={name:a??r,version:o,...i,hasInstallScript:v(e.hasInstallScript,C(t,`hasInstallScript`)),flags:Ye(e,t)};return n===`package`&&(s.resolution=Qe(e,t,s.name,o),s.inBundle=v(e.inBundle,C(t,`inBundle`))),s}var H=`packages`,nt=/^(?:(.+)\/)?node_modules\/((?:@[^/]+\/)?[^/]+)$/u;function rt(e,t){if(e===``)return{kind:`root`,parent:void 0,folder:void 0};i(e,t);let n=nt.exec(e);if(n!==null){if(n[2]===`node_modules`)throw new b(`a folder named "node_modules", which no package is`,t);return{kind:`package`,parent:n[1]??``,folder:y(n[2],t)}}let r=e.split(`/`);if(r.includes(`node_modules`))throw new b(`in a node_modules, but none of its packages`,t);if(r.every(e=>e===`..`))throw new b(`a directory the project is in, which is not supported`,t);return{kind:`importer`,parent:void 0,folder:$e(e)}}function it(e,t,n){let{kind:r,parent:i,folder:a}=rt(e,n),o={location:e,where:n,kind:r,parentLocation:i,folder:a,parent:void 0,fsParent:void 0,children:new Map,links:[],edges:new Map,edgesIn:[]};if(t?.link===void 0)return Object.assign(o,tt(t,n,r===`package`?`package`:`importer`,a));if(r!==`package`)throw new b(`a link outside a node_modules, where npm writes none`,n);return Object.assign(o,{kind:`link`,targetLocation:et(t,n),target:void 0})}function at(e,t){let n=t.get(e.parentLocation);if(n===void 0)throw new b(`in the node_modules of ${S(e.parentLocation)}, which the lockfile does not have`,e.where);if(n.kind===`link`)throw new b(`in the node_modules of ${S(e.parentLocation)}, a link, in which npm installs nothing`,e.where);let r=e.folder.toLowerCase(),i=n.children.get(r);if(i!==void 0)throw new b(`in the folder of ${S(i.location)} to npm, which takes names in one case`,e.where);n.children.set(r,e),e.parent=n}function ot(e,t){let n=t.get(e.targetLocation),r=C(e.where,`resolved`);if(n===void 0)throw new b(`${S(e.targetLocation)} is not in the lockfile, where npm looks for what a link leads to`,r);if(n.kind===`link`)throw new b(`${S(e.targetLocation)} is a link, where npm links the project, a directory or a package`,r);e.target=n,n.links.push(e)}function st(e,t){let n=e.location.split(`/`);for(;n.pop()!==void 0&&n.at(-1)!==`..`;){let e=t.get(n.join(`/`));if(e!==void 0)return e}}var U=e=>e.parent??e.fsParent,W=e=>e.kind===`link`?e.target:e,G=e=>e.location||`.`;function ct(e,t){let n=t.toLowerCase();for(let t=e;t!==void 0;t=U(t)){let e=t.children.get(n);if(e!==void 0)return e}}function lt(e){let t=new Map;for(let[n,r,i]of te(e,H))t.set(n,it(n,r,i));t.has(``)||t.set(``,it(``,Object.create(null),C(H,``)));for(let e of t.values())e.parentLocation!==void 0&&at(e,t),e.kind===`link`&&ot(e,t);for(let e of t.values())if(e.kind===`importer`){if(e.links.length===0)throw new b(`a directory no link leads to, of which npm installs nothing`,e.where);e.fsParent=st(e,t)}return t}function ut(n){let r=n.get(``),i=C(r.where,`workspaces`),a=new Map;for(let[o,s]of(r.workspaces??[]).entries()){let r=e(s.replace(/^\.?\/+/u,``),`${i}[${o}]`);for(let e of n.values()){if(e.kind!==`importer`||a.get(e.name)===e||!t(r,e.location))continue;let n=y(e.name,C(e.where,`name`));if(a.has(n))throw new b(`the name of the workspace ${S(a.get(n).location)} too, of which npm keeps one`,e.where);a.set(n,e)}}return a}var dt={__proto__:null,workspace:`workspaces`,peer:`peerDependencies`,peerOptional:`peerDependencies`,prod:`dependencies`,optional:`optionalDependencies`,dev:`devDependencies`},ft=e=>e.type===`workspace`?C(e.from.where,`workspaces`):C(C(e.from.where,dt[e.type]),e.name);function pt(e,t,n){let r=(t,n,r)=>{let i=t.toLowerCase(),a=e.edges.get(i);if(a?.type===`workspace`)return;let o={name:t,type:n,spec:r,accept:e.acceptDependencies?.[t],from:e,to:void 0};if(a!==void 0&&a.name!==t)throw new b(`${S(a.name)} too, to npm, which takes names in one case`,ft(o));e.edges.delete(i),e.edges.set(i,o)};if(e.kind===`root`)for(let[e,{location:n}]of t)r(e,`workspace`,`file:${n}`);let i=e.peerDependenciesMeta??Object.create(null),a=n?[]:Object.entries(e.peerDependencies??{});for(let[e,t]of a)i[e]?.optional||r(e,`peer`,t);for(let[e,t]of a)i[e]?.optional&&r(e,`peerOptional`,t);for(let t of e.parent===void 0?[`prod`,`optional`,`dev`]:[`prod`,`optional`])for(let[n,i]of Object.entries(e[dt[t]]??{}))r(n,t,i)}function mt(e,t,n){for(let r of e.values())r.kind!==`link`&&pt(r,t,n);for(let t of e.values())for(let e of t.edges.values())e.to=ct(t,e.name),e.to?.edgesIn.push(e)}var K=[...L,`extraneous`],ht=e=>new Map([...e.values()].map(e=>[e,Object.fromEntries(K.map(t=>[t,e.kind!==`root`]))]));function gt(e,t,n){if(!e.get(t)[n])for(let r=U(t);r!==void 0&&e.get(r)[n];r=U(r))e.get(r)[n]=!1}function _t(e,t){let[n,r,i]=[t===`dev`,t===`optional`||t===`peerOptional`,t.startsWith(`peer`)];return{extraneous:!e.extraneous&&!(i&&r),dev:!e.dev&&!n,optional:!e.optional&&!r,devOptional:!e.devOptional&&!e.dev&&!e.optional&&!n&&!r,peer:!e.peer&&!i}}function vt(e,t){let n=ht(e),r=new Set,i=[e.get(``)];for(;i.length>0;){let e=i.pop();r.add(e);let a=n.get(e);if(gt(n,e,`extraneous`),e.kind===`link`){let o=n.get(e.target),s=K.filter(e=>o[e]&&!a[e]);if(t)Object.assign(o,a);else for(let e of s)o[e]=!1;(t||s.length>0||!r.has(e.target))&&i.push(e.target);continue}for(let{type:t,to:r}of e.edges.values()){if(r===void 0)continue;let e=_t(a,t),o=n.get(r),s=K.filter(t=>o[t]&&e[t]);for(let e of s)o[e]=!1;s.length>0&&i.push(r)}}return n}function yt(e,t,n){let r=[e],i=new Set;for(;r.length>0;){let e=r.pop();i.has(e)||(i.add(e),r.push(...n(e,t(e))))}}function bt(e){let t=ht(e),n=(e,n)=>{if(!t.get(e)[n])return;let r=e=>Object.assign(t.get(e),{extraneous:!1,[n]:!1});yt(e,e=>{r(e),e.kind===`link`&&r(e.target)},e=>[...W(e).edges.values()].filter(({type:e,to:r})=>r!==void 0&&t.get(r)[n]&&(n!==`peer`&&e===`peer`||e===`prod`)).map(({to:e})=>e))},r=e=>{let i=t.get(e);i.extraneous=!1;for(let n of K)gt(t,e,n);if(e.kind===`link`){for(let n of L)t.get(e.target)[n]=i[n];return r(e.target)}for(let{type:r,to:a}of e.edges.values()){if(a===void 0)continue;t.get(a).extraneous=!1;let e=_t(i,r);for(let t of[`peer`,`devOptional`,`dev`,`optional`])e[t]&&n(a,t)}return e};return yt(e.get(``),r,(e,t)=>[...t.edges.values()].map(({to:e})=>e).filter(e=>e!==void 0)),t}function xt(e,t,n){for(let r of e.values()){let e=t.get(r);if(e.extraneous)return new b(`nothing installed leads to it, so ${n} takes it as extraneous, and prunes it`,r.where);if(r.kind===`link`)continue;let i={...e,devOptional:e.devOptional&&!e.dev&&!e.optional},a=L.find(e=>r.flags[e]!==i[e]);if(a!==void 0)return new b(`expected ${i[a]?`true`:`none`}, as ${n} sets it from what depends on it`,C(r.where,a))}}var q=[e=>vt(e,!1),e=>vt(e,!0),bt];function St(e){let[t,n,r]=e.split(`.`).map(Number);return t>11||t===11&&n>=18?q[0]:q[t===11&&(n>6||n===6&&r>=3)?1:2]}function Ct(e,t,n=t===void 0?`npm`:`npm ${t}`){let r=xt(e,(t===void 0?q[0]:St(t))(e),n);if(r!==void 0&&(t!==void 0||q.slice(1).every(t=>xt(e,t(e),`npm`)!==void 0)))throw r}var wt=64;function J(e,t){if(typeof e!=`object`||!e)return e;if(t>wt)throw new b(`nested more than ${wt} deep, as npm writes nothing`);if(Array.isArray(e))return e.map(e=>J(e,t+1));let n=Object.create(null);for(let[r,i]of Object.entries(e))n[r]=J(i,t+1);return n}function Tt(e,t){let n=e.split(`
|
|
1
|
+
import{a as e,e as t}from"./chunk-PAD2JHZT.js";import{A as n,B as r,C as i,E as a,F as o,G as s,H as c,M as l,O as u,Q as ee,S as d,a as f,d as p,e as m,f as te,i as ne,m as h,n as g,o as re,p as ie,q as _,r as v,u as ae,v as oe,x as y,z as se}from"./chunk-UCP3JRE2.js";import"./chunk-ZQHLECTI.js";import"./chunk-PXK7EU4V.js";import{d as b,e as ce,f as x,g as le,h as S,i as C,j as ue,l as de,m as fe}from"./chunk-JMG5DXII.js";import"./chunk-OOJM4CTU.js";function w(e,t=new Set){if(t.has(e))return;t.add(e);let{parent:n}=e;if(n===void 0)return;let r=w(n,t);return r===void 0?n.bundleDependencies?.includes(e.folder)||e.edgesIn.some(e=>w(e.from,t)===n)?n:void 0:r}var pe=({parent:e})=>e!==void 0&&(e.bundleDependencies!==void 0||pe(e)),me=e=>pe(e)?w(e):void 0;function he(e,t){let n=me(e);return n!==void 0&&n!==t}function ge(e,t){let n=me(e);if(e.inBundle!==(n!==void 0))throw new b(n===void 0?`set, where nothing bundles it`:`expected true, as ${S(n.location)} bundles it`,C(e.where,`inBundle`));let{resolution:r}=e;if(n===void 0||n===t){if(r===void 0)throw new b(`expected where it comes from, resolved or an integrity`,e.where)}else if(r!==void 0){let t=r.type===`git`||r.tarball!==void 0?`resolved`:`integrity`;throw new b(`npm takes it from the tarball of ${S(n.location)}, and from nothing else`,C(e.where,t))}}function _e(e){let t=e.get(``);for(let n of e.values())n.kind===`package`&&ge(n,t)}var T=e=>e?.endsWith(`.git`)?e.slice(0,-4):e;function E(e,t,n){let r=T(t);return e&&r?{user:e,project:r,committish:n}:void 0}var ve=e=>t=>{let[,n,r,i]=t.pathname.split(`/`,4);return i===e?void 0:E(n,r,t.hash.slice(1))},D={__proto__:null,github:{protocols:[`git:`,`http:`,`git+ssh:`,`git+https:`,`ssh:`,`https:`],domain:`github.com`,extract:e=>{let[,t,n,r,i]=e.pathname.split(`/`,5);if(!(r&&r!==`tree`))return E(t,n,r?i:e.hash.slice(1))}},bitbucket:{protocols:[`git+ssh:`,`git+https:`,`ssh:`,`https:`],domain:`bitbucket.org`,extract:ve(`get`)},gitlab:{protocols:[`git+ssh:`,`git+https:`,`ssh:`,`https:`],domain:`gitlab.com`,extract:e=>{let t=e.pathname.slice(1);if(t.includes(`/-/`)||t.includes(`/archive.tar.gz`))return;let n=t.split(`/`),r=n.pop();return E(n.join(`/`),r,e.hash.slice(1))}},gist:{protocols:[`git:`,`git+ssh:`,`git+https:`,`ssh:`,`https:`],domain:`gist.github.com`,extract:e=>{let[,t,n,r]=e.pathname.split(`/`,4);if(r!==`raw`&&(t||n))return{user:n?t:null,project:T(n||t),committish:e.hash.slice(1)}}},sourcehut:{protocols:[`git+ssh:`,`https:`],domain:`git.sr.ht`,extract:ve(`archive`)}},ye=new Map(Object.entries(D).map(([e,t])=>[t.domain,e])),be=new Map(Object.keys(D).map(e=>[`${e}:`,e])),xe=new Set([`git+ssh:`,`ssh:`,`git+https:`,`git:`,`http:`,`https:`,`git+http:`,...be.keys()]);function Se(e){let t=e.indexOf(`#`),n=e=>e===-1||t>-1&&e>t,r=e.indexOf(`/`);return n(e.search(/\s/u))&&r>0&&(t>-1?e[t-1]!==`/`:!e.endsWith(`/`))&&!e.startsWith(`.`)&&n(e.indexOf(`@`))&&n(e.indexOf(`:`))&&n(e.indexOf(`/`,r+1))}var O=(e,t,n)=>{let r=e.indexOf(n);return e.lastIndexOf(t,r>-1?r:1/0)};function Ce(e){let t=e.indexOf(`:`);if(xe.has(e.slice(0,t+1))||e.slice(t,t+3)===`://`)return e;let n=e.indexOf(`@`);return n>-1?n>t?`git+ssh://${e}`:e:`${e.slice(0,t+1)}//${e.slice(t+1)}`}function we(e){let t=e,n=O(t,`:`,`#`);return n>O(t,`@`,`#`)&&(t=`${t.slice(0,n)}/${t.slice(n+1)}`),O(t,`:`,`#`)===-1&&!t.includes(`//`)&&(t=`git+ssh://${t}`),t}var k=e=>e&&decodeURIComponent(e);function Te(e){let t=e.pathname.startsWith(`/`)?e.pathname.slice(1):e.pathname,n=t.indexOf(`@`);n>-1&&(t=t.slice(n+1));let r=t.lastIndexOf(`/`),i=T(k(t.slice(r+1)));return{user:r>-1&&k(t.slice(0,r))||null,project:i,committish:k(e.hash.slice(1))||null}}function A(e){if(!e)return;let t=Ce(Se(e)?`github:${e}`:e),n=URL.parse(t)??URL.parse(we(t));if(n===null)return;let r=be.get(n.protocol),i=r??ye.get(n.hostname.replace(/^www\./u,``));if(i!==void 0)try{if(r!==void 0)return{type:i,...Te(n)};if(!D[i].protocols.includes(n.protocol))return;let e=D[i].extract(n);return e===void 0?void 0:{type:i,user:k(e.user),project:k(e.project),committish:k(e.committish)||null}}catch(e){if(e instanceof URIError)return;throw e}}function Ee({type:e,user:t,project:n,committish:r},i){let a=i&&r?`#${r}`:``;return e===`gist`?`git@${D[e].domain}:${n}.git${a}`:`git@${D[e].domain}:${t}/${n}.git${a}`}var De=/^(?:[Gg][Ii][Tt]\+)?[A-Za-z]+:/u,Oe=/^[^@]+@[^.:]+\.[^:]+:.+$/iu,j=/\.(?:tgz|tar\.gz|tar)$/iu,ke=e=>j.test(e),M=/^git(?:\+(?:https?|rsync|ftp|ssh))?:/u,N=(e,t)=>new b(`${S(e)} is ${t}`);function Ae(e,t){let n=j.test(e)?`file`:`directory`;if(/^file:/iu.test(e)&&!e.startsWith(`file:`))throw N(e,`a path whose "file:" npm reads in another case otherwise`);let r=e.startsWith(`file:`)?e.slice(5):e;if(/^(?:[/~]|[A-Za-z]:)/u.test(r))throw N(e,`a path from the root, a drive or the home directory, which a lockfile does not hold`);return{type:n,path:o(t,r)}}function P(e,t){let n={committish:null,range:null};for(let r of t?t.split(`::`):[]){let[t,i]=r.includes(`:`)?r.split(`:`):[void 0,r];if(t===`path`)throw N(e,`a subdirectory of a repository, which is not supported`);if(t!==void 0&&t!==`semver`)throw N(e,`a git spec with ${S(t)}, which npm passes over`);if(n.committish!==null||n.range!==null)throw N(e,`a git spec with two refs or ranges, which npm refuses`);t===void 0?n.committish=i:n.range=je(e,i)}return n}var je=(e,t)=>x(()=>decodeURIComponent(t),()=>{throw N(e,`a git spec npm cannot decode`)});function Me(e){let t=e.startsWith(`git+ssh:`)?/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/iu.exec(e):null;if(t!==null&&!/:\d+(?:\/|$)/u.test(t[1]))return{type:`git`,hosted:void 0,fetchSpec:t[1],...P(e,t[2])};let n=URL.parse(e);if(n===null)throw N(e,`not a URL npm reads`);if(n.protocol===`http:`||n.protocol===`https:`)return{type:`remote`,url:e};if(!M.test(n.protocol))throw N(e,`of a protocol npm does not read, ${S(n.protocol)}`);let r=P(e,n.hash.slice(1));return n.hash=``,{type:`git`,hosted:void 0,fetchSpec:n.href.replace(/^git\+/u,``),...r}}function Ne(e,t,n){let r=t.trim();if(n===void 0)return{type:`registry`,name:e,fetchSpec:r,kind:void 0};let i=`tag`;if(n.valid(r,!0)===null?n.validRange(r,!0)!==null&&(i=`range`):i=`version`,i===`tag`&&encodeURIComponent(r)!==r)throw N(t,`a tag npm refuses, of a character a URL escapes`);return{type:`registry`,name:e,fetchSpec:r,kind:i}}function F(e,t,n,r){if(/^(?:file:|[.]|~\/|\/|[A-Za-z]:)/iu.test(t))return Ae(t,n);if(/^npm:/iu.test(t))return Fe(t,n,r);let i=A(t);return i===void 0?De.test(t)?Me(t):t.includes(`/`)||j.test(t)?Ae(t,n):Ne(e,t,r):{type:`git`,hosted:i,fetchSpec:void 0,...P(t,i.committish)}}function Pe(e,t,n){let r=e.indexOf(`@`,1),i=r>0?e.slice(0,r):e;return De.test(e)?F(void 0,e,t,n):Oe.test(e)?F(void 0,`git+ssh://${e}`,t,n):!i.startsWith(`@`)&&(i.includes(`/`)||j.test(i))?F(void 0,e,t,n):F(y(i,void 0),r>0&&e.slice(r+1)||`*`,t,n)}function Fe(e,t,n){let r=Pe(e.slice(4),t,n);if(r.type===`alias`)throw N(e,`an alias of an alias, which npm refuses`);if(r.type!==`registry`||r.name===void 0)throw N(e,`an alias of no package of the registry, which npm refuses`);return{type:`alias`,sub:r}}var I=(e,t,n,r)=>F(e,t||`*`,n,r),Ie=e=>F(void 0,e,`.`,void 0),L=[`dev`,`optional`,`devOptional`,`peer`],Le=[`name`,`version`,`dependencies`,`optionalDependencies`,`peerDependencies`,`peerDependenciesMeta`,`bundleDependencies`,`acceptDependencies`,`funding`,`engines`,`os`,`cpu`,`libc`,`license`,`hasInstallScript`,`bin`,`deprecated`,`workspaces`,...L],Re={link:[`link`,`resolved`],importer:[...Le,`devDependencies`],package:[...Le,`resolved`,`integrity`,`inBundle`]},ze={hasShrinkwrap:`a shrinkwrap of its own, which is not supported`,extraneous:`nothing leads to it, and npm prunes it rather than install it`};function R(e,t){if(typeof e==`object`&&e&&Object.keys(e).length===0)throw new b(`expected what npm writes, which leaves an empty ${Array.isArray(e)?`sequence`:`mapping`} out`,t);return e}var Be=e=>(t,n)=>ie(R(t,n),n,e),z=(e,t)=>_(R(e,t),t,y),Ve=(e,t)=>y(g(e,t),t),He=(e,t)=>re(R(e,t),t,y),B=(e,t)=>re(R(e,t),t),V=e=>(t,n)=>Array.isArray(t)?B(t,n):e(t,n),Ue=Be((e,t,n)=>(y(n,t),{optional:h(m(e,t),`optional`,t,ne)??!1}));function We(e,t){return typeof e==`string`?g(e,t):(m(R(e,t),t),{type:h(e,`type`,t,g),url:h(e,`url`,t,g)})}var Ge=(e,t)=>Array.isArray(e)?R(e,t).map((e,n)=>We(e,`${t}[${n}]`)):We(e,t);function Ke(e,t,i){if(!n(i)||/[/:]/u.test(i))throw new b(`${S(i)} is not the name of a bin, as npm writes one`,t);if(!r(g(e,t).replace(/\/$/u,``)))throw new b(`${S(e)} is not a path within the package, as npm writes a bin's`,t);return e}var qe=V((e,t)=>(m(R(e,t),t,[`packages`,`nohoist`]),h(e,`nohoist`,t,B),B(e.packages,C(t,`packages`)))),Je={__proto__:null,dependencies:z,optionalDependencies:z,peerDependencies:z,devDependencies:(e,t)=>_(e,t,y),peerDependenciesMeta:Ue,acceptDependencies:z,bundleDependencies:He,funding:Ge,engines:V((e,t)=>_(R(e,t),t)),os:B,cpu:B,libc:B,license:V(g),bin:Be(Ke),deprecated:g,workspaces:qe};function Ye(e,t){let n=Object.fromEntries(L.map(n=>[n,v(e[n],C(t,n))]));if(n.devOptional&&(n.dev||n.optional))throw new b(`set beside dev or optional, where npm leaves it out`,C(t,`devOptional`));return n}var Xe=(e,t)=>u(e,t)&&e;function Ze(e,t,n,r){if(e.startsWith(`file:`)){if(!ke(e))throw new b(`${S(e)} is a directory, which npm packs again at every install: not supported`,r);i(e.slice(5),r)}else{if(!ee(e))throw new b(`${S(e)} is not an http(s) URL, a file: tarball or a git URL`,r);if(A(e)!==void 0)throw new b(`${S(e)} is a repository to npm, which it reads as one on a git host`,r);d(e,t,n,r)}}function Qe(e,t,n,r){let i=C(t,`resolved`),a=h(e,`resolved`,t,g),o=h(e,`integrity`,t,Xe);if(a===void 0)return o===void 0?void 0:{type:`tarball`,tarball:void 0,integrity:o};if(M.test(a)){if(o!==void 0)throw new b(`an integrity, which npm does not check for a git repository`,C(t,`integrity`));let e=a.lastIndexOf(`#`);if(e===-1||!c(a.slice(e+1)))throw new b(`expected a full commit hash after the "#" of ${S(a)}`,i);return{type:`git`,repo:l(a.slice(0,e),i),commit:a.slice(e+1)}}if(Ze(a,n,r,i),o===void 0)throw new b(`expected an integrity, which npm checks the tarball with`,t);return{type:`tarball`,tarball:a,integrity:o}}function $e(e){let t=e.split(`/`),n=t.at(-1);return t.at(-2)?.startsWith(`@`)?`${t.at(-2)}/${n}`:n}function et(e,t){if(m(e,t,Re.link,ze),e.link!==!0)throw p(`true`,e.link,C(t,`link`));return e.resolved===``?``:i(e.resolved,C(t,`resolved`))}function tt(e,t,n,r){m(e,t,Re[n],ze);let i=Object.create(null);for(let[n,r]of Object.entries(Je))i[n]=h(e,n,t,r);if(n===`importer`&&r!==void 0&&i.bundleDependencies!==void 0)throw new b(`a bundle of a directory, which is not supported`,C(t,`bundleDependencies`));let a=h(e,`name`,t,Ve);if(a!==void 0&&a===r)throw new b(`the name of its folder, which npm leaves out`,C(t,`name`));let o=h(e,`version`,t,n===`package`?se:g);if(n===`package`&&o===void 0&&!M.test(e.resolved??``))throw new b(`expected a version, which only a package from a git repository is read without`,C(t,`version`));let s={name:a??r,version:o,...i,hasInstallScript:v(e.hasInstallScript,C(t,`hasInstallScript`)),flags:Ye(e,t)};return n===`package`&&(s.resolution=Qe(e,t,s.name,o),s.inBundle=v(e.inBundle,C(t,`inBundle`))),s}var H=`packages`,nt=/^(?:(.+)\/)?node_modules\/((?:@[^/]+\/)?[^/]+)$/u;function rt(e,t){if(e===``)return{kind:`root`,parent:void 0,folder:void 0};i(e,t);let n=nt.exec(e);if(n!==null){if(n[2]===`node_modules`)throw new b(`a folder named "node_modules", which no package is`,t);return{kind:`package`,parent:n[1]??``,folder:y(n[2],t)}}let r=e.split(`/`);if(r.includes(`node_modules`))throw new b(`in a node_modules, but none of its packages`,t);if(r.every(e=>e===`..`))throw new b(`a directory the project is in, which is not supported`,t);return{kind:`importer`,parent:void 0,folder:$e(e)}}function it(e,t,n){let{kind:r,parent:i,folder:a}=rt(e,n),o={location:e,where:n,kind:r,parentLocation:i,folder:a,parent:void 0,fsParent:void 0,children:new Map,links:[],edges:new Map,edgesIn:[]};if(t?.link===void 0)return Object.assign(o,tt(t,n,r===`package`?`package`:`importer`,a));if(r!==`package`)throw new b(`a link outside a node_modules, where npm writes none`,n);return Object.assign(o,{kind:`link`,targetLocation:et(t,n),target:void 0})}function at(e,t){let n=t.get(e.parentLocation);if(n===void 0)throw new b(`in the node_modules of ${S(e.parentLocation)}, which the lockfile does not have`,e.where);if(n.kind===`link`)throw new b(`in the node_modules of ${S(e.parentLocation)}, a link, in which npm installs nothing`,e.where);let r=e.folder.toLowerCase(),i=n.children.get(r);if(i!==void 0)throw new b(`in the folder of ${S(i.location)} to npm, which takes names in one case`,e.where);n.children.set(r,e),e.parent=n}function ot(e,t){let n=t.get(e.targetLocation),r=C(e.where,`resolved`);if(n===void 0)throw new b(`${S(e.targetLocation)} is not in the lockfile, where npm looks for what a link leads to`,r);if(n.kind===`link`)throw new b(`${S(e.targetLocation)} is a link, where npm links the project, a directory or a package`,r);e.target=n,n.links.push(e)}function st(e,t){let n=e.location.split(`/`);for(;n.pop()!==void 0&&n.at(-1)!==`..`;){let e=t.get(n.join(`/`));if(e!==void 0)return e}}var U=e=>e.parent??e.fsParent,W=e=>e.kind===`link`?e.target:e,G=e=>e.location||`.`;function ct(e,t){let n=t.toLowerCase();for(let t=e;t!==void 0;t=U(t)){let e=t.children.get(n);if(e!==void 0)return e}}function lt(e){let t=new Map;for(let[n,r,i]of te(e,H))t.set(n,it(n,r,i));t.has(``)||t.set(``,it(``,Object.create(null),C(H,``)));for(let e of t.values())e.parentLocation!==void 0&&at(e,t),e.kind===`link`&&ot(e,t);for(let e of t.values())if(e.kind===`importer`){if(e.links.length===0)throw new b(`a directory no link leads to, of which npm installs nothing`,e.where);e.fsParent=st(e,t)}return t}function ut(n){let r=n.get(``),i=C(r.where,`workspaces`),a=new Map;for(let[o,s]of(r.workspaces??[]).entries()){let r=e(s.replace(/^\.?\/+/u,``),`${i}[${o}]`);for(let e of n.values()){if(e.kind!==`importer`||a.get(e.name)===e||!t(r,e.location))continue;let n=y(e.name,C(e.where,`name`));if(a.has(n))throw new b(`the name of the workspace ${S(a.get(n).location)} too, of which npm keeps one`,e.where);a.set(n,e)}}return a}var dt={__proto__:null,workspace:`workspaces`,peer:`peerDependencies`,peerOptional:`peerDependencies`,prod:`dependencies`,optional:`optionalDependencies`,dev:`devDependencies`},ft=e=>e.type===`workspace`?C(e.from.where,`workspaces`):C(C(e.from.where,dt[e.type]),e.name);function pt(e,t,n){let r=(t,n,r)=>{let i=t.toLowerCase(),a=e.edges.get(i);if(a?.type===`workspace`)return;let o={name:t,type:n,spec:r,accept:e.acceptDependencies?.[t],from:e,to:void 0};if(a!==void 0&&a.name!==t)throw new b(`${S(a.name)} too, to npm, which takes names in one case`,ft(o));e.edges.delete(i),e.edges.set(i,o)};if(e.kind===`root`)for(let[e,{location:n}]of t)r(e,`workspace`,`file:${n}`);let i=e.peerDependenciesMeta??Object.create(null),a=n?[]:Object.entries(e.peerDependencies??{});for(let[e,t]of a)i[e]?.optional||r(e,`peer`,t);for(let[e,t]of a)i[e]?.optional&&r(e,`peerOptional`,t);for(let t of e.parent===void 0?[`prod`,`optional`,`dev`]:[`prod`,`optional`])for(let[n,i]of Object.entries(e[dt[t]]??{}))r(n,t,i)}function mt(e,t,n){for(let r of e.values())r.kind!==`link`&&pt(r,t,n);for(let t of e.values())for(let e of t.edges.values())e.to=ct(t,e.name),e.to?.edgesIn.push(e)}var K=[...L,`extraneous`],ht=e=>new Map([...e.values()].map(e=>[e,Object.fromEntries(K.map(t=>[t,e.kind!==`root`]))]));function gt(e,t,n){if(!e.get(t)[n])for(let r=U(t);r!==void 0&&e.get(r)[n];r=U(r))e.get(r)[n]=!1}function _t(e,t){let[n,r,i]=[t===`dev`,t===`optional`||t===`peerOptional`,t.startsWith(`peer`)];return{extraneous:!e.extraneous&&!(i&&r),dev:!e.dev&&!n,optional:!e.optional&&!r,devOptional:!e.devOptional&&!e.dev&&!e.optional&&!n&&!r,peer:!e.peer&&!i}}function vt(e,t){let n=ht(e),r=new Set,i=[e.get(``)];for(;i.length>0;){let e=i.pop();r.add(e);let a=n.get(e);if(gt(n,e,`extraneous`),e.kind===`link`){let o=n.get(e.target),s=K.filter(e=>o[e]&&!a[e]);if(t)Object.assign(o,a);else for(let e of s)o[e]=!1;(t||s.length>0||!r.has(e.target))&&i.push(e.target)}else for(let{type:t,to:r}of e.edges.values()){if(r===void 0)continue;let e=_t(a,t),o=n.get(r),s=K.filter(t=>o[t]&&e[t]);for(let e of s)o[e]=!1;s.length>0&&i.push(r)}}return n}function yt(e,t,n){let r=[e],i=new Set;for(;r.length>0;){let e=r.pop();i.has(e)||(i.add(e),r.push(...n(e,t(e))))}}function bt(e){let t=ht(e),n=(e,n)=>{if(!t.get(e)[n])return;let r=e=>Object.assign(t.get(e),{extraneous:!1,[n]:!1});yt(e,e=>{r(e),e.kind===`link`&&r(e.target)},e=>[...W(e).edges.values()].filter(({type:e,to:r})=>r!==void 0&&t.get(r)[n]&&(n!==`peer`&&e===`peer`||e===`prod`)).map(({to:e})=>e))},r=e=>{let i=t.get(e);i.extraneous=!1;for(let n of K)gt(t,e,n);if(e.kind===`link`){for(let n of L)t.get(e.target)[n]=i[n];return r(e.target)}for(let{type:r,to:a}of e.edges.values()){if(a===void 0)continue;t.get(a).extraneous=!1;let e=_t(i,r);for(let t of[`peer`,`devOptional`,`dev`,`optional`])e[t]&&n(a,t)}return e};return yt(e.get(``),r,(e,t)=>[...t.edges.values()].map(({to:e})=>e).filter(e=>e!==void 0)),t}function xt(e,t,n){for(let r of e.values()){let e=t.get(r);if(e.extraneous)return new b(`nothing installed leads to it, so ${n} takes it as extraneous, and prunes it`,r.where);if(r.kind===`link`)continue;let i={...e,devOptional:e.devOptional&&!e.dev&&!e.optional},a=L.find(e=>r.flags[e]!==i[e]);if(a!==void 0)return new b(`expected ${i[a]?`true`:`none`}, as ${n} sets it from what depends on it`,C(r.where,a))}}var q=[e=>vt(e,!1),e=>vt(e,!0),bt];function St(e){let[t,n,r]=e.split(`.`).map(Number);return t>11||t===11&&n>=18?q[0]:q[t===11&&(n>6||n===6&&r>=3)?1:2]}function Ct(e,t,n=t===void 0?`npm`:`npm ${t}`){let r=xt(e,(t===void 0?q[0]:St(t))(e),n);if(r!==void 0&&(t!==void 0||q.slice(1).every(t=>xt(e,t(e),`npm`)!==void 0)))throw r}var wt=64;function J(e,t){if(typeof e!=`object`||!e)return e;if(t>wt)throw new b(`nested more than ${wt} deep, as npm writes nothing`);if(Array.isArray(e))return e.map(e=>J(e,t+1));let n=Object.create(null);for(let[r,i]of Object.entries(e))n[r]=J(i,t+1);return n}function Tt(e,t){let n=e.split(`
|
|
2
2
|
`),r=t.split(`
|
|
3
3
|
`),i=0;for(;n[i]===r[i];)i++;if(i===r.length-1&&i===n.length)return ue(`expected a line end after the last "}"`,i-1);let a=i<n.length?S(n[i]):`the end of the file`;return ue(`expected ${i<r.length?S(r[i]):`the end of the file`}, as npm writes it, found ${a}`,i)}function Et(e){de(e,`npm`);let[t,n]=fe(e,`npm`),r=x(()=>JSON.parse(e),e=>ce(`not JSON: ${e.message}`)),i=J(r,0),a=`${JSON.stringify(r,null,n)}
|
|
4
4
|
`.replaceAll(`
|
|
5
|
-
`,t);if(a!==e)throw Tt(e,a);return i}var Dt=/^[\dA-Fa-f]{40,64}$/u;function Ot(e){let t=e.resolution?.tarball;return t?.startsWith(`file:`)?a(t.slice(5),`..`):G(e)}var Y=e=>S(e.location);function kt(e,{fetchSpec:t,kind:n},r){if(n===void 0||n===`range`&&t===`*`)return;if(n===`tag`)return e.kind===`link`||!/^https?:/u.test(e.resolution?.tarball??``)?`is a tag, which npm holds met by a tarball from a URL alone, and ${Y(e)} is none`:void 0;let{version:i}=W(e);return r.satisfies(i??``,t,!0)?void 0:`is not satisfied by ${Y(e)}, ${i??`of no version`}`}function At(e,t,n){let{resolution:r,version:i}=e;if(e.kind===`link`||r?.type!==`git`)return`asks for a git repository, and ${Y(e)} is from none`;let a=Ie(`${r.repo}#${r.commit}`),o=Dt.test(t.committish??``);if(!(t.hosted===void 0?a.hosted===void 0&&a.fetchSpec===t.fetchSpec:a.hosted!==void 0&&Ee(t.hosted,o)===Ee(a.hosted,o)))return`asks for another repository than ${Y(e)} is from${o?`, or another commit`:``}`;if(!(t.range===null||n===void 0||n.satisfies(i??``,t.range,!0)))return`asks for a version of the repository ${Y(e)} is not, ${i??`of no version`}`}function jt(e,t,n){switch(t.type){case`registry`:return kt(e,t,n);case`alias`:return kt(e,t.sub,n);case`directory`:return e.kind===`link`&&G(e.target)===t.path?void 0:`asks for a link to ${S(t.path)}, and ${Y(e)} is ${e.kind===`link`?`one to ${S(G(e.target))}`:`no link`}`;case`file`:case`remote`:{let n=t.type===`file`?`file:${t.path}`:t.url;return e.kind!==`link`&&e.resolution?.tarball===n?void 0:`asks for the tarball ${S(n)}, and ${Y(e)} is from another`}default:return At(e,t,n)}}function Mt(e,t){let{name:n}=W(e);if(t.type===`alias`&&n!==t.sub.name)return`asks for ${S(t.sub.name)}, and ${Y(e)} is ${S(n)}, which npm does not check`;let{committish:r}=t;if(t.type===`git`&&Dt.test(r??``)&&r.toLowerCase()!==e.resolution.commit)return`asks for another commit than ${Y(e)} is of, which npm does not check of a repository on no host it knows`}function Nt(e,t,n){let{from:r,to:i,spec:a}=e;if(e.type.startsWith(`peer`)&&i.parent===r&&r.parent!==void 0)return`${S(a)} is met in the node_modules of the package that asks for it, which npm holds a peer not to be`;if(i.folder!==e.name)return`is met by ${Y(i)}, which npm takes for it, though the names are in other cases`;let o=a=>{let o=I(e.name,a,Ot(r),t);return jt(i,o,t)??(n?Mt(i,o):void 0)},s=o(a);if(!(s===void 0||e.accept!==void 0&&o(e.accept)===void 0))return`${S(a)} ${s}, so npm would install another`}function Pt(e,t){return x(()=>Nt(e,t,!1)===void 0,e=>{if(e instanceof b)return!1;throw e})}function Ft(e,t){if(e.type===`peerOptional`)return;let n=ft(e);if(e.to===void 0)throw new b(`${S(e.spec)} is met by nothing where npm looks for ${S(e.name)}, so npm would install it`,n);let r=le(()=>Nt(e,t,!0),n);if(r!==void 0)throw new b(r,n)}function It(e,t){let n=new Set([e.get(``)]);for(let e of n){let r=new Set(e.kind===`package`?e.bundleDependencies:[]);for(let i of e.edges.values()){r.has(i.name)||Ft(i,t);let e=i.to===void 0?void 0:W(i.to);e!==void 0&&!e.location.startsWith(`../`)&&n.add(e)}}}var Lt=[`version`,`resolved`,`integrity`,`bundled`,...L,`requires`,`dependencies`,`from`],X=e=>e.location===``?`the project`:S(e.location);function Rt(e){let[t,n,r]=e.split(`.`).map(Number);return t===9||t===10&&(n<9||n===9&&r<=2)||t===11&&n<2}function zt(e,t){let n=[],r;for(let i of e.edgesIn){let e=i.from.location.split(`node_modules`),a=[e.length,e.at(-1)],o=r===void 0?-1:a[0]-r[0]||a[1].localeCompare(r[1],`en`);o>0||!Pt(i,t)||(o<0?[n,r]=[[i],a]:n.push(i))}return n}function Bt(e,t){let n=s(e,t);return`file:${n===`.`?``:n}`}function Vt(e,t){let n=G(t.from),r=I(e.folder,t.spec,n,void 0),i=`${e.folder}@${t.spec}`;return r.type===`file`?{type:`file`,save:Bt(n,r.path),raw:i}:r.type===`remote`?{type:`remote`,save:r.url,raw:i}:{type:r.type,raw:i}}function Ht(e,t,n){if(e.kind===`link`)return{version:`file:${n(e.target.location)}`};let{resolution:r}=e,i=r?.type===`git`?`${r.repo}#${r.commit}`:r?.tarball,a;r?.type===`git`?a=`git`:i!==void 0&&(a=i.startsWith(`file:`)?`file`:`remote`);let o=t===void 0?{type:a,save:i,raw:i}:Vt(e,t);return o.type===`file`||o.type===`remote`?{version:o.save}:o.type===`git`||a===`git`?{version:i,from:o.raw}:{version:e.name===e.folder?e.version:`npm:${e.name}@${e.version}`,resolved:a===`remote`?i:void 0}}var Ut=e=>[...new Map(e.map(e=>[JSON.stringify(e),e])).values()];function Z(e,t,n,r){if(e===t)return;let i=t===void 0?`none`:typeof t==`string`?S(t):String(t);throw new b(`expected ${i}, found ${f(e)}, as npm writes it of ${X(r)}`,n)}var Q=(e,t,n,r,i)=>Z(e[t],n,C(r,t),i);function Wt(e,t,n,r){let{path:i}=le(()=>I(e.name,e.spec,t,void 0),r);return n(Bt(t,i))}function Gt(e,t,n){if(e.edges.size===0)return;let r=Object.create(null);for(let i of e.edges.values())i.type.startsWith(`peer`)||(r[i.name]=i.spec.startsWith(`file:`)?Wt(i,G(e),t,C(n,i.name)):i.spec);return r}function Kt(e,t,n,r){let i=Gt(t,n,r);if(i===void 0)return Z(e,void 0,r,t);let a=m(e,r);for(let[e,n]of Object.entries(a)){if(!Object.hasOwn(i,e))throw new b(`${X(t)} asks for no such package, or for a peer, which npm leaves out`,C(r,e));if(n!==i[e])throw new b(`expected ${S(i[e])}, as ${X(t)} asks for it, found ${f(n)}, which npm writes there of an override alone, not read here`,C(r,e))}let o=Object.keys(i).find(e=>!Object.hasOwn(a,e));if(o!==void 0)throw new b(`expected ${S(o)}, which ${X(t)} asks for`,r)}function qt(e,t,n,r,i){let a=new Set([...t.children.values()].filter(e=>!r.includes(W(e).location)));if(a.size===0)return Z(e,void 0,n,t);let o=[...r,t.location],s=e===void 0?Object.create(null):m(e,n);for(let[e,r]of Object.entries(s)){let s=t.children.get(e.toLowerCase()),c=`${t.location===``?``:`${t.location}/`}node_modules/${e}`;if(s===void 0||s.folder!==e)throw new b(`${S(c)} is not in packages`,C(n,e));if(!a.has(s))throw new b(`${S(c)} links to ${S(G(W(s)))}, which this is under already, and npm leaves it out`,C(n,e));Xt(r,s,C(n,e),o,i)}let c=a.values().find(e=>!Object.hasOwn(s,e.folder));if(c!==void 0)throw new b(`expected ${S(c.folder)}, as npm writes ${S(c.location)} of packages`,n)}function Jt(e,t,n,r,i){if(t!==void 0&&e===void 0){if(i.resolved!==void 0)throw new b(`expected ${S(t)}: npm leaves it out of every entry or of none, and ${i.resolved} has it`,n);i.omitted??=n;return}if(Z(e,t,n,r),e!==void 0){if(i.omitted!==void 0)throw new b(`expected none: npm leaves it out of every entry or of none, and ${i.omitted} has none`,n);i.resolved??=n}}function Yt(e,t){let{semver:n,escape:r,own:i,root:a}=t;if(!i.has(e)){let t=e.kind===`link`?[]:zt(e,n),o=Ut(t.length===0?[Ht(e,void 0,r)]:t.map(t=>Ht(e,t,r)));i.set(e,{heads:o,bundled:he(e,a)||void 0})}return i.get(e)}function Xt(e,t,n,r,i){m(e,n,Lt);let{heads:a,bundled:o}=Yt(t,i),s=a.find(({version:t,from:n})=>t===e.version&&n===e.from)??a[0];Q(e,`version`,s.version,n,t),Q(e,`from`,s.from,n,t),Jt(e.resolved,s.resolved,C(n,`resolved`),t,i),Q(e,`bundled`,o,n,t),Q(e,`integrity`,t.resolution?.integrity,n,t);for(let r of L)Q(e,r,t.flags?.[r]||void 0,n,t);let c=W(t);Kt(e.requires,c,i.escape,C(n,`requires`)),qt(e.dependencies,c,C(n,`dependencies`),r,i)}function $(e,t,n,r,i={}){let a=e=>e.includes(`#`)?(i.hash=!0,r?e.replaceAll(`#`,`%23`):e):e,o=t.get(``);qt(e,o,`dependencies`,[],{semver:n,escape:a,own:new Map,root:o,omitted:void 0,resolved:void 0})}var Zt=`9.0.0`;function Qt(e,t,n,r){if(r!==void 0)return $(e,t,n,Rt(r));let i={hash:!1};try{$(e,t,n,!1,i)}catch(r){if(!(r instanceof b)||!i.hash)throw r;try{$(e,t,n,!0)}catch{throw r}Ct(t,Zt,`an npm that writes a "#" as "%23"`)}}var $t=[`checkVersions`,`semver`,`legacyPeerDeps`,`npm`],en=[`satisfies`,`valid`,`validRange`],tn=[`name`,`version`,`lockfileVersion`,`requires`,`packages`,...L];function nn(e){let{semver:t,legacyPeerDeps:n=!1,npm:r}=ae(e,$t),i=oe(e,en);if(typeof n!=`boolean`)throw TypeError(`legacyPeerDeps: expected a boolean`);if(r!==void 0&&!(/^\d+\.\d+\.\d+$/u.test(r)&&Number(r.split(`.`)[0])>=9))throw TypeError(`npm: expected a version of npm 9 or later, such as 11.12.1`);if(r===`11.6.1`||r===`11.6.2`)throw TypeError(`npm: ${r} works the flags out in a way not read here`);return{semver:i?t:void 0,legacyPeerDeps:n,npm:r}}function rn(e){let t=m(e,void 0).lockfileVersion;if(t!==2&&t!==3)throw new b(`unsupported version: expected 2 or 3, found ${f(t)}`,`lockfileVersion`);if(m(e,void 0,t===2?[...tn,`dependencies`]:tn),e.requires!==!0)throw p(`true`,e.requires,`requires`);return t}function an(e,t){let n=g(e.name,`name`);if(t.name!==void 0&&t.name!==n)throw new b(`expected the project's, ${S(t.name)}`,`name`);if(e.version!==t.version)throw new b(t.version===void 0?`a version, where the project has none`:`expected the project's, ${S(t.version)}`,`version`);let r=L.find(n=>v(e[n],n)!==t.flags[n]);if(r!==void 0)throw new b(`expected ${t.flags[r]?`true`:`none`}, as the project's in packages`,r);return{name:n,version:t.version}}var on=e=>e.kind===`link`?`link:${G(e.target)}`:e.location;function sn(e){let t=Object.create(null);for(let n of e.edges.values())t[n.name]={type:n.type,spec:n.spec,accept:n.accept,target:n.to===void 0?void 0:on(n.to)};return t}function cn(e){let{name:t,version:n,os:r,cpu:i,libc:a,license:o,funding:s,deprecated:c,hasInstallScript:l,flags:u}=e;return{name:t,version:n,edges:sn(e),bundleDependencies:e.bundleDependencies??[],engines:e.engines??Object.create(null),os:r,cpu:i,libc:a,bin:e.bin??Object.create(null),license:o,funding:s,deprecated:c,hasInstallScript:l,...u,devOptional:u.devOptional||u.dev||u.optional}}function ln(e,t={}){if(typeof e!=`string`)throw TypeError(`expected a string`);let{semver:n,legacyPeerDeps:r,npm:i}=nn(t),a=Et(e),o=rn(a),s=lt(a.packages),c=s.get(``),l=ut(s);mt(s,l,r),It(s,n),Ct(s,i),_e(s),o===2&&Qt(a.dependencies,s,n,i);let u=an(a,c),ee=new Set(l.values()),d=Object.create(null),f=Object.create(null),p=Object.create(null);for(let e of new Set([c,...s.values()]))e.kind===`link`?p[e.location]=G(e.target):e.kind===`package`?f[e.location]={...cn(e),resolution:e.resolution,inBundle:e.inBundle}:d[G(e)]={...cn(e),workspace:ee.has(e),workspaces:e.workspaces??[]};return{lockfileVersion:o,...u,importers:d,packages:f,links:p}}export{b as LockfileError,ln as parseNpmLockfile};
|
|
5
|
+
`,t);if(a!==e)throw Tt(e,a);return i}var Dt=/^[\dA-Fa-f]{40,64}$/u;function Ot(e){let t=e.resolution?.tarball;return t?.startsWith(`file:`)?a(t.slice(5),`..`):G(e)}var Y=e=>S(e.location);function kt(e,{fetchSpec:t,kind:n},r){if(n===void 0||n===`range`&&t===`*`)return;if(n===`tag`)return e.kind===`link`||!/^https?:/u.test(e.resolution?.tarball??``)?`is a tag, which npm holds met by a tarball from a URL alone, and ${Y(e)} is none`:void 0;let{version:i}=W(e);return r.satisfies(i??``,t,!0)?void 0:`is not satisfied by ${Y(e)}, ${i??`of no version`}`}function At(e,t,n){let{resolution:r,version:i}=e;if(e.kind===`link`||r?.type!==`git`)return`asks for a git repository, and ${Y(e)} is from none`;let a=Ie(`${r.repo}#${r.commit}`),o=Dt.test(t.committish??``);if(!(t.hosted===void 0?a.hosted===void 0&&a.fetchSpec===t.fetchSpec:a.hosted!==void 0&&Ee(t.hosted,o)===Ee(a.hosted,o)))return`asks for another repository than ${Y(e)} is from${o?`, or another commit`:``}`;if(!(t.range===null||n===void 0||n.satisfies(i??``,t.range,!0)))return`asks for a version of the repository ${Y(e)} is not, ${i??`of no version`}`}function jt(e,t,n){switch(t.type){case`registry`:return kt(e,t,n);case`alias`:return kt(e,t.sub,n);case`directory`:return e.kind===`link`&&G(e.target)===t.path?void 0:`asks for a link to ${S(t.path)}, and ${Y(e)} is ${e.kind===`link`?`one to ${S(G(e.target))}`:`no link`}`;case`file`:case`remote`:{let n=t.type===`file`?`file:${t.path}`:t.url;return e.kind!==`link`&&e.resolution?.tarball===n?void 0:`asks for the tarball ${S(n)}, and ${Y(e)} is from another`}default:return At(e,t,n)}}function Mt(e,t){let{name:n}=W(e);if(t.type===`alias`&&n!==t.sub.name)return`asks for ${S(t.sub.name)}, and ${Y(e)} is ${S(n)}, which npm does not check`;let{committish:r}=t;if(t.type===`git`&&Dt.test(r??``)&&r.toLowerCase()!==e.resolution.commit)return`asks for another commit than ${Y(e)} is of, which npm does not check of a repository on no host it knows`}function Nt(e,t,n){let{from:r,to:i,spec:a}=e;if(e.type.startsWith(`peer`)&&i.parent===r&&r.parent!==void 0)return`${S(a)} is met in the node_modules of the package that asks for it, which npm holds a peer not to be`;if(i.folder!==e.name)return`is met by ${Y(i)}, which npm takes for it, though the names are in other cases`;let o=a=>{let o=I(e.name,a,Ot(r),t);return jt(i,o,t)??(n?Mt(i,o):void 0)},s=o(a);if(!(s===void 0||e.accept!==void 0&&o(e.accept)===void 0))return`${S(a)} ${s}, so npm would install another`}function Pt(e,t){return x(()=>Nt(e,t,!1)===void 0,e=>{if(e instanceof b)return!1;throw e})}function Ft(e,t){if(e.type===`peerOptional`)return;let n=ft(e);if(e.to===void 0)throw new b(`${S(e.spec)} is met by nothing where npm looks for ${S(e.name)}, so npm would install it`,n);let r=le(()=>Nt(e,t,!0),n);if(r!==void 0)throw new b(r,n)}function It(e,t){let n=new Set([e.get(``)]);for(let e of n){let r=new Set(e.kind===`package`?e.bundleDependencies:[]);for(let i of e.edges.values()){r.has(i.name)||Ft(i,t);let e=i.to===void 0?void 0:W(i.to);e!==void 0&&!e.location.startsWith(`../`)&&n.add(e)}}}var Lt=[`version`,`resolved`,`integrity`,`bundled`,...L,`requires`,`dependencies`,`from`],X=e=>e.location===``?`the project`:S(e.location);function Rt(e){let[t,n,r]=e.split(`.`).map(Number);return t===9||t===10&&(n<9||n===9&&r<=2)||t===11&&n<2}function zt(e,t){let n=[],r;for(let i of e.edgesIn){let e=i.from.location.split(`node_modules`),a=[e.length,e.at(-1)],o=r===void 0?-1:a[0]-r[0]||a[1].localeCompare(r[1],`en`);o>0||!Pt(i,t)||(o<0?[n,r]=[[i],a]:n.push(i))}return n}function Bt(e,t){let n=s(e,t);return`file:${n===`.`?``:n}`}function Vt(e,t){let n=G(t.from),r=I(e.folder,t.spec,n,void 0),i=`${e.folder}@${t.spec}`;return r.type===`file`?{type:`file`,save:Bt(n,r.path),raw:i}:r.type===`remote`?{type:`remote`,save:r.url,raw:i}:{type:r.type,raw:i}}function Ht(e,t,n){if(e.kind===`link`)return{version:`file:${n(e.target.location)}`};let{resolution:r}=e,i=r?.type===`git`?`${r.repo}#${r.commit}`:r?.tarball,a;r?.type===`git`?a=`git`:i!==void 0&&(a=i.startsWith(`file:`)?`file`:`remote`);let o=t===void 0?{type:a,save:i,raw:i}:Vt(e,t);return o.type===`file`||o.type===`remote`?{version:o.save}:o.type===`git`||a===`git`?{version:i,from:o.raw}:{version:e.name===e.folder?e.version:`npm:${e.name}@${e.version}`,resolved:a===`remote`?i:void 0}}var Ut=e=>[...new Map(e.map(e=>[JSON.stringify(e),e])).values()];function Z(e,t,n,r){if(e===t)return;let i=t===void 0?`none`:typeof t==`string`?S(t):String(t);throw new b(`expected ${i}, found ${f(e)}, as npm writes it of ${X(r)}`,n)}var Q=(e,t,n,r,i)=>Z(e[t],n,C(r,t),i);function Wt(e,t,n,r){let{path:i}=le(()=>I(e.name,e.spec,t,void 0),r);return n(Bt(t,i))}function Gt(e,t,n){if(e.edges.size===0)return;let r=Object.create(null);for(let i of e.edges.values())i.type.startsWith(`peer`)||(r[i.name]=i.spec.startsWith(`file:`)?Wt(i,G(e),t,C(n,i.name)):i.spec);return r}function Kt(e,t,n,r){let i=Gt(t,n,r);if(i===void 0)return Z(e,void 0,r,t);let a=m(e,r);for(let[e,n]of Object.entries(a)){if(!Object.hasOwn(i,e))throw new b(`${X(t)} asks for no such package, or for a peer, which npm leaves out`,C(r,e));if(n!==i[e])throw new b(`expected ${S(i[e])}, as ${X(t)} asks for it, found ${f(n)}, which npm writes there of an override alone, not read here`,C(r,e))}let o=Object.keys(i).find(e=>!Object.hasOwn(a,e));if(o!==void 0)throw new b(`expected ${S(o)}, which ${X(t)} asks for`,r)}function qt(e,t,n,r,i){let a=new Set([...t.children.values()].filter(e=>!r.includes(W(e).location)));if(a.size===0)return Z(e,void 0,n,t);let o=[...r,t.location],s=e===void 0?Object.create(null):m(e,n);for(let[e,r]of Object.entries(s)){let s=t.children.get(e.toLowerCase()),c=`${t.location===``?``:`${t.location}/`}node_modules/${e}`;if(s===void 0||s.folder!==e)throw new b(`${S(c)} is not in packages`,C(n,e));if(!a.has(s))throw new b(`${S(c)} links to ${S(G(W(s)))}, which this is under already, and npm leaves it out`,C(n,e));Xt(r,s,C(n,e),o,i)}let c=a.values().find(e=>!Object.hasOwn(s,e.folder));if(c!==void 0)throw new b(`expected ${S(c.folder)}, as npm writes ${S(c.location)} of packages`,n)}function Jt(e,t,n,r,i){if(t!==void 0&&e===void 0){if(i.resolved!==void 0)throw new b(`expected ${S(t)}: npm leaves it out of every entry or of none, and ${i.resolved} has it`,n);i.omitted??=n}else if(Z(e,t,n,r),e!==void 0){if(i.omitted!==void 0)throw new b(`expected none: npm leaves it out of every entry or of none, and ${i.omitted} has none`,n);i.resolved??=n}}function Yt(e,t){let{semver:n,escape:r,own:i,root:a}=t;if(!i.has(e)){let t=e.kind===`link`?[]:zt(e,n),o=Ut(t.length===0?[Ht(e,void 0,r)]:t.map(t=>Ht(e,t,r)));i.set(e,{heads:o,bundled:he(e,a)||void 0})}return i.get(e)}function Xt(e,t,n,r,i){m(e,n,Lt);let{heads:a,bundled:o}=Yt(t,i),s=a.find(({version:t,from:n})=>t===e.version&&n===e.from)??a[0];Q(e,`version`,s.version,n,t),Q(e,`from`,s.from,n,t),Jt(e.resolved,s.resolved,C(n,`resolved`),t,i),Q(e,`bundled`,o,n,t),Q(e,`integrity`,t.resolution?.integrity,n,t);for(let r of L)Q(e,r,t.flags?.[r]||void 0,n,t);let c=W(t);Kt(e.requires,c,i.escape,C(n,`requires`)),qt(e.dependencies,c,C(n,`dependencies`),r,i)}function $(e,t,n,r,i={}){let a=e=>e.includes(`#`)?(i.hash=!0,r?e.replaceAll(`#`,`%23`):e):e,o=t.get(``);qt(e,o,`dependencies`,[],{semver:n,escape:a,own:new Map,root:o,omitted:void 0,resolved:void 0})}var Zt=`9.0.0`;function Qt(e,t,n,r){if(r!==void 0)return $(e,t,n,Rt(r));let i={hash:!1};try{$(e,t,n,!1,i)}catch(r){if(!(r instanceof b)||!i.hash)throw r;try{$(e,t,n,!0)}catch{throw r}Ct(t,Zt,`an npm that writes a "#" as "%23"`)}}var $t=[`checkVersions`,`semver`,`legacyPeerDeps`,`npm`],en=[`satisfies`,`valid`,`validRange`],tn=[`name`,`version`,`lockfileVersion`,`requires`,`packages`,...L];function nn(e){let{semver:t,legacyPeerDeps:n=!1,npm:r}=ae(e,$t),i=oe(e,en);if(typeof n!=`boolean`)throw TypeError(`legacyPeerDeps: expected a boolean`);if(r!==void 0&&!(/^\d+\.\d+\.\d+$/u.test(r)&&Number(r.split(`.`)[0])>=9))throw TypeError(`npm: expected a version of npm 9 or later, such as 11.12.1`);if(r===`11.6.1`||r===`11.6.2`)throw TypeError(`npm: ${r} works the flags out in a way not read here`);return{semver:i?t:void 0,legacyPeerDeps:n,npm:r}}function rn(e){let t=m(e,void 0).lockfileVersion;if(t!==2&&t!==3)throw new b(`unsupported version: expected 2 or 3, found ${f(t)}`,`lockfileVersion`);if(m(e,void 0,t===2?[...tn,`dependencies`]:tn),e.requires!==!0)throw p(`true`,e.requires,`requires`);return t}function an(e,t){let n=g(e.name,`name`);if(t.name!==void 0&&t.name!==n)throw new b(`expected the project's, ${S(t.name)}`,`name`);if(e.version!==t.version)throw new b(t.version===void 0?`a version, where the project has none`:`expected the project's, ${S(t.version)}`,`version`);let r=L.find(n=>v(e[n],n)!==t.flags[n]);if(r!==void 0)throw new b(`expected ${t.flags[r]?`true`:`none`}, as the project's in packages`,r);return{name:n,version:t.version}}var on=e=>e.kind===`link`?`link:${G(e.target)}`:e.location;function sn(e){let t=Object.create(null);for(let n of e.edges.values())t[n.name]={type:n.type,spec:n.spec,accept:n.accept,target:n.to===void 0?void 0:on(n.to)};return t}function cn(e){let{name:t,version:n,os:r,cpu:i,libc:a,license:o,funding:s,deprecated:c,hasInstallScript:l,flags:u}=e;return{name:t,version:n,edges:sn(e),bundleDependencies:e.bundleDependencies??[],engines:e.engines??Object.create(null),os:r,cpu:i,libc:a,bin:e.bin??Object.create(null),license:o,funding:s,deprecated:c,hasInstallScript:l,...u,devOptional:u.devOptional||u.dev||u.optional}}function ln(e,t={}){if(typeof e!=`string`)throw TypeError(`expected a string`);let{semver:n,legacyPeerDeps:r,npm:i}=nn(t),a=Et(e),o=rn(a),s=lt(a.packages),c=s.get(``),l=ut(s);mt(s,l,r),It(s,n),Ct(s,i),_e(s),o===2&&Qt(a.dependencies,s,n,i);let u=an(a,c),ee=new Set(l.values()),d=Object.create(null),f=Object.create(null),p=Object.create(null);for(let e of new Set([c,...s.values()]))e.kind===`link`?p[e.location]=G(e.target):e.kind===`package`?f[e.location]={...cn(e),resolution:e.resolution,inBundle:e.inBundle}:d[G(e)]={...cn(e),workspace:ee.has(e),workspaces:e.workspaces??[]};return{lockfileVersion:o,...u,importers:d,packages:f,links:p}}export{b as LockfileError,ln as parseNpmLockfile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-GO7FT4OD.js";import{c as t,d as n,e as r,h as i,i as a,j as o,m as s,n as c,o as l,p as u}from"./chunk-24AKGEH3.js";import{a as d}from"./chunk-7GJNLCXF.js";import"./chunk-PXK7EU4V.js";import{a as f,c as p}from"./chunk-JCIIBLKR.js";import{l as m,p as h,q as g,v as _}from"./chunk-65PLAG3I.js";import{b as v}from"./chunk-IYPY47MC.js";import"./chunk-QRKFPLA4.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function y(e){if(e instanceof Uint8Array)return{proven:!1,reason:`unsupported`,at:null};if(typeof e!=`string`)throw TypeError(`a text must be a string or its UTF-8 bytes, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a text must be a well-formed string`);return{proven:!1,reason:`unsupported`,at:null}}var b=e=>e.subarray(0,8e3).includes(0),x=(e,t)=>(e+Math.imul(t,97)>>>0)%107927,S=e=>Uint8Array.from({length:256},(t,n)=>Number(n===10||e.includes(String.fromCodePoint(n)))),C=S(``),w=S(`,;={}`);function T(e,t=C){let n=!b(e),r=new Map,i=(e,t)=>r.set(e,(r.get(e)??0)+t),a=0,o=0,s=0;for(let r=0;r<e.length;r++){let c=e[r];if(n&&c===13&&e[r+1]===10)continue;let l=a;a=(a<<7^o>>>25)+c>>>0,o=(o<<7^l>>>25)>>>0,!(++s<64&&t[c]===0)&&(i(x(a,o),s),s=0,a=0,o=0)}s>0&&i(x(a,o),s);let c=Uint32Array.from(r.keys()).sort();return{hashes:c,bytes:Float64Array.from(c,e=>r.get(e)),total:r.values().reduce((e,t)=>e+t,0)}}function E(e,t){let n=0;for(let r=0,i=0;r<e.hashes.length&&i<t.hashes.length;)e.hashes[r]<t.hashes[i]?r++:e.hashes[r]>t.hashes[i]?i++:n+=Math.min(e.bytes[r++],t.bytes[i++]);return n}function D(e,t,n){let r=0,i=e.total,a=t.total;for(let o=0,s=0;o<e.hashes.length&&s<t.hashes.length;)if(e.hashes[o]<t.hashes[s]?i-=e.bytes[o++]:(e.hashes[o]>t.hashes[s]||(r+=Math.min(e.bytes[o],t.bytes[s]),i-=e.bytes[o++]),a-=t.bytes[s++]),(r+Math.min(i,a))*6e4<n)return 0;return r}function O(e,t,n,r,i=!1){if(e===null||t===null||t.length===0)return 0;let a=Math.abs(e.length-t.length),o=Math.max(e.length,t.length);if(o*(6e4-n)<a*6e4)return 0;let s=r(e),c=r(t),l=i?D(s,c,n*o):E(s,c);return Math.trunc(l*6e4/o)}var k=/^[\w-]{6,}$/u,A=/[\dA-Z]/u,ee=/^(?:\.[\w-]+)+$/u,te=/^[\w-]{8,32}$/u;function j(e){let t=[];for(let n=e.length-1;n>0;n--){if(e[n]!==`-`&&e[n]!==`.`)continue;let r=e.indexOf(`.`,n+1),i=e.slice(r),a=e.slice(n+1,r);r!==-1&&te.test(a)&&ee.test(i)&&/[A-Za-z]/u.test(a)&&A.test(a)&&t.push([e.slice(0,n),a,i])}return t}var M=e=>e.replaceAll(/\d/gu,`0`).replaceAll(/[a-z]/gu,`a`).replaceAll(/[A-Z]/gu,`A`);function ne(e,t){let n=j(t);for(let[t,r,i]of j(e)){let e=n.find(e=>e[2]===i);if(e&&e[1]!==r)return e[0]===t&&M(e[1])!==M(r)}return!1}function re(e){let t=e.lastIndexOf(`/`),n=e.slice(t+1),r=n.lastIndexOf(`.`),i=r>0?n.slice(r):``;return{name:n,key:`${e.slice(0,t+1)}\0${i}\0${n.length}`}}function ie(e,t){let n=e.length,r=0;for(;r<e.length&&e[r]===t[r];)r++;for(;n>r&&e[n-1]===t[n-1];)n--;for(;r>0&&!`-._`.includes(e[r-1]);)r--;for(;n<e.length&&e[n]!==`.`;)n++;let i=e.slice(r,n),a=t.slice(r,n);return r>0&&k.test(i)&&k.test(a)&&(A.test(i)||A.test(a))}function ae({sources:e,dests:t,pairs:n,used:r,record:i,punctuatedScoreOf:a},{remaining:o,open:s},c,l){let u=(e,t)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>[t,re(e[t].path)])),d=u(t,s),f=u(e,o),p=Map.groupBy(f.keys(),e=>f.get(e).key),m=Map.groupBy(d.keys(),e=>d.get(e).key),h=[];for(let[e,t]of m){let n=p.get(e)??[];for(let e of t)for(let t of n)ie(f.get(t).name,d.get(e).name)&&h.push({s:t,d:e})}let g=Map.groupBy(h,({d:e})=>e),_=Map.groupBy(h,({s:e})=>e),v=[];for(let{s:e,d:t}of h){let n=_.get(e).length===1&&g.get(t).length===1&&ne(f.get(e).name,d.get(t).name),r=a(e,t,n?0:c);(n||r>=c)&&v.push({s:e,d:t,score:r})}let y=[],b=new Set,x=new Set;for(let e of v.sort((e,t)=>t.score-e.score))n.has(e.d)||r.has(e.s)||(x.has(e.s)||b.has(e.d)||l(e)?(y.push(e),x.add(e.s),b.add(e.d)):i(e.d,e.s,e.score));return y}function oe(e,t){let n=e.length;if(n!==t.length)return!1;let r=0;if(n>=32&&(e.byteOffset&3)==(t.byteOffset&3)){for(let n=4-(e.byteOffset&3)&3;r<n;r++)if(e[r]!==t[r])return!1;let i=n-r>>>2,a=new Int32Array(e.buffer,e.byteOffset+r,i),o=new Int32Array(t.buffer,t.byteOffset+r,i);for(let e=0;e<i;e++)if(a[e]!==o[e])return!1;r+=i*4}for(;r<n;r++)if(e[r]!==t[r])return!1;return!0}var N=class extends Error{constructor(e,t,n){let r=n===void 0?``:` in the ${n} tree`;super(t===void 0?e:`${e}: ${JSON.stringify(t)}${r}`),this.name=`CompareError`,this.path=t,this.tree=n}},se=new Set([`file`,`contiguous-file`]),ce=new Set([`fifo`,`character-device`,`block-device`]),le=/(?:^|\/)\.{0,2}(?:\/|$)/u;function ue(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`)}function de(e,t,n,r){if(typeof e!=`string`)throw TypeError(`an entry's name must be a string, not ${typeof e}`);if(e!==`.`||t!==`directory`){if(r?e===``:le.test(e))throw new N(r?`a name must not be empty`:"a name must be a relative path with no empty, `.` or `..` segment",e,n);if(!e.isWellFormed())throw new N(`a name must be well-formed Unicode`,e,n)}}function fe(e,t,n){if(typeof e!=`string`||e===``)throw new N(`a link must name its target`,t,n);if(!e.isWellFormed())throw new N(`a link target must be well-formed Unicode`,t,n);return e}function pe(e){if(e===void 0)return new Uint8Array;if(e instanceof Uint8Array)return e;if(typeof e!=`string`)throw TypeError(`a file's data must be a string or a Uint8Array, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a file's text must be well-formed Unicode`);return e}var P=e=>typeof e==`string`?d(e):e;function me(e,t,n){if(typeof e!=`object`||!e)throw TypeError(`an entry must be an object, not ${e===null?`null`:typeof e}`);let{name:r,type:i=`file`,mode:a,linkname:o,data:s}=e;if(de(r,i,t,n),a!==void 0&&ue(a),se.has(i))return{path:r,type:`file`,mode:a??420,data:pe(s)};if(i===`symlink`||i===`hardlink`)return{path:r,type:i,target:fe(o,r,t)};if(i===`directory`)return{path:r,type:i};throw ce.has(i)?new N(`a ${i} is neither a file nor a link`,r,t):TypeError(`${JSON.stringify(i)} is not an entry type`)}function F(e,t){return e.type===t.type?e.type===`symlink`?e.target===t.target:e.data===t.data?!0:typeof e.data==`string`&&typeof t.data==`string`?!1:oe(P(e.data),P(t.data)):!1}function he(e,t,n){let r=new Set([e.path]),i=t.get(e.target);for(;i?.type===`hardlink`;){if(r.has(i.path))throw new N(`a hard link leads back to itself`,e.path,n);r.add(i.path),i=t.get(i.target)}if(i===void 0||i.type===`directory`)throw new N(`a hard link must name a file or a link in the tree`,e.path,n);return{...i,path:e.path}}function I(e,t,n){let r=new Map;for(let i of e){let e=me(i,t,n);if(e.type!==`directory`||e.path!==`.`){if(r.has(e.path))throw new N(`a name is given twice`,e.path,t);r.set(e.path,e)}}let i=new Map;for(let[e,a]of r){for(let i=n?-1:e.lastIndexOf(`/`);i>0;i=e.lastIndexOf(`/`,i-1)){let n=r.get(e.slice(0,i));if(n!==void 0&&n.type!==`directory`)throw new N(`a path lies under a ${n.type===`symlink`?`link`:`file`}`,e,t)}a.type===`hardlink`?i.set(e,he(a,r,t)):a.type!==`directory`&&i.set(e,a)}return i}var ge=100,_e=4,L=e=>e.slice(e.lastIndexOf(`/`)+1);function R(t,n){if(t.type===`symlink`)return`l${t.target}`;let r=n(t);return`f${r.length}:${e(r)}`}function ve({sources:e,dests:t,sourceNames:n,destNames:r,used:i,record:a,bytes:o}){let s=Map.groupBy(e.keys(),t=>R(e[t],o));for(let c=0;c<t.length;c++){let l=-1,u=ge;for(let a of s.get(R(t[c],o))??[])if(!i.has(a)&&F(e[a],t[c])&&((l===-1||n[a]===r[c])&&(l=a),n[a]===r[c]||--u===0))break;l!==-1&&a(c,l,6e4)}}var ye=new Map([[`.ts`,`.js`],[`.mts`,`.mjs`],[`.cts`,`.cjs`],[`.tsx`,`.jsx`]]),be=new Map([...[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.mts`,`.cts`,`.tsx`].map(e=>[e,`script`]),...[`.css`,`.scss`,`.sass`,`.less`].map(e=>[e,`style`])]);function z(e){let t=e.split(`/`),n=t.pop(),r=n.lastIndexOf(`.`);return r>0?{dirs:t,stem:n.slice(0,r),extension:n.slice(r)}:{dirs:t,stem:n,extension:``}}function B(e){let{dirs:t,stem:n,extension:r}=z(e);return JSON.stringify([t.map(e=>e===`lib`||e===`src`?null:e),n,ye.get(r)??r])}function xe(e){let{dirs:t,stem:n,extension:r}=z(e),i=[n,be.get(r)??r],a=t.lastIndexOf(`node_modules`),o=a===-1?0:a+(t[a+1]?.startsWith(`@`)?3:2),s=[JSON.stringify([...i,t])];for(let e=o;e<t.length;e++)s.push(JSON.stringify([...i,t.toSpliced(e,1,null)]));return s}var V=(e,t)=>Math.max(t,e+Math.trunc((6e4-e)/2));function H({pairs:e,used:t,scoreOf:n},{remaining:r,open:i},{s:a,d:o,score:s},c){let l=V(s,c);return i.some(t=>t!==o&&!e.has(t)&&n(a,t,l)>=l)||r.some(e=>e!==a&&!t.has(e)&&n(e,o,l)>=l)}function Se(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=Map.groupBy(t.remaining.filter(e=>i[e].type===`file`),e=>B(i[e].path)),d=t.open.filter(e=>a[e].type===`file`).flatMap(e=>(u.get(B(a[e].path))??[]).map(t=>({s:t,d:e,score:l(t,e,0)})));for(let i of d.sort((e,t)=>t.score-e.score))o.has(i.d)||s.has(i.s)||n&&H(e,t,i,r)||c(i.d,i.s,i.score)}function Ce(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=new Map,d=(e,t,n)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>{let r=xe(e[t].path);for(let e of r)(u.get(e)??u.set(e,{sources:[],dests:[]}).get(e))[n].push(t);return[t,r]})),f=d(a,t.open.filter(e=>!o.has(e)),`dests`),p=d(i,t.remaining.filter(e=>!s.has(e)),`sources`),m=(e,t)=>{let n=new Set(e.flatMap(e=>u.get(e)[t]));return n.size===1?[...n][0]:-1};for(let[i,a]of p){let o=m(a,`dests`);if(o===-1||m(f.get(o),`sources`)!==i)continue;let s={s:i,d:o,score:l(i,o,0)};n&&H(e,t,s,r)||c(o,i,s.score)}}function we(e,t,n){let r=G(e),i=t<6e4&&r.remaining.length*r.open.length<=n*n;Se(e,r,i,t),Ce(e,r,i,t)}function U(e,t){let n=new Map;for(let r of t)n.set(e[r],n.has(e[r])?-1:r);return n}function Te({sourceNames:e,destNames:t,record:n,scoreOf:r},{remaining:i,open:a},o){let s=U(t,a),c=U(e,i);for(let t of i){let i=s.get(e[t]);if(i===void 0||i===-1||c.get(e[t])===-1)continue;let a=r(t,i,o);a>=o&&n(i,t,a)}}var W=(e,t)=>t.score-e.score||t.nameScore-e.nameScore;function Ee(e,t){if(e.length<_e){e.push(t);return}let n=0;for(let t=1;t<e.length;t++)W(e[t],e[n])>0&&(n=t);W(e[n],t)>0&&(e[n]=t)}function De({sourceNames:e,destNames:t,pairs:n,used:r,record:i,scoreOf:a},{remaining:o,open:s},c,l){let u=[];for(let n of s){let r=[];for(let i of o)Ee(r,{score:a(i,n,c),nameScore:+(e[i]===t[n]),dst:n,src:i});u.push(...r)}let d=0,f=e=>{for(;d<l.length&&V(l[d].score,c)>e;d++){let{s:e,d:t,score:a}=l[d];!n.has(t)&&!r.has(e)&&i(t,e,a)}};for(let{dst:e,src:t,score:a}of u.sort(W)){if(a<c)break;f(a),!n.has(e)&&!r.has(t)&&i(e,t,a)}f(-1/0)}var G=({sources:e,dests:t,pairs:n,used:r})=>({remaining:e.keys().filter(e=>!r.has(e)).toArray(),open:t.keys().filter(e=>!n.has(e)).toArray()}),K=e=>V(e,e);function q(e,t,{minimum:n,limit:r,byPath:i}){let a=new Map,o=new Set;if(e.length===0||t.length===0)return a;let s=new Map,c=new Map,l=new Map,u=e=>e.type===`file`?c.get(e)??c.set(e,P(e.data)).get(e):null,d=e=>s.get(e)??s.set(e,T(e)).get(e),f=e=>l.get(e)??l.set(e,T(e,w)).get(e),p={sources:e,dests:t,pairs:a,used:o,sourceNames:e.map(e=>L(e.path)),destNames:t.map(e=>L(e.path)),record(e,t,n){a.set(e,{source:t,score:n}),o.add(t)},bytes:u,scoreOf:(n,r,i)=>O(u(e[n]),u(t[r]),i,d),punctuatedScoreOf:(n,r,i)=>O(u(e[n]),u(t[r]),i,f,!0)};if(ve(p),i&&we(p,n,r),n>=6e4)return a;Te(p,G(p),K(n));let m=G(p);if(m.remaining.length*m.open.length>r*r)return a;let h=i?ae(p,m,K(n),e=>H(p,m,e,n)):[];return De(p,G(p),n,h),a}var Oe=50,ke=1e3;function J(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.codePointAt(r)-t.codePointAt(r);return e.length-t.length}function Ae(e){if(e===!1)return null;let t=e===!0?Oe:e;if(typeof t!=`number`)throw TypeError(`renames must be a boolean or a percentage, not ${typeof e}`);if(!(t>0&&t<=100))throw RangeError(`renames must be a percentage above 0 and at most 100, not ${e}`);return Math.max(1,Math.trunc(6e4*t/100))}function je({renamesByPath:e,renameLimit:t,renameGroup:n,paths:r,lines:i}){if(typeof e!=`boolean`)throw TypeError(`renamesByPath must be a boolean, not ${typeof e}`);if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw RangeError(`renameLimit must be a whole number or Infinity, not ${t}`);if(n!==null&&typeof n!=`function`)throw TypeError(`renameGroup must be a function, not ${typeof n}`);if(r!==`tree`&&r!==`keys`)throw RangeError(`paths must be 'tree' or 'keys', not ${r}`);if(typeof i!=`boolean`)throw TypeError(`lines must be a boolean, not ${typeof i}`)}var Me=(e,t)=>F(e,t)&&(e.type!==`file`||e.mode===t.mode),Y=(e,t,n,r=null)=>({status:e,old:t,new:n,similarity:r}),Ne=/\.d\.(?:[^./]+\.)?[cm]?ts$/u,Pe=e=>e.endsWith(`.mts`)?`module`:e.endsWith(`.cts`)?`commonjs`:null,Fe=/^export\s*\{\s*\}\s*;?$/u;function Ie(e){if(e===null)return{proven:!0,runtime:``,loads:!1};try{return t(e)===void 0?{proven:!1}:y(e.data)}catch{return{proven:!1}}}function Le(e){if(![e.old,e.new].filter(e=>e!==null).every(e=>e.type===`file`&&Ne.test(e.path))||e.old&&e.new&&e.old.mode!==e.new.mode)return e;let t=Ie(e.new),n=Ie(e.old);return!n.proven||!t.proven||n.runtime!==t.runtime&&!(e.old===null&&Fe.test(t.runtime))||n.loads&&e.old&&e.new&&e.old.path!==e.new.path&&Pe(e.old.path)!==Pe(e.new.path)?e:{...e,typeOnly:!0}}function Re(e,t){let n=[],r=[],i=[];for(let[n,a]of e){let e=t.get(n);e===void 0?i.push(a):e.type===a.type?Me(a,e)||r.push(Y(`modified`,a,e)):r.push(Y(`type-changed`,a,e))}for(let[r,i]of t)e.has(r)||n.push(i);return i.sort((e,t)=>J(e.path,t.path)),n.sort((e,t)=>J(e.path,t.path)),{changes:r,deleted:i,added:n}}function ze(e,t,{group:n,...r}){if(n===null)return q(e,t,r);let i=new Map,a=e=>Map.groupBy(e.keys(),t=>n(e[t].path)),o=a(e);for(let[n,s]of a(t)){let a=o.get(n);if(a!==void 0)for(let[n,{source:o,score:c}]of q(a.map(t=>e[t]),s.map(e=>t[e]),r))i.set(s[n],{source:a[o],score:c})}return i}function Be(e,t,{renames:i=!0,renamesByPath:a=!0,renameLimit:o=ke,renameGroup:s=null,paths:c=`tree`,lines:l=!0,horizon:u,whitespace:d,ignoreCase:f}={}){let p=Ae(i);je({renamesByPath:a,renameLimit:o,renameGroup:s,paths:c,lines:l});let m=n({horizon:u,whitespace:d,ignoreCase:f}),h=c===`keys`,{changes:g,deleted:_,added:v}=Re(I(e,`old`,h),I(t,`new`,h)),y=p===null?new Map:ze(_,v,{minimum:p,limit:o,byPath:a,group:s});for(let[e,t]of v.entries()){let n=y.get(e);g.push(n===void 0?Y(`added`,null,t):Y(`renamed`,_[n.source],t,Math.trunc(n.score*100/6e4)))}let b=new Set(y.values().map(({source:e})=>e));for(let[e,t]of _.entries())b.has(e)||g.push(Y(`deleted`,t,null));return g.sort((e,t)=>J((e.new??e.old).path,(t.new??t.old).path)),(l?g.map(e=>({...e,...r(e.old,e.new,m)})):g).map(Le)}function X(e,t,n){let r=new Map,o=new Set,s=0;for(let a of e){let e=i(n,a);e===null||!t.has(e)||(r.set(a,e),o.add(e),e!==a&&s++)}for(let n of e)r.has(n)||!t.has(n)||o.has(n)||(r.set(n,n),o.add(n));let c=r.size;for(let s of e){if(r.has(s))continue;let e=i(n,s)??a(n,s);for(;t.has(e)||o.has(e);)e=`../${e}`;r.set(s,e),o.add(e)}return{paths:r,paired:c,moved:s}}function Ve(e,t){let n=new Set(e),r=new Set(t),i=(e,t)=>{let n=new Map;for(let r of e)for(let e=r.indexOf(`/`);e!==-1;e=r.indexOf(`/`,e+1)){let i=r.slice(0,e+1);t.has(r.slice(e+1))&&n.set(i,(n.get(i)??0)+1)}let r=null,i=!1;for(let[e,t]of n)t>(n.get(r)??0)?[r,i]=[e,!1]:t===n.get(r)&&(i=!0);return i?null:r},a=X(n,r,null).paired,o=[[{base:``,other:i(r,n)},n],[{base:i(n,r),other:``},r]].filter(([e])=>e.base!==null&&e.other!==null).map(([e,t])=>({root:e,side:t,...X(n,r,e)})).filter(({side:e,paired:t,moved:n})=>t>a&&n*2>=e.size);return o.length===2&&o[0].paired===o[1].paired?null:o.toSorted((e,t)=>t.paired-e.paired)[0]?.root??null}function He(e,t){let n=[...e],r=new Set(t),i=Ve(n,r);return{root:i,paths:X(n,r,i).paths}}function Ue(e,t,n){if(!e&&!t)return null;let r=[...e??[]],i=Map.groupBy(r,([,e])=>e),a=new Map(i.entries().map(([e,t])=>[e,o(n,e,t.map(([t])=>t.slice(e.length+1)))]));return new Map([...r.map(([e,t])=>[n.paths.get(e)??e,a.get(t)]),...t??[]])}function We(e,t,n=new Map,r=new Map,i=null,a=()=>!1){let o=e=>{let t=n.get(e)??r.get(e);return t===void 0?[...new Set([e,Ze(i,e)??e])]:[t]},s=[],c=[],u=[],d=new Set;for(let n of e.values()){let e=o(n.parent).map(e=>t.get(l(e,n.specifier,n.conditions,n.platform))).find(Boolean),i=r.get(n.target)??n.target;if(e){if(d.add(e.key),!o(n.target).includes(e.target)){let{target:t,...n}=e;s.push({...n,baseTarget:i,otherTarget:t})}continue}let u=o(n.parent).find(a);if(u===void 0)continue;let{specifier:f,conditions:p,platform:m}=n;c.push({key:l(u,f,p,m),parent:u,specifier:f,conditions:p,platform:m,baseTarget:i,otherTarget:null})}for(let e of t.values()){if(d.has(e.key)||!a(e.parent))continue;let{target:t,...n}=e;u.push({...n,baseTarget:null,otherTarget:t})}for(let e of[s,c,u])e.sort((e,t)=>e.key.localeCompare(t.key));return{changed:s,onlyBase:c,onlyOther:u,totalChanges:s.length+c.length+u.length}}function Z(e){return m(e)??0}function Ge(e,t){return e===t||e?.format===`base64`&&t?.format===`base64`&&e.data===t.data||e?.format===`digest`&&t?.format===`digest`&&e.digest===t.digest}function Q(e){if(e?.kind!==`stasis`||!e.bundle)return null;let{formats:t,executable:n,entries:r}=e.bundle;return e=>({format:t?.get(e),executable:n?.has(e)??!1,entry:r?.has(e)??!1})}function Ke(e,t){return!e||!t?[]:[`format`,`executable`,`entry`].filter(n=>e[n]!==t[n]).map(n=>({field:n,from:e[n],to:t[n]}))}function qe(e){return(t,n)=>Math.abs(n.delta)-Math.abs(t.delta)||t[e].localeCompare(n[e])}function $(e){return(t,n)=>n.bytes-t.bytes||t[e].localeCompare(n[e])}function Je(e,t){return typeof e==`string`?`\0text\0${e.toWellFormed()}`:e?.format===`base64`?`\0base64\0${e.data}`:e?.format===`digest`?`\0digest\0${e.digest}`:`\0none\0${t}`}var Ye=250;function Xe(e,t,n,r,i){let a=(e,t,n)=>e.filter(({path:e})=>e!==``&&e.isWellFormed()).map(({path:e},r)=>({name:e,data:Je(t.get(e),`${n}${r}`)})),o={paths:`keys`,renameGroup:i,renameLimit:Ye,lines:!1},s=Be(a(e,n,`a`),a(t,r,`b`),o);return new Map(s.filter(({status:e})=>e===`renamed`).map(e=>[e.old.path,e.new.path]))}function Ze(e,t){return e?e.base===``?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}function Qe(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function $e(e,t,n,r=He(e.keys(),t.keys()),i=[]){let{root:a,paths:o}=r,s=new Map([...o].map(([e,t])=>[t,e]));e=new Map([...e].map(([e,t])=>[o.get(e),t]));let c=e=>s.get(e)===e?{}:{basePath:s.get(e)},l=(e,t)=>{let n=Ke(i[0]?.(e),i[1]?.(t));return n.length>0?{meta:n}:{}},u=[],d=[],f=[],p=0,m=0,h=0,g=0,_=0,v=0,y=new Map,b=e=>{let t=n(e),r=y.get(t);return r||(r=Qe(),y.set(t,r)),r},x=new Set([...e.keys(),...t.keys()]);for(let n of x){let r=e.has(n),i=t.has(n),a=b(n);if(r&&i){let r=e.get(n),i=t.get(n),o=Ge(r,i),u=l(s.get(n),n),d=Z(r),h=o?d:Z(i);if(p+=d,m+=h,a.baseBytes+=d,a.otherBytes+=h,o&&!u.meta)v++;else{let e=h-d;f.push({path:n,...c(n),baseBytes:d,otherBytes:h,delta:e,...u,...o?{modified:!1}:{}}),_+=e,a.changedFiles++}}else if(r){let t=Z(e.get(n));p+=t,h+=t,a.baseBytes+=t,a.onlyBaseFiles++,u.push({path:n,...c(n),bytes:t})}else{let e=Z(t.get(n));m+=e,g+=e,a.otherBytes+=e,a.onlyOtherFiles++,d.push({path:n,bytes:e})}}let S=Xe(u,d,e,t,n);if(S.size>0){let n=new Set(S.values());for(let[n,r]of S){let i=e.get(n),a=t.get(r),o=Ge(i,a),c=Z(i),u=o?c:Z(a);h-=c,g-=u,f.push({path:r,renamedFrom:n,basePath:s.get(n),baseBytes:c,otherBytes:u,delta:u-c,modified:!o,...l(s.get(n),r)}),_+=u-c;let d=b(n);d.onlyBaseFiles--,d.onlyOtherFiles--,d.changedFiles++}u.splice(0,u.length,...u.filter(e=>!S.has(e.path))),d.splice(0,d.length,...d.filter(e=>!n.has(e.path)))}let C=[],w=[],T=[],E=[];for(let[e,t]of y){let n=t.baseBytes>0||t.onlyBaseFiles>0||t.changedFiles>0,r=t.otherBytes>0||t.onlyOtherFiles>0||t.changedFiles>0,i=t.onlyBaseFiles+t.onlyOtherFiles+t.changedFiles;n&&!r?C.push({pkg:e,bytes:t.baseBytes}):r&&!n?w.push({pkg:e,bytes:t.otherBytes}):i>0||t.baseBytes!==t.otherBytes?T.push({pkg:e,baseBytes:t.baseBytes,otherBytes:t.otherBytes,delta:t.otherBytes-t.baseBytes}):E.push({pkg:e,bytes:t.baseBytes})}return u.sort($(`path`)),d.sort($(`path`)),f.sort(qe(`path`)),C.sort($(`pkg`)),w.sort($(`pkg`)),T.sort(qe(`pkg`)),{totals:{baseFiles:e.size,baseBytes:p,otherFiles:t.size,otherBytes:m,onlyBaseFiles:u.length,onlyBaseBytes:h,onlyOtherFiles:d.length,onlyOtherBytes:g,changedFiles:f.length,renamedFiles:S.size,changedDelta:_,unchangedFiles:v,fileDelta:t.size-e.size,byteDelta:m-p,identical:u.length===0&&d.length===0&&f.length===0},files:{onlyBase:u,onlyOther:d,changed:f,root:a,basePaths:o},packages:{onlyBase:C,onlyOther:w,changed:T,unchanged:E}}}function et(e,t,n=null){let[r,i]=[e,t],[a,o]=s(r,i,n),l=c(r,a),d=c(i,o),m=He(l.keys(),d.keys()),y=Ue(h(r),h(i),m),b=$e(l,d,e=>v(e,{packageDir:y?.get(e)}),m,[Q(r),Q(i)]),x=_(r),S=_(i),C=(e,t)=>{let n=0;for(let r of t)n+=e.get(r)??0;return n};Object.assign(b.totals,{baseLines:C(x,l.keys()),otherLines:C(S,d.keys())});for(let e of b.files.onlyBase)e.lines=x.get(e.basePath??e.path)??0;for(let e of b.files.onlyOther)e.lines=S.get(e.path)??0;for(let e of b.files.changed)Object.assign(e,{baseLines:x.get(e.basePath??e.path)??0,otherLines:S.get(e.path)??0});let w=new Set([...b.files.onlyOther,...b.files.changed.filter(e=>e.modified!==!1)].map(e=>e.path));b.resolutions=We(u(r,a),u(i,o),new Map(b.files.changed.filter(e=>e.renamedFrom!=null).map(e=>[e.basePath,e.path])),b.files.basePaths,b.files.root,e=>d.has(e)&&!w.has(e));let T=e=>v(``,{packageDir:e}),E=g(r,a?l.keys():null,T),D=g(i,o?d.keys():null,T);return b.versionUpdates=p(E,D),b.packageRows=f(b.packages,E,D),b.scope=n??``,b}export{et as prepareComparison};
|
package/out/chunk-WMFDQS2L.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import{a as e,b as t,c as n,d as r}from"./chunk-M3Y6SLC4.js";import{C as i,D as a,E as o,H as s,M as c,N as l,Q as u,S as d,a as f,e as p,f as m,h,i as g,j as _,k as v,m as y,n as b,o as x,p as S,q as ee,r as C,x as w,y as T,z as te}from"./chunk-UCP3JRE2.js";import{a as ne}from"./chunk-Z667U2UJ.js";import{b as re}from"./chunk-DEVAORP2.js";import"./chunk-ZQHLECTI.js";import"./chunk-PXK7EU4V.js";import{a as ie,b as E,c as ae,d as D,f as oe,h as O,i as k,k as se,n as A,q as ce}from"./chunk-JMG5DXII.js";import"./chunk-OOJM4CTU.js";var j=class extends ae{},le=e=>RegExp(`(?:[^ ?:,[\\]{}#&*!|>'"%@\`-]|[-?:](?=[^${e}]))(?:[^:${e}]|:(?=[^${e}])| +(?=[^#:${e}]|:[^${e}]))*`,`uy`),ue={block:le(` `),flow:le(` ,[\\]{}`)},de=/'((?:[^']|'')*)'/uy,fe=/"((?:[^"\\]|\\.)*)"/uy,pe={__proto__:null,0:`\0`,a:`\x07`,b:`\b`,t:` `,n:`
|
|
2
2
|
`,v:`\v`,f:`\f`,r:`\r`,e:`\x1B`," ":` `,'"':`"`,"/":`/`,"\\":`\\`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`},me=/\\(?:x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|U([\dA-Fa-f]{8})|(.))/gu;function he(e,t){return e.replace(me,(e,n,r,i,a)=>{if(a!==void 0){if(!(a in pe))throw new j(`unknown escape \\${a}`,t.line);return pe[a]}let o=Number.parseInt(n??r??i,16);if(o>1114111||o>=55296&&o<=57343)throw new j(`${e} is not a Unicode scalar value`,t.line);return String.fromCodePoint(o)})}var ge={__proto__:null,true:!0,false:!1,null:null},_e=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[Ee][+-]?\d+)?$/u,ve=/^(?:~|null|true|false|\.nan|[+-]?(?:\.inf|0[box][\d_a-f]+|(?:\d[\d_]*(?:\.[\d_]*)?|\.[\d_]+)(?:e[+-]?\d+)?))$/iu,ye=/^\d{4}-(?:\d\d-\d\d|\d\d?-\d\d?(?:[Tt]| +)\d\d?:\d\d:\d\d(?:\.\d*)?(?: *(?:Z|[+-]\d\d?(?::\d\d)?))?)$/u;function be(e,t){if(e in ge)return ge[e];if(_e.test(e)&&e!==`-0`){let n=Number(e);if(Math.abs(n)>2**53-1)throw new j(`number out of range ${E(e)}`,t.line);return n}if(ve.test(e)||ye.test(e))throw new j(`ambiguous scalar ${E(e)}, quote it`,t.line);return e}var M=e=>e.pos<e.text.length?E(e.text.slice(e.pos)):`the end of the line`,xe=(e,t)=>he(e,{line:t});function Se(e,t){let n=A(e,de);return n===null?(n=A(e,fe),n===null?(n=A(e,ue[t]),n===null?void 0:be(n[0],e)):he(n[1],e)):n[1].replaceAll(`''`,`'`)}function Ce(e,t){let n=Se(e,t);if(n===void 0)throw new j(`expected a scalar, found ${M(e)}`,e.line);return n}function N(e,t,n,r){if(typeof t!=`string`)throw new j(`keys must be strings`,r);if(t===`<<`)throw new j(`merge keys are not supported`,r);if(t in e)throw new j(`duplicate key ${E(t)}`,r);e[t]=n}var P=/ */uy,we=/, */uy,Te=/: +/uy,Ee=/:(?: +(?:#.*)?|$)/uy,De=/(?: +#.*| *)$/uy,Oe=64;function F(e,t){let n=t===`]`?[]:Object.create(null);if(e.workflow&&++e.depth>Oe)throw new j(`nested too deep`,e.line);if(e.pos++,A(e,P),e.text[e.pos]!==t)do{if(e.workflow&&e.text[e.pos]===t)break;if(e.workflow)je(e,n,t);else{let r=I(e);if(t===`]`)n.push(r);else{if(A(e,Te)===null)throw new j(`expected ": " after the key, found ${M(e)}`,e.line);N(n,r,I(e),e.line)}}A(e,P)}while(A(e,we)!==null);if(e.text[e.pos]!==t)throw new j(`expected "," or "${t}", found ${M(e)}`,e.line);return e.pos++,e.workflow&&e.depth--,n}function I(e){let t=e.text[e.pos];return e.workflow&&(t===`[`||t===`{`)?F(e,t===`[`?`]`:`}`):Ce(e,`flow`)}var ke=/ *:(?=[ ,\]}]|$)/uy,Ae=/ *:/uy;function je(e,t,n){let r=e.text[e.pos]===`"`||e.text[e.pos]===`'`,i=I(e),a=A(e,r?Ae:ke)!==null;if(n===`]`&&!a){t.push(i);return}A(e,P);let o=a&&e.text[e.pos]!==`,`&&e.text[e.pos]!==n?I(e):null;if(n===`}`){N(t,i,o,e.line);return}let s=Object.create(null);N(s,i,o,e.line),t.push(s)}function L(e,t,n=!1){let r={text:e,pos:0,line:t,workflow:n,depth:0},i=e.startsWith(`{`)?F(r,`}`):e.startsWith(`[`)?F(r,`]`):Ce(r,`block`);if(A(r,De)===null)throw new j(`unexpected ${M(r)} after the value`,t);return i}function Me(e,t){let n={text:e,pos:0,line:t},r=Se(n,`block`),i=n.pos;if(r===void 0||A(n,Ee)===null)return null;if(i>1024)throw new j(`a key longer than 1024 characters is written after "? "`,t);return{key:r,rest:e.slice(n.pos)}}var Ne=2**20,R=128;function z(e){if(e.text.includes(` `))throw new j(`U+0009 is not allowed outside a block scalar`,e.number)}function B(e,t){if(!e.startsWith(`&`))return{anchor:null,rest:e};let n=/^&([^ ,[\]{}]+)(?: +|$)/u.exec(e);if(n===null)throw new j(`expected an anchor's name, found ${E(e)}`,t);let r=e.slice(n[0].length);if(r.startsWith(`*`))throw new j(`an alias with an anchor is not supported`,t);return{anchor:n[1],rest:r}}function Pe(e,t,n){if(/^\*[^ ,[\]{}]+ *:(?: |$)/u.test(t))throw new j(`an alias as a key is not supported`,n);let r=/^\*([^ ,[\]{}]+)(?: +#.*| *)$/u.exec(t);if(r===null)throw new j(`unexpected ${E(t)} after an alias`,n);if(!e.anchors.has(r[1]))throw new j(`unknown alias ${E(`*${r[1]}`)}`,n);return e.aliased=!0,e.anchors.get(r[1])}function Fe(e,t=1){let n=e[0];for(let r=t;r<e.length;r++)if(n===`"`&&e[r]===`\\`)r++;else if(e[r]===n){if(n===`'`&&e[r+1]===`'`)r++;else return r}return-1}function Ie(e,t){let n=/ *$/u.exec(e).index,r=/\\*$/u.exec(e.slice(0,n))[0].length;return t&&r%2==1?n===e.length?{text:e.slice(0,-1),escaped:!0}:{text:e.slice(0,n+1),escaped:!1}:{text:e.slice(0,n),escaped:!1}}function Le(e,t,n){let r=0,i=!1,a=``;for(let[o,s]of e.entries()){let c=o===e.length-1,l=o===0?s:s.replace(/^ +/u,``);if(o>0&&!c&&l===``){r++;continue}if(i&&r>0)throw new j(`an empty line after an escaped line break is not supported`,n);o>0&&(a+=r>0?`
|
|
3
|
-
`.repeat(r):i?``:` `);let u=c?{text:l,escaped:!1}:Ie(l,t);a+=u.text,r=0,i=u.escaped}return a}function Re(e,t,n,r){let i=t[0]===`"`,a=[t.slice(1)],o=[n.number];for(let s=e.line;;s=e.advance()){if(s===void 0||e.isMarker(s))throw new j(`a quoted scalar that does not close`,n.number);z(s),o.push(s.number);let c=Fe(`${t[0]}${s.text}`);if(c===-1){a.push(s.text);continue}if(a.push(s.text.slice(0,c-1)),!/^(?: +#.*| *)$/u.test(s.text.slice(c)))throw new j(`unexpected ${E(s.text.slice(c))} after the value`,s.number);if(e.advance(),i)for(let[e,t]of a.entries())r(t,o[e]);let l=Le(a,i,n.number);return i?r(l,n.number):l.replaceAll(`''`,`'`)}}function ze(e,t,n){if(/(?:^| )#/u.test(t))return t;let r=0,i=t.replace(/ +$/u,``);for(let t=e.line;t!==void 0;t=e.advance())
|
|
3
|
+
`.repeat(r):i?``:` `);let u=c?{text:l,escaped:!1}:Ie(l,t);a+=u.text,r=0,i=u.escaped}return a}function Re(e,t,n,r){let i=t[0]===`"`,a=[t.slice(1)],o=[n.number];for(let s=e.line;;s=e.advance()){if(s===void 0||e.isMarker(s))throw new j(`a quoted scalar that does not close`,n.number);z(s),o.push(s.number);let c=Fe(`${t[0]}${s.text}`);if(c===-1){a.push(s.text);continue}if(a.push(s.text.slice(0,c-1)),!/^(?: +#.*| *)$/u.test(s.text.slice(c)))throw new j(`unexpected ${E(s.text.slice(c))} after the value`,s.number);if(e.advance(),i)for(let[e,t]of a.entries())r(t,o[e]);let l=Le(a,i,n.number);return i?r(l,n.number):l.replaceAll(`''`,`'`)}}function ze(e,t,n){if(/(?:^| )#/u.test(t))return t;let r=0,i=t.replace(/ +$/u,``);for(let t=e.line;t!==void 0;t=e.advance())if(t.text===``)r++;else{if(t.indent<=n||t.text.startsWith(`#`)||e.isMarker(t))break;if(z(t),i+=`${r>0?`
|
|
4
4
|
`.repeat(r):` `}${t.text.replace(/ +$/u,``)}`,r=0,/ #/u.test(t.text)){e.advance();break}}return i}function Be(e,t,n){let r=n===`plain`;for(let i=0;i<e.length;i++){let a=e[i];if(a!==` `){if((a===`"`||a===`'`)&&n!==`plain`){let t=Fe(e.slice(i));if(t===-1)return{open:-1,kept:e,last:n,comment:!1};i+=t,n=`quoted`}else{if(a===`#`&&(i===0||e[i-1]===` `))return{open:t,kept:e.slice(0,i),last:n,comment:!0};if(a===`[`||a===`{`)t++,n=`open`;else if(a===`]`||a===`}`){if(n=`close`,--t===0)return{open:t,kept:e.slice(0,i+1),after:e.slice(i+1),last:n,comment:!1}}else if(a===`,`||a===`:`&&/^(?:[ ,[\]{}]|$)/u.test(e[i+1]??``)){if(a===`:`&&r)return{open:t,kept:e,last:n,comment:!1,keyed:!0};n=`indicator`}else n=`plain`}r&&=n===`plain`}}return{open:t,kept:e,last:n,comment:!1}}function Ve(e,t,n,r){let i=0,a=!1,o=null,s=!1,c=Be(t,0,null),l=null,u=``;for(let t=n;;){if(c.open===-1)throw new j(`a quoted scalar in a flow collection does not close on its line`,t.number);let d=c.kept.replace(/ +$/u,``);if(d!==``){let e=s&&!/^(?:[,\]}]|:(?:[ ,[\]{}]|$))/u.test(d);if(e&&a)throw new j(`a plain scalar in a flow collection goes on past a comment`,t.number);if(c.keyed||d.startsWith(`:`)&&!e&&(o===`plain`||o===`quoted`))throw new j(`a key over more than one line is not supported`,t.number);if(e&&l!==null&&z(l),e&&t.indent<=r)throw new j(`bad indentation of a plain scalar in a flow collection`,t.number);u!==``&&(u+=e&&i>1?`
|
|
5
5
|
`.repeat(i-1):` `),u+=d,i=0,o=c.last,s=o===`plain`,a=!1,l=null}if(a||=s&&c.comment,c.after!==void 0){if(!/^(?: +#.*| *)$/u.test(c.after))throw new j(`unexpected ${E(c.after)} after the value`,t.number);return t!==n&&e.advance(),u}if(t=t===n?e.line:e.advance(),t===void 0||e.isMarker(t))throw new j(`a flow collection that does not close`,n.number);let f=/^[\t ]*$/u.test(t.text);!f&&!t.text.startsWith(`#`)?z(t):f&&s&&!a&&t.text.includes(` `)&&(l??=t),i++,c=Be(f?``:t.text,c.open,s&&!a?`plain`:null)}}function He(e){let t=new Map,n=(e,r)=>{if(typeof e!=`object`||!e)return{size:1,height:0};if(r>R)throw new j(`aliases nest the document past ${R} levels`);let i=t.get(e);if(i===void 0){i={size:1,height:0};for(let t of Object.values(e)){let e=n(t,r+1);if(i.size+=e.size,i.height=Math.max(i.height,e.height+1),i.size>Ne)throw new j(`aliases expand the document past ${Ne} nodes`)}t.set(e,i)}if(r+i.height>R)throw new j(`aliases nest the document past ${R} levels`);return i};n(e,0)}var Ue=64,We=RegExp(`(?! )${se.source}`,`u`);function Ge(e){if(typeof e!=`object`||!e)throw TypeError(`expected an options object`);let t=Object.keys(e).find(e=>e!==`workflow`&&e!==`lines`);if(t!==void 0)throw TypeError(`unknown option ${t}`);let{workflow:n=!1,lines:r}=e;if(typeof n!=`boolean`)throw TypeError(`expected workflow to be a boolean`);if(r!==void 0&&!(r instanceof WeakMap))throw TypeError(`expected lines to be a WeakMap`);return{workflow:n,lines:r}}var Ke=e=>e.indent===0&&/^(?:---|\.\.\.)(?: |$)/u.test(e.text);function qe(e,t={}){if(typeof e!=`string`)throw TypeError(`expected a string`);let n={text:e,pos:0,number:-1,line:void 0,...Ge(t),anchors:null,aliased:!1};n.workflow&&Object.assign(n,{advance:()=>V(n),isMarker:Ke}),V(n);let r=[];Je(n);do r.push(Ye(n));while(Je(n));return r}function Je(e){return H(e)!==void 0||e.line===void 0?!1:(V(e),!0)}function Ye(e){let t=H(e);if(t===void 0)throw new j(`empty document`,e.line?.number);if(t.indent!==0)throw new j(`the document does not start at column 0`,t.number);e.workflow&&Object.assign(e,{anchors:new Map,aliased:!1});let n=G(e,0,0);if(e.aliased&&He(n),H(e)!==void 0)throw new j(`unexpected content after the document`,e.line.number);if(typeof n!=`object`||!n)throw new j(`the document is a lone scalar, not a mapping or a sequence`,t.number);return n}function V(e){let{text:t,pos:n}=e;if(e.line=void 0,n>=t.length)return;let r=t.indexOf(`
|
|
6
6
|
`,n);r===-1&&(r=t.length),e.pos=r+1;let i=++e.number;if(t[r-1]===`\r`&&r--,r-n>ce)throw new j(`line longer than ${ce} characters`,i);let a=n;for(;t[a]===` `;)a++;let o=t.slice(a,r),s=(e.workflow?We:se).exec(o)?.[0];if(s!==void 0)throw new j(`${ie(s)} is not allowed`,i);return e.line={indent:a-n,text:o,number:i},e.line}function H(e){let t=e.line;for(;t!==void 0&&(t.text===``||t.text[0]===`#`||e.workflow&&/^[\t ]*$/u.test(t.text));)t=V(e);if(t!==void 0&&e.workflow&&z(t),t?.indent!==0||!/^(?:---|\.\.\.(?: |$)|%)/u.test(t.text))return t;if(!/^--- *$/u.test(t.text))throw new j(t.text.startsWith(`---`)?`content on the document marker line`:`document end markers and directives are not supported`,t.number)}var U=e=>/^-(?: |$)/u.test(e.text),W=e=>/^[|>]/u.test(e);function G(e,t,n){let r=H(e);if(n>Ue)throw new j(`nested too deep`,r.number);if(U(r))return Qe(e,t,n);let i=r.text.startsWith(`? `)?void 0:q(e,r);return i===null?(V(e),e.workflow?K(e,r.text,r.indent-1,n,r):L(r.text,r.number)):Ze(e,t,n,i)}function Xe(e,t,n,r){let i;for(i=H(e);i?.indent===t;i=H(e)){if(r?.(i))return;n(i)}if(i?.indent>t)throw new j(`bad indentation`,i.number)}function Ze(e,t,n,r){let i=Object.create(null),a=e.lines&&new Map;e.lines?.set(i,a);let o=r;return Xe(e,t,r=>{if(!r.text.startsWith(`? `)){let s=o??q(e,r);if(o=void 0,s===null)throw new j(`expected a mapping key, found ${E(r.text)}`,r.number);V(e),s.anchor&&e.anchors.set(s.anchor,s.key),N(i,s.key,$e(e,s.rest,t,n,r),r.number),a?.set(s.key,r.number);return}V(e);let s=L(r.text.slice(2),r.number),c=H(e);if(c?.indent!==t||!/^:(?: |$)/u.test(c.text))throw new j(`expected ": " below the explicit key`,(c??r).number);N(i,s,et(e,c,t,n),r.number),a?.set(s,r.number)}),i}function Qe(e,t,n,r=!1){let i=[],a=e.lines&&[];return e.lines?.set(i,a),Xe(e,t,r=>{if(!U(r))throw new j(`expected "- ", found ${E(r.text)}`,r.number);a?.push(r.number),i.push(et(e,r,t,n))},r?e=>!U(e):void 0),i}function $e(e,t,n,r,i){if(e.workflow)return K(e,t,n,r,i);if(W(t))return tt(e,t,n,i);if(t!==``)return L(t,i.number);let a=H(e);if(a?.indent===n&&U(a)&&!U(i))throw new j(`a sequence under a key must be indented`,a.number);if(a===void 0||a.indent<=n)throw new j(`missing value`,i.number);return G(e,a.indent,r+1)}function et(e,t,n,r){let i=/^[-:] *(?:#.*)?/u.exec(t.text)[0].length;if(e.workflow)return at(e,t,n,r,i);let a=t.text.slice(i);return a===``||W(a)?(V(e),$e(e,a,n,r,t)):(e.line={...t,indent:t.indent+i,text:a},G(e,t.indent+i,r+1))}function tt(e,t,n,r){let{folded:i,digit:a,chomp:o}=nt(e,t,r),s=n+Number(a),c=a!==``,l=0,u=``,d=null;for(let t=e.line;t!==void 0&&(t.text===``||t.indent>n);t=V(e)){if(c||(s=Math.max(s,t.indent)),c||=t.text!==``,t.text!==``&&t.indent<s)throw new j(`bad indentation in the block scalar`,t.number);let e=`${` `.repeat(Math.max(t.indent-s,0))}${t.text}`;if(e!==``){let t=/^[\t ]/u.test(e);u+=i?rt(l,d,t):`
|
|
@@ -8,4 +8,4 @@ import{a as e,b as t,c as n,d as r}from"./chunk-M3Y6SLC4.js";import{C as i,D as
|
|
|
8
8
|
`.repeat(l):o===`-`?u:u&&`${u}
|
|
9
9
|
`}function nt(e,t,n){let r=e.workflow?/^([|>])(?:([1-9])([+-]?)|([+-])([1-9]?))?(?: +#.*| *)$/u.exec(t):/^\|([1-9]?)([+-]?)$/u.exec(t);if(r===null)throw new j(`unsupported block scalar ${E(t)}`,n.number);return e.workflow?{folded:r[1]===`>`,digit:r[2]??r[5]??``,chomp:r[3]||r[4]||``}:{folded:!1,digit:r[1],chomp:r[2]}}var rt=(e,t,n)=>t===null||t||n?`
|
|
10
10
|
`.repeat(e):e===1?` `:`
|
|
11
|
-
`.repeat(e-1);function K(e,t,n,r,i){let{anchor:a,rest:o}=B(t,i.number),s=it(e,o.startsWith(`#`)?``:o,n,r,i);return a!==null&&e.anchors.set(a,s),s}function it(e,t,n,r,i){if(t.startsWith(`*`))return Pe(e,t,i.number);if(W(t))return tt(e,t,n,i);if(t.startsWith(`[`)||t.startsWith(`{`))return L(Ve(e,t,i,n),i.number,!0);let a=t.startsWith(`'`)||t.startsWith(`"`);if(a&&Fe(t)===-1)return Re(e,t,i,xe);if(t!==``)return L(a?t:ze(e,t,n),i.number,!0);let o=H(e);return o?.indent===n&&U(o)&&!U(i)?Qe(e,n,r+1,!0):o===void 0||o.indent<=n?null:!U(o)&&!o.text.startsWith(`? `)&&q(e,o)===null?(V(e),K(e,o.text,n,r+1,o)):G(e,o.indent,r+1)}function at(e,t,n,r,i){let a=t.text.slice(i),{anchor:o,rest:s}=B(a,t.number),c=t.indent+i;if(s!==``&&!s.startsWith(`#`)&&(U({text:s})||s.startsWith(`? `))){if(o!==null)throw new j(`an anchor before a block on its own line is not supported`,t.number);return e.line={...t,indent:c,text:s},G(e,c,r+1)}return s!==``&&!s.startsWith(`#`)&&Me(s,t.number)!==null?(e.line={...t,indent:c,text:a},G(e,c,r+1)):(V(e),K(e,a,n,r,t))}function q(e,t){if(!e.workflow||!t.text.startsWith(`&`))return Me(t.text,t.number);let{anchor:n,rest:r}=B(t.text,t.number),i=Me(r,t.number);return i&&{...i,anchor:n}}var ot=`(patch_hash=`;function st(e){let t={start:e.length,peers:e.length};if(!e.endsWith(`)`))return t;let n=1;for(let t=e.length-2;t>=0;t--)if(e[t]===`(`)n--;else if(e[t]===`)`)n++;else if(n===0){if(!e.startsWith(ot,t+1))return{start:t+1,peers:t+1};let n=e.indexOf(`(`,t+2);return{start:t+1,peers:n===-1?e.length:n}}return t}function J(e){if(typeof e!=`string`)throw TypeError(`expected a string`);return e.slice(0,st(e).start)}function ct(e,t,n){let r=[],[i,a]=[0,0];for(let o=0;o<e.length;o++){if(i===0&&(e[o]!==`(`||e[o+1]===`)`||e.startsWith(ot,o)))throw new D(`${O(t)} does not end in peers in parentheses`,n);e[o]===`(`&&i++===0?a=o+1:e[o]===`)`&&--i===0&&r.push(e.slice(a,o))}return r}function lt(e,t){let{start:n,peers:r}=st(e),i;if(n<r){let a=e.slice(n,r);if(i=/^\(patch_hash=([\da-z]+)\)$/u.exec(a)?.[1],i===void 0)throw new D(`${O(a)} is not a patch hash`,t)}return{base:e.slice(0,n),patchHash:i,peers:ct(e.slice(r),e,t)}}var Y=e=>ne(e,{padding:!1}),X=(e,t,n)=>oe(()=>e===e.toLowerCase()&&n(e).length===t,()=>!1);function ut(e,t){let n=e.indexOf(`@`,1);if(n===-1||n===e.length-1)throw new D(`${O(e)} is not a key of the form name@version`,t);if(J(e)!==e)throw new D(`${O(e)} carries a peer or patch suffix, which only a snapshot key does`,t);return{name:w(e.slice(0,n),t),ref:e.slice(n+1)}}var dt=(e,t)=>/^[^:(]*@/u.test(e)?e:`${t}@${e}`;function ft(e,t){let n=b(e,t);if(n.startsWith(`file:`))i(n.slice(5),t);else if(!u(n))throw new D(`${O(n)} is not an http(s) URL or a file: path`,t);return n}var pt=(e,t)=>e===``?`.`:i(e,t),mt=(e,t)=>y(e,`path`,t,(e,t)=>(a(b(e,t).replace(/^\//u,``),t),e));function ht(e,t){p(e,t,[`integrity`,`tarball`,`path`,`gitHosted`]);let{integrity:n,tarball:r}=e;if(n===void 0&&r===void 0)throw new D(`expected an integrity or a tarball`,t);return{type:`tarball`,integrity:y(e,`integrity`,t,l),tarball:y(e,`tarball`,t,ft),path:mt(e,t),gitHosted:C(e.gitHosted,k(t,`gitHosted`))}}function gt(e,t){p(e,t,[`type`,`repo`,`commit`,`path`]);let n=b(e.commit,k(t,`commit`));if(!s(n))throw new D(`${O(n)} is not a full commit hash`,k(t,`commit`));return{type:`git`,repo:c(e.repo,k(t,`repo`)),commit:n,path:mt(e,t)}}function _t(e,t){return p(e,t,[`type`,`directory`]),{type:`directory`,directory:pt(e.directory,k(t,`directory`))}}var vt=new Map([[void 0,ht],[`git`,gt],[`directory`,_t]]);function yt(e,t){let n=p(e,t),r=vt.get(n.type);if(r===void 0)throw new D(`unsupported resolution type, ${f(n.type)}`,k(t,`type`));return r(n,t)}var bt=[`resolution`,`version`,`name`,`engines`,`cpu`,`os`,`libc`,`deprecated`,`hasBin`,`bundledDependencies`,`peerDependencies`,`peerDependenciesMeta`],xt=[`dependencies`,`optionalDependencies`,`optional`,`transitivePeerDependencies`],St=new Set([`bitbucket`,`catalog`,`custom`,`file`,`git`,`github`,`gitlab`,`http`,`https`,`jsr`,`link`,`npm`,`ssh`,`workspace`]);function Ct(e,t,n,r,i){let{type:a,tarball:o}=r,s=o?.startsWith(`file:`);if(T(t)){if(a!==`tarball`||r.integrity===void 0||s||r.gitHosted||r.path!==void 0)throw new D(`expected a registry tarball with an integrity, for the version ${O(t)}`,k(i,`resolution`));if(n.version!==void 0&&n.version!==t)throw new D(`expected the version in the key, ${O(t)}`,k(i,`version`));return o!==void 0&&d(o,e,t,k(k(i,`resolution`),`tarball`)),t}let c=/^([A-Za-z][\w+.-]*):/u.exec(t)?.[1];if(c===void 0)throw new D(`${O(t)} is neither a version nor a source`,i);if(c===`runtime`||!St.has(c)&&T(t.slice(c.length+1)))throw new D(`${O(t)} is from a runtime or a named registry, which is not supported`,i);if(!(c===`file`?t===(a===`directory`?`file:${n.resolution.directory}`:o):a===`git`||a===`tarball`&&o!==void 0&&!s))throw new D(`${O(t)} is not where the resolution says the package comes from`,k(i,`resolution`));if(a===`directory`){if(n.version!==void 0)throw new D(`a directory has no version in the lockfile`,k(i,`version`));return}if(n.version===void 0)throw new D(`expected a version, for a package not from the registry`,i);return te(n.version,k(i,`version`))}var wt=(e,t)=>x(e,t,w);function Tt(e,t,n){p(t,n,bt);let{name:r,ref:i}=ut(e,n);if(t.name!==void 0&&t.name!==r)throw new D(`expected the name in the key, ${O(r)}`,k(n,`name`));let a=yt(t.resolution,k(n,`resolution`)),o=t.bundledDependencies;return{name:r,version:Ct(r,i,t,a,n),resolution:a,engines:ee(v(t.engines),k(n,`engines`)),os:y(t,`os`,n,x),cpu:y(t,`cpu`,n,x),libc:y(t,`libc`,n,x),deprecated:y(t,`deprecated`,n,b),hasBin:C(t.hasBin,k(n,`hasBin`)),bundledDependencies:o===void 0||o===!0?o:wt(o,k(n,`bundledDependencies`)),peerDependencies:ee(v(t.peerDependencies),k(n,`peerDependencies`),w),peerDependenciesMeta:Et(t.peerDependenciesMeta,k(n,`peerDependenciesMeta`))}}var Z=(e,t)=>(n,r)=>S(v(n),r,(n,r,i)=>(p(n,r,e),w(i,r),t(n,r))),Et=Z([`optional`],(e,t)=>({optional:C(e.optional,k(t,`optional`))}));function Dt(e,t,n,r,i){if(e.startsWith(`link:`))return`link:${o(n,pt(e.slice(5),i))}`;let a=dt(e,t);if(!(a in r))throw new D(`${O(e)} leads to ${O(a)}, which is not in snapshots`,i);return a}var Ot=(e,t,n)=>S(v(e),t,(e,t,r)=>{let i=b(e,t);if(i===`link:<root>`||i.startsWith(`link:<root>/`))throw new D(`${O(i)} leads into the package that asks for it, which is not supported`,t);return Dt(i,w(r,t),`.`,n,t)});function kt(e,n,r){return p(e,n,xt),{...t(e,n,(e,t)=>Ot(e,t,r)),optional:C(e.optional,k(n,`optional`)),transitivePeerDependencies:y(e,`transitivePeerDependencies`,n,wt)??[]}}var At=e=>X(e,16,Y)||X(e,16,re);function jt(e){let t=e.indexOf(`@`,1);return t===-1?``:e.slice(0,t)}function Q(e){let t=oe(()=>lt(e),()=>{});if(t===void 0)return;let n=t.patchHash===void 0?t.base:`${t.base}(patch_hash=${t.patchHash})`;if(t.peers.length===1&&At(t.peers[0]))return{unpeered:n,peers:void 0};let r=new Map(t.peers.map(e=>[jt(e),e]));return r.size===t.peers.length?{unpeered:n,peers:r}:void 0}var Mt=32;function Nt(e,t,n,r=0){if(e===t)return!0;let[i,a]=[Q(e),Q(t)];if(r>Mt||i===void 0||a===void 0||i.unpeered!==a.unpeered)return!1;if(i.peers===void 0||a.peers===void 0)return!0;let{dependencies:o,optionalDependencies:s}=n[t];return i.peers.entries().every(([e,t])=>{if(!a.peers.has(e))return!1;let i=o[e]??s[e];return i===void 0?t===a.peers.get(e):!i.startsWith(`link:`)&&Nt(t,i,n,r+1)})}function Pt(e,t,n,r,i,a){if(e.length===0||e.length===1&&At(e[0]))return;let o=new Set,s=new Set;for(let[e,r]of Object.entries({...t.dependencies,...t.optionalDependencies})){if(r.startsWith(`link:`)){s.add(e);continue}o.add(r);let t=n.get(J(r));t!==void 0&&(t.version===void 0?s.add(t.name):o.add(`${t.name}@${t.version}`))}let c=t.transitivePeerDependencies;for(let n of e){let e=jt(n);if(e===``)throw new D(`${O(n)} is not a peer, as pnpm writes one in a key`,a);let l=!n.includes(`(`);if(o.has(n)||l&&s.has(e))continue;let u=l&&c.includes(e)&&!T(n.slice(e.length+1));if(!(c.length>0&&(r().has(n)||u))){if(l)throw Ft(n,a);i.push({group:n,snapshot:t,where:a})}}}var Ft=(e,t)=>new D(`the peer ${O(e)} is not one of its dependencies, nor a peer of theirs it resolves`,t);function It(e,t){let n;for(let{group:r,snapshot:i,where:a}of e){let e=Object.values({...i.dependencies,...i.optionalDependencies}).filter(e=>!e.startsWith(`link:`)),o=Q(r)?.unpeered;if(i.transitivePeerDependencies.includes(jt(r))&&o!==void 0&&(n??=Map.groupBy(Object.keys(t),e=>Q(e)?.unpeered),e.push(...n.get(o)??[])),!e.some(e=>Nt(r,e,t)))throw Ft(r,a)}}function Lt(e,t,n){if(e.version===void 0&&t.keys().some(t=>t.startsWith(`${e.name}@`)))throw new D(`a package of no version in the lockfile, which a patch of a version of ${O(e.name)} may be of`,n);let r=`${e.name}@${e.version}`;return e.version!==void 0&&t.has(r)?r:t.has(e.name)?e.name:void 0}function Rt(e,t,n){let r=new Map,i=new Map,a=k(t,`packages`);for(let[t,n,o]of m(v(e.packages),a)){let e=Tt(t,n,o);r.set(t,e),n.version!==void 0&&t===`${e.name}@${e.version}`&&i.set(t,k(o,`version`))}let o=k(t,`snapshots`),s=p(v(e.snapshots),o),c,l=()=>c??=new Set([...Object.keys(s),...r.keys(),...r.values().map(e=>`${e.name}@${e.version}`)]),u=new Set,d=new Set,f=[],h=S(s,o,(e,t,a)=>{let{base:o,patchHash:c,peers:p}=lt(a,t),m=r.get(o);if(m===void 0)throw new D(`${O(o)} is not in packages`,t);let h=Lt(m,n,t);h!==void 0&&d.add(h);let g=h===void 0?void 0:n.get(h).hash;if(g!==c){let e=h===void 0?`none, as patchedDependencies patches no such package`:`${O(g)}, of patchedDependencies[${O(h)}]`;throw new D(`expected the patch hash ${e}, found ${c===void 0?`none`:O(c)}`,t)}u.add(o),a.includes(`:`)&&i.delete(o);let _=kt(e,t,s);return Pt(p,_,r,l,f,t),{...m,patchHash:c,..._}});It(f,h);let g=r.keys().find(e=>!u.has(e));if(g!==void 0)throw new D(`no snapshot is of this package`,k(a,g));let _=n.keys().find(e=>!d.has(e));if(_!==void 0)throw new D(`patches no package in the lockfile, which pnpm refuses to install with`,k(k(t,`patchedDependencies`),_));let[y]=i.values();if(y!==void 0)throw new D(`a registry package has its version in its key, except where a snapshot of it has a source in its peers`,y);return{packages:h,snapshots:s}}var zt=[...e,`dependenciesMeta`,`publishDirectory`,`linkDirectory`],$=[`configDependencies`,`packageManagerDependencies`];function Bt(e,t,n,r,i){let a=Object.create(null),o={specifiers:a},s=Object.create(null);for(let c of t)o[c]=S(v(e[c]),k(r,c),(e,t,r)=>{if(w(r,t),p(e,t,[`specifier`,`version`]),r in a)throw new D(`listed under ${s[r]} too`,t);a[r]=h(e.specifier,k(t,`specifier`)),s[r]=c;let o=k(t,`version`);return Dt(b(e.version,o),r,n,i,o)});return o}var Vt=Z([`injected`,`node`],(e,t)=>({injected:y(e,`injected`,t,g)??!1,node:y(e,`node`,t,b)}));function Ht(t,n,r,a){if(p(t,r,zt),t.linkDirectory!==void 0&&t.linkDirectory!==!1)throw new D(`expected false, the only value pnpm writes`,k(r,`linkDirectory`));return{...Bt(t,e,n,r,a),dependenciesMeta:Vt(t.dependenciesMeta,k(r,`dependenciesMeta`)),publishDirectory:y(t,`publishDirectory`,r,i),linkDirectory:t.linkDirectory!==!1}}function Ut(e,t,n,r){let a=S(e,t,(e,t,a)=>{if(i(a,t),!r)return Ht(e,a,t,n);if(a!==`.`)throw new D(`the env document has no importer but "."`,t);return p(e,t,$),Bt(e,$,a,t,n)});if(r&&!(`.`in a))throw new D(`expected the "." importer`,t);return a}var Wt=[`lockfileVersion`,`settings`,`catalogs`,`overrides`,`patchedDependencies`,`packageExtensionsChecksum`,`pnpmfileChecksum`,`ignoredOptionalDependencies`,`time`,`importers`,`packages`,`snapshots`],Gt=[`lockfileVersion`,`importers`,`packages`,`snapshots`],Kt={__proto__:null,autoInstallPeers:g,dedupePeers:g,excludeLinksFromLockfile:g,injectWorkspacePackages:g,peersSuffixMaxLength:_},qt=(e,t)=>S(p(v(e),t,Object.keys(Kt)),t,(e,t,n)=>Kt[n](e,t)),Jt=(e,t)=>S(v(e),t,(e,t,n)=>(b(n,t),Z([`specifier`,`version`],(e,t)=>({specifier:h(e.specifier,k(t,`specifier`)),version:b(e.version,k(t,`version`))}))(e,t)));function Yt(e,t){if(e.indexOf(`@`,1)===-1)return w(e,t);if(!T(ut(e,t).ref))throw new D(`${O(e)} is not a name and a version, or a name alone, which is not supported`,t)}var Xt=(e,t)=>S(v(e),t,(e,t,n)=>{let r=typeof e!=`string`;r&&p(e,t,[`hash`,`path`]);let a=r?k(t,`hash`):t,o=b(r?e.hash:e,a);if(!X(o,32,re)&&!X(o,16,Y))throw new D(`${O(o)} is not a patch hash`,a);return Yt(n,t),{hash:o,path:r?i(e.path,k(t,`path`)):void 0}});function Zt(e,t){let n=b(e,t);if(X(n,16,re)||X(n,16,Y))return n;if(!n.startsWith(`sha256-`))throw new D(`${O(n)} is not a checksum`,t);return l(n,t)}var Qt=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?Z$/u,$t=(e,t,n)=>S(v(e),t,(e,t,r)=>{if(!(r in n))throw new D(`${O(r)} is not in packages`,t);let i=b(e,t),a=Qt.test(i)?Date.parse(i):NaN;if(Number.isNaN(a)||new Date(a).toISOString().slice(0,19)!==i.slice(0,19))throw new D(`${O(i)} is not a UTC timestamp`,t);return i});function en(e,t,r,i){let a=n(Object.values(e).flatMap(e=>i.map(t=>e[t])),t);if(a!==void 0)throw new D(`no importer depends on it, directly or not`,k(k(r,`snapshots`),a))}function tn(e,t,n){let i=r(t,e,n?{required:$,dev:[],optional:[]}:void 0);for(let e of Object.values(t)){let{dev:t,devOptional:n}=i(e);Object.assign(e,{dev:t,devOptional:n})}}function nn(t,n,r){let i=n===``?void 0:n,a=p(t,i).lockfileVersion;if(a!==`9.0`)throw new D(`unsupported version: expected "9.0", found ${f(a)}`,k(n,`lockfileVersion`));p(t,i,r?Gt:Wt);let o=Xt(t.patchedDependencies,k(n,`patchedDependencies`)),{packages:s,snapshots:c}=Rt(t,n,new Map(Object.entries(o))),l=Ut(t.importers,k(n,`importers`),c,r);return en(l,s,n,r?$:e),tn(l,s,r),r?{lockfileVersion:a,importers:l,packages:s}:{lockfileVersion:a,settings:qt(t.settings,k(n,`settings`)),catalogs:Jt(t.catalogs,k(n,`catalogs`)),overrides:ee(v(t.overrides),k(n,`overrides`),b),patchedDependencies:o,packageExtensionsChecksum:y(t,`packageExtensionsChecksum`,n,Zt),pnpmfileChecksum:y(t,`pnpmfileChecksum`,n,Zt),ignoredOptionalDependencies:y(t,`ignoredOptionalDependencies`,n,x)??[],time:$t(t.time,k(n,`time`),v(t.packages)),importers:l,packages:s}}function rn(e){if(typeof e!=`string`)throw TypeError(`expected a string`);let t=/^---\r?\n/u.exec(e)?.[0];if(t===void 0){let t=qe(e);if(t.length!==1)throw new D(`expected one document, found ${t.length}`);return{lockfile:nn(t[0],``,!1),env:void 0}}let n=/\n---\r?\n/gu;n.lastIndex=t.length;let r=n.exec(e);if(r===null)throw new D(`expected the env document the first "---" starts to end at a line of "---"`);let i=/^(?: *\r?\n)* *$/u.test(e.slice(n.lastIndex)),a=qe(i?e.slice(0,r.index+1):e);if(a.length!==(i?1:2))throw new D(`expected the env document${i?``:` and the lockfile`} between lines of "---" alone, found ${a.length} documents`);return{lockfile:i?void 0:nn(a[1],``,!1),env:nn(a[0],`env`,!0)}}export{D as LockfileError,j as YamlError,J as packageKeyOf,rn as parsePnpmLockfile};
|
|
11
|
+
`.repeat(e-1);function K(e,t,n,r,i){let{anchor:a,rest:o}=B(t,i.number),s=it(e,o.startsWith(`#`)?``:o,n,r,i);return a!==null&&e.anchors.set(a,s),s}function it(e,t,n,r,i){if(t.startsWith(`*`))return Pe(e,t,i.number);if(W(t))return tt(e,t,n,i);if(t.startsWith(`[`)||t.startsWith(`{`))return L(Ve(e,t,i,n),i.number,!0);let a=t.startsWith(`'`)||t.startsWith(`"`);if(a&&Fe(t)===-1)return Re(e,t,i,xe);if(t!==``)return L(a?t:ze(e,t,n),i.number,!0);let o=H(e);return o?.indent===n&&U(o)&&!U(i)?Qe(e,n,r+1,!0):o===void 0||o.indent<=n?null:!U(o)&&!o.text.startsWith(`? `)&&q(e,o)===null?(V(e),K(e,o.text,n,r+1,o)):G(e,o.indent,r+1)}function at(e,t,n,r,i){let a=t.text.slice(i),{anchor:o,rest:s}=B(a,t.number),c=t.indent+i;if(s!==``&&!s.startsWith(`#`)&&(U({text:s})||s.startsWith(`? `))){if(o!==null)throw new j(`an anchor before a block on its own line is not supported`,t.number);return e.line={...t,indent:c,text:s},G(e,c,r+1)}return s!==``&&!s.startsWith(`#`)&&Me(s,t.number)!==null?(e.line={...t,indent:c,text:a},G(e,c,r+1)):(V(e),K(e,a,n,r,t))}function q(e,t){if(!e.workflow||!t.text.startsWith(`&`))return Me(t.text,t.number);let{anchor:n,rest:r}=B(t.text,t.number),i=Me(r,t.number);return i&&{...i,anchor:n}}var ot=`(patch_hash=`;function st(e){let t={start:e.length,peers:e.length};if(!e.endsWith(`)`))return t;let n=1;for(let t=e.length-2;t>=0;t--)if(e[t]===`(`)n--;else if(e[t]===`)`)n++;else if(n===0){if(!e.startsWith(ot,t+1))return{start:t+1,peers:t+1};let n=e.indexOf(`(`,t+2);return{start:t+1,peers:n===-1?e.length:n}}return t}function J(e){if(typeof e!=`string`)throw TypeError(`expected a string`);return e.slice(0,st(e).start)}function ct(e,t,n){let r=[],[i,a]=[0,0];for(let o=0;o<e.length;o++){if(i===0&&(e[o]!==`(`||e[o+1]===`)`||e.startsWith(ot,o)))throw new D(`${O(t)} does not end in peers in parentheses`,n);e[o]===`(`&&i++===0?a=o+1:e[o]===`)`&&--i===0&&r.push(e.slice(a,o))}return r}function lt(e,t){let{start:n,peers:r}=st(e),i;if(n<r){let a=e.slice(n,r);if(i=/^\(patch_hash=([\da-z]+)\)$/u.exec(a)?.[1],i===void 0)throw new D(`${O(a)} is not a patch hash`,t)}return{base:e.slice(0,n),patchHash:i,peers:ct(e.slice(r),e,t)}}var Y=e=>ne(e,{padding:!1}),X=(e,t,n)=>oe(()=>e===e.toLowerCase()&&n(e).length===t,()=>!1);function ut(e,t){let n=e.indexOf(`@`,1);if(n===-1||n===e.length-1)throw new D(`${O(e)} is not a key of the form name@version`,t);if(J(e)!==e)throw new D(`${O(e)} carries a peer or patch suffix, which only a snapshot key does`,t);return{name:w(e.slice(0,n),t),ref:e.slice(n+1)}}var dt=(e,t)=>/^[^:(]*@/u.test(e)?e:`${t}@${e}`;function ft(e,t){let n=b(e,t);if(n.startsWith(`file:`))i(n.slice(5),t);else if(!u(n))throw new D(`${O(n)} is not an http(s) URL or a file: path`,t);return n}var pt=(e,t)=>e===``?`.`:i(e,t),mt=(e,t)=>y(e,`path`,t,(e,t)=>(a(b(e,t).replace(/^\//u,``),t),e));function ht(e,t){p(e,t,[`integrity`,`tarball`,`path`,`gitHosted`]);let{integrity:n,tarball:r}=e;if(n===void 0&&r===void 0)throw new D(`expected an integrity or a tarball`,t);return{type:`tarball`,integrity:y(e,`integrity`,t,l),tarball:y(e,`tarball`,t,ft),path:mt(e,t),gitHosted:C(e.gitHosted,k(t,`gitHosted`))}}function gt(e,t){p(e,t,[`type`,`repo`,`commit`,`path`]);let n=b(e.commit,k(t,`commit`));if(!s(n))throw new D(`${O(n)} is not a full commit hash`,k(t,`commit`));return{type:`git`,repo:c(e.repo,k(t,`repo`)),commit:n,path:mt(e,t)}}function _t(e,t){return p(e,t,[`type`,`directory`]),{type:`directory`,directory:pt(e.directory,k(t,`directory`))}}var vt=new Map([[void 0,ht],[`git`,gt],[`directory`,_t]]);function yt(e,t){let n=p(e,t),r=vt.get(n.type);if(r===void 0)throw new D(`unsupported resolution type, ${f(n.type)}`,k(t,`type`));return r(n,t)}var bt=[`resolution`,`version`,`name`,`engines`,`cpu`,`os`,`libc`,`deprecated`,`hasBin`,`bundledDependencies`,`peerDependencies`,`peerDependenciesMeta`],xt=[`dependencies`,`optionalDependencies`,`optional`,`transitivePeerDependencies`],St=new Set([`bitbucket`,`catalog`,`custom`,`file`,`git`,`github`,`gitlab`,`http`,`https`,`jsr`,`link`,`npm`,`ssh`,`workspace`]);function Ct(e,t,n,r,i){let{type:a,tarball:o}=r,s=o?.startsWith(`file:`);if(T(t)){if(a!==`tarball`||r.integrity===void 0||s||r.gitHosted||r.path!==void 0)throw new D(`expected a registry tarball with an integrity, for the version ${O(t)}`,k(i,`resolution`));if(n.version!==void 0&&n.version!==t)throw new D(`expected the version in the key, ${O(t)}`,k(i,`version`));return o!==void 0&&d(o,e,t,k(k(i,`resolution`),`tarball`)),t}let c=/^([A-Za-z][\w+.-]*):/u.exec(t)?.[1];if(c===void 0)throw new D(`${O(t)} is neither a version nor a source`,i);if(c===`runtime`||!St.has(c)&&T(t.slice(c.length+1)))throw new D(`${O(t)} is from a runtime or a named registry, which is not supported`,i);if(!(c===`file`?t===(a===`directory`?`file:${n.resolution.directory}`:o):a===`git`||a===`tarball`&&o!==void 0&&!s))throw new D(`${O(t)} is not where the resolution says the package comes from`,k(i,`resolution`));if(a===`directory`){if(n.version!==void 0)throw new D(`a directory has no version in the lockfile`,k(i,`version`))}else{if(n.version===void 0)throw new D(`expected a version, for a package not from the registry`,i);return te(n.version,k(i,`version`))}}var wt=(e,t)=>x(e,t,w);function Tt(e,t,n){p(t,n,bt);let{name:r,ref:i}=ut(e,n);if(t.name!==void 0&&t.name!==r)throw new D(`expected the name in the key, ${O(r)}`,k(n,`name`));let a=yt(t.resolution,k(n,`resolution`)),o=t.bundledDependencies;return{name:r,version:Ct(r,i,t,a,n),resolution:a,engines:ee(v(t.engines),k(n,`engines`)),os:y(t,`os`,n,x),cpu:y(t,`cpu`,n,x),libc:y(t,`libc`,n,x),deprecated:y(t,`deprecated`,n,b),hasBin:C(t.hasBin,k(n,`hasBin`)),bundledDependencies:o===void 0||o===!0?o:wt(o,k(n,`bundledDependencies`)),peerDependencies:ee(v(t.peerDependencies),k(n,`peerDependencies`),w),peerDependenciesMeta:Et(t.peerDependenciesMeta,k(n,`peerDependenciesMeta`))}}var Z=(e,t)=>(n,r)=>S(v(n),r,(n,r,i)=>(p(n,r,e),w(i,r),t(n,r))),Et=Z([`optional`],(e,t)=>({optional:C(e.optional,k(t,`optional`))}));function Dt(e,t,n,r,i){if(e.startsWith(`link:`))return`link:${o(n,pt(e.slice(5),i))}`;let a=dt(e,t);if(!(a in r))throw new D(`${O(e)} leads to ${O(a)}, which is not in snapshots`,i);return a}var Ot=(e,t,n)=>S(v(e),t,(e,t,r)=>{let i=b(e,t);if(i===`link:<root>`||i.startsWith(`link:<root>/`))throw new D(`${O(i)} leads into the package that asks for it, which is not supported`,t);return Dt(i,w(r,t),`.`,n,t)});function kt(e,n,r){return p(e,n,xt),{...t(e,n,(e,t)=>Ot(e,t,r)),optional:C(e.optional,k(n,`optional`)),transitivePeerDependencies:y(e,`transitivePeerDependencies`,n,wt)??[]}}var At=e=>X(e,16,Y)||X(e,16,re);function jt(e){let t=e.indexOf(`@`,1);return t===-1?``:e.slice(0,t)}function Q(e){let t=oe(()=>lt(e),()=>{});if(t===void 0)return;let n=t.patchHash===void 0?t.base:`${t.base}(patch_hash=${t.patchHash})`;if(t.peers.length===1&&At(t.peers[0]))return{unpeered:n,peers:void 0};let r=new Map(t.peers.map(e=>[jt(e),e]));return r.size===t.peers.length?{unpeered:n,peers:r}:void 0}var Mt=32;function Nt(e,t,n,r=0){if(e===t)return!0;let[i,a]=[Q(e),Q(t)];if(r>Mt||i===void 0||a===void 0||i.unpeered!==a.unpeered)return!1;if(i.peers===void 0||a.peers===void 0)return!0;let{dependencies:o,optionalDependencies:s}=n[t];return i.peers.entries().every(([e,t])=>{if(!a.peers.has(e))return!1;let i=o[e]??s[e];return i===void 0?t===a.peers.get(e):!i.startsWith(`link:`)&&Nt(t,i,n,r+1)})}function Pt(e,t,n,r,i,a){if(e.length===0||e.length===1&&At(e[0]))return;let o=new Set,s=new Set;for(let[e,r]of Object.entries({...t.dependencies,...t.optionalDependencies})){if(r.startsWith(`link:`)){s.add(e);continue}o.add(r);let t=n.get(J(r));t!==void 0&&(t.version===void 0?s.add(t.name):o.add(`${t.name}@${t.version}`))}let c=t.transitivePeerDependencies;for(let n of e){let e=jt(n);if(e===``)throw new D(`${O(n)} is not a peer, as pnpm writes one in a key`,a);let l=!n.includes(`(`);if(o.has(n)||l&&s.has(e))continue;let u=l&&c.includes(e)&&!T(n.slice(e.length+1));if(!(c.length>0&&(r().has(n)||u))){if(l)throw Ft(n,a);i.push({group:n,snapshot:t,where:a})}}}var Ft=(e,t)=>new D(`the peer ${O(e)} is not one of its dependencies, nor a peer of theirs it resolves`,t);function It(e,t){let n;for(let{group:r,snapshot:i,where:a}of e){let e=Object.values({...i.dependencies,...i.optionalDependencies}).filter(e=>!e.startsWith(`link:`)),o=Q(r)?.unpeered;if(i.transitivePeerDependencies.includes(jt(r))&&o!==void 0&&(n??=Map.groupBy(Object.keys(t),e=>Q(e)?.unpeered),e.push(...n.get(o)??[])),!e.some(e=>Nt(r,e,t)))throw Ft(r,a)}}function Lt(e,t,n){if(e.version===void 0&&t.keys().some(t=>t.startsWith(`${e.name}@`)))throw new D(`a package of no version in the lockfile, which a patch of a version of ${O(e.name)} may be of`,n);let r=`${e.name}@${e.version}`;return e.version!==void 0&&t.has(r)?r:t.has(e.name)?e.name:void 0}function Rt(e,t,n){let r=new Map,i=new Map,a=k(t,`packages`);for(let[t,n,o]of m(v(e.packages),a)){let e=Tt(t,n,o);r.set(t,e),n.version!==void 0&&t===`${e.name}@${e.version}`&&i.set(t,k(o,`version`))}let o=k(t,`snapshots`),s=p(v(e.snapshots),o),c,l=()=>c??=new Set([...Object.keys(s),...r.keys(),...r.values().map(e=>`${e.name}@${e.version}`)]),u=new Set,d=new Set,f=[],h=S(s,o,(e,t,a)=>{let{base:o,patchHash:c,peers:p}=lt(a,t),m=r.get(o);if(m===void 0)throw new D(`${O(o)} is not in packages`,t);let h=Lt(m,n,t);h!==void 0&&d.add(h);let g=h===void 0?void 0:n.get(h).hash;if(g!==c){let e=h===void 0?`none, as patchedDependencies patches no such package`:`${O(g)}, of patchedDependencies[${O(h)}]`;throw new D(`expected the patch hash ${e}, found ${c===void 0?`none`:O(c)}`,t)}u.add(o),a.includes(`:`)&&i.delete(o);let _=kt(e,t,s);return Pt(p,_,r,l,f,t),{...m,patchHash:c,..._}});It(f,h);let g=r.keys().find(e=>!u.has(e));if(g!==void 0)throw new D(`no snapshot is of this package`,k(a,g));let _=n.keys().find(e=>!d.has(e));if(_!==void 0)throw new D(`patches no package in the lockfile, which pnpm refuses to install with`,k(k(t,`patchedDependencies`),_));let[y]=i.values();if(y!==void 0)throw new D(`a registry package has its version in its key, except where a snapshot of it has a source in its peers`,y);return{packages:h,snapshots:s}}var zt=[...e,`dependenciesMeta`,`publishDirectory`,`linkDirectory`],$=[`configDependencies`,`packageManagerDependencies`];function Bt(e,t,n,r,i){let a=Object.create(null),o={specifiers:a},s=Object.create(null);for(let c of t)o[c]=S(v(e[c]),k(r,c),(e,t,r)=>{if(w(r,t),p(e,t,[`specifier`,`version`]),r in a)throw new D(`listed under ${s[r]} too`,t);a[r]=h(e.specifier,k(t,`specifier`)),s[r]=c;let o=k(t,`version`);return Dt(b(e.version,o),r,n,i,o)});return o}var Vt=Z([`injected`,`node`],(e,t)=>({injected:y(e,`injected`,t,g)??!1,node:y(e,`node`,t,b)}));function Ht(t,n,r,a){if(p(t,r,zt),t.linkDirectory!==void 0&&t.linkDirectory!==!1)throw new D(`expected false, the only value pnpm writes`,k(r,`linkDirectory`));return{...Bt(t,e,n,r,a),dependenciesMeta:Vt(t.dependenciesMeta,k(r,`dependenciesMeta`)),publishDirectory:y(t,`publishDirectory`,r,i),linkDirectory:t.linkDirectory!==!1}}function Ut(e,t,n,r){let a=S(e,t,(e,t,a)=>{if(i(a,t),!r)return Ht(e,a,t,n);if(a!==`.`)throw new D(`the env document has no importer but "."`,t);return p(e,t,$),Bt(e,$,a,t,n)});if(r&&!(`.`in a))throw new D(`expected the "." importer`,t);return a}var Wt=[`lockfileVersion`,`settings`,`catalogs`,`overrides`,`patchedDependencies`,`packageExtensionsChecksum`,`pnpmfileChecksum`,`ignoredOptionalDependencies`,`time`,`importers`,`packages`,`snapshots`],Gt=[`lockfileVersion`,`importers`,`packages`,`snapshots`],Kt={__proto__:null,autoInstallPeers:g,dedupePeers:g,excludeLinksFromLockfile:g,injectWorkspacePackages:g,peersSuffixMaxLength:_},qt=(e,t)=>S(p(v(e),t,Object.keys(Kt)),t,(e,t,n)=>Kt[n](e,t)),Jt=(e,t)=>S(v(e),t,(e,t,n)=>(b(n,t),Z([`specifier`,`version`],(e,t)=>({specifier:h(e.specifier,k(t,`specifier`)),version:b(e.version,k(t,`version`))}))(e,t)));function Yt(e,t){if(e.indexOf(`@`,1)===-1)return w(e,t);if(!T(ut(e,t).ref))throw new D(`${O(e)} is not a name and a version, or a name alone, which is not supported`,t)}var Xt=(e,t)=>S(v(e),t,(e,t,n)=>{let r=typeof e!=`string`;r&&p(e,t,[`hash`,`path`]);let a=r?k(t,`hash`):t,o=b(r?e.hash:e,a);if(!X(o,32,re)&&!X(o,16,Y))throw new D(`${O(o)} is not a patch hash`,a);return Yt(n,t),{hash:o,path:r?i(e.path,k(t,`path`)):void 0}});function Zt(e,t){let n=b(e,t);if(X(n,16,re)||X(n,16,Y))return n;if(!n.startsWith(`sha256-`))throw new D(`${O(n)} is not a checksum`,t);return l(n,t)}var Qt=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?Z$/u,$t=(e,t,n)=>S(v(e),t,(e,t,r)=>{if(!(r in n))throw new D(`${O(r)} is not in packages`,t);let i=b(e,t),a=Qt.test(i)?Date.parse(i):NaN;if(Number.isNaN(a)||new Date(a).toISOString().slice(0,19)!==i.slice(0,19))throw new D(`${O(i)} is not a UTC timestamp`,t);return i});function en(e,t,r,i){let a=n(Object.values(e).flatMap(e=>i.map(t=>e[t])),t);if(a!==void 0)throw new D(`no importer depends on it, directly or not`,k(k(r,`snapshots`),a))}function tn(e,t,n){let i=r(t,e,n?{required:$,dev:[],optional:[]}:void 0);for(let e of Object.values(t)){let{dev:t,devOptional:n}=i(e);Object.assign(e,{dev:t,devOptional:n})}}function nn(t,n,r){let i=n===``?void 0:n,a=p(t,i).lockfileVersion;if(a!==`9.0`)throw new D(`unsupported version: expected "9.0", found ${f(a)}`,k(n,`lockfileVersion`));p(t,i,r?Gt:Wt);let o=Xt(t.patchedDependencies,k(n,`patchedDependencies`)),{packages:s,snapshots:c}=Rt(t,n,new Map(Object.entries(o))),l=Ut(t.importers,k(n,`importers`),c,r);return en(l,s,n,r?$:e),tn(l,s,r),r?{lockfileVersion:a,importers:l,packages:s}:{lockfileVersion:a,settings:qt(t.settings,k(n,`settings`)),catalogs:Jt(t.catalogs,k(n,`catalogs`)),overrides:ee(v(t.overrides),k(n,`overrides`),b),patchedDependencies:o,packageExtensionsChecksum:y(t,`packageExtensionsChecksum`,n,Zt),pnpmfileChecksum:y(t,`pnpmfileChecksum`,n,Zt),ignoredOptionalDependencies:y(t,`ignoredOptionalDependencies`,n,x)??[],time:$t(t.time,k(n,`time`),v(t.packages)),importers:l,packages:s}}function rn(e){if(typeof e!=`string`)throw TypeError(`expected a string`);let t=/^---\r?\n/u.exec(e)?.[0];if(t===void 0){let t=qe(e);if(t.length!==1)throw new D(`expected one document, found ${t.length}`);return{lockfile:nn(t[0],``,!1),env:void 0}}let n=/\n---\r?\n/gu;n.lastIndex=t.length;let r=n.exec(e);if(r===null)throw new D(`expected the env document the first "---" starts to end at a line of "---"`);let i=/^(?: *\r?\n)* *$/u.test(e.slice(n.lastIndex)),a=qe(i?e.slice(0,r.index+1):e);if(a.length!==(i?1:2))throw new D(`expected the env document${i?``:` and the lockfile`} between lines of "---" alone, found ${a.length} documents`);return{lockfile:i?void 0:nn(a[1],``,!1),env:nn(a[0],`env`,!0)}}export{D as LockfileError,j as YamlError,J as packageKeyOf,rn as parsePnpmLockfile};
|
package/out/chunk-Y5ZHFNBD.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,b as t,c as n,d as r,e as i,f as a}from"./chunk-G3LY2FV4.js";import{a as o}from"./chunk-4EMM6UCD.js";import{C as s,H as c,K as l,L as u,Q as d,m as f}from"./chunk-UCP3JRE2.js";import"./chunk-ZQHLECTI.js";import"./chunk-PXK7EU4V.js";import{d as p,h as m,i as h,j as g,k as ee,p as te,r as ne,s as _}from"./chunk-JMG5DXII.js";import"./chunk-OOJM4CTU.js";var re=e=>/^[A-Za-z\d][\w.-]*$/u.test(e)&&/[A-Za-z]/u.test(e);function ie(e){let t=e.split(`-`);for(;t.at(-1)===``;)t.pop();return t}var v=()=>{},ae={3:[[/aix(\d+)?/u,`aix`],[/cygwin/u,`cygwin`,v],[/darwin(\d+)?/u,`darwin`],[/^macruby$/u,`macruby`,v],[/freebsd(\d+)?/u,`freebsd`],[/^(?:java|jruby)$/u,`java`,v],[/^java([\d.]*)/u,`java`],[/^dalvik(\d+)?$/u,`dalvik`],[/^dotnet$/u,`dotnet`,v],[/^dotnet([\d.]*)/u,`dotnet`],[/linux-?(\w+)?/u,`linux`],[/mingw32/u,`mingw32`,v],[/mingw-?(\w+)?/u,`mingw`],[/(mswin\d+)(_(\d+))?/u,void 0,e=>e[3]],[/netbsdelf/u,`netbsdelf`,v],[/openbsd(\d+\.\d+)?/u,`openbsd`],[/solaris(\d+\.\d+)?/u,`solaris`],[/wasi/u,`wasi`,v],[/^(\w+_platform)(\d+)?/u,void 0,e=>e[2]]],4:[[/aix-?(\d+)?/u,`aix`],[/cygwin/u,`cygwin`,v],[/darwin-?(\d+)?/u,`darwin`],[/^macruby$/u,`macruby`,v],[/^macruby-?(\d+(?:\.\d+)*)?/u,`macruby`],[/freebsd-?(\d+)?/u,`freebsd`],[/^(?:java|jruby)$/u,`java`,v],[/^java-?(\d+(?:\.\d+)*)?/u,`java`],[/^dalvik-?(\d+)?$/u,`dalvik`],[/^dotnet$/u,`dotnet`,v],[/^dotnet-?(\d+(?:\.\d+)*)?/u,`dotnet`],[/linux-?(\w+)?/u,`linux`],[/mingw32/u,`mingw32`,v],[/mingw-?(\w+)?/u,`mingw`],[/(mswin\d+)(?:[_-](\d+))?/u,void 0,e=>e[2]],[/netbsdelf/u,`netbsdelf`,v],[/openbsd-?(\d+\.\d+)?/u,`openbsd`],[/solaris-?(\d+\.\d+)?/u,`solaris`],[/wasi/u,`wasi`,v],[/^(\w+_platform)-?(\d+)?/u,void 0,e=>e[2]]]};function oe(e,t){if(e===void 0)return[`unknown`,void 0,void 0];for(let[n,r,i=e=>e[1]]of ae[t]){let t=n.exec(e);if(t===null)continue;let a=r??t[1];return[a,i(t),/^mswin\d*32$/u.test(a)?`x86`:void 0]}return[`unknown`,void 0,void 0]}function y(e){let t=ie(e);if(t.length>2&&!/\d$/u.test(t.at(-1))){let e=t.pop();t[t.length-1]+=`-${e}`}let n=t.shift();return t.length===2&&/^\d+(?:\.\d+)?$/u.test(t[1])?{cpu:n,os:t[0],version:t[1]}:{cpu:n,os:t[0]}}function b(e){let t=e.length;for(;e[t-1]===`-`;)t--;let n=e.slice(0,t),r=n.indexOf(`-`);return r===-1?{cpu:n||void 0}:{cpu:n.slice(0,r),os:n.slice(r+1)}}function x(e,t){let{cpu:n,os:r,version:i}=t===3?y(e):b(e),a=n!==void 0&&/i\d86/u.test(n)?`x86`:n;if(i!==void 0)return[a,r,i];let[o,s,c]=oe(r??n,t);return[r===void 0?c:a,o,s]}function S(e,t){let n=x(e,t);return n.filter(e=>e!==void 0).join(t===4&&n[0]===void 0?``:`-`)}var C=e=>e!==`ruby`&&e!==`current`&&/^[\w.-]+$/u.test(e)&&S(e,3)===e&&S(e,4)===e;function w(e){let t=e?.replace(/^gnu/u,``).replace(/eabi(?:hf)?$/u,``);return t===``?void 0:t}var T=Symbol(`all`),E=Symbol(`arm`);function se(e){let t=new Map;for(let n of e){if(n===`ruby`)continue;let[e,r,i]=x(n,3),a=t.get(r)??t.set(r,new Map).get(r);for(let t of[e,T,...e?.startsWith(`arm`)?[E]:[]]){let e=a.get(t)??a.set(t,{versions:new Set,libcs:new Set}).get(t);e.versions.add(i),e.libcs.add(w(i))}}return t}function ce(e,t,n){return e===void 0?!1:n===void 0||e.versions.has(void 0)||e.versions.has(n)?!0:t===`linux`&&(e.libcs.has(w(n))||[`musl`,`musleabi`,`musleabihf`].some(t=>e.versions.has(`${t}${n}`)))}function le(e,t){if(t===`java`||t===`mswin64`)return[void 0,t];if(t===`mswin32`&&e===`x86`)return[e,t];if(t===`mingw32`)return[e===`universal`||e===`x64`?e:e===`x86_64`?`x64`:`x86`,t]}function D(e,t,n,r){let i=e.get(n),a=t===void 0||t===`universal`?[T]:[t,void 0,`universal`,...t===`arm`?[E]:[]];return i!==void 0&&a.some(e=>ce(i.get(e),n,r))?!0:n.startsWith(`mingw`)&&[`mingw`,`mingw32`].some(n=>e.get(n)?.has(t===`universal`?T:`universal`))}function ue(e,t){let[n,r,i]=x(t,3),a=le(n,r);return D(e,n,r,i)||a!==void 0&&D(e,...a,void 0)}var de={GIT:{order:[`remote`,`revision`,`ref`,`branch`,`tag`,`submodules`,`glob`],required:2},PATH:{order:[`remote`,`glob`],required:1},GEM:{order:[`remote`],required:0}},fe=`{,*,*/*}.gemspec`;function pe({type:e,number:t,options:n}){let{order:r,required:i}=de[e],a=Object.create(null),o=0;for(let{key:t,value:i,number:s}of n){let n=r.indexOf(t);if(n===-1)throw g(`${m(t)} is not an option Bundler writes for a ${e} source`,s);if(t in a)throw g(e===`GEM`?`a second remote: Bundler fetches each gem of the source from either, and the lockfile does not say which`:`a second ${t}`,s);if(n<o)throw g(`${t} after ${r[o-1]}, where Bundler writes it before`,s);if(i.trim()!==i)throw g(`${m(i)} has a space at an end, which no ${t} Bundler writes has`,s);o=n+1,a[t]=i}let s=r.slice(0,i).find(e=>!(e in a));if(s!==void 0)throw g(`a ${e} source without its ${s}`,t);return a}var O=/\\|(?:^|[/{,])\.\.(?=$|[/},])|(?:^|[{,])(?:\/|[A-Za-z]:)/u;function k(e,t){if(e===fe)throw new p(`${m(e)}, which Bundler reads by where none is written, and does not write`,t);if(e!==void 0&&O.test(e))throw new p(`${m(e)} reaches out of the source, which Bundler globs its gemspecs from`,t);return e}function A(e,t){let{remote:n}=e;if(n.endsWith(`/`))throw new p(`${m(n)} ends in "/", which Bundler 2.4 and later drop as they read it, and 2.2 and 2.3 keep`,h(t,`remote`));u(n,h(t,`remote`));let{revision:r,ref:i}=e;if(!c(r))throw new p(`${m(r)} is not a full commit hash`,h(t,`revision`));if(i!==void 0&&/\s/u.test(i))throw new p(`${m(i)} is not a reference git reads`,h(t,`ref`));if(i?.startsWith(`-`))throw new p(`${m(i)} starts with "-", which git reads as an option`,h(t,`ref`));if(i!==void 0&&c(i)&&i!==r)throw new p(`the commit ${i}, and the revision another`,h(t,`ref`));if(e.submodules!==void 0&&e.submodules!==`true`)throw new p(`expected "true", found ${m(e.submodules)}`,h(t,`submodules`));return{type:`git`,remote:n,revision:r,ref:i,branch:f(e,`branch`,t,l),tag:f(e,`tag`,t,l),submodules:e.submodules===`true`,glob:k(e.glob,h(t,`glob`))}}function j(e,t){let n=h(t,`path`);if(e.remote.startsWith(`/`))throw new p(`${m(e.remote)} is an absolute path, which is the path on one machine alone`,n);if(e.remote.startsWith(`~`))throw new p(`${m(e.remote)} is a path from a home directory, which Bundler writes from the lockfile's`,n);return{type:`path`,path:s(e.remote,n),glob:k(e.glob,h(t,`glob`))}}function M(e){let t=URL.parse(e);return t!==null&&t.href===e&&(t.protocol===`file:`?t.host===``:t.protocol===`s3:`&&t.host!==``)}function N(e,t){let{remote:n}=e;if(n===void 0)return{type:`gem`,remote:n};if(!d(n)&&!M(n))throw new p(`${m(n)} is not an http(s) URL, or a file: or s3: URL in normal form`,h(t,`remote`));if(!n.endsWith(`/`))throw new p(`${m(n)} does not end in "/", as Bundler writes a source`,h(t,`remote`));return{type:`gem`,remote:n}}var P={GIT:A,PATH:j,GEM:N};function F(e){if(e.type===`gem`)return;if(e.type===`path`)return`source at \`${e.path}\``;let t=/^([A-Za-z][\w+.-]*):\/\/([^/]*)/u.exec(e.remote);return t!==null&&(/[A-Z]/u.test(t[1])||t[2].includes(`@`))?void 0:`${e.remote} (`}var I=e=>`the ${e.type} source ${m(e.remote??e.path)}`;function L(e,t){let n;for(let[r,i]of e.entries()){let e=F(i);if(e!==void 0){if(n!==void 0&&o(e,n.key)<0)throw g(`${I(i)} after ${I(n.source)}, where Bundler sorts them the other way`,t[r].number);n={key:e,source:i}}}}function R(e,t){let n=e.findIndex(e=>e.type===`gem`);if(n===-1)throw new p(`no GEM source, which Bundler always writes`);let r=e[n].remote===void 0,i=e.findIndex((e,t)=>t>n&&e.type===`gem`&&e.remote===void 0);if(i!==-1)throw g(r?`a second GEM source of no remote, where Bundler writes one, the Gemfile's own`:`a GEM source of no remote after one of a remote, where Bundler writes it first`,t[i].number);return r?n:-1}function z(e){let t=e.map((e,t)=>P[e.type](pe(e),`sources[${t}]`));return L(t,e),{sources:t,local:R(t,e)}}var B=/<<<<<<<|=======|>>>>>>>|\|{7}/u,me=new Set([`GIT`,`PATH`,`GEM`]),V={PLATFORMS:[2],DEPENDENCIES:[2],CHECKSUMS:[2],"RUBY VERSION":[2,3],"BUNDLED WITH":[2,3]},H=Object.keys(V);function U(e,t,n){let r=te(e);if(!t.includes(r))throw g(`expected ${t.join(` or `)} spaces of indentation, found ${r}`,n);return e.slice(r)}var he=/^([^\s()]+) \(([^\s()]+)\)(?: (\S+))?$/u;function W(e,t,n){let r=he.exec(e);if(r===null||!n&&r[3]!==void 0)throw g(`expected a gem as "name (version)", found ${m(e)}`,t);let[,i,a,o]=r,s=a.indexOf(`-`);return{name:i,version:s===-1?a:a.slice(0,s),platform:s===-1?void 0:a.slice(s+1),checksum:o,number:t}}var ge=/^([^\s()!]+)(?: \(([^()]+)\))?(!)?$/u;function G(e,t,n){let r=ge.exec(e);if(r===null||!n&&r[3]!==void 0)throw g(`expected a dependency as "name" or "name (requirement)", found ${m(e)}`,t);return{name:r[1],requirements:r[2]?.split(`, `)??[],pinned:r[3]!==void 0}}var _e=/^ {2}([a-z]+): (.+)$/u;function ve(e){let{line:t,number:n}=e,r=[];for(_(e);;_(e)){let t=_e.exec(e.line??``);if(t===null)break;r.push({key:t[1],value:t[2],number:e.number})}if(e.line!==` specs:`)throw g(`expected an option, "key: value", or "specs:", two spaces in, found ${e.line===void 0?`the end of the file`:m(e.line)}`,e.number);let i=[];for(_(e);e.line?.startsWith(` `);_(e)){let t=U(e.line,[4,6],e.number);if(e.line.length-t.length===4)
|
|
1
|
+
import{a as e,b as t,c as n,d as r,e as i,f as a}from"./chunk-G3LY2FV4.js";import{a as o}from"./chunk-4EMM6UCD.js";import{C as s,H as c,K as l,L as u,Q as d,m as f}from"./chunk-UCP3JRE2.js";import"./chunk-ZQHLECTI.js";import"./chunk-PXK7EU4V.js";import{d as p,h as m,i as h,j as g,k as ee,p as te,r as ne,s as _}from"./chunk-JMG5DXII.js";import"./chunk-OOJM4CTU.js";var re=e=>/^[A-Za-z\d][\w.-]*$/u.test(e)&&/[A-Za-z]/u.test(e);function ie(e){let t=e.split(`-`);for(;t.at(-1)===``;)t.pop();return t}var v=()=>{},ae={3:[[/aix(\d+)?/u,`aix`],[/cygwin/u,`cygwin`,v],[/darwin(\d+)?/u,`darwin`],[/^macruby$/u,`macruby`,v],[/freebsd(\d+)?/u,`freebsd`],[/^(?:java|jruby)$/u,`java`,v],[/^java([\d.]*)/u,`java`],[/^dalvik(\d+)?$/u,`dalvik`],[/^dotnet$/u,`dotnet`,v],[/^dotnet([\d.]*)/u,`dotnet`],[/linux-?(\w+)?/u,`linux`],[/mingw32/u,`mingw32`,v],[/mingw-?(\w+)?/u,`mingw`],[/(mswin\d+)(_(\d+))?/u,void 0,e=>e[3]],[/netbsdelf/u,`netbsdelf`,v],[/openbsd(\d+\.\d+)?/u,`openbsd`],[/solaris(\d+\.\d+)?/u,`solaris`],[/wasi/u,`wasi`,v],[/^(\w+_platform)(\d+)?/u,void 0,e=>e[2]]],4:[[/aix-?(\d+)?/u,`aix`],[/cygwin/u,`cygwin`,v],[/darwin-?(\d+)?/u,`darwin`],[/^macruby$/u,`macruby`,v],[/^macruby-?(\d+(?:\.\d+)*)?/u,`macruby`],[/freebsd-?(\d+)?/u,`freebsd`],[/^(?:java|jruby)$/u,`java`,v],[/^java-?(\d+(?:\.\d+)*)?/u,`java`],[/^dalvik-?(\d+)?$/u,`dalvik`],[/^dotnet$/u,`dotnet`,v],[/^dotnet-?(\d+(?:\.\d+)*)?/u,`dotnet`],[/linux-?(\w+)?/u,`linux`],[/mingw32/u,`mingw32`,v],[/mingw-?(\w+)?/u,`mingw`],[/(mswin\d+)(?:[_-](\d+))?/u,void 0,e=>e[2]],[/netbsdelf/u,`netbsdelf`,v],[/openbsd-?(\d+\.\d+)?/u,`openbsd`],[/solaris-?(\d+\.\d+)?/u,`solaris`],[/wasi/u,`wasi`,v],[/^(\w+_platform)-?(\d+)?/u,void 0,e=>e[2]]]};function oe(e,t){if(e===void 0)return[`unknown`,void 0,void 0];for(let[n,r,i=e=>e[1]]of ae[t]){let t=n.exec(e);if(t===null)continue;let a=r??t[1];return[a,i(t),/^mswin\d*32$/u.test(a)?`x86`:void 0]}return[`unknown`,void 0,void 0]}function y(e){let t=ie(e);if(t.length>2&&!/\d$/u.test(t.at(-1))){let e=t.pop();t[t.length-1]+=`-${e}`}let n=t.shift();return t.length===2&&/^\d+(?:\.\d+)?$/u.test(t[1])?{cpu:n,os:t[0],version:t[1]}:{cpu:n,os:t[0]}}function b(e){let t=e.length;for(;e[t-1]===`-`;)t--;let n=e.slice(0,t),r=n.indexOf(`-`);return r===-1?{cpu:n||void 0}:{cpu:n.slice(0,r),os:n.slice(r+1)}}function x(e,t){let{cpu:n,os:r,version:i}=t===3?y(e):b(e),a=n!==void 0&&/i\d86/u.test(n)?`x86`:n;if(i!==void 0)return[a,r,i];let[o,s,c]=oe(r??n,t);return[r===void 0?c:a,o,s]}function S(e,t){let n=x(e,t);return n.filter(e=>e!==void 0).join(t===4&&n[0]===void 0?``:`-`)}var C=e=>e!==`ruby`&&e!==`current`&&/^[\w.-]+$/u.test(e)&&S(e,3)===e&&S(e,4)===e;function w(e){let t=e?.replace(/^gnu/u,``).replace(/eabi(?:hf)?$/u,``);return t===``?void 0:t}var T=Symbol(`all`),E=Symbol(`arm`);function se(e){let t=new Map;for(let n of e){if(n===`ruby`)continue;let[e,r,i]=x(n,3),a=t.get(r)??t.set(r,new Map).get(r);for(let t of[e,T,...e?.startsWith(`arm`)?[E]:[]]){let e=a.get(t)??a.set(t,{versions:new Set,libcs:new Set}).get(t);e.versions.add(i),e.libcs.add(w(i))}}return t}function ce(e,t,n){return e===void 0?!1:n===void 0||e.versions.has(void 0)||e.versions.has(n)?!0:t===`linux`&&(e.libcs.has(w(n))||[`musl`,`musleabi`,`musleabihf`].some(t=>e.versions.has(`${t}${n}`)))}function le(e,t){if(t===`java`||t===`mswin64`)return[void 0,t];if(t===`mswin32`&&e===`x86`)return[e,t];if(t===`mingw32`)return[e===`universal`||e===`x64`?e:e===`x86_64`?`x64`:`x86`,t]}function D(e,t,n,r){let i=e.get(n),a=t===void 0||t===`universal`?[T]:[t,void 0,`universal`,...t===`arm`?[E]:[]];return i!==void 0&&a.some(e=>ce(i.get(e),n,r))?!0:n.startsWith(`mingw`)&&[`mingw`,`mingw32`].some(n=>e.get(n)?.has(t===`universal`?T:`universal`))}function ue(e,t){let[n,r,i]=x(t,3),a=le(n,r);return D(e,n,r,i)||a!==void 0&&D(e,...a,void 0)}var de={GIT:{order:[`remote`,`revision`,`ref`,`branch`,`tag`,`submodules`,`glob`],required:2},PATH:{order:[`remote`,`glob`],required:1},GEM:{order:[`remote`],required:0}},fe=`{,*,*/*}.gemspec`;function pe({type:e,number:t,options:n}){let{order:r,required:i}=de[e],a=Object.create(null),o=0;for(let{key:t,value:i,number:s}of n){let n=r.indexOf(t);if(n===-1)throw g(`${m(t)} is not an option Bundler writes for a ${e} source`,s);if(t in a)throw g(e===`GEM`?`a second remote: Bundler fetches each gem of the source from either, and the lockfile does not say which`:`a second ${t}`,s);if(n<o)throw g(`${t} after ${r[o-1]}, where Bundler writes it before`,s);if(i.trim()!==i)throw g(`${m(i)} has a space at an end, which no ${t} Bundler writes has`,s);o=n+1,a[t]=i}let s=r.slice(0,i).find(e=>!(e in a));if(s!==void 0)throw g(`a ${e} source without its ${s}`,t);return a}var O=/\\|(?:^|[/{,])\.\.(?=$|[/},])|(?:^|[{,])(?:\/|[A-Za-z]:)/u;function k(e,t){if(e===fe)throw new p(`${m(e)}, which Bundler reads by where none is written, and does not write`,t);if(e!==void 0&&O.test(e))throw new p(`${m(e)} reaches out of the source, which Bundler globs its gemspecs from`,t);return e}function A(e,t){let{remote:n}=e;if(n.endsWith(`/`))throw new p(`${m(n)} ends in "/", which Bundler 2.4 and later drop as they read it, and 2.2 and 2.3 keep`,h(t,`remote`));u(n,h(t,`remote`));let{revision:r,ref:i}=e;if(!c(r))throw new p(`${m(r)} is not a full commit hash`,h(t,`revision`));if(i!==void 0&&/\s/u.test(i))throw new p(`${m(i)} is not a reference git reads`,h(t,`ref`));if(i?.startsWith(`-`))throw new p(`${m(i)} starts with "-", which git reads as an option`,h(t,`ref`));if(i!==void 0&&c(i)&&i!==r)throw new p(`the commit ${i}, and the revision another`,h(t,`ref`));if(e.submodules!==void 0&&e.submodules!==`true`)throw new p(`expected "true", found ${m(e.submodules)}`,h(t,`submodules`));return{type:`git`,remote:n,revision:r,ref:i,branch:f(e,`branch`,t,l),tag:f(e,`tag`,t,l),submodules:e.submodules===`true`,glob:k(e.glob,h(t,`glob`))}}function j(e,t){let n=h(t,`path`);if(e.remote.startsWith(`/`))throw new p(`${m(e.remote)} is an absolute path, which is the path on one machine alone`,n);if(e.remote.startsWith(`~`))throw new p(`${m(e.remote)} is a path from a home directory, which Bundler writes from the lockfile's`,n);return{type:`path`,path:s(e.remote,n),glob:k(e.glob,h(t,`glob`))}}function M(e){let t=URL.parse(e);return t!==null&&t.href===e&&(t.protocol===`file:`?t.host===``:t.protocol===`s3:`&&t.host!==``)}function N(e,t){let{remote:n}=e;if(n===void 0)return{type:`gem`,remote:n};if(!d(n)&&!M(n))throw new p(`${m(n)} is not an http(s) URL, or a file: or s3: URL in normal form`,h(t,`remote`));if(!n.endsWith(`/`))throw new p(`${m(n)} does not end in "/", as Bundler writes a source`,h(t,`remote`));return{type:`gem`,remote:n}}var P={GIT:A,PATH:j,GEM:N};function F(e){if(e.type===`gem`)return;if(e.type===`path`)return`source at \`${e.path}\``;let t=/^([A-Za-z][\w+.-]*):\/\/([^/]*)/u.exec(e.remote);return t!==null&&(/[A-Z]/u.test(t[1])||t[2].includes(`@`))?void 0:`${e.remote} (`}var I=e=>`the ${e.type} source ${m(e.remote??e.path)}`;function L(e,t){let n;for(let[r,i]of e.entries()){let e=F(i);if(e!==void 0){if(n!==void 0&&o(e,n.key)<0)throw g(`${I(i)} after ${I(n.source)}, where Bundler sorts them the other way`,t[r].number);n={key:e,source:i}}}}function R(e,t){let n=e.findIndex(e=>e.type===`gem`);if(n===-1)throw new p(`no GEM source, which Bundler always writes`);let r=e[n].remote===void 0,i=e.findIndex((e,t)=>t>n&&e.type===`gem`&&e.remote===void 0);if(i!==-1)throw g(r?`a second GEM source of no remote, where Bundler writes one, the Gemfile's own`:`a GEM source of no remote after one of a remote, where Bundler writes it first`,t[i].number);return r?n:-1}function z(e){let t=e.map((e,t)=>P[e.type](pe(e),`sources[${t}]`));return L(t,e),{sources:t,local:R(t,e)}}var B=/<<<<<<<|=======|>>>>>>>|\|{7}/u,me=new Set([`GIT`,`PATH`,`GEM`]),V={PLATFORMS:[2],DEPENDENCIES:[2],CHECKSUMS:[2],"RUBY VERSION":[2,3],"BUNDLED WITH":[2,3]},H=Object.keys(V);function U(e,t,n){let r=te(e);if(!t.includes(r))throw g(`expected ${t.join(` or `)} spaces of indentation, found ${r}`,n);return e.slice(r)}var he=/^([^\s()]+) \(([^\s()]+)\)(?: (\S+))?$/u;function W(e,t,n){let r=he.exec(e);if(r===null||!n&&r[3]!==void 0)throw g(`expected a gem as "name (version)", found ${m(e)}`,t);let[,i,a,o]=r,s=a.indexOf(`-`);return{name:i,version:s===-1?a:a.slice(0,s),platform:s===-1?void 0:a.slice(s+1),checksum:o,number:t}}var ge=/^([^\s()!]+)(?: \(([^()]+)\))?(!)?$/u;function G(e,t,n){let r=ge.exec(e);if(r===null||!n&&r[3]!==void 0)throw g(`expected a dependency as "name" or "name (requirement)", found ${m(e)}`,t);return{name:r[1],requirements:r[2]?.split(`, `)??[],pinned:r[3]!==void 0}}var _e=/^ {2}([a-z]+): (.+)$/u;function ve(e){let{line:t,number:n}=e,r=[];for(_(e);;_(e)){let t=_e.exec(e.line??``);if(t===null)break;r.push({key:t[1],value:t[2],number:e.number})}if(e.line!==` specs:`)throw g(`expected an option, "key: value", or "specs:", two spaces in, found ${e.line===void 0?`the end of the file`:m(e.line)}`,e.number);let i=[];for(_(e);e.line?.startsWith(` `);_(e)){let t=U(e.line,[4,6],e.number);if(e.line.length-t.length===4)i.push({...W(t,e.number,!1),dependencies:[]});else{if(i.length===0)throw g(`a dependency before any spec`,e.number);i.at(-1).dependencies.push(G(t,e.number,!1))}}return{type:t,number:n,options:r,specs:i}}function ye(e,t){let n=[];for(_(e);e.line?.startsWith(` `);_(e)){let r=U(e.line,t,e.number);n.push({text:r,indent:e.line.length-r.length,number:e.number})}return n}function be(e){let[t,n]=[`RUBY VERSION`,`BUNDLED WITH`].map(t=>e.get(t)?.lines[0]);if(t!==void 0&&n!==void 0&&t.indent!==n.indent)throw g(`${t.indent} spaces of indentation, and ${n.indent} under BUNDLED WITH`,t.number)}function xe(e){let t=B.exec(e)?.[0];if(t!==void 0)throw new p(`${m(t)}, which Bundler reads as a merge conflict`);if(e===``)throw new p(`an empty lockfile, which Bundler reads as none`);if(!e.endsWith(`
|
|
2
2
|
`))throw new p(`no line end after the last line, where Bundler ends every line`);let n=ne(e,ee),r=[],i=new Map,a;for(_(n);n.line!==void 0;){let{line:e,number:t}=n;if(e===``||e.startsWith(` `))throw g(e===``?`a blank line, where Bundler writes one between sections alone`:`expected a section, at column 0`,t);if(e===`PLUGIN SOURCE`)throw g(`a plugin source, which only its plugin can read, and which is not read here`,t);if(me.has(e)){if(a!==void 0)throw g(`a ${e} source after ${a}, where Bundler writes the sources first`,t);if(e!==`GEM`&&r.at(-1)?.type===`GEM`)throw g(`a ${e} source after a GEM one, where Bundler writes the GEM sources last`,t);r.push(ve(n))}else{let r=H.indexOf(e);if(r===-1)throw g(`${m(e)} is not a section Bundler writes`,t);if(i.has(e))throw g(`a second ${e}`,t);if(r<H.indexOf(a))throw g(`${e} after ${a}, where Bundler writes it before`,t);a=e,i.set(e,{number:t,lines:ye(n,V[e])})}if(n.line===void 0)break;if(n.line!==``)throw g(`expected a blank line before ${m(n.line)}`,n.number);if(_(n),n.line===void 0)throw g(`a blank line at the end, where Bundler writes none`,n.number)}return be(i),{sources:r,sections:i}}function K(e,t){if(!re(e))throw new p(`${m(e)} is not a gem name`,t);return e}var q=({name:e,version:t,platform:n=`ruby`})=>n===`ruby`?`${e}-${t}`:`${e}-${t}-${n}`;function J({name:t,version:n,platform:r},i){if(K(t,i),!e(n))throw new p(`${m(n)} is not a version as RubyGems writes one`,i);if(r===`ruby`)throw new p(`the platform ruby, which Bundler leaves out of a gem of no platform`,i);if(r!==void 0&&!C(r))throw new p(`${m(r)} is not a platform as RubyGems writes one`,i);return{name:t,version:n,platform:r??`ruby`}}function Se(e,r){for(let[t,i]of e.entries()){if(n(i)===void 0)throw new p(`${m(i)} is not a requirement as Bundler writes one, "op version"`,r);if(t>0&&i>e[t-1])throw new p(`${m(i)} after ${m(e[t-1])}, where Bundler sorts them backwards`,r)}let[i]=e;if(e.length===1&&i.startsWith(`>= `)&&t(i.slice(3),`0`)===0)throw new p(`${m(i)}, which Bundler leaves out, as any version`,r);return e}function Y(e,t,n,r=e=>e){let i=Object.create(null),a;for(let o of e){let e=h(t,o.name);if(K(o.name,e),a!==void 0&&o.name<=a)throw new p(`${o.name===a?`listed twice`:`after ${m(a)}`}, where Bundler sorts ${n} by name`,e);a=o.name,i[o.name]=r(Se(o.requirements,e),o)}return i}function Ce(e,t){let n=Object.create(null);for(let[r,{specs:i}]of e.entries()){let e;for(let a of i){let i=q(a),o=h(`specs`,i),{name:s,version:c,platform:l}=J(a,o);if(s===`bundler`)throw new p(`Bundler itself, which Bundler leaves out of the sources`,o);if(i in n)throw new p(`listed twice, of which Bundler keeps the last alone, at line ${a.number+1}`,o);if(e!==void 0&&i<e)throw new p(`after ${m(e)}, where Bundler sorts a source's gems by full name`,o);if(e=i,r===t)throw new p(`from sources[${r}], which has no remote: Bundler takes it from the gems installed where it runs`,o);n[i]={name:s,version:c,platform:l,source:r,dependencies:Y(a.dependencies,h(o,`dependencies`),`a gem's dependencies`),checksum:void 0}}}return n}var we=/^sha256=[\da-f]{64}$/u;function X(e,t){if(!we.test(e))throw new p(`${m(e)} is not a checksum as Bundler writes one, "sha256=" and the hex digest`,t);return e}function Te(e,t,n){let r,i,a=new Set;for(let{text:o,number:s}of e){if(i!==void 0&&o<=i)throw g(`${m(o)} after ${m(i)}, where Bundler sorts the checksums, each once`,s);i=o;let e=W(o,s,!0);if(e.name===`bundler`&&e.platform===void 0&&r===void 0){let{version:t}=J(e,`bundlerChecksum`);if(e.checksum===void 0)throw g(`Bundler itself, without the checksum Bundler writes it with`,s);r={version:t,checksum:X(e.checksum,h(`bundlerChecksum`,`checksum`))};continue}let c=q(e),l=m(o.split(` `,2).join(` `));if(!(c in t))throw g(`${l} is no gem of the sources`,s);if(a.has(c))throw g(`${l} a second time, where Bundler lists each gem once`,s);a.add(c);let u=t[c];if(e.checksum===void 0)continue;let d=h(h(`specs`,c),`checksum`);if(n[u.source].type!==`gem`)throw new p(`a checksum of a gem from a ${n[u.source].type} source, which has no .gem to check`,d);u.checksum=X(e.checksum,d)}let o=Object.keys(t).find(e=>!a.has(e));if(o!==void 0)throw new p(`not in CHECKSUMS, where Bundler lists every gem`,h(`specs`,o));return r}function Z(e,t){let n=e.get(t);if(n===void 0)throw new p(`no ${t}, which Bundler always writes`);return n}function Ee(e){let t=e.lines.map(({text:e})=>e);if(t.length===0)throw g(`no platform under PLATFORMS`,e.number);for(let[e,n]of t.entries()){let r=`platforms[${e}]`;if(n!==`ruby`&&!C(n))throw new p(`${m(n)} is not a platform as RubyGems writes one`,r);if(e>0&&n<=t[e-1])throw new p(`${m(n)} after ${m(t[e-1])}, where Bundler sorts the platforms, each once`,r)}return t}function De(e,t){let n=se(t);for(let[t,{platform:r}]of Object.entries(e))if(r!==`ruby`&&!ue(n,r))throw new p(`of the platform ${m(r)}, which no platform of PLATFORMS takes, where Bundler locks a gem for one`,h(`specs`,t))}function Oe(e){return Y(e.lines.map(({text:e,number:t})=>G(e,t,!0)),`dependencies`,`the dependencies`,(e,{pinned:t})=>({requirements:e,pinned:t}))}var ke=/^ruby \d+\.\d+\.\d+(?:\.[\dA-Za-z]+)*(?:p(?:-1|0|[1-9]\d*))?(?: \((?!ruby )[\w.-]+ [\w.-]+\))?$/u;function Ae(e,t){if(e.lines.length!==1)throw g(`expected one line under ${t}, found ${e.lines.length}`,e.number);return e.lines[0].text}var je=/^(?:2\.[2-7]|4\.0)\./u;function Q(t){let[n,r]=[`RUBY VERSION`,`BUNDLED WITH`].map(e=>t.has(e)?Ae(t.get(e),e):void 0);if(n!==void 0&&!ke.test(n))throw new p(`${m(n)} is not a Ruby as Bundler writes one, "ruby 3.3.6p108"`,`rubyVersion`);if(r!==void 0&&!e(r))throw new p(`${m(r)} is not a version as RubyGems writes one`,`bundledWith`);if(r!==void 0&&!je.test(r))throw new p(`${m(r)} is not a version of Bundler from 2.2 to 4.0, which this reader reads`,`bundledWith`);return{rubyVersion:n,bundledWith:r}}function Me(e){let t=Object.create(null),n=new Map;for(let[r,i]of Object.entries(e)){let a=t[i.name]??=[],[o]=a;if(o!==void 0&&e[o].source!==i.source)throw new p(`from sources[${i.source}], and ${m(o)} from sources[${e[o].source}], where Bundler takes a gem from one source`,h(`specs`,r));let s=n.get(`${i.name} ${i.platform}`);if(s!==void 0)throw new p(`for the platform of ${m(s)}, where Bundler locks one version of a gem for each`,h(`specs`,r));n.set(`${i.name} ${i.platform}`,r),a.push(r)}return t}function Ne({specs:e,gems:t,dependencies:n,sources:r,local:i}){let a;for(let[o,{pinned:s}]of Object.entries(n)){if(s||t[o]===void 0)continue;let n=h(`dependencies`,o),c=e[t[o][0]].source,{type:l}=r[c];if(l===`git`)throw new p(`from a git source, without the "!" Bundler writes of it`,n);if(l===`gem`&&i!==-1)throw new p(`from sources[${c}], where Bundler takes what the Gemfile names no source of from its default, sources[${i}], of no remote`,n);if(a??={name:o,index:c},c!==a.index)throw new p(`from sources[${c}], and ${m(a.name)} from sources[${a.index}], where Bundler takes what the Gemfile names no source of from its default alone`,n)}}function $(e,t,{specs:i,gems:o,versions:s},c){let l=s.get(e);if(!(l===void 0||t.every(e=>a(l,n(e)))))for(let a of o[e]){let e=t.find(e=>!r(i[a].version,n(e)));if(e!==void 0)throw new p(`${m(e)} is not met by ${m(a)}`,c)}}function Pe({specs:e,gems:t,dependencies:n}){let r={specs:e,gems:t,versions:new Map(Object.entries(t).map(([t,n])=>[t,i(n.map(t=>e[t].version))]))},a=new Set,o=[],s=e=>{e in t&&!a.has(e)&&o.push(e),a.add(e)};for(let[e,{requirements:t}]of Object.entries(n))$(e,t,r,h(`dependencies`,e)),s(e);for(;o.length>0;)for(let n of t[o.pop()]){let i=h(h(`specs`,n),`dependencies`);for(let[a,o]of Object.entries(e[n].dependencies)){let e=h(i,a);if(a!==`bundler`&&!(a in t))throw new p(`names no gem of the sources`,e);$(a,o,r,e),s(a)}}let c=Object.keys(t).find(e=>!a.has(e));if(c!==void 0)throw new p(`nothing depends on it, and Bundler locks what it resolves alone`,h(`specs`,t[c][0]))}function Fe(e){if(typeof e!=`string`)throw TypeError(`expected a string`);let{sources:t,sections:n}=xe(e),{sources:r,local:i}=z(t),a=Ce(t,i),o=Ee(Z(n,`PLATFORMS`));De(a,o);let s=Oe(Z(n,`DEPENDENCIES`)),c=Me(a);Ne({sources:r,local:i,specs:a,gems:c,dependencies:s}),Pe({specs:a,gems:c,dependencies:s});let l=n.get(`CHECKSUMS`),u=l===void 0?void 0:Te(l.lines,a,r);return{sources:r,specs:a,gems:c,platforms:o,dependencies:s,checksums:l!==void 0,bundlerChecksum:u,...Q(n)}}export{p as LockfileError,Fe as parseGemfileLock};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{a as e,c as t}from"./chunk-SYXT3SFP.js";import{g as n,n as r,r as i,s as a,t as o,u as s,v as c,w as l,x as u}from"./chunk-J2FWBXFV.js";import{a as d}from"./chunk-NRPC74AM.js";import{e as f,i as p}from"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import"./chunk-IZ6MYRYB.js";import"./chunk-PTFQKLKO.js";import{D as m}from"./chunk-QRKFPLA4.js";import"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{a as h,c as g,g as _}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var v=`h1{font-size:1.35rem;margin-bottom:.5rem}h2{font-size:1.1rem;margin-bottom:.5rem}.triage-import{display:flex;gap:1rem;align-items:center;margin:1.5rem 0 2rem}.triage-import .btn{flex-shrink:0}.triage-import p{margin:0}.workspace-drop{display:grid;gap:.8rem;padding:2rem;margin:1.5rem 0;border:1px dashed var(--border);border-radius:var(--ui-radius, 8px)}.workspace-drop.dragging{border-color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.workspace-drop span,p,li span{color:var(--muted);line-height:1.5}.actions,.local-choice{display:flex;gap:.8rem;flex-wrap:wrap;align-items:center}.local-choice{margin-bottom:1.5rem}.import-preview{display:grid;gap:.8rem}input:not([type=radio]),select{padding:.55rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);color:var(--text);background:var(--bg);font:inherit}.import-preview input:not([type=radio]),.import-preview select{width:100%;box-sizing:border-box}fieldset{display:grid;gap:.8rem;padding:1rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px)}fieldset label{display:flex;gap:.5rem;align-items:center}li{padding:.4rem 0;overflow-wrap:anywhere}li span{display:block;font-size:.8rem}ul{padding-left:1.2rem}.primary{justify-self:start;color:var(--accent)}.error{color:var(--critical)}button:disabled{opacity:.5}input:focus-visible,select:focus-visible,button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
|
|
2
2
|
`;async function y(e,{session:t,confirmImport:n,...r}){if(t?.role!==`admin`||!t.csrfToken)throw Error(`An administrator session is required.`);if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw Error(`Invalid local triage.`);let i=Object.create(null);for(let[t,n]of Object.entries(e??{})){let{ignoredReports:e,scopedIgnoredReports:r,...a}=f(n)??{};Object.keys(a).length!==0&&(i[t]=a)}let a=Object.keys(i).length,o=new Set,s=[],c;if(a>0)do{r.signal?.throwIfAborted();let e=`/api/admin/reports/finding-ids`+(c?`?after=${encodeURIComponent(c)}`:``),{reports:t,nextCursor:n}=await r.api.send(e);r.signal?.throwIfAborted();for(let e of t){let t=e.findingIds.filter(e=>Object.hasOwn(i,e)&&!o.has(e));t.length>0&&s.push({id:e.id,ids:t});for(let e of t)o.add(e)}c=n}while(c);for(let e of o){if(!e||e.length>100)throw Error(`Triage finding IDs must be between 1 and 100 characters.`);if(u(i[e])===`invalid`)throw Error(`Triage for ${e} exceeds the managed server limits.`)}if(r.signal?.throwIfAborted(),n){let e=await n({matched:o.size,available:a});if(r.signal?.throwIfAborted(),!e)return null}let l=r.importedIds??new Set;for(let e of s)await C(i,{...r,importedIds:l,ids:e.ids,path:`/api/admin/reports/${encodeURIComponent(e.id)}/import-triage`});return o.size}function b(e,t){let n=[],r=Object.create(null);for(let[i,a]of Object.entries(e)){let e=t[i];if(!e)throw Error(`The server did not return the requested triage snapshot.`);let o=e.entry??{},s=r[i]={...o};delete s.comment;for(let[t,r]of Object.entries(a))if(t===`comment`){if(e.comments.some(e=>e.body===r))continue;e.comments.length>0?n.push({id:i,property:t,local:e.comments.map(e=>e.body).join(`
|
|
3
3
|
|
|
4
|
-
`),imported:r}):s.comment=r}else if(o[t]!==void 0&&o[t]!==r){let e=e=>t===`flagged`?e?`flagged`:`not flagged`:e;n.push({id:i,property:t,local:e(o[t]),imported:e(r)})}else s[t]=r}return{entries:r,conflicts:n}}async function x(e,t,n,r,i){i?.throwIfAborted();let{entries:a,conflicts:o}=b(e,t);if(o.length===0)return a;let s=await r(o,n,{title:`Triage conflicts on import`,intro:`disagree with stored triage on`,trailingNote:`Imported comments are added alongside existing comments. Other choices apply to these finding IDs across all teams.`,importedSideLabel:`Apply imported`});if(i?.throwIfAborted(),!s)throw Object.assign(Error(`Triage conflict resolution was cancelled.`),{cancelled:!0});for(let t of o){let n=s[`${t.id}:${t.property}`];if(![`local`,`imported`].includes(n))throw Error(`Resolve every triage conflict before importing.`);n===`imported`&&(a[t.id][t.property]=e[t.id][t.property])}return a}function S(e,t){let n=[],r={entries:{},expected:{}};for(let[i,a]of Object.entries(e)){let e={entries:{...r.entries,[i]:a},expected:{...r.expected,[i]:t[i].version}};if(new TextEncoder().encode(JSON.stringify(e)).length<=262144){r=e;continue}if(Object.keys(r.entries).length===0)throw Error(`This triage entry is too large to import.`);n.push(r),r={entries:{[i]:a},expected:{[i]:t[i].version}}}return Object.keys(r.entries).length>0&&n.push(r),n}async function C(e,{api:t,path:n,ids:r=Object.keys(e),importedIds:i=new Set,lookup:a=new Map,resolveConflicts:o,signal:s}){r=r.filter(t=>Object.hasOwn(e,t)&&!i.has(t));for(let c=0;c<r.length;c+=200){let l=r.slice(c,c+200);for(let r=0;r<5&&l.length>0;r++){s?.throwIfAborted();let{snapshots:r}=await t.send(n,{findingIds:l}),c=await x(Object.fromEntries(l.map(t=>[t,e[t]])),r,a,o,s);for(let e of S(c,r)){if(s?.throwIfAborted(),(await t.send(n,e)).conflict)break;Object.keys(e.entries).forEach(e=>i.add(e))}l=l.filter(e=>!i.has(e))}if(l.length>0)throw Error(`Stored triage keeps changing. Retry to resolve it against the latest values.`)}}var w=`You can retry the remaining steps.`;function T(e){return String(e?.detail??e?.message??e).replace(/\.$/u,``)}function E(e,t){return t?.aborted===!0||e?.name===`AbortError`||e?.cancelled===!0}function D(e){if(typeof e!=`string`)return{ok:!0,path:null};if(/\p{Cc}/u.test(e)||e.includes(`\\`)||e!==e.trim())return{ok:!1};let t=[];for(let n of e.split(`/`))if(n!==``&&n!==`.`){if(n===`..`||n!==n.trim())return{ok:!1};t.push(n)}let n=t.join(`/`);return n.length>500?{ok:!1}:{ok:!0,path:n===``?null:n}}async function O(e,t){let n=new Uint8Array(await e.arrayBuffer());return r(n)?t({tryPassword:e=>i(n,e)}):n[0]===31&&n[1]===139?i(n):a(new TextDecoder(`utf-8`,{fatal:!0}).decode(n))}function k(e,t,n,r,i=``){let a=e?d(e,t,r,i):null,o=n.find(t=>a?t.repoId===a.repoId:t.fullName.toLowerCase()===e?.toLowerCase());return{repoId:o?.repoId??null,directory:a?.directory??t,github:o?.fullName??e}}async function A(e,t,r=[]){let i=new Map,a=[];for(let n of e.reports){if(typeof n?.name!=`string`||!n.name||typeof n.content!=`string`)throw Error(`Every report must have a name and content.`);let u=o(n.content,n.name);if(!u.data)throw Error(`${n.name}: ${u.reason??`Unsupported report`}`);let d=m(u.data),f=d??m(n)??m({repo:{github:e.repoUrls?.[n.name]}})??c(u.data),p=d?``:l(u.data),h=D(u.data.repo?.directory);if(!h.ok)throw Error(`${n.name}: invalid repository directory`);let g=u.format===`links`?[]:(await s(n.content,n.name))?.findings??[];for(let e of g)e.id&&i.set(e.id,e);let _=h.path??``;a.push({...n,links:u.format===`links`,...k(f,_,t,r,p),declaredGithub:f,declaredDirectory:_,filePrefix:p,embedded:d,ids:[...new Set(g.map(e=>e.id).filter(Boolean))],uploaded:null})}let u=Object.create(null);if(e.triage!=null&&(typeof e.triage!=`object`||Array.isArray(e.triage)))throw Error(`Invalid workspace triage.`);let d=await n(e.triage,t=>e.reports.find(e=>e.name===t)?.content);for(let[e,t]of Object.entries(d.entries)){if(!i.has(e))continue;let n=f(t);if(!n)continue;let{ignoredReports:r,scopedIgnoredReports:a,...o}=n;Object.keys(o).length!==0&&(u[e]=o)}let p=[];for(let t of e.bundleBlobs??[]){let e=Uint8Array.fromBase64(t.data),n=`sha512-${new Uint8Array(await crypto.subtle.digest(`SHA-512`,e)).toBase64()}`;if(n!==t.integrity)throw Error(`${t.name}: bundle integrity mismatch`);p.push({name:t.name,integrity:n,bytes:e,uploaded:null})}return{name:e.workspace.name.slice(0,100),reports:a,bundles:p,triage:u,lookup:i,references:e.bundles??[],team:null,completed:new Set,importedIds:new Set}}function j(e,t,n){async function r(r,i,a={}){n?.throwIfAborted();let o=await e(r,{credentials:`same-origin`,signal:n,...i===void 0?{}:{method:`POST`,body:i instanceof File?i:JSON.stringify(i)},headers:{...i instanceof File?{}:{"content-type":`application/json`},"x-csrf-token":t.csrfToken,...a}});if(n?.throwIfAborted(),o.status===409)return{conflict:!0};if(!o.ok){let e=await o.json().then(e=>typeof e?.error==`string`?e.error:``,()=>``);n?.throwIfAborted();let t=`Import request failed (HTTP ${o.status}${e?`: ${e}`:``}).`;throw Object.assign(Error(`${t} ${w}`),{detail:t})}let s=await o.json();return n?.throwIfAborted(),s}return{send:r}}async function M(e,t,n,r,i,a){if(e.bundles.length===0&&e.references.length===0)return;let o=i??(await n.send(`/api/admin/bundles`)).bundles,s=new Set(e.bundles.map(e=>e.uploaded.id));if([...s].some(e=>!o.some(t=>t.id===e)))throw Error(`Could not verify the uploaded source bundles. Retry the import.`);let c=new Set(e.references);for(let i of o){if(!s.has(i.id)&&!c.has(i.integrity))continue;let o=!a.has(i.repoId),l=o?t:i.repoId;o&&await r(`bundle-repo:${i.id}:${l}`,()=>n.send(`/api/admin/bundles/set-repo`,{bundleId:i.id,repoId:l}));let u=o?``:i.repoDirectory??``;await r(`repo:${l}:${u}`,()=>n.send(`/api/admin/teams/set-repo`,{teamId:e.team.id,repoId:l,path:u}))}}async function N(e,t){e.uploaded||=await t.send(`/api/admin/deduplication`,new File([e.content],e.name),{"x-report-filename":encodeURIComponent(e.name)})}async function P(e,t){let n=(await t.send(`/api/admin/repositories/browsable`)).repos,r=e.reports.filter(e=>!e.links&&e.declaredGithub&&!e.uploaded);if(r.length>0){let{aliases:e=[]}=await t.send(`/api/admin/repositories/aliases`);for(let t of r)Object.assign(t,k(t.declaredGithub,t.declaredDirectory,n,e,t.filePrefix))}return new Set(n.map(e=>e.repoId))}async function F(e,{plan:t,api:n,step:r,activeRepos:i,defaultRepo:a,includeTriage:o,resolveConflicts:s,signal:c}){if(e.links){await N(e,n);return}let l=i.has(e.repoId)?e.repoId:a;if(!e.uploaded){let t=await n.send(`/api/admin/reports`,new File([e.content],e.name),{"x-report-filename":encodeURIComponent(e.name),"x-repo-id":String(l),"x-repo-directory":encodeURIComponent(e.directory)});if(t.conflict)throw Error(`Could not reuse the stored report ${e.name}. Retry the import.`);e.uploaded=t}let u=e.uploaded;i.has(u.repoId)||await r(`report-repo:${u.id}:${l}:${e.directory}`,async()=>{if((await n.send(`/api/admin/reports/set-repo`,{reportId:u.id,repoId:l,directory:e.directory})).conflict)throw Error(`Could not assign the stored report ${e.name} to its repository.`);u.repoId=l,u.repoDirectory=e.directory});let d=u.repoDirectory??``;await r(`repo:${u.repoId}:${d}`,()=>n.send(`/api/admin/teams/set-repo`,{teamId:t.team.id,repoId:u.repoId,path:d})),o&&await C(t.triage,{api:n,resolveConflicts:s,signal:c,ids:e.ids,importedIds:t.importedIds,lookup:t.lookup,path:`/api/admin/reports/${encodeURIComponent(e.uploaded.id)}/import-triage`}),await r(`publish:${e.uploaded.id}`,()=>n.send(`/api/admin/reports/set-visible`,{reportId:e.uploaded.id,visible:!0}))}async function I(e,{api:t,session:n,defaultRepo:r,includeTriage:i,resolveConflicts:a,signal:o,progress:s=()=>{}}){if(n?.role!==`admin`||!n.csrfToken)throw Error(`An administrator session is required.`);if(!e.name.trim()||e.name.trim().length>100)throw Error(`Enter a team name of up to 100 characters.`);if(i)for(let[t,n]of Object.entries(e.triage)){if(!t||t.length>100)throw Error(`Triage finding IDs must be between 1 and 100 characters. Choose Skip triage to import the files without it.`);if(u(n)===`invalid`)throw Error(`Triage for ${t} exceeds the managed server limits. Choose Skip triage to import the files without it.`)}o?.throwIfAborted();let c=null;if(e.bundles.length===0){let n=new Set(e.references);c=n.size>0?(await t.send(`/api/admin/bundles`)).bundles.filter(e=>n.has(e.integrity)):[]}if(e.reports.length===0&&e.bundles.length===0&&c.length===0)throw Error(e.references.length>0?`None of the referenced source bundles are available on the server. Export with bundle bytes included and try again.`:`This workspace contains no report or bundle files.`);let l=await P(e,t);for(let t of e.reports.filter(e=>!e.links)){if(t.embedded&&!l.has(t.repoId))throw Error(`Connect ${t.embedded} in Repositories before importing ${t.name}.`);if(!l.has(t.repoId)&&!l.has(r))throw Error(`Choose an active repository for ${t.name}.`)}if((e.bundles.length>0||c.some(e=>!l.has(e.repoId)))&&!l.has(r))throw Error(`Choose an active repository for the source bundles.`);let d=()=>o?.throwIfAborted(),f=async(t,n)=>{d(),e.completed.has(t)||(await n(),e.completed.add(t))};if(d(),!e.team){let n=await t.send(`/api/admin/teams`,{name:e.name.trim()});if(n.conflict)throw Error(`A team already has this name. Choose another name.`);e.team=n}await f(`member`,()=>t.send(`/api/admin/teams/set-member`,{teamId:e.team.id,userId:n.id,security:!0,dependencies:!0}));for(let n of e.bundles)d(),s(`Importing ${n.name}\u2026`),n.uploaded||=await t.send(`/api/admin/bundles`,new File([n.bytes],n.name),{"x-bundle-filename":encodeURIComponent(n.name)});await M(e,r,t,f,c,l);let p=[];for(let n of e.reports){d(),s(`Importing ${n.name}\u2026`);try{await F(n,{plan:e,api:t,step:f,activeRepos:l,defaultRepo:r,includeTriage:i,resolveConflicts:a,signal:o})}catch(e){if(E(e,o))throw e;p.push(`${n.name}: ${T(e)}`)}}if(p.length>0)throw Error(`Could not import ${p.length} of ${e.reports.length} files: ${p.join(`; `)}. ${w}`);return e.team}function L(e){let t=()=>e.isEncryptionEnabled()&&!e.isUnlocked();return{get locked(){return t()},unlock:t=>e.unlockEncryption(t),async read({signal:n}={}){let r=!1,i=e.onVaultStateChange(()=>{r=!0}),a=()=>{if(n?.throwIfAborted(),t()||r)throw Error(`Local data was locked or changed. Unlock it and import triage again.`)};try{a();let t=await e.readTriageBlob();return a(),t}finally{i()}}}}function R(e){let t=()=>e.isEncryptionEnabled()&&!e.isUnlocked();async function n(){let t=JSON.parse(await e.hydrateKey(`deepview.workspaces`)||`[]`);return(Array.isArray(t)?t:t.workspaces??[]).filter(e=>typeof e.id==`string`&&typeof e.name==`string`)}async function r(n,r){let i=!1,a=[e.onVaultStateChange,e.onFileMutated,e.onBundleMutated].map(e=>e(()=>{i=!0})),o=()=>{if(r?.throwIfAborted(),t()||i)throw Error(`Local data was locked or changed. Unlock it and select the workspace again.`)};try{o();let e=await n(o);return o(),e}finally{a.forEach(e=>e())}}return{get locked(){return t()},unlock:t=>e.unlockEncryption(t),list:({signal:e}={})=>r(async()=>(await n()).map(e=>({id:e.id,name:e.name})),e),read:(t,{signal:i}={})=>r(async r=>{let i=(await n()).find(e=>e.id===t);if(!i)throw Error(`This local workspace no longer exists.`);let a=JSON.stringify(i),o=JSON.parse(await e.hydrateKey(`deepview.repoUrls`)||`{}`),s=[];for(let t of i.reports??[]){r();let n=await e.withStoredItem(`report`,t,()=>e.readFile(t));r(),s.push({name:t,content:n,...o[t]?{repo:{github:o[t]}}:{}})}let c=await e.listBundles(),l=[];for(let t of i.bundles??[]){r();let n=c.find(e=>e.integrity===t);if(!n)continue;let i=await e.withStoredItem(`bundle`,t,()=>e.readBundle(t));r(),l.push({integrity:t,name:n.name,data:i.toBase64()})}let u=await e.readTriageBlob()??{};if(JSON.stringify((await n()).find(e=>e.id===t))!==a)throw Error(`The local workspace changed. Select it again.`);return{version:1,workspace:{id:t,name:i.name,privateKey:``},reports:s,bundles:i.bundles??[],bundleBlobs:l,triage:u,repoUrls:o}},i)}}var z=e=>e===`bundle`?`bundles`:`reports`,B=(e,t)=>JSON.stringify([e,t||``]),V=(e,t)=>new Set(t.map(t=>e===`bundle`?t.integrity:B(t.sha256,t.analyzer)));async function H(e){let t=new Uint8Array(await e.arrayBuffer()),n=o(new TextDecoder().decode(t),e.name);if(!n.data)throw Error(n.reason??`Not a recognized report`);let r=new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)).toBase64({alphabet:`base64url`,omitPadding:!0});return{hash:r,key:B(r,typeof n.data.source==`string`?n.data.source:null)}}async function U(e,{source:t,deps:n,api:r,signal:i}){let a=JSON.parse(await n.hydrateKey(`deepview.workspaces`)||`[]`),o=(Array.isArray(a)?a:a.workspaces??[]).filter(e=>typeof e.id==`string`&&typeof e.name==`string`);i.throwIfAborted();let s=await t.list(e),c=V(e,(await r.send(`/api/admin/${z(e)}`))[z(e)]),l=o.map(e=>({id:e.id,name:e.name,items:[]})),u={id:null,name:`Not in a workspace`,items:[]},d=[];for(let r of s){i.throwIfAborted();let a={value:r.value,name:r.label,key:r.value,synced:!1,present:!1,error:``};if(e===`report`)try{Object.assign(a,await t.importItem(e,a.value,H,{signal:i})),a.syncHash=await n.reportSyncHash(a.value)}catch(e){i.throwIfAborted(),a.error=String(e?.message??e)}i.throwIfAborted(),a.present=c.has(a.key);let s=!1;o.forEach((t,r)=>{if(!t[z(e)]?.includes(a.value))return;let i=n.localContentSyncStatus(t.id,e,a.value,a.syncHash);a.synced||=i.synced,l[r].items.push({item:a,...i}),s=!0}),s||u.items.push({item:a,synced:!1,cached:!1}),d.push(a)}return{kind:e,items:d,groups:[...l,u].filter(e=>e.items.length>0)}}async function W(e,t,{source:n,api:r,signal:i,progress:a=()=>{},imported:o=new Set}){let{kind:s}=e,c=V(s,(await r.send(`/api/admin/${z(s)}`))[z(s)]),l=new Set(t),u=[],d=0;for(let t of e.items)if(i.throwIfAborted(),!(!l.has(t.value)||t.error||t.present)){if(c.has(t.key)){t.present=!0;continue}a(`Importing ${t.name}\u2026`),d++;try{await n.importItem(s,t.value,async e=>{let n=s===`report`?(await H(e)).key:await p(new Uint8Array(await e.arrayBuffer()));if(i.throwIfAborted(),n!==t.key)throw Error(`${t.name} changed. Choose files again before importing.`);if((await r.send(`/api/admin/${z(s)}`,e,{[`x-${s}-filename`]:encodeURIComponent(e.name)})).conflict)throw Error(`Could not import ${t.name}. Try again.`)},{signal:i})}catch(e){if(E(e,i))throw e;u.push(`${t.name}: ${T(e)}`);continue}c.add(t.key),t.present=!0,o.add(t.value)}if(u.length>0)throw Error(`Imported ${d-u.length} of ${d} ${s}s. Could not import ${u.join(`; `)}. Import again to retry them.`);return o.size}var G=(e,t)=>e===void 0?`managed-only`:t===void 0?`local-only`:`mismatch`;function K(e,t){let n=t.slice(),r=e.map(e=>{let t=n.indexOf(e);return t!==-1&&n.splice(t,1),{text:e,different:t===-1}}),i=e.slice(),a=t.map(e=>{let t=i.indexOf(e);return t!==-1&&i.splice(t,1),{text:e,different:t===-1}});return!r.some(e=>e.different)&&!a.some(e=>e.different)?null:{property:`comment`,local:r,managed:a,kind:r.some(e=>e.different)?a.some(e=>e.different)?`mismatch`:`local-only`:`managed-only`}}function q(e,t){let n=f(e)??{},r=f(t.entry)??{},i=[];for(let e of[`triage`,`color`,`fix`,`flagged`])n[e]!==r[e]&&i.push({property:e,local:n[e],managed:r[e],kind:G(n[e],r[e])});let a=K(n.comment?[n.comment]:[],t.comments.map(e=>e.body));return a&&i.push(a),n.ignoredReports?.length&&i.push({property:`ignoredReports`,local:[...new Set(n.ignoredReports)],managed:void 0,kind:`local-only`}),i}async function J(e,{lookup:t,triage:n,matched:r,findings:i,api:a,signal:o}){let s=[...new Set(e.findingIds)].filter(e=>t.has(e)&&!r.has(e));for(let c=0;c<s.length;c+=200){let l=s.slice(c,c+200);if(l.some(e=>e.length>100))throw Error(`A shared finding ID exceeds the managed triage limit.`);o.throwIfAborted();let{snapshots:u}=await a.send(`/api/admin/reports/${encodeURIComponent(e.id)}/import-triage`,{findingIds:l});o.throwIfAborted();for(let e of l){if(!u?.[e])throw Error(`The server did not return the requested triage snapshot.`);let a=q(n[e],u[e]);a.length>0&&i.push({id:e,finding:t.get(e),differences:a}),r.add(e)}}}async function Y({source:e,readTriage:t,api:n,signal:r,progress:i=()=>{}}){let a=new Map,c=[];for(let t of await e.list(`report`)){r.throwIfAborted(),i(`Reading ${t.label}\u2026`);try{let n=await e.importItem(`report`,t.value,async e=>{let t=await e.text(),n=o(t,e.name);if(!n.data)throw Error(n.reason??`Not a recognized report`);return n.format===`links`?[]:(await s(t,e.name))?.findings??[]},{signal:r});r.throwIfAborted();for(let e of n)typeof e.id!=`string`||!e.id||(a.has(e.id)||a.set(e.id,{...e,reports:[]}),a.get(e.id).reports.push(t.label))}catch(e){r.throwIfAborted(),c.push({name:t.label,reason:String(e?.message??e)})}}let l=await t()??{};if(r.throwIfAborted(),typeof l!=`object`||Array.isArray(l))throw Error(`Invalid local triage.`);let u=[],d=new Set;if(a.size===0)return{matched:0,localFindings:0,findings:u,skipped:c};let f;do{r.throwIfAborted(),i(`Comparing local and managed triage…`);let e=await n.send(`/api/admin/reports/finding-ids`+(f?`?after=${encodeURIComponent(f)}`:``));r.throwIfAborted();for(let t of e.reports)await J(t,{lookup:a,triage:l,matched:d,findings:u,api:n,signal:r});f=e.nextCursor}while(f);return r.throwIfAborted(),{matched:d.size,localFindings:a.size,findings:u,skipped:c}}function X(n,r){if(customElements.get(`managed-admin-import`))return;class i extends n{static styles=[h(t),h(v)];static properties={localDeps:{attribute:!1},_busy:{state:!0},_error:{state:!0},_message:{state:!0},_plan:{state:!0},_catalog:{state:!0},_localOpen:{state:!0},_workspaces:{state:!0},_localId:{state:!0},_triage:{state:!0},_repo:{state:!0},_drag:{state:!0}};constructor(){super(),this._busy=!1,this._error=``,this._message=``,this._plan=null,this._catalog=null,this._workspaces=[],this._localOpen=!1,this._localId=``,this._triage=``,this._repo=null,this._files=[],this._drag=!1,this._local=!1,this._over=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),this._drag=!0)},this._drop=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),this._drag=!1,this._busy||(this._files.push(...e.dataTransfer.files),this._nextFile()))},this._localChanged=()=>{this._workspaces=[],this._localId=``,!this._unlocking&&(this._local&&(this._plan=null),(this._local||this._importingTriage||this._importingContent||this._comparingTriage)&&(this._operation?.abort(),this._message=``,this._error=this._comparingTriage?`Local data changed or was locked. Compare triage again to continue.`:this._importingContent?`Local data changed or was locked. Choose files again to continue.`:this._importingTriage?`Local data changed or was locked. Import triage again to continue.`:`Local data changed or was locked. Choose the workspace again.`))},this._blur=()=>{this._readingLocal&&this._localChanged()}}connectedCallback(){super.connectedCallback(),this.addEventListener(`dragover`,this._over),this.addEventListener(`drop`,this._drop),globalThis.addEventListener(`blur`,this._blur),globalThis.addEventListener(`storage`,this._localChanged),this._offVault=this.localDeps?.onVaultStateChange(this._localChanged),this._loadCatalog()}disconnectedCallback(){this._operation?.abort(),this._offVault?.(),this._plan=null,this._files=[],this.removeEventListener(`dragover`,this._over),this.removeEventListener(`drop`,this._drop),globalThis.removeEventListener(`blur`,this._blur),globalThis.removeEventListener(`storage`,this._localChanged),super.disconnectedCallback()}updated(e){e.has(`session`)&&(this._role!==`admin`||e.get(`session`)?.id!==this.session?.id)&&(this._operation?.abort(),this._plan=null,this._files=[])}async _action(e){if(this._busy||this._role!==`admin`)return;let t=this._operation=new AbortController,n=AbortSignal.any([t.signal,this.appState.sessionController.signal]);this._busy=!0,this._error=``;try{await e(n),n.throwIfAborted()}catch(e){n.aborted||(this._error=String(e?.message??e))}finally{this._operation===t&&(this._busy=!1)}}async _loadCatalog(){if(this._role===`admin`)try{await this._loadCollection(`workspace-import:catalog`,`import options`,async e=>{let t=j(r,this.session,e),[n,i,a,o]=await Promise.all([t.send(`/api/admin/reports`),t.send(`/api/admin/teams`),t.send(`/api/admin/bundles`),t.send(`/api/admin/repositories/aliases`)]);return{repos:n.repos,teams:i.teams,bundles:a.bundles,aliases:o.aliases}},e=>{this._catalog=e})}catch(e){this._error=String(e?.message??e)}}_browse(){let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`.enc,.gz,.json`,e.addEventListener(`change`,()=>{this._files.push(...e.files),this._nextFile()},{once:!0}),e.click()}async _prepare(e,t){if(!e)return;if(this._catalog||await this._loadCatalog(),t.throwIfAborted(),!this._catalog)throw Error(`Could not load repositories. Try again.`);let n=await A(e,this._catalog.repos,this._catalog.aliases);t.throwIfAborted();let r=new Set(this._catalog.teams.map(e=>e.name)),i=n.name||`Imported workspace`,a=2;for(;r.has(n.name);){let e=` (${a++})`;n.name=i.slice(0,100-e.length)+e}let o=new Set(n.reports.map(e=>e.repoId).filter(e=>e!=null));this._repo=o.size===1?[...o][0]:null,this._triage=Object.keys(n.triage).length>0?``:`skip`,this._plan=n,this._message=``}async _nextFile(){if(this._files.length===0||this._busy)return;let e=this._files.shift();this._local=!1,this._plan=null,await this._action(async t=>{let n=await O(e,this.promptPassword);t.throwIfAborted(),await this._prepare(n,t)})}async _unlock(e,t){this._unlocking=!0;try{return!e.locked||await e.unlock({signal:t})}finally{this._unlocking=!1}}async _chooseLocal(){this._localOpen=!0,await this._action(async e=>{let t=R(this.localDeps);await this._unlock(t,e)&&(e.throwIfAborted(),this._workspaces=await t.list({signal:e}))})}async _readLocal(){if(!this._localId)return;let e=this._localId;this._local=!0,this._plan=null,await this._action(async t=>{let n=R(this.localDeps);if(await this._unlock(n,t)){this._readingLocal=!0;try{await this._prepare(await n.read(e,{signal:t}),t)}finally{this._readingLocal=!1}}})}async _import(){!this._plan||!this._triage||!this._csrf||(await this._action(async e=>{if(this._local&&R(this.localDeps).locked)throw Error(`Unlock local data and choose the workspace again.`);let t=this._plan,n=[`teams`,`reports`,`bundles`,`history`,`workspace-import`,`scan-sources`,`repo-impact`];try{let i=await this.appState.mutate(()=>I(t,{api:j(r,this.session,e),session:this.session,defaultRepo:this._repo,includeTriage:this._triage===`include`,resolveConflicts:this.resolveConflicts,signal:e,progress:e=>{this._message=e}}),n);this._catalog.teams.push(i),this._message=`Imported into ${i.name}.`,this._plan=null}finally{this.appState.invalidate(n),t.team&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}}),!this._plan&&!this._error&&await this._nextFile())}async _importLocalTriage(){this._csrf&&await this._action(async e=>{this._importingTriage=!0,this._message=``;let t=new Set,n=[`reports`,`history`];try{let n=L(this.localDeps);if(!await this._unlock(n,e))return;this._readingLocal=!0;let i;try{i=await n.read({signal:e})}finally{this._readingLocal=!1}let a=await y(i,{api:j(r,this.session,e),session:this.session,resolveConflicts:this.resolveConflicts,signal:e,importedIds:t,confirmImport:async t=>(await this.confirmTriageImport({...t,signal:e}))?.confirmed===!0});if(e.throwIfAborted(),a===null)return;this._message=a?`Imported triage for ${a} finding${a===1?``:`s`}.`:`No local triage matches findings in managed reports.`}finally{this._importingTriage=!1,this.appState.invalidate(n),t.size>0&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}})}async _compareLocalTriage(){this._csrf&&await this._action(async e=>{this._comparingTriage=!0,this._message=``;let t=this.localImportSource,n=t.subscribe(this._localChanged);try{if(!await this._unlock(t,e))return;e.throwIfAborted(),this._readingLocal=!0;let n=L(this.localDeps),i=await Y({source:t,signal:e,readTriage:()=>n.read({signal:e}),api:j(r,this.session,e),progress:e=>{this._message=e}});e.throwIfAborted(),this._message=``,await this.showTriageComparison({comparison:i,signal:e})}finally{n(),this._readingLocal=!1,this._comparingTriage=!1,this._message=``}})}async _importLocalContent(e){this._csrf&&await this._action(async t=>{this._importingContent=!0,this._message=``;let n=this.localImportSource,i=[`reports`,`bundles`,`bundle-metadata`,`history`,`workspace-import`,`scan-sources`,`repo-impact`],a=new Set,o=n.subscribe(this._localChanged);try{if(!await this._unlock(n,t))return;t.throwIfAborted(),this._readingLocal=!0;let i=j(r,this.session,t),o=await U(e,{source:n,deps:this.localDeps,api:i,signal:t}),s=await this.confirmContentImport({plan:o,signal:t});if(t.throwIfAborted(),!s?.confirmed)return;let c=await W(o,s.selected,{source:n,api:i,signal:t,imported:a,progress:e=>{this._message=e}});this._message=`Imported ${c} ${e}${c===1?``:`s`}.`}finally{o(),this._readingLocal=!1,this._importingContent=!1,this.appState.invalidate(i),a.size>0&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}})}render(){if(this._role!==`admin`)return _;let t=this._plan,n=t?Object.keys(t.triage).length:0,r=new Set([...t?.references??[],...t?.bundles.map(e=>e.integrity)??[]]),i=(this._catalog?.bundles??[]).filter(e=>r.has(e.integrity)),a=t?.references.filter(e=>!t.bundles.some(t=>t.integrity===e)).length??0;return g`<div class="wrap" @dragleave="${()=>{this._drag=!1}}">${e(`manage-import`,this._role,this.allowShare)}<h1>Import</h1><section class="triage-import" aria-label="Import local files"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent(`bundle`)}">Import bundles</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent(`report`)}">Import reports</button></div><p>Choose files from this browser, grouped by workspace. Import files without teams or triage.</p></section><section class="triage-import" aria-label="Local triage"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalTriage()}">Import triage</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._compareLocalTriage()}">Compare triage</button></div><p>Import saved triage and comments for findings already in managed reports.<br>Unmatched data stays in this browser.<br>Conflicting values prompt for resolution; per-report ignores are skipped.</p></section><h2>Import workspace</h2><p class="intro ui-hint">Create a new team from a workspace export or a workspace stored in this browser.</p><section class="${`workspace-drop ${this._drag?`dragging`:``}`}" aria-label="Workspace files"><strong>Drop workspace files here</strong><span>Encrypted exports, JSON, or compressed JSON. Encrypted files prompt for a password.</span><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._catalog}" @click="${()=>this._browse()}">Choose files</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>this._chooseLocal()}">Choose local workspace</button></div></section>${this._localOpen?g`<section class="local-choice"><label for="local-workspace">Local workspace</label> <select id="local-workspace" .value="${this._localId}" ?disabled="${this._busy}" @change="${e=>{this._localId=e.target.value}}"><option value="">Choose a workspace…</option>${this._workspaces.map(e=>g`<option value="${e.id}">${e.name}</option>`)}</select> <button type="button" class="btn" ?disabled="${this._busy||!this._localId}" @click="${()=>this._readLocal()}">Select workspace</button> ${!this._busy&&this._workspaces.length===0?g`<p class="ui-hint">No unlocked local workspaces. Choose local workspace to unlock or refresh.</p>`:_}</section>`:_} ${t?g`<section class="import-preview" aria-label="Import options">${t.team?g`<p>Team ${t.team.name} has been created. Retry continues its remaining import steps.</p>`:_} <label for="import-team">New team name</label><input id="import-team" maxlength="100" .value="${t.name}" ?disabled="${this._busy||!!t.team}" @input="${e=>{t.name=e.target.value,this.requestUpdate()}}"><p>${t.reports.length} reports / links · ${r.size} source bundles · ${n} triaged findings</p><label for="import-repo">Repository for files and source bundles without an active repository</label> <select id="import-repo" .value="${String(this._repo??``)}" ?disabled="${this._busy||!!t.team}" @change="${e=>{this._repo=e.target.value?Number(e.target.value):null}}"><option value="" ?selected="${this._repo==null}">Choose a repository…</option>${(this._catalog?.repos??[]).map(e=>g`<option value="${String(e.repoId)}" ?selected="${this._repo===e.repoId}">${e.fullName}</option>`)}</select><p>Declared report repositories and directories are preserved. Stored reports without an active repository use the selected repository. The new team receives those repository paths; other published reports in the same paths are also visible to that team.</p><ul>${t.reports.map(e=>g`<li>${e.name}<span>${e.links?`Global deduplication — enabled for all teams`:e.github??`Uses selected repository`}${e.links||e.github==null||e.repoId!=null?``:e.embedded?` — connect this repository first`:` — not connected; uses selected repository`}</span></li>`)}</ul>${i.length>0?g`<p>Existing source bundles in active repositories keep their locations. The new team also receives access to those directories. Unassigned bundles and bundles in inactive repositories use the selected repository.</p><ul>${i.map(e=>g`<li>${e.filename}<span>${e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:``}`:`Uses selected repository`}</span></li>`)}</ul>`:_} ${a?g`<p>${a} referenced source bundles have no bytes in this export. Reports can use matching bundles already on the server.</p>`:_} ${n?g`<fieldset ?disabled="${this._busy||!!t.team}"><legend>Import triage?</legend><label><input type="radio" name="import-triage" value="include" ?checked="${this._triage===`include`}" @change="${()=>{this._triage=`include`}}"> Include triage and comments</label> <label><input type="radio" name="import-triage" value="skip" ?checked="${this._triage===`skip`}" @change="${()=>{this._triage=`skip`}}"> Skip triage</label><p>Conflicting values prompt for resolution. Triage stays shared by finding ID across teams. Per-report local ignores are not imported.</p></fieldset>`:_} <button type="button" class="btn primary" ?disabled="${this._busy||!this._triage||!this._csrf}" @click="${()=>this._import()}">${this._busy?`Importing…`:t.team?`Retry remaining import`:`Import workspace`}</button></section>`:_} ${this._message?g`<p role="status">${this._message}</p>`:_} ${this._error?g`<p class="error" role="alert">${this._error}${this._catalog?_:g`<button class="btn" @click="${()=>this._loadCatalog()}">Retry</button>`}</p>`:_} ${this._files.length>0&&!this._busy?g`<button class="btn" @click="${()=>this._nextFile()}">Next workspace file (${this._files.length} waiting)</button>`:_}</div>`}}customElements.define(`managed-admin-import`,i)}export{X as registerWorkspaceImport};
|
|
4
|
+
`),imported:r}):s.comment=r}else if(o[t]!==void 0&&o[t]!==r){let e=e=>t===`flagged`?e?`flagged`:`not flagged`:e;n.push({id:i,property:t,local:e(o[t]),imported:e(r)})}else s[t]=r}return{entries:r,conflicts:n}}async function x(e,t,n,r,i){i?.throwIfAborted();let{entries:a,conflicts:o}=b(e,t);if(o.length===0)return a;let s=await r(o,n,{title:`Triage conflicts on import`,intro:`disagree with stored triage on`,trailingNote:`Imported comments are added alongside existing comments. Other choices apply to these finding IDs across all teams.`,importedSideLabel:`Apply imported`});if(i?.throwIfAborted(),!s)throw Object.assign(Error(`Triage conflict resolution was cancelled.`),{cancelled:!0});for(let t of o){let n=s[`${t.id}:${t.property}`];if(![`local`,`imported`].includes(n))throw Error(`Resolve every triage conflict before importing.`);n===`imported`&&(a[t.id][t.property]=e[t.id][t.property])}return a}function S(e,t){let n=[],r={entries:{},expected:{}};for(let[i,a]of Object.entries(e)){let e={entries:{...r.entries,[i]:a},expected:{...r.expected,[i]:t[i].version}};if(new TextEncoder().encode(JSON.stringify(e)).length<=262144)r=e;else{if(Object.keys(r.entries).length===0)throw Error(`This triage entry is too large to import.`);n.push(r),r={entries:{[i]:a},expected:{[i]:t[i].version}}}}return Object.keys(r.entries).length>0&&n.push(r),n}async function C(e,{api:t,path:n,ids:r=Object.keys(e),importedIds:i=new Set,lookup:a=new Map,resolveConflicts:o,signal:s}){r=r.filter(t=>Object.hasOwn(e,t)&&!i.has(t));for(let c=0;c<r.length;c+=200){let l=r.slice(c,c+200);for(let r=0;r<5&&l.length>0;r++){s?.throwIfAborted();let{snapshots:r}=await t.send(n,{findingIds:l}),c=await x(Object.fromEntries(l.map(t=>[t,e[t]])),r,a,o,s);for(let e of S(c,r)){if(s?.throwIfAborted(),(await t.send(n,e)).conflict)break;Object.keys(e.entries).forEach(e=>i.add(e))}l=l.filter(e=>!i.has(e))}if(l.length>0)throw Error(`Stored triage keeps changing. Retry to resolve it against the latest values.`)}}var w=`You can retry the remaining steps.`;function T(e){return String(e?.detail??e?.message??e).replace(/\.$/u,``)}function E(e,t){return t?.aborted===!0||e?.name===`AbortError`||e?.cancelled===!0}function D(e){if(typeof e!=`string`)return{ok:!0,path:null};if(/\p{Cc}/u.test(e)||e.includes(`\\`)||e!==e.trim())return{ok:!1};let t=[];for(let n of e.split(`/`))if(n!==``&&n!==`.`){if(n===`..`||n!==n.trim())return{ok:!1};t.push(n)}let n=t.join(`/`);return n.length>500?{ok:!1}:{ok:!0,path:n===``?null:n}}async function O(e,t){let n=new Uint8Array(await e.arrayBuffer());return r(n)?t({tryPassword:e=>i(n,e)}):n[0]===31&&n[1]===139?i(n):a(new TextDecoder(`utf-8`,{fatal:!0}).decode(n))}function k(e,t,n,r,i=``){let a=e?d(e,t,r,i):null,o=n.find(t=>a?t.repoId===a.repoId:t.fullName.toLowerCase()===e?.toLowerCase());return{repoId:o?.repoId??null,directory:a?.directory??t,github:o?.fullName??e}}async function A(e,t,r=[]){let i=new Map,a=[];for(let n of e.reports){if(typeof n?.name!=`string`||!n.name||typeof n.content!=`string`)throw Error(`Every report must have a name and content.`);let u=o(n.content,n.name);if(!u.data)throw Error(`${n.name}: ${u.reason??`Unsupported report`}`);let d=m(u.data),f=d??m(n)??m({repo:{github:e.repoUrls?.[n.name]}})??c(u.data),p=d?``:l(u.data),h=D(u.data.repo?.directory);if(!h.ok)throw Error(`${n.name}: invalid repository directory`);let g=u.format===`links`?[]:(await s(n.content,n.name))?.findings??[];for(let e of g)e.id&&i.set(e.id,e);let _=h.path??``;a.push({...n,links:u.format===`links`,...k(f,_,t,r,p),declaredGithub:f,declaredDirectory:_,filePrefix:p,embedded:d,ids:[...new Set(g.map(e=>e.id).filter(Boolean))],uploaded:null})}let u=Object.create(null);if(e.triage!=null&&(typeof e.triage!=`object`||Array.isArray(e.triage)))throw Error(`Invalid workspace triage.`);let d=await n(e.triage,t=>e.reports.find(e=>e.name===t)?.content);for(let[e,t]of Object.entries(d.entries)){if(!i.has(e))continue;let n=f(t);if(!n)continue;let{ignoredReports:r,scopedIgnoredReports:a,...o}=n;Object.keys(o).length!==0&&(u[e]=o)}let p=[];for(let t of e.bundleBlobs??[]){let e=Uint8Array.fromBase64(t.data),n=`sha512-${new Uint8Array(await crypto.subtle.digest(`SHA-512`,e)).toBase64()}`;if(n!==t.integrity)throw Error(`${t.name}: bundle integrity mismatch`);p.push({name:t.name,integrity:n,bytes:e,uploaded:null})}return{name:e.workspace.name.slice(0,100),reports:a,bundles:p,triage:u,lookup:i,references:e.bundles??[],team:null,completed:new Set,importedIds:new Set}}function j(e,t,n){async function r(r,i,a={}){n?.throwIfAborted();let o=await e(r,{credentials:`same-origin`,signal:n,...i===void 0?{}:{method:`POST`,body:i instanceof File?i:JSON.stringify(i)},headers:{...i instanceof File?{}:{"content-type":`application/json`},"x-csrf-token":t.csrfToken,...a}});if(n?.throwIfAborted(),o.status===409)return{conflict:!0};if(!o.ok){let e=await o.json().then(e=>typeof e?.error==`string`?e.error:``,()=>``);n?.throwIfAborted();let t=`Import request failed (HTTP ${o.status}${e?`: ${e}`:``}).`;throw Object.assign(Error(`${t} ${w}`),{detail:t})}let s=await o.json();return n?.throwIfAborted(),s}return{send:r}}async function M(e,t,n,r,i,a){if(e.bundles.length===0&&e.references.length===0)return;let o=i??(await n.send(`/api/admin/bundles`)).bundles,s=new Set(e.bundles.map(e=>e.uploaded.id));if([...s].some(e=>!o.some(t=>t.id===e)))throw Error(`Could not verify the uploaded source bundles. Retry the import.`);let c=new Set(e.references);for(let i of o){if(!s.has(i.id)&&!c.has(i.integrity))continue;let o=!a.has(i.repoId),l=o?t:i.repoId;o&&await r(`bundle-repo:${i.id}:${l}`,()=>n.send(`/api/admin/bundles/set-repo`,{bundleId:i.id,repoId:l}));let u=o?``:i.repoDirectory??``;await r(`repo:${l}:${u}`,()=>n.send(`/api/admin/teams/set-repo`,{teamId:e.team.id,repoId:l,path:u}))}}async function N(e,t){e.uploaded||=await t.send(`/api/admin/deduplication`,new File([e.content],e.name),{"x-report-filename":encodeURIComponent(e.name)})}async function P(e,t){let n=(await t.send(`/api/admin/repositories/browsable`)).repos,r=e.reports.filter(e=>!e.links&&e.declaredGithub&&!e.uploaded);if(r.length>0){let{aliases:e=[]}=await t.send(`/api/admin/repositories/aliases`);for(let t of r)Object.assign(t,k(t.declaredGithub,t.declaredDirectory,n,e,t.filePrefix))}return new Set(n.map(e=>e.repoId))}async function F(e,{plan:t,api:n,step:r,activeRepos:i,defaultRepo:a,includeTriage:o,resolveConflicts:s,signal:c}){if(e.links){await N(e,n);return}let l=i.has(e.repoId)?e.repoId:a;if(!e.uploaded){let t=await n.send(`/api/admin/reports`,new File([e.content],e.name),{"x-report-filename":encodeURIComponent(e.name),"x-repo-id":String(l),"x-repo-directory":encodeURIComponent(e.directory)});if(t.conflict)throw Error(`Could not reuse the stored report ${e.name}. Retry the import.`);e.uploaded=t}let u=e.uploaded;i.has(u.repoId)||await r(`report-repo:${u.id}:${l}:${e.directory}`,async()=>{if((await n.send(`/api/admin/reports/set-repo`,{reportId:u.id,repoId:l,directory:e.directory})).conflict)throw Error(`Could not assign the stored report ${e.name} to its repository.`);u.repoId=l,u.repoDirectory=e.directory});let d=u.repoDirectory??``;await r(`repo:${u.repoId}:${d}`,()=>n.send(`/api/admin/teams/set-repo`,{teamId:t.team.id,repoId:u.repoId,path:d})),o&&await C(t.triage,{api:n,resolveConflicts:s,signal:c,ids:e.ids,importedIds:t.importedIds,lookup:t.lookup,path:`/api/admin/reports/${encodeURIComponent(e.uploaded.id)}/import-triage`}),await r(`publish:${e.uploaded.id}`,()=>n.send(`/api/admin/reports/set-visible`,{reportId:e.uploaded.id,visible:!0}))}async function I(e,{api:t,session:n,defaultRepo:r,includeTriage:i,resolveConflicts:a,signal:o,progress:s=()=>{}}){if(n?.role!==`admin`||!n.csrfToken)throw Error(`An administrator session is required.`);if(!e.name.trim()||e.name.trim().length>100)throw Error(`Enter a team name of up to 100 characters.`);if(i)for(let[t,n]of Object.entries(e.triage)){if(!t||t.length>100)throw Error(`Triage finding IDs must be between 1 and 100 characters. Choose Skip triage to import the files without it.`);if(u(n)===`invalid`)throw Error(`Triage for ${t} exceeds the managed server limits. Choose Skip triage to import the files without it.`)}o?.throwIfAborted();let c=null;if(e.bundles.length===0){let n=new Set(e.references);c=n.size>0?(await t.send(`/api/admin/bundles`)).bundles.filter(e=>n.has(e.integrity)):[]}if(e.reports.length===0&&e.bundles.length===0&&c.length===0)throw Error(e.references.length>0?`None of the referenced source bundles are available on the server. Export with bundle bytes included and try again.`:`This workspace contains no report or bundle files.`);let l=await P(e,t);for(let t of e.reports.filter(e=>!e.links)){if(t.embedded&&!l.has(t.repoId))throw Error(`Connect ${t.embedded} in Repositories before importing ${t.name}.`);if(!l.has(t.repoId)&&!l.has(r))throw Error(`Choose an active repository for ${t.name}.`)}if((e.bundles.length>0||c.some(e=>!l.has(e.repoId)))&&!l.has(r))throw Error(`Choose an active repository for the source bundles.`);let d=()=>o?.throwIfAborted(),f=async(t,n)=>{d(),e.completed.has(t)||(await n(),e.completed.add(t))};if(d(),!e.team){let n=await t.send(`/api/admin/teams`,{name:e.name.trim()});if(n.conflict)throw Error(`A team already has this name. Choose another name.`);e.team=n}await f(`member`,()=>t.send(`/api/admin/teams/set-member`,{teamId:e.team.id,userId:n.id,security:!0,dependencies:!0}));for(let n of e.bundles)d(),s(`Importing ${n.name}\u2026`),n.uploaded||=await t.send(`/api/admin/bundles`,new File([n.bytes],n.name),{"x-bundle-filename":encodeURIComponent(n.name)});await M(e,r,t,f,c,l);let p=[];for(let n of e.reports){d(),s(`Importing ${n.name}\u2026`);try{await F(n,{plan:e,api:t,step:f,activeRepos:l,defaultRepo:r,includeTriage:i,resolveConflicts:a,signal:o})}catch(e){if(E(e,o))throw e;p.push(`${n.name}: ${T(e)}`)}}if(p.length>0)throw Error(`Could not import ${p.length} of ${e.reports.length} files: ${p.join(`; `)}. ${w}`);return e.team}function L(e){let t=()=>e.isEncryptionEnabled()&&!e.isUnlocked();return{get locked(){return t()},unlock:t=>e.unlockEncryption(t),async read({signal:n}={}){let r=!1,i=e.onVaultStateChange(()=>{r=!0}),a=()=>{if(n?.throwIfAborted(),t()||r)throw Error(`Local data was locked or changed. Unlock it and import triage again.`)};try{a();let t=await e.readTriageBlob();return a(),t}finally{i()}}}}function R(e){let t=()=>e.isEncryptionEnabled()&&!e.isUnlocked();async function n(){let t=JSON.parse(await e.hydrateKey(`deepview.workspaces`)||`[]`);return(Array.isArray(t)?t:t.workspaces??[]).filter(e=>typeof e.id==`string`&&typeof e.name==`string`)}async function r(n,r){let i=!1,a=[e.onVaultStateChange,e.onFileMutated,e.onBundleMutated].map(e=>e(()=>{i=!0})),o=()=>{if(r?.throwIfAborted(),t()||i)throw Error(`Local data was locked or changed. Unlock it and select the workspace again.`)};try{o();let e=await n(o);return o(),e}finally{a.forEach(e=>e())}}return{get locked(){return t()},unlock:t=>e.unlockEncryption(t),list:({signal:e}={})=>r(async()=>(await n()).map(e=>({id:e.id,name:e.name})),e),read:(t,{signal:i}={})=>r(async r=>{let i=(await n()).find(e=>e.id===t);if(!i)throw Error(`This local workspace no longer exists.`);let a=JSON.stringify(i),o=JSON.parse(await e.hydrateKey(`deepview.repoUrls`)||`{}`),s=[];for(let t of i.reports??[]){r();let n=await e.withStoredItem(`report`,t,()=>e.readFile(t));r(),s.push({name:t,content:n,...o[t]?{repo:{github:o[t]}}:{}})}let c=await e.listBundles(),l=[];for(let t of i.bundles??[]){r();let n=c.find(e=>e.integrity===t);if(!n)continue;let i=await e.withStoredItem(`bundle`,t,()=>e.readBundle(t));r(),l.push({integrity:t,name:n.name,data:i.toBase64()})}let u=await e.readTriageBlob()??{};if(JSON.stringify((await n()).find(e=>e.id===t))!==a)throw Error(`The local workspace changed. Select it again.`);return{version:1,workspace:{id:t,name:i.name,privateKey:``},reports:s,bundles:i.bundles??[],bundleBlobs:l,triage:u,repoUrls:o}},i)}}var z=e=>e===`bundle`?`bundles`:`reports`,B=(e,t)=>JSON.stringify([e,t||``]),V=(e,t)=>new Set(t.map(t=>e===`bundle`?t.integrity:B(t.sha256,t.analyzer)));async function H(e){let t=new Uint8Array(await e.arrayBuffer()),n=o(new TextDecoder().decode(t),e.name);if(!n.data)throw Error(n.reason??`Not a recognized report`);let r=new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)).toBase64({alphabet:`base64url`,omitPadding:!0});return{hash:r,key:B(r,typeof n.data.source==`string`?n.data.source:null)}}async function U(e,{source:t,deps:n,api:r,signal:i}){let a=JSON.parse(await n.hydrateKey(`deepview.workspaces`)||`[]`),o=(Array.isArray(a)?a:a.workspaces??[]).filter(e=>typeof e.id==`string`&&typeof e.name==`string`);i.throwIfAborted();let s=await t.list(e),c=V(e,(await r.send(`/api/admin/${z(e)}`))[z(e)]),l=o.map(e=>({id:e.id,name:e.name,items:[]})),u={id:null,name:`Not in a workspace`,items:[]},d=[];for(let r of s){i.throwIfAborted();let a={value:r.value,name:r.label,key:r.value,synced:!1,present:!1,error:``};if(e===`report`)try{Object.assign(a,await t.importItem(e,a.value,H,{signal:i})),a.syncHash=await n.reportSyncHash(a.value)}catch(e){i.throwIfAborted(),a.error=String(e?.message??e)}i.throwIfAborted(),a.present=c.has(a.key);let s=!1;o.forEach((t,r)=>{if(!t[z(e)]?.includes(a.value))return;let i=n.localContentSyncStatus(t.id,e,a.value,a.syncHash);a.synced||=i.synced,l[r].items.push({item:a,...i}),s=!0}),s||u.items.push({item:a,synced:!1,cached:!1}),d.push(a)}return{kind:e,items:d,groups:[...l,u].filter(e=>e.items.length>0)}}async function W(e,t,{source:n,api:r,signal:i,progress:a=()=>{},imported:o=new Set}){let{kind:s}=e,c=V(s,(await r.send(`/api/admin/${z(s)}`))[z(s)]),l=new Set(t),u=[],d=0;for(let t of e.items)if(i.throwIfAborted(),!(!l.has(t.value)||t.error||t.present)){if(c.has(t.key)){t.present=!0;continue}a(`Importing ${t.name}\u2026`),d++;try{await n.importItem(s,t.value,async e=>{let n=s===`report`?(await H(e)).key:await p(new Uint8Array(await e.arrayBuffer()));if(i.throwIfAborted(),n!==t.key)throw Error(`${t.name} changed. Choose files again before importing.`);if((await r.send(`/api/admin/${z(s)}`,e,{[`x-${s}-filename`]:encodeURIComponent(e.name)})).conflict)throw Error(`Could not import ${t.name}. Try again.`)},{signal:i})}catch(e){if(E(e,i))throw e;u.push(`${t.name}: ${T(e)}`);continue}c.add(t.key),t.present=!0,o.add(t.value)}if(u.length>0)throw Error(`Imported ${d-u.length} of ${d} ${s}s. Could not import ${u.join(`; `)}. Import again to retry them.`);return o.size}var G=(e,t)=>e===void 0?`managed-only`:t===void 0?`local-only`:`mismatch`;function K(e,t){let n=t.slice(),r=e.map(e=>{let t=n.indexOf(e);return t!==-1&&n.splice(t,1),{text:e,different:t===-1}}),i=e.slice(),a=t.map(e=>{let t=i.indexOf(e);return t!==-1&&i.splice(t,1),{text:e,different:t===-1}});return!r.some(e=>e.different)&&!a.some(e=>e.different)?null:{property:`comment`,local:r,managed:a,kind:r.some(e=>e.different)?a.some(e=>e.different)?`mismatch`:`local-only`:`managed-only`}}function q(e,t){let n=f(e)??{},r=f(t.entry)??{},i=[];for(let e of[`triage`,`color`,`fix`,`flagged`])n[e]!==r[e]&&i.push({property:e,local:n[e],managed:r[e],kind:G(n[e],r[e])});let a=K(n.comment?[n.comment]:[],t.comments.map(e=>e.body));return a&&i.push(a),n.ignoredReports?.length&&i.push({property:`ignoredReports`,local:[...new Set(n.ignoredReports)],managed:void 0,kind:`local-only`}),i}async function J(e,{lookup:t,triage:n,matched:r,findings:i,api:a,signal:o}){let s=[...new Set(e.findingIds)].filter(e=>t.has(e)&&!r.has(e));for(let c=0;c<s.length;c+=200){let l=s.slice(c,c+200);if(l.some(e=>e.length>100))throw Error(`A shared finding ID exceeds the managed triage limit.`);o.throwIfAborted();let{snapshots:u}=await a.send(`/api/admin/reports/${encodeURIComponent(e.id)}/import-triage`,{findingIds:l});o.throwIfAborted();for(let e of l){if(!u?.[e])throw Error(`The server did not return the requested triage snapshot.`);let a=q(n[e],u[e]);a.length>0&&i.push({id:e,finding:t.get(e),differences:a}),r.add(e)}}}async function Y({source:e,readTriage:t,api:n,signal:r,progress:i=()=>{}}){let a=new Map,c=[];for(let t of await e.list(`report`)){r.throwIfAborted(),i(`Reading ${t.label}\u2026`);try{let n=await e.importItem(`report`,t.value,async e=>{let t=await e.text(),n=o(t,e.name);if(!n.data)throw Error(n.reason??`Not a recognized report`);return n.format===`links`?[]:(await s(t,e.name))?.findings??[]},{signal:r});r.throwIfAborted();for(let e of n)typeof e.id!=`string`||!e.id||(a.has(e.id)||a.set(e.id,{...e,reports:[]}),a.get(e.id).reports.push(t.label))}catch(e){r.throwIfAborted(),c.push({name:t.label,reason:String(e?.message??e)})}}let l=await t()??{};if(r.throwIfAborted(),typeof l!=`object`||Array.isArray(l))throw Error(`Invalid local triage.`);let u=[],d=new Set;if(a.size===0)return{matched:0,localFindings:0,findings:u,skipped:c};let f;do{r.throwIfAborted(),i(`Comparing local and managed triage…`);let e=await n.send(`/api/admin/reports/finding-ids`+(f?`?after=${encodeURIComponent(f)}`:``));r.throwIfAborted();for(let t of e.reports)await J(t,{lookup:a,triage:l,matched:d,findings:u,api:n,signal:r});f=e.nextCursor}while(f);return r.throwIfAborted(),{matched:d.size,localFindings:a.size,findings:u,skipped:c}}function X(n,r){if(customElements.get(`managed-admin-import`))return;class i extends n{static styles=[h(t),h(v)];static properties={localDeps:{attribute:!1},_busy:{state:!0},_error:{state:!0},_message:{state:!0},_plan:{state:!0},_catalog:{state:!0},_localOpen:{state:!0},_workspaces:{state:!0},_localId:{state:!0},_triage:{state:!0},_repo:{state:!0},_drag:{state:!0}};constructor(){super(),this._busy=!1,this._error=``,this._message=``,this._plan=null,this._catalog=null,this._workspaces=[],this._localOpen=!1,this._localId=``,this._triage=``,this._repo=null,this._files=[],this._drag=!1,this._local=!1,this._over=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),this._drag=!0)},this._drop=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),this._drag=!1,this._busy||(this._files.push(...e.dataTransfer.files),this._nextFile()))},this._localChanged=()=>{this._workspaces=[],this._localId=``,!this._unlocking&&(this._local&&(this._plan=null),(this._local||this._importingTriage||this._importingContent||this._comparingTriage)&&(this._operation?.abort(),this._message=``,this._error=this._comparingTriage?`Local data changed or was locked. Compare triage again to continue.`:this._importingContent?`Local data changed or was locked. Choose files again to continue.`:this._importingTriage?`Local data changed or was locked. Import triage again to continue.`:`Local data changed or was locked. Choose the workspace again.`))},this._blur=()=>{this._readingLocal&&this._localChanged()}}connectedCallback(){super.connectedCallback(),this.addEventListener(`dragover`,this._over),this.addEventListener(`drop`,this._drop),globalThis.addEventListener(`blur`,this._blur),globalThis.addEventListener(`storage`,this._localChanged),this._offVault=this.localDeps?.onVaultStateChange(this._localChanged),this._loadCatalog()}disconnectedCallback(){this._operation?.abort(),this._offVault?.(),this._plan=null,this._files=[],this.removeEventListener(`dragover`,this._over),this.removeEventListener(`drop`,this._drop),globalThis.removeEventListener(`blur`,this._blur),globalThis.removeEventListener(`storage`,this._localChanged),super.disconnectedCallback()}updated(e){e.has(`session`)&&(this._role!==`admin`||e.get(`session`)?.id!==this.session?.id)&&(this._operation?.abort(),this._plan=null,this._files=[])}async _action(e){if(this._busy||this._role!==`admin`)return;let t=this._operation=new AbortController,n=AbortSignal.any([t.signal,this.appState.sessionController.signal]);this._busy=!0,this._error=``;try{await e(n),n.throwIfAborted()}catch(e){n.aborted||(this._error=String(e?.message??e))}finally{this._operation===t&&(this._busy=!1)}}async _loadCatalog(){if(this._role===`admin`)try{await this._loadCollection(`workspace-import:catalog`,`import options`,async e=>{let t=j(r,this.session,e),[n,i,a,o]=await Promise.all([t.send(`/api/admin/reports`),t.send(`/api/admin/teams`),t.send(`/api/admin/bundles`),t.send(`/api/admin/repositories/aliases`)]);return{repos:n.repos,teams:i.teams,bundles:a.bundles,aliases:o.aliases}},e=>{this._catalog=e})}catch(e){this._error=String(e?.message??e)}}_browse(){let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`.enc,.gz,.json`,e.addEventListener(`change`,()=>{this._files.push(...e.files),this._nextFile()},{once:!0}),e.click()}async _prepare(e,t){if(!e)return;if(this._catalog||await this._loadCatalog(),t.throwIfAborted(),!this._catalog)throw Error(`Could not load repositories. Try again.`);let n=await A(e,this._catalog.repos,this._catalog.aliases);t.throwIfAborted();let r=new Set(this._catalog.teams.map(e=>e.name)),i=n.name||`Imported workspace`,a=2;for(;r.has(n.name);){let e=` (${a++})`;n.name=i.slice(0,100-e.length)+e}let o=new Set(n.reports.map(e=>e.repoId).filter(e=>e!=null));this._repo=o.size===1?[...o][0]:null,this._triage=Object.keys(n.triage).length>0?``:`skip`,this._plan=n,this._message=``}async _nextFile(){if(this._files.length===0||this._busy)return;let e=this._files.shift();this._local=!1,this._plan=null,await this._action(async t=>{let n=await O(e,this.promptPassword);t.throwIfAborted(),await this._prepare(n,t)})}async _unlock(e,t){this._unlocking=!0;try{return!e.locked||await e.unlock({signal:t})}finally{this._unlocking=!1}}async _chooseLocal(){this._localOpen=!0,await this._action(async e=>{let t=R(this.localDeps);await this._unlock(t,e)&&(e.throwIfAborted(),this._workspaces=await t.list({signal:e}))})}async _readLocal(){if(!this._localId)return;let e=this._localId;this._local=!0,this._plan=null,await this._action(async t=>{let n=R(this.localDeps);if(await this._unlock(n,t)){this._readingLocal=!0;try{await this._prepare(await n.read(e,{signal:t}),t)}finally{this._readingLocal=!1}}})}async _import(){this._plan&&this._triage&&this._csrf&&(await this._action(async e=>{if(this._local&&R(this.localDeps).locked)throw Error(`Unlock local data and choose the workspace again.`);let t=this._plan,n=[`teams`,`reports`,`bundles`,`history`,`workspace-import`,`scan-sources`,`repo-impact`];try{let i=await this.appState.mutate(()=>I(t,{api:j(r,this.session,e),session:this.session,defaultRepo:this._repo,includeTriage:this._triage===`include`,resolveConflicts:this.resolveConflicts,signal:e,progress:e=>{this._message=e}}),n);this._catalog.teams.push(i),this._message=`Imported into ${i.name}.`,this._plan=null}finally{this.appState.invalidate(n),t.team&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}}),!this._plan&&!this._error&&await this._nextFile())}async _importLocalTriage(){this._csrf&&await this._action(async e=>{this._importingTriage=!0,this._message=``;let t=new Set,n=[`reports`,`history`];try{let n=L(this.localDeps);if(!await this._unlock(n,e))return;this._readingLocal=!0;let i;try{i=await n.read({signal:e})}finally{this._readingLocal=!1}let a=await y(i,{api:j(r,this.session,e),session:this.session,resolveConflicts:this.resolveConflicts,signal:e,importedIds:t,confirmImport:async t=>(await this.confirmTriageImport({...t,signal:e}))?.confirmed===!0});if(e.throwIfAborted(),a===null)return;this._message=a?`Imported triage for ${a} finding${a===1?``:`s`}.`:`No local triage matches findings in managed reports.`}finally{this._importingTriage=!1,this.appState.invalidate(n),t.size>0&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}})}async _compareLocalTriage(){this._csrf&&await this._action(async e=>{this._comparingTriage=!0,this._message=``;let t=this.localImportSource,n=t.subscribe(this._localChanged);try{if(!await this._unlock(t,e))return;e.throwIfAborted(),this._readingLocal=!0;let n=L(this.localDeps),i=await Y({source:t,signal:e,readTriage:()=>n.read({signal:e}),api:j(r,this.session,e),progress:e=>{this._message=e}});e.throwIfAborted(),this._message=``,await this.showTriageComparison({comparison:i,signal:e})}finally{n(),this._readingLocal=!1,this._comparingTriage=!1,this._message=``}})}async _importLocalContent(e){this._csrf&&await this._action(async t=>{this._importingContent=!0,this._message=``;let n=this.localImportSource,i=[`reports`,`bundles`,`bundle-metadata`,`history`,`workspace-import`,`scan-sources`,`repo-impact`],a=new Set,o=n.subscribe(this._localChanged);try{if(!await this._unlock(n,t))return;t.throwIfAborted(),this._readingLocal=!0;let i=j(r,this.session,t),o=await U(e,{source:n,deps:this.localDeps,api:i,signal:t}),s=await this.confirmContentImport({plan:o,signal:t});if(t.throwIfAborted(),!s?.confirmed)return;let c=await W(o,s.selected,{source:n,api:i,signal:t,imported:a,progress:e=>{this._message=e}});this._message=`Imported ${c} ${e}${c===1?``:`s`}.`}finally{o(),this._readingLocal=!1,this._importingContent=!1,this.appState.invalidate(i),a.size>0&&this.dispatchEvent(new CustomEvent(`managed-import-complete`,{bubbles:!0,composed:!0}))}})}render(){if(this._role!==`admin`)return _;let t=this._plan,n=t?Object.keys(t.triage).length:0,r=new Set([...t?.references??[],...t?.bundles.map(e=>e.integrity)??[]]),i=(this._catalog?.bundles??[]).filter(e=>r.has(e.integrity)),a=t?.references.filter(e=>!t.bundles.some(t=>t.integrity===e)).length??0;return g`<div class="wrap" @dragleave="${()=>{this._drag=!1}}">${e(`manage-import`,this._role,this.allowShare)}<h1>Import</h1><section class="triage-import" aria-label="Import local files"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent(`bundle`)}">Import bundles</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent(`report`)}">Import reports</button></div><p>Choose files from this browser, grouped by workspace. Import files without teams or triage.</p></section><section class="triage-import" aria-label="Local triage"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalTriage()}">Import triage</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._compareLocalTriage()}">Compare triage</button></div><p>Import saved triage and comments for findings already in managed reports.<br>Unmatched data stays in this browser.<br>Conflicting values prompt for resolution; per-report ignores are skipped.</p></section><h2>Import workspace</h2><p class="intro ui-hint">Create a new team from a workspace export or a workspace stored in this browser.</p><section class="${`workspace-drop ${this._drag?`dragging`:``}`}" aria-label="Workspace files"><strong>Drop workspace files here</strong><span>Encrypted exports, JSON, or compressed JSON. Encrypted files prompt for a password.</span><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._catalog}" @click="${()=>this._browse()}">Choose files</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>this._chooseLocal()}">Choose local workspace</button></div></section>${this._localOpen?g`<section class="local-choice"><label for="local-workspace">Local workspace</label> <select id="local-workspace" .value="${this._localId}" ?disabled="${this._busy}" @change="${e=>{this._localId=e.target.value}}"><option value="">Choose a workspace…</option>${this._workspaces.map(e=>g`<option value="${e.id}">${e.name}</option>`)}</select> <button type="button" class="btn" ?disabled="${this._busy||!this._localId}" @click="${()=>this._readLocal()}">Select workspace</button> ${!this._busy&&this._workspaces.length===0?g`<p class="ui-hint">No unlocked local workspaces. Choose local workspace to unlock or refresh.</p>`:_}</section>`:_} ${t?g`<section class="import-preview" aria-label="Import options">${t.team?g`<p>Team ${t.team.name} has been created. Retry continues its remaining import steps.</p>`:_} <label for="import-team">New team name</label><input id="import-team" maxlength="100" .value="${t.name}" ?disabled="${this._busy||!!t.team}" @input="${e=>{t.name=e.target.value,this.requestUpdate()}}"><p>${t.reports.length} reports / links · ${r.size} source bundles · ${n} triaged findings</p><label for="import-repo">Repository for files and source bundles without an active repository</label> <select id="import-repo" .value="${String(this._repo??``)}" ?disabled="${this._busy||!!t.team}" @change="${e=>{this._repo=e.target.value?Number(e.target.value):null}}"><option value="" ?selected="${this._repo==null}">Choose a repository…</option>${(this._catalog?.repos??[]).map(e=>g`<option value="${String(e.repoId)}" ?selected="${this._repo===e.repoId}">${e.fullName}</option>`)}</select><p>Declared report repositories and directories are preserved. Stored reports without an active repository use the selected repository. The new team receives those repository paths; other published reports in the same paths are also visible to that team.</p><ul>${t.reports.map(e=>g`<li>${e.name}<span>${e.links?`Global deduplication — enabled for all teams`:e.github??`Uses selected repository`}${e.links||e.github==null||e.repoId!=null?``:e.embedded?` — connect this repository first`:` — not connected; uses selected repository`}</span></li>`)}</ul>${i.length>0?g`<p>Existing source bundles in active repositories keep their locations. The new team also receives access to those directories. Unassigned bundles and bundles in inactive repositories use the selected repository.</p><ul>${i.map(e=>g`<li>${e.filename}<span>${e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:``}`:`Uses selected repository`}</span></li>`)}</ul>`:_} ${a?g`<p>${a} referenced source bundles have no bytes in this export. Reports can use matching bundles already on the server.</p>`:_} ${n?g`<fieldset ?disabled="${this._busy||!!t.team}"><legend>Import triage?</legend><label><input type="radio" name="import-triage" value="include" ?checked="${this._triage===`include`}" @change="${()=>{this._triage=`include`}}"> Include triage and comments</label> <label><input type="radio" name="import-triage" value="skip" ?checked="${this._triage===`skip`}" @change="${()=>{this._triage=`skip`}}"> Skip triage</label><p>Conflicting values prompt for resolution. Triage stays shared by finding ID across teams. Per-report local ignores are not imported.</p></fieldset>`:_} <button type="button" class="btn primary" ?disabled="${this._busy||!this._triage||!this._csrf}" @click="${()=>this._import()}">${this._busy?`Importing…`:t.team?`Retry remaining import`:`Import workspace`}</button></section>`:_} ${this._message?g`<p role="status">${this._message}</p>`:_} ${this._error?g`<p class="error" role="alert">${this._error}${this._catalog?_:g`<button class="btn" @click="${()=>this._loadCatalog()}">Retry</button>`}</p>`:_} ${this._files.length>0&&!this._busy?g`<button class="btn" @click="${()=>this._nextFile()}">Next workspace file (${this._files.length} waiting)</button>`:_}</div>`}}customElements.define(`managed-admin-import`,i)}export{X as registerWorkspaceImport};
|