import{Gq as D,Hq as hJ,Jl as R,Kl as BJ,ZB as k,_B as HJ,en as G,hn as a}from"./cli-0.5.4-k5fz4zd3.mjs";import{B3 as bJ,b3 as ZJ,m3 as $J}from"./cli-0.5.4-jqt00ywx.mjs";import{E$ as WJ,T$ as yJ,a8 as C,b8 as GJ,c8 as h,d8 as FJ,e8 as u,f8 as kJ}from"./cli-0.5.4-cbq01zg3.mjs";import{Gca as q,Ica as s,Jca as Y,Kca as r}from"./cli-0.5.4-37v5fhf1.mjs";import{Kda as x,Wda as gJ}from"./cli-0.5.4-2dw33ms6.mjs";import{Cea as jJ,xea as M}from"./cli-0.5.4-x1fzfxmm.mjs";import{$ea as CJ,_ea as o,ffa as n,gfa as EJ,pfa as l,qfa as TJ}from"./cli-0.5.4-end8wj9r.mjs";import{$ga as zJ,Oga as c,Pga as OJ,Tla as QJ,Uha as H,Vha as F,Wha as I,Xha as YJ,Yha as P,Zha as XJ,_ga as g,aha as A,bha as wJ,ima as mJ,mha as f,nha as PJ}from"./cli-0.5.4-jmc3bzbn.mjs";import{rma as K,sma as DJ}from"./cli-0.5.4-959vxhhb.mjs";import{Zma as B}from"./cli-0.5.4-aacw1src.mjs";function UJ(J,Q){return Q.length<2?J:P(J,R(Q,0,-1))}var z;var L=B(()=>{XJ();BJ();z=UJ});function xJ(J,Q){Q=H(Q,J);var W=-1,$=Q.length;if(!$)return!0;while(++W<$){var Z=I(Q[W]);if(Z==="__proto__"&&!KJ.call(J,"__proto__"))return!1;if((Z==="constructor"||Z==="prototype")&&W<$-1)return!1}var X=z(J,Q);return X==null||delete X[I(k(Q))]}var IJ,KJ,N;var O=B(()=>{F();HJ();L();YJ();IJ=Object.prototype,KJ=IJ.hasOwnProperty;N=xJ});function MJ(J){return C(J)?void 0:J}var E;var T=B(()=>{GJ();E=MJ});function RJ(J){return A(J)||f(J)||!!(S&&J&&J[S])}var S,d;var _=B(()=>{DJ();PJ();wJ();S=K?K.isConcatSpreadable:void 0;d=RJ});function v(J,Q,W,$,Z){var X=-1,V=J.length;W||(W=d),Z||(Z=[]);while(++X<V){var U=J[X];if(Q>0&&W(U))if(Q>1)v(U,Q-1,W,$,Z);else g(Z,U);else if(!$)Z[Z.length]=U}return Z}var m;var j=B(()=>{zJ();_();m=v});function LJ(J){var Q=J==null?0:J.length;return Q?m(J,1):[]}var y;var b=B(()=>{j();y=LJ});function NJ(J){return u(h(J,void 0,y),J+"")}var i;var p=B(()=>{b();FJ();kJ();i=NJ});var SJ=1,AJ=2,fJ=4,dJ,NQ;var _J=B(()=>{OJ();TJ();O();F();EJ();T();p();CJ();dJ=i(function(J,Q){var W={};if(J==null)return W;var $=!1;if(Q=c(Q,function(X){return X=H(X,J),$||($=X.length>1),X}),n(J,o(J),W),$)W=l(W,SJ|AJ|fJ,E);var Z=Q.length;while(Z--)N(W,Q[Z]);return W}),NQ=dJ});function t(){let J=x("tengu_harbor_ledger",[]),Q=vJ().safeParse(J);return Q.success?Q.data:[]}function e(){return x("tengu_harbor",!1)}var vJ;var JJ=B(()=>{s();r();a();gJ();vJ=Y(()=>q.array(q.object({marketplace:q.string(),plugin:q.string()})))});function uQ(J,Q,W){let $=Object.entries(W??{}).filter(([Z])=>iJ.test(Z)).map(([Z,X])=>` ${Z}="${D(X)}"`).join("");return`<${M} source="${D(J)}"${$}>
${Q}
</${M}>`}function pJ(J,Q){if((J==="team"||J==="enterprise")&&Q)return{entries:Q,source:"org"};return{entries:t(),source:"ledger"}}function cJ(J,Q){let W=J.split(":");return Q.find(($)=>$.kind==="server"?J===$.name:W[0]==="plugin"&&W[1]===$.name)}function iQ(J,Q,W){if(!Q?.experimental?.["claude/channel"])return{action:"skip",kind:"capability",reason:"server did not declare claude/channel capability"};if(!e())return{action:"skip",kind:"disabled",reason:"channels feature is not currently available"};if(!ZJ()?.accessToken)return{action:"skip",kind:"auth",reason:"channels requires claude.ai authentication (run /login)"};let $=$J(),Z=$==="team"||$==="enterprise",X=Z?WJ("policySettings"):void 0;if(Z&&X?.channelsEnabled!==!0)return{action:"skip",kind:"policy",reason:"channels not enabled by org policy (set channelsEnabled: true in managed settings)"};let V=cJ(J,QJ());if(!V)return{action:"skip",kind:"session",reason:`server ${J} not in --channels list for this session`};if(V.kind==="plugin"){let U=W?G(W).marketplace:void 0;if(U!==V.marketplace)return{action:"skip",kind:"marketplace",reason:`you asked for plugin:${V.name}@${V.marketplace} but the installed ${V.name} plugin is from ${U??"an unknown source"}`};if(!V.dev){let{entries:qJ,source:VJ}=pJ($,X?.allowedChannelPlugins);if(!qJ.some((w)=>w.plugin===V.name&&w.marketplace===V.marketplace))return{action:"skip",kind:"allowlist",reason:VJ==="org"?`plugin ${V.name}@${V.marketplace} is not on your org's approved channels list (set allowedChannelPlugins in managed settings)`:`plugin ${V.name}@${V.marketplace} is not on the approved channels allowlist (use --dangerously-load-development-channels for local dev)`}}}else if(!V.dev)return{action:"skip",kind:"allowlist",reason:`server ${V.name} is not on the approved channels allowlist (use --dangerously-load-development-channels for local dev)`};return{action:"register"}}var bQ,uJ="notifications/claude/channel/permission",hQ,iJ;var oJ=B(()=>{s();mJ();jJ();bJ();r();a();yJ();hJ();JJ();bQ=Y(()=>q.object({method:q.literal("notifications/claude/channel"),params:q.object({content:q.string(),meta:q.record(q.string(),q.string()).optional()})})),hQ=Y(()=>q.object({method:q.literal(uJ),params:q.object({request_id:q.string(),behavior:q.enum(["allow","deny"])})})),iJ=/^[a-zA-Z_][a-zA-Z0-9_]*$/});
export{NQ as Se,_J as Te,JJ as Ue,bQ as Ve,uQ as We,cJ as Xe,iQ as Ye,oJ as Ze};
