import{o as e}from"./chunk-DR8-3Aex.js";import{Q as t,Rn as n,b as r,t as i,tt as a,x as o}from"./src-Di342QoJ.js";import{t as s}from"./jsx-runtime-D-D469L8.js";import{Cr as c,cn as l}from"./state-sIHsFpDu.js";import{Qa as u,Sc as d,ac as f,oo as p,yc as m}from"./paths-Ci1iwL5Y.js";import{_ as h,h as g}from"./debug-otxXY3j-.js";import{n as _,r as v}from"./analytics-DqMQntaB.js";import{n as y,t as b}from"./cwd--iizewsn.js";import{BD as x,By as S,CE as C,Da as w,Ea as T,Vw as E,aS as D,wE as O,zD as k,zw as A}from"./loadAgentsDir-C_wFhytF.js";import{qn as j}from"./prompt-6ZKyqv6z.js";import{t as M}from"./useKeybinding-DPOUuymz.js";import{n as N,t as P}from"./useExitOnCtrlCDWithKeybindings-BHi41Ku_.js";import{n as F,t as I}from"./PermissionDialog-_WQPRYHQ.js";import{homedir as L}from"os";var R=e(n(),1),z=s();i(),l(),_(),y(),h(),m(),O(),M(),E(),S(),P(),F(),p(),j(),w(),x();function B(e){if(e===null||e.disableAllHooks)return!1;if(e.statusLine||e.fileSuggestion)return!0;if(!e.hooks)return!1;for(let t of Object.values(e.hooks))if(t.length>0)return!0;return!1}function V(){let e=[];return B(u(`projectSettings`))&&e.push(`.claude/settings.json`),B(u(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function H(e){return e.some(e=>e.ruleBehavior===`allow`&&(e.ruleValue.toolName===`Bash`||e.ruleValue.toolName.startsWith(`Bash(`)))}function U(){let e=[];return H(k(`projectSettings`))&&e.push(`.claude/settings.json`),H(k(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function W(e){return!!e?.otelHeadersHelper}function G(){let e=[];return W(u(`projectSettings`))&&e.push(`.claude/settings.json`),W(u(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function K(e){return!!e?.apiKeyHelper}function q(){let e=[];return K(u(`projectSettings`))&&e.push(`.claude/settings.json`),K(u(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function J(e){return!!(e?.awsAuthRefresh||e?.awsCredentialExport)}function Y(){let e=[];return J(u(`projectSettings`))&&e.push(`.claude/settings.json`),J(u(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function X(e){return!!e?.gcpAuthRefresh}function Z(){let e=[];return X(u(`projectSettings`))&&e.push(`.claude/settings.json`),X(u(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function Q(e){return e?.env?Object.keys(e.env).some(e=>!T.has(e.toUpperCase())):!1}function $(){let e=[];return Q(u(`projectSettings`))&&e.push(`.claude/settings.json`),Q(u(`localSettings`))&&e.push(`.claude/settings.local.json`),e}j();function ee({onDone:e,commands:n}){let{servers:i}=A(`project`),s=Object.keys(i).length>0,l=V().length>0,u=U(),p=q().length>0,m=Y().length>0,h=Z().length>0,_=G().length>0,y=$().length>0,x=n?.some(e=>e.type===`prompt`&&e.loadedFrom===`commands_DEPRECATED`&&(e.source===`projectSettings`||e.source===`localSettings`)&&e.allowedTools?.some(e=>e===`Bash`||e.startsWith(`Bash(`)))??!1,S=n?.some(e=>e.type===`prompt`&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`)&&(e.source===`projectSettings`||e.source===`localSettings`||e.source===`plugin`)&&e.allowedTools?.some(e=>e===`Bash`||e.startsWith(`Bash(`)))??!1,w=u.length>0||x||S,T=f(),[E,O]=R.useState(null);R.useEffect(()=>{if(E!==null){let e=E,t=setTimeout(()=>C(e));return()=>clearTimeout(t)}},[E]),R.useEffect(()=>{v(`tengu_trust_dialog_shown`,{isHomeDir:L()===b(),hasMcpServers:s,hasHooks:l,hasBashExecution:w,hasApiKeyHelper:p,hasAwsCommands:m,hasGcpCommands:h,hasOtelHeadersHelper:_,hasDangerousEnvVars:y})},[s,l,w,p,m,h,_,y]);function k(t){if(t===`exit`){O(1);return}let n=L()===b();v(`tengu_trust_dialog_accept`,{isHomeDir:n,hasMcpServers:s,hasHooks:l,hasBashExecution:w,hasApiKeyHelper:p,hasAwsCommands:m,hasGcpCommands:h,hasOtelHeadersHelper:_,hasDangerousEnvVars:y}),n?c(!0):d(e=>({...e,hasTrustDialogAccepted:!0})),e()}let j=N(()=>O(1));return a(`confirm:no`,()=>{O(0)},{context:`Confirmation`}),E===null?T?(setTimeout(e),null):(0,z.jsx)(I,{color:`warning`,titleColor:`warning`,title:`Accessing workspace:`,children:(0,z.jsxs)(o,{flexDirection:`column`,gap:1,paddingTop:1,children:[(0,z.jsx)(r,{bold:!0,children:g().cwd()}),(0,z.jsx)(r,{children:`Is this a project you trust? (Your own code, a well-known open source project, or work from your team).`}),(0,z.jsx)(r,{children:`Once trusted, Claude Code can read, edit, and run commands in this folder.`}),(0,z.jsx)(r,{dimColor:!0,children:(0,z.jsx)(t,{url:`https://code.claude.com/docs/en/security`,children:`Security guide`})}),(0,z.jsx)(D,{options:[{label:`Yes, I trust this folder`,value:`enable_all`},{label:`No, exit`,value:`exit`}],onChange:e=>k(e),onCancel:()=>k(`exit`)}),(0,z.jsx)(r,{dimColor:!0,children:j.pending?(0,z.jsxs)(z.Fragment,{children:[`Press `,j.keyName,` again to exit`]}):(0,z.jsx)(z.Fragment,{children:`Enter to confirm · Esc to cancel`})})]})}):null}export{ee as TrustDialog};