// @bun
var{defineProperty:D,getOwnPropertyNames:K,getOwnPropertyDescriptor:L}=Object,M=Object.prototype.hasOwnProperty;function N(b){return this[b]}var $=(b)=>{var h=(I??=new WeakMap).get(b),j;if(h)return h;if(h=D({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var z of K(b))if(!M.call(h,z))D(h,z,{get:N.bind(b,z),enumerable:!(j=L(b,z))||j.enumerable})}return I.set(b,h),h},I;var O=(b)=>b;function P(b,h){this[b]=O.bind(null,h)}var Q=(b,h)=>{for(var j in h)D(b,j,{get:h[j],enumerable:!0,configurable:!0,set:P.bind(h,j)})};var R=(b,h)=>()=>(b&&(h=b(b=0)),h);var Z={};Q(Z,{groupByToArray:()=>U,groupByMultiple:()=>V,groupBy:()=>J,getUniqueTags:()=>W,getUniqueOwners:()=>X,getUniqueDomains:()=>Y,filterBy:()=>T,GroupingStrategies:()=>E});function T(b,h){return b.filter((j)=>{if(h.tags?.length){if(!h.tags.some((A)=>j.meta.tags?.includes(A)))return!1}if(h.owners?.length){if(!h.owners.some((A)=>j.meta.owners?.includes(A)))return!1}if(h.stability?.length){if(!h.stability.includes(j.meta.stability??"stable"))return!1}if(h.domain){if(E.byDomain(j)!==h.domain)return!1}if(h.keyPattern){let z=j.meta.key??j.meta.key??"",A=h.keyPattern.replace(/\*/g,".*").replace(/\?/g,".");if(!new RegExp(`^${A}$`,"i").test(z))return!1}return!0})}function J(b,h){let j=new Map;for(let z of b){let A=h(z),C=j.get(A);if(C)C.push(z);else j.set(A,[z])}return j}function U(b,h){let j=J(b,h);return Array.from(j.entries()).map(([z,A])=>({key:z,items:A}))}function V(b,h){let j=new Map;for(let z of b){let A=h(z);for(let C of A){let H=j.get(C);if(H)H.push(z);else j.set(C,[z])}}return j}function W(b){let h=new Set;for(let j of b)for(let z of j.meta.tags??[])h.add(z);return Array.from(h).sort()}function X(b){let h=new Set;for(let j of b)for(let z of j.meta.owners??[])h.add(z);return Array.from(h).sort()}function Y(b){let h=new Set;for(let j of b)h.add(E.byDomain(j));return Array.from(h).sort()}var E;var _=R(()=>{E={byTag:(b)=>b.meta.tags?.[0]??"untagged",byAllTags:(b)=>b.meta.tags?.length?b.meta.tags:["untagged"],byOwner:(b)=>b.meta.owners?.[0]??"unowned",byDomain:(b)=>{return(b.meta.key??b.meta.key??"").split(".")[0]??"default"},byStability:(b)=>b.meta.stability??"stable",byUrlPath:(b)=>(h)=>{if(!h.path)return"root";return h.path.split("/").filter(Boolean).slice(0,b).join("/")||"root"}}});_();export{U as groupByToArray,V as groupByMultiple,J as groupBy,W as getUniqueTags,X as getUniqueOwners,Y as getUniqueDomains,T as filterBy,E as GroupingStrategies};
