import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{t as i}from"./button-C1nwPVFQ.js";import{p as a}from"./dist-OTL8-1C2.js";import{n as o,r as s}from"./mcp-consent-store-DZ1pCmhN.js";import{t as c}from"./label-Dv_9VZWz.js";import{a as l,c as u,i as d,n as f,o as p,s as m,t as h}from"./dialog-BFN-ujuF.js";var g=r(),_=e(t(),1),v=n();function y(e){let t=new Set;for(let n of e)n.detected&&t.add(n.id);return t}function b(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function x(e,t){let n=[];for(let r of t)e.has(r.id)&&n.push(r.id);return n}var S={error:e=>a.error(e)};function C(e){let t=(0,g.c)(9),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{store:r,toast:i,payload:a}=n,s=r===void 0?o:r,c=i===void 0?S:i,l;t[2]!==a||t[3]!==s?(l=a??s.getSnapshot(),t[2]=a,t[3]=s,t[4]=l):l=t[4];let u=l;if(!u)return null;let d;return t[5]!==u||t[6]!==s||t[7]!==c?(d=(0,v.jsx)(w,{payload:u,store:s,toast:c}),t[5]=u,t[6]=s,t[7]=c,t[8]=d):d=t[8],d}function w(e){let t=(0,g.c)(46),{payload:n,store:r,toast:a}=e,o=n.detectedEditors,S;t[0]===o?S=t[1]:(S=()=>y(o),t[0]=o,t[1]=S);let[C,w]=(0,_.useState)(S),[T,E]=(0,_.useState)(!1),D=(0,_.useId)(),O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(e){w(t=>b(t,e))},t[2]=O):O=t[2];let k=O,A;t[3]!==o||t[4]!==C||t[5]!==r||t[6]!==a?(A=async function(){E(!0);let e=await r.confirm(x(C,o));e.ok||(a.error(e.error),E(!1))},t[3]=o,t[4]=C,t[5]=r,t[6]=a,t[7]=A):A=t[7];let j=A,M;t[8]!==r||t[9]!==a?(M=async function(){E(!0);let e=await r.skip();e.ok||(a.error(e.error),E(!1))},t[8]=r,t[9]=a,t[10]=M):M=t[10];let N=M,P;t[11]!==T||t[12]!==N?(P=function(e){!e&&!T&&N()},t[11]=T,t[12]=N,t[13]=P):P=t[13];let F=P,I;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,v.jsxs)(m,{children:[(0,v.jsx)(u,{children:`Add Open Knowledge to your AI tools`}),(0,v.jsx)(l,{children:`Connect Open Knowledge to your AI tools so they can read and write your notes.`})]}),t[14]=I):I=t[14];let L;if(t[15]!==T||t[16]!==o||t[17]!==D||t[18]!==C){let e;t[20]!==T||t[21]!==D||t[22]!==C?(e=e=>{let t=C.has(e.id),n=`${D}-${e.id}`,r=e.willReplace?`Will replace existing Open Knowledge entry`:e.detected?`Detected on this machine`:`Not detected`,i=e.willReplace?`text-xs text-amber-600 dark:text-amber-400`:`text-xs text-muted-foreground`;return(0,v.jsx)(`li`,{children:(0,v.jsxs)(c,{htmlFor:n,className:`flex cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal hover:bg-accent`,children:[(0,v.jsx)(s,{id:n,checked:t,disabled:T,onCheckedChange:()=>k(e.id),className:`mt-0.5`,"data-testid":`mcp-consent-checkbox-${e.id}`}),(0,v.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.label}),(0,v.jsx)(`span`,{className:i,"data-testid":`mcp-consent-status-${e.id}`,children:r})]})]})},e.id)},t[20]=T,t[21]=D,t[22]=C,t[23]=e):e=t[23],L=o.map(e),t[15]=T,t[16]=o,t[17]=D,t[18]=C,t[19]=L}else L=t[19];let R;t[24]===L?R=t[25]:(R=(0,v.jsx)(f,{children:(0,v.jsx)(`ul`,{className:`rounded-md border border-border bg-card/50 divide-y divide-border overflow-hidden`,children:L})}),t[24]=L,t[25]=R);let z;t[26]===N?z=t[27]:(z=()=>void N(),t[26]=N,t[27]=z);let B;t[28]!==T||t[29]!==z?(B=(0,v.jsx)(i,{variant:`outline`,className:`font-mono uppercase`,onClick:z,disabled:T,"data-testid":`mcp-consent-skip`,children:`Skip`}),t[28]=T,t[29]=z,t[30]=B):B=t[30];let V;t[31]===j?V=t[32]:(V=()=>void j(),t[31]=j,t[32]=V);let H=T||C.size===0,U=T?`Working`:`Add`,W;t[33]!==V||t[34]!==H||t[35]!==U?(W=(0,v.jsx)(i,{onClick:V,disabled:H,"data-testid":`mcp-consent-add`,children:U}),t[33]=V,t[34]=H,t[35]=U,t[36]=W):W=t[36];let G;t[37]!==B||t[38]!==W?(G=(0,v.jsxs)(p,{children:[B,W]}),t[37]=B,t[38]=W,t[39]=G):G=t[39];let K;t[40]!==G||t[41]!==R?(K=(0,v.jsxs)(d,{className:`sm:max-w-md`,children:[I,R,G]}),t[40]=G,t[41]=R,t[42]=K):K=t[42];let q;return t[43]!==F||t[44]!==K?(q=(0,v.jsx)(h,{open:!0,onOpenChange:F,children:K}),t[43]=F,t[44]=K,t[45]=q):q=t[45],q}export{C as McpConsentDialogBody,C as default,y as computeInitialSelection,x as selectedIdsOrdered,b as toggleSelectedId};