import{n as e}from"./rolldown-runtime-Czos8NxU.js";import{dt as t,ft as n,st as r,ut as i}from"./app-initial~app-main~worktree-init-v2-page~appgen-settings-page~page~appgen-publication-ter~fzo5ij6p-BKVLyD1q.js";function a({directoryApps:e,pluginApps:t}){let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>{let t=n.get(e.id);if(t==null||t.name===t.id)return null;let r=e.category?.trim()||s(t);if(!r)return t;let i=t.branding??{category:null,developer:null,website:null,privacyPolicy:null,termsOfService:null,isDiscoverableApp:!1};return{...t,branding:{...i,category:r}}}).filter(e=>e!=null)}function o({directoryApps:e,appTemplates:t}){if(!Array.isArray(t))return[];let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>{let t=(e.canonicalConnectorId==null?void 0:n.get(e.canonicalConnectorId))??n.get(e.templateId);return t==null?e:{...e,category:e.category?.trim()||s(t),description:e.description||t.description,logoUrl:e.logoUrl||t.logoUrl,logoUrlDark:e.logoUrlDark||t.logoUrlDark}})}function s(e){return e.branding?.category?.trim()||e.appMetadata?.categories?.find(e=>e.trim())?.trim()||null}function c(e,t,n){return!l(e,t)||n.type!==`local`?null:n.path}function l(e,r){return e==null||r==null?!1:t(r)===t(i(n(e),m))}function u({installedSkills:e,pluginSkills:t}){let n=d(e),r=[],i=[];for(let e of t){let t=f(e,n);if(t!=null){r.push({installedSkill:t,pluginSkill:e});continue}i.push(e)}return{installedSkills:r,unavailableSkills:i}}function d(e){let t=new Map,n=new Map,r=new Map;for(let{skill:i}of e){r.set(i.path,i),n.set(i.name,i);let e=p(i.name),a=t.get(e);if(a==null){t.set(e,[i]);continue}a.push(i)}return{byComparableKey:t,byName:n,byPath:r}}function f(e,t){let n=(e.path==null?void 0:t.byPath.get(e.path))??t.byName.get(e.name);if(n!=null)return n;let r=t.byComparableKey.get(p(e.name));return r?.length===1?r[0]:null}function p(e){return(e??``).trim().toLowerCase().split(`:`).map(e=>e.replace(/[\s_-]+/g,``)).join(`:`)}var m,h=e((()=>{r(),m=`.agents/plugins/marketplace.json`}));export{h as a,c as i,a as n,l as o,u as r,o as t};
//# sourceMappingURL=plugin-detail-page-utils-ByGS2xXG.js.map