/* Socket Lib - Built with esbuild */
var f=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var C=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},D=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of m(n))!_.call(e,i)&&i!==t&&f(e,i,{get:()=>n[i],enumerable:!(r=A(n,i))||r.enumerable});return e};var P=e=>D(f({},"__esModule",{value:!0}),e);var j={};C(j,{collectIncompatibleLicenses:()=>q,collectLicenseWarnings:()=>U,createAstNode:()=>c,createBinaryOperationNode:()=>O,createLicenseNode:()=>h,parseSpdxExp:()=>E,resolvePackageLicenses:()=>T,visitLicenses:()=>B});module.exports=P(j);var y=require("#constants/core"),I=require("#constants/licenses"),L=require("../objects"),S=require("../path");const R=(0,I.getCopyLeftLicenses)(),x="BinaryOperation",g="License",b=/^SEE LICEN[CS]E IN (.+)$/;let l;function k(){return l===void 0&&(l=require("node:path")),l}let N;function v(){return N===void 0&&(N=require("../external/spdx-correct")),N}let u;function w(){return u===void 0&&(u=require("../external/spdx-expression-parse")),u}function q(e){const n=[];for(let t=0,{length:r}=e;t<r;t+=1){const i=e[t];i&&R.has(i.license)&&n.push(i)}return n}function U(e){const n=new Map;for(let t=0,{length:r}=e;t<r;t+=1){const i=e[t];if(!i)continue;const{license:o}=i;o==="UNLICENSED"?n.set("UNLICENSED","Package is unlicensed"):i.inFile!==void 0&&n.set("IN_FILE",`License terms specified in ${i.inFile}`)}return[...n.values()]}function c(e){return(0,L.hasOwn)(e,"license")?h(e):O(e)}function O(e){let n,t,r=e.left,i=e.right;const{conjunction:o}=e;return{__proto__:null,type:x,get left(){return n===void 0&&(n=c(r),r=void 0),n},conjunction:o,get right(){return t===void 0&&(t=c(i),i=void 0),t}}}function h(e){return{__proto__:null,...e,type:g}}function E(e){const n=w();try{return n(e)}catch{}const r=v()(e);return r?n(r):void 0}function T(e,n){if(e==="UNLICENSED"||e==="UNLICENCED")return[{license:"UNLICENSED"}];const t=b.exec(e);if(t)return[{license:e,inFile:(0,S.normalizePath)(k().relative(n,t[1]||""))}];const r=[],i=E(e);return r}function B(e,n){const t=[[c(e),void 0]];let r=0,{length:i}=t;for(;r<i;){if(r===y.LOOP_SENTINEL)throw new Error("Detected infinite loop in ast crawl of visitLicenses");const{0:o,1:s}=t[r++],{type:d}=o,p=n;if(typeof p[d]=="function"&&(0,L.hasOwn)(n,d)){if(d===g){const a=p.License;if(typeof a=="function"&&a(o,s)===!1)break}else if(d===x){const a=p.BinaryOperation;if(typeof a=="function"&&a(o,s)===!1)break}}d===x&&(t[i++]=[o.left,o],t[i++]=[o.right,o])}}0&&(module.exports={collectIncompatibleLicenses,collectLicenseWarnings,createAstNode,createBinaryOperationNode,createLicenseNode,parseSpdxExp,resolvePackageLicenses,visitLicenses});
//# sourceMappingURL=licenses.js.map
