// @bun
var{defineProperty:h,getOwnPropertyNames:J,getOwnPropertyDescriptor:L}=Object,M=Object.prototype.hasOwnProperty;function N(z){return this[z]}var u=(z)=>{var V=(H??=new WeakMap).get(z),R;if(V)return V;if(V=h({},"__esModule",{value:!0}),z&&typeof z==="object"||typeof z==="function"){for(var S of J(z))if(!M.call(V,S))h(V,S,{get:N.bind(z,S),enumerable:!(R=L(z,S))||R.enumerable})}return H.set(z,V),V},H;var P=(z)=>z;function Q(z,V){this[z]=P.bind(null,V)}var W=(z,V)=>{for(var R in V)h(z,R,{get:V[R],enumerable:!0,configurable:!0,set:Q.bind(V,R)})};var X=(z,V)=>()=>(z&&(V=z(z=0)),V);var O={};W(O,{groupByToArray:()=>Y,groupByMultiple:()=>Z,groupBy:()=>K,getUniqueTags:()=>C,getUniqueOwners:()=>_,getUniqueDomains:()=>x,filterBy:()=>A,GroupingStrategies:()=>j});function A(z,V){return z.filter((R)=>{if(V.tags?.length){if(!V.tags.some(($)=>R.meta.tags?.includes($)))return!1}if(V.owners?.length){if(!V.owners.some(($)=>R.meta.owners?.includes($)))return!1}if(V.stability?.length){if(!V.stability.includes(R.meta.stability??"stable"))return!1}if(V.domain){if(j.byDomain(R)!==V.domain)return!1}if(V.keyPattern){let S=R.meta.key??R.meta.key??"",$=V.keyPattern.replace(/\*/g,".*").replace(/\?/g,".");if(!new RegExp(`^${$}$`,"i").test(S))return!1}return!0})}function K(z,V){let R=new Map;for(let S of z){let $=V(S),b=R.get($);if(b)b.push(S);else R.set($,[S])}return R}function Y(z,V){let R=K(z,V);return Array.from(R.entries()).map(([S,$])=>({key:S,items:$}))}function Z(z,V){let R=new Map;for(let S of z){let $=V(S);for(let b of $){let E=R.get(b);if(E)E.push(S);else R.set(b,[S])}}return R}function C(z){let V=new Set;for(let R of z)for(let S of R.meta.tags??[])V.add(S);return Array.from(V).sort()}function _(z){let V=new Set;for(let R of z)for(let S of R.meta.owners??[])V.add(S);return Array.from(V).sort()}function x(z){let V=new Set;for(let R of z)V.add(j.byDomain(R));return Array.from(V).sort()}var j;var I=X(()=>{j={byTag:(z)=>z.meta.tags?.[0]??"untagged",byAllTags:(z)=>z.meta.tags?.length?z.meta.tags:["untagged"],byOwner:(z)=>z.meta.owners?.[0]??"unowned",byDomain:(z)=>{return(z.meta.key??z.meta.key??"").split(".")[0]??"default"},byStability:(z)=>z.meta.stability??"stable",byUrlPath:(z)=>(V)=>{if(!V.path)return"root";return V.path.split("/").filter(Boolean).slice(0,z).join("/")||"root"}}});I();import{compareVersions as T}from"compare-versions";var U=(z)=>`${z.meta.key}.v${z.meta.version}`;class D{contractType;items=new Map;constructor(z,V){this.contractType=z;if(V)V.forEach((R)=>this.register(R))}register(z){let V=U(z);if(this.items.has(V))throw Error(`Duplicate contract \`${this.contractType}\` ${V}`);return this.items.set(V,z),this}count(){return this.items.size}list(){return[...this.items.values()]}get(z,V){if(V!=null)return this.items.get(`${z}.v${V}`);let R;for(let[S,$]of this.items.entries()){if(!S.startsWith(`${z}.v`))continue;if(!R||T($.meta.version,R.meta.version)>0)R=$}return R}has(z,V){return!!this.get(z,V)}filter(z){return A(this.list(),z)}listByTag(z){return this.list().filter((V)=>V.meta.tags?.includes(z))}listByOwner(z){return this.list().filter((V)=>V.meta.owners?.includes(z))}groupBy(z){return K(this.list(),z)}getUniqueTags(){return C(this.list())}}function F(z){return`${z.meta.key}.v${z.meta.version}`}class q extends D{constructor(z){super("visualization",z)}}export{F as visualizationKey,q as VisualizationRegistry};
