var e=[`plugin`,`user`,`admin`,`project`,`sessionFlags`,`unknown`],t=`__unknown__`,n=[`preToolUse`,`permissionRequest`,`postToolUse`,`preCompact`,`postCompact`,`sessionStart`,`userPromptSubmit`,`subagentStart`,`subagentStop`,`stop`];function r(e){return n.map(t=>{let n=e.filter(e=>e.eventName===t);return{eventName:t,active:n.filter(C).length,installed:n.length,needsReview:n.filter(f).length}})}function i(e){return e.filter(f).length}function a(e,t){if(t==null)return[];let n=new Set(t.hooks.map(e=>e.key));return b(e?.flatMap(e=>e.hooks.filter(e=>e.source===`plugin`&&e.pluginId===t.summary.id&&n.has(e.key)&&f(e)))??[])}function o(e,t,n){if(!(e==null||!e.summary.installed||e.hooks.length===0)){if(t.length>0)return t;if(n!=null)return[n]}}function s(e){return{issueCount:e.warnings.length+e.errors.length,needsReview:e.hooks.filter(f).length}}function c(t){let n=[];for(let r of e){let e=h(t,r);e!=null&&n.push(e)}return n}function l({pluginId:e,source:t,projectRoot:n,projectRoots:r}){let i=w(t);return(i===`project`||i==null&&t==null)&&n!=null&&r?.includes(n)===!0?{source:`project`,projectRoot:n}:i==null||i===`project`?null:i===`plugin`?e==null?{source:`plugin`}:e===`__unknown__`?{source:`plugin`,pluginId:null}:{source:`plugin`,pluginId:e}:{source:i}}function u(e,t){if(t==null)return null;let n=e.find(e=>e.id===t.source);return n==null?null:t.source===`project`?n.id===`project`?n.projectEntries.find(e=>e.cwd===t.projectRoot)??null:null:t.source===`plugin`?n.id===`plugin`?t.pluginId===void 0?n.entry:n.pluginEntries.find(e=>e.pluginId===t.pluginId)?.entry??null:null:n.id===t.source?n.entry:null}function d(e,t){return e.filter(e=>e.eventName===t).sort((e,t)=>e.displayOrder<t.displayOrder?-1:e.displayOrder>t.displayOrder?1:0)}function f(e){return e.trustStatus===`untrusted`||e.trustStatus===`modified`}function p(e){switch(e){case`plugin`:return`plugin`;case`user`:return`user`;case`system`:case`mdm`:case`cloudRequirements`:case`cloudManagedConfig`:case`legacyManagedConfigFile`:case`legacyManagedConfigMdm`:return`admin`;case`project`:return`project`;case`sessionFlags`:return`sessionFlags`;case`unknown`:return`unknown`}}function m(e){if(e.length===0)return null;let t=new Set(e.map(p));return t.size===1?t.values().next().value??null:null}function h(e,t){switch(t){case`project`:{let n=e.map(g).filter(e=>e!=null);return n.length===0?null:{id:t,projectEntries:n}}case`plugin`:{let n=v(e,t),r=_(e);return n==null||r.length===0?null:{id:t,entry:n,pluginEntries:r}}case`user`:case`admin`:case`sessionFlags`:case`unknown`:{let n=v(e,t);return n==null?null:{id:t,entry:n}}}}function g(e){let t=e.hooks.filter(e=>p(e.source)===`project`);return t.length===0?null:{...e,hooks:t}}function _(e){let t=new Map;for(let n of e)for(let e of n.hooks){if(p(e.source)!==`plugin`)continue;let n=t.get(e.pluginId);n==null?t.set(e.pluginId,[e]):n.push(e)}return Array.from(t.entries()).map(([t,n])=>({pluginId:t,entry:y(e,n)}))}function v(e,t){let n=e.flatMap(e=>e.hooks.filter(e=>p(e.source)===t)),r=t===`unknown`?e.filter(S):[];return n.length===0&&r.length===0?null:y(e,n,r)}function y(e,t,n=[]){let r=b(t),i=new Set(r.map(e=>e.key)),a=[...e.filter(e=>e.hooks.some(e=>i.has(e.key))),...n];return{cwd:``,hooks:r,warnings:Array.from(new Set(a.flatMap(e=>e.warnings))),errors:x(a.flatMap(e=>e.errors))}}function b(e){let t=new Map;for(let n of e)t.has(n.key)||t.set(n.key,n);return Array.from(t.values())}function x(e){let t=new Map;for(let n of e)t.set(`${n.path}:${n.message}`,n);return Array.from(t.values())}function S(e){return e.hooks.length===0&&(e.warnings.length>0||e.errors.length>0)}function C(e){return e.trustStatus===`managed`||e.enabled&&e.trustStatus===`trusted`}function w(e){switch(e){case`plugin`:case`user`:case`admin`:case`project`:case`sessionFlags`:case`unknown`:return e;case null:return null;default:return null}}export{d as a,a as c,m as d,f,c as i,l,s as n,i as o,r,o as s,t,u};
//# sourceMappingURL=hooks-settings-model-B-xhl-k2.js.map