PageSourceSearch

https://riskassist.ai/assets/audit-run-DyS5wDPj.js

js riskassist.ai collected 2026-10-05 14:31:56 UTC 135,489 bytes, 1 lines download raw bytes

1import{c as Ot,u as _a,d as Ma,r as n,t as x,j as e,L as Ve,h as l,B as p,b as D,T as I,C as H,X as me}from"./index-qUK8Hdpx.js";import{u as Oa}from"./useQuery-CPigJIO8.js";import{u as Ce,C as pe}from"./chevron-down-BwA7OcuG.js";import{A as Ea,c as Q,L as $,T as Rt,d as $a,e as Ft,b as za}from"./app-layout-3v6Gn9Sa.js";import{C as b,a as f}from"./card-BiWwXSqu.js";import{B as O}from"./badge-BIIZzDl8.js";import{P as J}from"./progress-C3UeGtO9.js";import{I as xe,C as rt}from"./select-DBovPMB7.js";import{P as He,a as Xe,b as Ke,C as We,s as Qe}from"./popover-pBEw-Trd.js";import{s as js,m as vs,b as Ns,e as Ye,c as La,a as Ze,p as Ua,d as ks,f as Ie,i as Ga}from"./api-DpTwDa7Z.js";import{G as Pe,F as Ba}from"./globe-CeyBAaPy.js";import{S as X}from"./shield-BiG9WfHj.js";import{T as Dt}from"./target-D8Rhj-yB.js";import{S as Z}from"./shield-check-CQXNi2IY.js";import{C as ys}from"./clipboard-check-CT_u-I7l.js";import{A as Tt}from"./activity-D2EAAn9t.js";import{F as re}from"./file-check-CnVlpslV.js";import{U as Je}from"./upload-BFSFffwA.js";import{A as Re}from"./arrow-right-D8h0518s.js";import{C as et}from"./calendar-B89yUSDA.js";import{f as tt}from"./format-CBM5bock.js";import{P as st}from"./plus-Bak1PblU.js";import{F as Fe}from"./file-spreadsheet-dKJSnqjM.js";import{F as _t}from"./file-2Z1Fz-So.js";import{C as Y}from"./check-MYrTRj9c.js";import{C as z}from"./circle-x-CfH_Ja2U.js";import{L as qa}from"./list-checks-mbf6Bv9_.js";import{a as ws}from"./message-square-Z_3Z7reJ.js";import{F as P}from"./file-text-BTYIWt8s.js";import{F as Va}from"./file-search-DR1btlk0.js";import{T as Ss}from"./tag-H7RYqQ1Y.js";import{C as As}from"./clock-BrUktc3l.js";import{C as Mt}from"./cloud-Csi-_dXR.js";import{R as Cs}from"./refresh-cw-goksMloN.js";import{P as Ha}from"./pencil-Cm3qmSEX.js";import{F as Xa}from"./folder-open-BWVFqCYd.js";import{U as Is}from"./user-check-60bAK_LV.js";import{B as Ka,S as Wa}from"./logo_new-Dyl6rEJX.js";import{E as Qa}from"./eye-CYAnA-nr.js";import{B as Ps}from"./book-open-Ct8y6l4E.js";import{C as Ya}from"./camera-BNRkTwWb.js";import"./users-xw4djSrm.js";import"./en-US-DaTnBiBt.js";import"./chevron-left-DzCZ-ehq.js";import"./startOfDay-BURNxTQf.js";const Za=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ja=Ot("copy",Za);const er=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],tr=Ot("pause",er);const sr=[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]],Rs=Ot("scale",sr);function oi(){const[,M]=_a(),K=Ma(),[d,N]=n.useState("select-framework"),[De,k]=n.useState("validating"),[m,S]=n.useState(null),[j,T]=n.useState(""),[v,Te]=n.useState(void 0),[h,_e]=n.useState(void 0),[L,ue]=n.useState([]),[Fs,it]=n.useState(!1),[U,W]=n.useState(0),[g,Et]=n.useState(null),[Me,Ds]=n.useState(null),[_,$t]=n.useState(null),[zt,Ts]=n.useState(new Set),[G,lt]=n.useState(null),[w,ge]=n.useState(null),[_s,nt]=n.useState(!1),[ee,Lt]=n.useState([]),[Ut,Gt]=n.useState([]),[Ms,dt]=n.useState(!1),[Bt,ot]=n.useState(!1),[Os,qt]=n.useState(0),[Es,Vt]=n.useState(new Map),[$s,Ht]=n.useState(new Map),[zs,Xt]=n.useState(new Set),[he,ct]=n.useState(""),[ie,be]=n.useState([]),[fe,mt]=n.useState(""),[le,je]=n.useState([]),[ve,xt]=n.useState(""),[Ne,Oe]=n.useState([]),[ke,pt]=n.useState(""),[Ee,$e]=n.useState([]),[ye,ut]=n.useState(""),[Kt,Ls]=n.useState(""),[nr,Wt]=n.useState([]),[dr,or]=n.useState(null),[cr,mr]=n.useState(new Set),[xr,pr]=n.useState(new Map),[gt,Us]=n.useState(!1),[te,ze]=n.useState([]),[Gs,Bs]=n.useState(new Map),[qs,Qt]=n.useState(null),[ur,Yt]=n.useState(null),[Vs,Hs]=n.useState(null),[Xs,ht]=n.useState(!1),[Zt,Jt]=n.useState(0),es=n.useRef(null),[Ks,Ws]=n.useState(null),[ts,ss]=n.useState(!1),se=n.useRef(null),[c,as]=n.useState(null),[F,rs]=n.useState(null),[Qs,is]=n.useState(!1),[A,Ys]=n.useState(null),[ls,ns]=n.useState(!1),[V,ds
1]=n.useState(null),[Zs,os]=n.useState(!1),[ne,cs]=n.useState(!1);n.useEffect(()=>{(d==="scope-context"||d==="review-readiness")&&g&&(async()=>{try{os(!0);const t=await js.get(g);ds(t),t.confirmed&&cs(!0),t.data&&t.status!=="none"&&(t.data.orgName&&!j&&T(t.data.orgName),t.data.scopeStatement&&!he&&ct(t.data.scopeStatement),t.data.locations?.length&&ie.length===0&&be(t.data.locations),t.data.inScopeSystems?.length&&le.length===0&&je(t.data.inScopeSystems),t.data.outOfScopeItems?.length&&Ee.length===0&&$e(t.data.outOfScopeItems))}catch(t){console.error("Failed to load scope profile:",t)}finally{os(!1)}})(),d==="review-readiness"&&g&&(vs.get(g).then(t=>{rs(t)}).catch(t=>console.error("Failed to fetch missing artifacts:",t)),Ns.get(g).then(t=>{as(t)}).catch(t=>console.error("Failed to fetch stage 1 readiness:",t)))},[d,g]);const Js=async()=>{if(g)try{await js.confirm(g),cs(!0),ds(t=>t&&{...t,confirmed:!0}),x.success("Scope profile confirmed successfully")}catch(t){console.error("Failed to confirm scope profile:",t),x.error("Failed to confirm scope profile")}};n.useEffect(()=>{if(ts&&g)return se.current=setInterval(async()=>{try{const t=await Ye.classificationStatus(g);Gt(s=>s.map(a=>{const r=t.files.find(i=>i.id===a.id);return r?{...a,classificationStatus:r.classificationStatus,mappedControlIds:r.mappedControlIds,evidenceType:r.evidenceType,supportType:r.supportType,documentType:r.documentType,documentConfidence:r.documentConfidence,mappedClauses:r.mappedClauses,classificationNotes:r.classificationNotes}:a})),t.files&&Lt(s=>{if(s.length===0)return s;const a=new Map;return t.files.forEach(r=>{r.classificationStatus==="CLASSIFIED"&&r.mappedControlIds&&r.mappedControlIds.forEach(i=>{a.set(i,(a.get(i)||0)+1)})}),s.map(r=>{const i=a.get(r.controlId)||0;return{...r,evidenceCollected:i,status:i>=r.evidenceRequired?"complete":"pending"}})}),t.unclassified===0&&(ss(!1),se.current&&(clearInterval(se.current),se.current=null),g&&(Ns.get(g).then(s=>{as(s)}).catch(s=>{console.error("Failed to fetch stage 1 readiness:",s)}),vs.get(g).then(s=>{rs(s)}).catch(s=>console.error("Failed to fetch missing artifacts:",s))))}catch(t){console.error("Classification polling error:",t)}},3e3),()=>{se.current&&(clearInterval(se.current),se.current=null)}},[ts,g]);const de=(t,s)=>`${t}-${s}`,we=(t,s,a)=>{const r=de(t,s);Vt(i=>new Map(i).set(r,a))},ms=(t,s)=>{const a=de(t,s);return Es.get(a)||"pending"},ea=(t,s,a)=>{const r=de(t,s);Ht(i=>new Map(i).set(r,a))},ta=(t,s)=>{const a=de(t,s);return $s.get(a)||""},sa=(t,s)=>{const a=de(t,s);Xt(r=>{const i=new Set(r);return i.has(a)?i.delete(a):i.add(a),i})},aa=(t,s,a)=>{x.info(`Re-validating ${s}: ${a}...`),we(t,s,"pending")},xs=()=>{if(!_)return{total:0,reviewed:0,pending:0,approved:0,rejected:0,hold:0,needsEdit:0};let t=0,s=0,a=0,r=0,i=0;_.results.forEach(y=>{y.applicableControls.forEach(C=>{switch(t++,ms(y.fileId,C.controlId)){case"approved":s++;break;case"rejected":a++;break;case"hold":r++;break;case"needs-edit":i++;break}})});const o=s+a+r+i,u=t-o;return{total:t,reviewed:o,pending:u,approved:s,rejected:a,hold:r,needsEdit:i}},ra=()=>U<30?"Creating audit record...":U<60?`Uploading evidence files... (${Os} of ${L.length} files)`:U<90?"Running AI validation...":"Completing validation...",{data:bt}=Oa({queryKey:["integrations-status"],queryFn:()=>Ga.getStatus()}),B=Ce({mutationFn:t=>Ze.create(t),onSuccess:t=>{Et(t.id),K.invalidateQueries({queryKey:["audits"]})}});Ce({mutationFn:async({auditId:t,files:s})=>{const a=s.map(r=>Ye.create(t,{fileName:r.name,fileSize:r.size,fileType:r.type,source:"local",file:r}));return Promise.all(a)}});const ia=Ce({mutationFn:t=>Ze.validateEvidence(t),onSuccess:t=>{$t(t)}}),ft=Ce({mutationFn:t=>Ze.process(t),onSuccess:t=>{Ds(t),K.invalidateQueries({queryKey:["audits"]})}}),Se=Ce({mutationFn:async({auditId:t,file:s})=>Ze.parseSoA(t,{fileName:s.name,fileSize:s.size,fileType:s.type}),onSuccess:t=>{const s={message:t.message||"SoA parsing complete",summary:t.summary,ismsClauseControls:t.ismsClauseControls??t.controls?.filter(a=>a.isIsmsClause).length??0,annexAControls:t.annexAControls??t.controls?.filter(a=>!a.isIsmsClause&&a.isApplicable).length??0,totalApplicable:t.totalApplicable??t.applicableControls??t.controls?.filter(a=>a.isApplicable).length??0,applicableControls:t.applicableControls??t.controls?.filter(a=>a.isApplicable).length??0,excludedControls:t.excludedControls??t.controls?.filter(a=>!a.isApplicable).length??0,totalControls:t.totalControls??t.controls?.length??0,controls:t.controls||[],evidenceChecklist:t.evidenceChecklist||[]};ge(s),s.evidenceChecklist&&s.evidenceChecklist.length>0&&Lt(s.evidenceChecklist)}}),la=async(t,s)=>await Ye.create(t,{fileName:s.name,fileSize:s.size,fileType:s.type,source:"local",file:s}),na=t=>{Ts(s=>{const a=new Set(s);return a.has(t)?a.delete(t):a.add(t),a})},da=n.useCallback(t=>{t.preventDefault(),it(!0)},[]),oa=n.useCallback(t=>{t.preventDefault(),it(!1)}
1,[]),ca=n.useCallback(t=>{t.preventDefault(),it(!1);const s=Array.from(t.dataTransfer.files);ue(a=>[...a,...s])},[]),ma=t=>{t.target.files&&ue(s=>[...s,...Array.from(t.target.files||[])])},xa=t=>{ue(s=>s.filter((a,r)=>r!==t))},pa=t=>{S(t),N(t==="ISO27001"||t==="ISO27701"||t==="ISO42001"?"mandatory-docs":"client-info")},ua=j.trim()!==""&&v&&h&&he.trim()!==""&&ie.length>0&&le.length>0&&Ne.length>0,ga=async()=>{if(!j.trim()){x.error("Please enter an organization name");return}if(!v){x.error("Please select an audit period start date");return}if(!h){x.error("Please select an audit period end date");return}if(!he.trim()){x.error("Please enter an ISMS scope statement");return}if(ie.length===0){x.error("Please add at least one site/location");return}if(le.length===0){x.error("Please add at least one in-scope system");return}if(Ne.length===0){x.error("Please add at least one in-scope process");return}if(G&&!w){x.error("Please parse the uploaded SoA file before continuing");return}let t=g;if(!t)try{t=(await B.mutateAsync({clientName:j,framework:m||"ISO27001",status:"draft",periodStart:v||null,periodEnd:h||null})).id}catch(s){console.error("Error creating audit:",s),x.error("Failed to create audit. Please try again.");return}try{await Ua.upsert(t,{organizationName:j,periodStart:v.toISOString(),periodEnd:h.toISOString(),ismsScope:he,sitesLocations:ie,inScopeSystems:le,inScopeProcesses:Ne,outOfScopeItems:Ee,interestedParties:Kt||null})}catch(s){console.error("Error saving profile:",s),x.error("Failed to save audit profile. Please try again.");return}try{const s=await ks.initialize(t);if(Wt(s),w){const a=s.find(r=>r.artifactKey==="soa");if(a&&a.status==="not_started")try{const r=await ks.update(t,a.id,{status:"uploaded"});Wt(i=>i.map(o=>o.id===a.id?r:o))}catch(r){console.error("Failed to auto-link SoA artifact",r)}}}catch(s){console.error("Failed to initialize artifacts:",s)}N("upload-evidence")},ha=async()=>{if(!j.trim()){x.error("Please enter a client name");return}N("upload")},ba=n.useCallback(t=>{t.preventDefault(),nt(!0)},[]),fa=n.useCallback(t=>{t.preventDefault(),nt(!1)},[]),ja=n.useCallback(t=>{t.preventDefault(),nt(!1);const s=Array.from(t.dataTransfer.files);if(s.length>0){const a=s[0],r=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],o=[".pdf",".docx",".xls",".xlsx"].some(u=>a.name.toLowerCase().endsWith(u));r.includes(a.type)||o?(lt(a),ge(null)):x.error("Please upload a PDF, DOCX, XLS, or XLSX file")}},[]),va=t=>{if(t.target.files&&t.target.files[0]){const s=t.target.files[0];lt(s),ge(null)}},Na=async()=>{if(!G){x.error("Please upload an SoA file first");return}let t=g;if(!t){const o=j.trim()||"Untitled Organization";j.trim()||T(o);try{t=(await B.mutateAsync({clientName:o,framework:m||"ISO27001",status:"draft",periodStart:v||null,periodEnd:h||null})).id}catch(u){console.error("Error creating audit:",u);const y=u instanceof Error?u.message:"Unknown error";x.error(`Failed to create audit: ${y}`);return}}const s=async o=>{try{return o===0&&await Ye.create(t,{fileName:G.name,fileSize:G.size,fileType:G.type,source:"local",isSoaFile:!0,file:G}),await Se.mutateAsync({auditId:t,file:G}),!0}catch(u){return console.error(`Error parsing SoA (attempt ${o+1}):`,u),!1}};if(await s(0)){x.success("SoA parsed successfully!");return}if(x.info("First attempt failed, retrying..."),await s(1)){x.success("SoA parsed successfully on retry!");return}const i=Se.error instanceof Error?Se.error.message:"The AI analysis service may be temporarily unavailable";x.error(`Failed to parse SoA: ${i}. Please try again later.`)},ps={"Google Drive":"google-drive",OneDrive:"onedrive",SharePoint:"sharepoint"},jt=async t=>{const s=ps[t],a=s&&bt?.[s]?.connected,r=s&&bt?.[s]?.configured;if(a)x.info("Cloud import coming soon - files will be available after OAuth connection");else if(r||s==="sharepoint")try{const o=await(await fetch(`/api/oauth/${s}/authorize`)).json();o.authUrl?(g&&sessionStorage.setItem("pendingAuditId",g),window.location.href=o.authUrl):x.error(o.message||"Failed to start connection")}catch{x.error("Failed to connect. Please try again.")}else x.error(`${t} integration is not configured. Please contact your administrator.`)},oe=t=>{const s=ps[t];return s&&bt?.[s]?.connected},ka=async()=>
1{if(!m||!j.trim()){x.error("Missing required information");return}if(L.length===0){x.error("Please upload at least one evidence file");return}ot(!0),qt(0);const t=m==="ISO27001"||m==="ISO27701"||m==="ISO42001";try{t?(N("review-readiness"),k("validating")):N("validating"),W(10),dt(!0);let s=g;s||(s=(await B.mutateAsync({clientName:j,framework:m,periodStart:v||null,periodEnd:h||null})).id),W(30);const a=[],r=30/L.length;for(let i=0;i<L.length;i++){const o=L[i];qt(i+1);try{const u=await la(s,o);a.push(u),Gt(y=>[...y,u]),W(30+r*(i+1))}catch(u){console.error(`Error uploading file ${o.name}:`,u),x.error(`Failed to upload ${o.name}`)}}W(60),dt(!1),ss(!0),W(70),await ia.mutateAsync(s),W(95),setTimeout(()=>{W(100),t?k("results"):N("validation-results"),ot(!1)},500),x.success("Files uploaded! AI classification in progress...")}catch(s){console.error("Error validating evidence:",s),x.error("Failed to validate evidence. Please try again."),N(t?"upload-evidence":"upload"),dt(!1),ot(!1)}},Le=t=>m==="ISO27701"?{"A.7.2.1":"GDPR Art. 6 (Lawful basis)","A.7.2.2":"GDPR Art. 5(1)(b) (Purpose limitation)","A.7.2.5":"GDPR Art. 35 (DPIA)","A.7.2.6":"GDPR Art. 28 (Processor contracts)","A.7.2.8":"GDPR Art. 26 (Joint controllers)","A.7.3.1":"GDPR Art. 13-14 (Transparency)","A.7.3.2":"GDPR Art. 15 (Right of access)","A.7.3.3":"GDPR Art. 16 (Right to rectification)","A.7.3.4":"GDPR Art. 17 (Right to erasure)","A.7.3.5":"GDPR Art. 18 (Restriction of processing)","A.7.3.6":"GDPR Art. 20 (Data portability)","A.7.3.7":"GDPR Art. 21 (Right to object)","A.7.3.9":"GDPR Art. 22 (Automated decisions)","A.7.4.1":"GDPR Art. 25 (Privacy by design)","A.7.4.5":"GDPR Art. 25 (Privacy by design)","A.7.4.7":"GDPR Art. 44-49 (Cross-border transfers)","A.7.5.1":"GDPR Art. 30 (ROPA)","A.7.5.4":"GDPR Art. 33-34 (Breach notification)","B.8.2.2":"GDPR Art. 28(3) (Processor obligations)","B.8.2.4":"GDPR Art. 28(2) (Sub-processors)","B.8.3.1":"GDPR Art. 28(3)(g) (Data return/deletion)","B.8.5.1":"GDPR Art. 44-49 (Processor transfers)"}[t]||null:m==="ISO42001"&&{"AI-A.4.5":"EU AI Act Art. 6 (Risk classification)","AI-A.5.2":"EU AI Act Art. 9 (Risk management)","AI-A.6.2":"EU AI Act Art. 10 (Data governance)","AI-A.7.2":"EU AI Act Art. 9 (Impact assessment)","AI-A.7.3":"EU AI Act Art. 9(7) (Testing)","AI-A.7.4":"EU AI Act Art. 11 (Technical documentation)","AI-A.8.3":"EU AI Act Art. 9(3) (Monitoring)","AI-A.10.2":"EU AI Act Art. 13 (Transparency)","AI-A.10.4":"EU AI Act Art. 10(2)(f) (Bias examination)","AI-A.10.5":"EU AI Act Art. 9 (Safety systems)","AI-A.10.6":"EU AI Act Art. 14 (Human oversight)","AI-A.10.7":"EU AI Act Art. 9(9) (Accountability)"}[t]||null,vt=m==="ISO27701"?[{key:"pims_scope",label:"PIMS Scope Statement",icon:Pe,description:"Defines the boundaries and applicability of your Privacy Information Management System",category:"governance"},{key:"privacy_policy",label:"Privacy Policy",icon:Z,description:"Top-level privacy policy covering PII processing principles",category:"governance"},{key:"ropa",label:"Records of Processing Activities (ROPA)",icon:Fe,description:"Register of all PII processing activities per GDPR Art. 30",category:"governance"},{key:"dpia",label:"Data Protection Impact Assessment (DPIA)",icon:I,description:"Privacy impact assessments for high-risk PII processing",category:"governance"},{key:"pims_soa",label:"PIMS Statement of Applicability",icon:Fe,description:"Applicability of ISO 27701 Annex A/B controls",category:"governance"},{key:"risk_assessment",label:"PII Risk Assessment",icon:I,description:"Risk assessment covering privacy and PII processing risks",category:"governance"},{key:"internal_audit_program",label:"Internal Audit Program",icon:Q,description:"Audit plan covering PIMS requirements",category:"governance"},{key:"management_review_minutes",label:"Management Review Minutes",icon:P,description:"Minutes covering PIMS performance and privacy metrics",category:"governance"},{key:"dsr_procedure",label:"Data Subject Rights Procedure",icon:Is,description:"Procedures for handling access, erasure, portability, and objection requests",category:"operational"},{key:"consent_records",label:"Consent Management Records",icon:re,description:"Records of consent collection, withdrawal, and management",category:"operational"},{key:"dpa_agreements",label:"Data Processing Agreements",icon:Rs,description:"DPAs with processors and sub-processors per GDPR Art. 28",category:"operational"},{key:"transfer_safeguards",label:"Cross-Border Transfer Safeguards",icon:Pe,description:"SCCs, BCRs, or adequacy decisions for international PII transfers",category:"operational"},{key:"breach_notification",label:"Breach Notification Procedure + Logs",icon:I,description:"Data breach notification procedures and incident records",category:"operational"},{key:"privacy_training",label:"Privacy Training Records",icon:P,description:"Privacy awareness training completion records for PII handlers",category:"operational"}]:m==="ISO42001"?[{key:"aims_scope",label:"AIMS Scope Statement",icon:Pe,description:"Defines the boundaries and applicability of your AI Management System",category:"governance"},{key:"ai_policy",label:"AI Policy",icon:Ka,description:"Top-level policy for responsible AI development and deployment",category:"governance"},{key:"ai_risk_assessment",label:"AI Risk Assessment",icon:I,description:"Risk asse
1ssment covering AI system risks including bias, safety, and societal impact",category:"governance"},{key:"ai_impact_assessment",label:"AI Impact Assessment",icon:Rs,description:"Assessment of AI system impacts on individuals, groups, and society",category:"governance"},{key:"aims_soa",label:"AIMS Statement of Applicability",icon:Fe,description:"Applicability of ISO 42001 Annex A controls",category:"governance"},{key:"ai_system_inventory",label:"AI System Inventory",icon:Q,description:"Register of AI systems with purpose, risk classification, and lifecycle stage",category:"governance"},{key:"internal_audit_program",label:"Internal Audit Program",icon:Q,description:"Audit plan covering AIMS requirements and AI-specific controls",category:"governance"},{key:"management_review_minutes",label:"Management Review Minutes",icon:P,description:"Minutes covering AIMS performance and AI governance metrics",category:"governance"},{key:"model_documentation",label:"Model Cards / Documentation",icon:P,description:"Technical documentation of AI models including architecture, training data, and performance metrics",category:"operational"},{key:"fairness_testing",label:"Fairness & Bias Testing Reports",icon:Qa,description:"Testing results for algorithmic fairness, bias detection, and mitigation measures",category:"operational"},{key:"human_oversight",label:"Human Oversight Procedures",icon:Is,description:"Procedures for human oversight, intervention, and override of AI decisions",category:"operational"},{key:"data_governance",label:"AI Data Governance Records",icon:X,description:"Data quality, provenance, and governance documentation for training/evaluation data",category:"operational"},{key:"monitoring_logs",label:"AI System Monitoring Logs",icon:Tt,description:"Performance monitoring, drift detection, and operational logs for AI systems",category:"operational"},{key:"ai_training_records",label:"AI Competency Training Records",icon:P,description:"Training records for personnel involved in AI development and operations",category:"operational"}]:[{key:"isms_scope",label:"ISMS Scope Statement",icon:Pe,description:"Defines the boundaries and applicability of your ISMS",category:"governance"},{key:"isms_policy",label:"Information Security Policy",icon:Z,description:"Top-level ISMS policy with management approval",category:"governance"},{key:"risk_assessment",label:"Risk Assessment",icon:I,description:"Latest risk assessment including risk register and methodology",category:"governance"},{key:"risk_treatment_plan",label:"Risk Treatment Plan",icon:Q,description:"Maps controls to identified risks with treatment plans",category:"governance"},{key:"soa",label:"Statement of Applicability (SoA)",icon:Fe,description:"Lists all Annex A controls and their applicability status",category:"governance"},{key:"internal_audit_program",label:"Internal Audit Program",icon:Q,description:"Audit plan, schedule, and program documentation",category:"governance"},{key:"management_review_minutes",label:"Management Review Minutes",icon:P,description:"Minutes from latest management review meeting",category:"governance"},{key:"access_control",label:"Access Control Procedure + Reviews",icon:Z,description:"Access management procedure and periodic access review records",category:"operational"},{key:"change_management",label:"Change Management Procedure + Tickets",icon:P,description:"Change management process and sample change tickets",category:"operational"},{key:"incident_management",label:"Incident Management Procedure + Logs",icon:I,description:"Incident response procedure and incident log records",category:"operational"},{key:"vulnerability_scans",label:"Vulnerability Scan Reports",icon:X,description:"Latest vulnerability assessment and scan results",category:"operational"},{key:"patch_management",label:"Patch Management Evidence",icon:re,description:"Patch management process and deployment records",category:"operational"},{key:"backup_restore",label:"Backup Procedure + Restore Test",icon:P,description:"Backup procedures and restore test documentation",category:"operational"},{key:"asset_inventory",label:"Asset Inventory",icon:Q,description:"Current inventory of information assets",category:"operational"},{key:"supplier_assessment",label:"Supplier Assessment Records",icon:P,description:"Third-party supplier risk assessments and reviews",category:"operational"},{key:"training_records",label:"Training Records",icon:P,description:"Security awareness training records and completion evidence",category:"operational"}],ce=vt.filter(t=>t.category==="governance"),Ae=vt.filter(t=>t.category==="operational"),Nt=te.filter(t=>ce.some(s=>s.key===t.artifactKey)&&t.parseStatus==="parsed").length,kt=te.filter(t=>Ae.some(s=>s.key===t.artifactKey)&&t.parseStatus==="parsed").length,yt=Nt===ce.length,us=async(t,s)=>{Bs(r=>new Map(r).set(t,s));let a=g;if(!a){const r=j.trim()||"Untitled Organization";j.trim()||T(r);try{a=(await B.mutateAsync({clientName:r,framework:m||"ISO27001",status:"draft",periodStart:v||null,periodEnd:h||null})).id}catch(i){console.error("Error creating audit:",i),x.error("Failed to create audit. Please try again.");return}}if(te.length===0)try{const r=await Ie.initialize(a);ze(r)}catch(r){console.error("Failed to initialize mandatory artifacts:",r),x.error("Failed to initialize artifacts.");return}try{const r=await Ie.update(a,t,{fileName:s.name,fileSize:s.size,fileType:s.type,file:s});ze(i=>i.map(o=>o.artifactKey===t?r:o)),gs(a,t)}catch(r){console.error("Failed to update artifact:",r),x.error(`Failed to upload ${s.name}`)}},ya={isms_scope:["scope","isms scope","isms_scope","boundaries"],isms_policy:["security policy","isms policy","information security policy","infosec policy"],risk_assessment:["risk assessment","risk_assessment","risk register","risk report"],risk_treatment_plan:["risk treatment","risk_treatment","treatment plan","rtp"],soa:["soa","statement of applicability","applicability"],internal_audit_program:["internal audit","audit program","audit plan"],management_review_minutes:["management review","mgmt review","management minutes"],access_control:["access control","access review","access_control"],change_management:["change management","change_management","change ticket"],incident_management:["incident","incident management","incident_management"],vulnerability_scans:["vulnerability","vuln scan","vulnerability_scan"],patch_management:["patch management","patch_management","patching"],backup_restore:["backup","restore","backup_restore"],asset_inventory:["asset inventory","asset_inventory","asset register"],supplier_assessment:["supplier","vendor","third party","supplier_assessment"],training_records:["training","awareness","training_records"]},wa=t=>{const s=t.toLowerCase(),a=new Set(te.filter(r=>r.parseStatus==="parsed"||r.parseStatus==="uploading").map(r=>r.artifactKey));for(const[r,i]of Object.entries(ya))if(!a.has(r)){for(const o of i)if(s.includes(o.replace(/\s+/g,"_"))||s.includes(o.replace(/\s+/g,"-"))||s.includes(o.replace(/\s+/g," ")))return r}return null},wt=n.useCallback(async t=>{if(t.length===0)return;Jt(t.length);let s=0,a=[];for(const r of t){const i=wa(r.name);i?(s++,await us(i,r)):a.push(r.name)}Jt(0),s>0&&x.success(`${s} file(s) matched and uploaded to checklist items`),a.length>0&&x.info(`${a.length} file(s) could not be auto-matched: ${a.join(", ")}. Upload them individually.`)},[te,g,j,v,h]),Sa=n.useCallback(t=>{t.preventDefault(),ht(!0)},[]),Aa=n.useCallback(t=>{t.preventDefault(),ht(!1)},[]),Ca=n.useCallback(t=>{t.preventDefault(),ht(!1);const s=Array.from(t.dataTransfer.files);wt(s)},[wt]),Ia=t=>{t.target.files&&(wt(Array.from(t.target.files)),t.target.value="")},gs=async(t,s)=>{if(!s)return;const a=t||g;if(a){Qt(s);try{const r=await Ie.parse(a,s);if(ze(i=>i.map(o=>o.artifactKey===s?r:o)),s==="isms_scope"&&r.extractedData){const i=r.extractedData;i.organizationName&&T(i.organizationName),i.locations&&Array.isArray(i.locations)&&be(i.locations),i.inScopeSystems&&Array.isArray(i.inScopeSystems)&&je(i.inScopeSystems),i.inScopeProcesses&&Array.isArray(i.inScopeProcesses)&&Oe(i.inScopeProcesses),i.scopeStatement&&ct(i.scopeStatement)}if(s==="soa"&&r.extractedData){const i=r.extractedData;(i.controls||i.applicableControls)&&ge({message:r.parseSummary||"SoA parsed from mandatory documents",summary:r.parseSummary||void 0,controls:i.controls||[],applicableControls:i.applicableControls,excludedControls:i.excludedControls,totalControls:i.totalControls})}try{const i=await Ie.readiness(a);Yt(i)}catch(i){console.error("Failed to check readiness:",i)}x.success(`${vt.find(i=>i.key===s)?.label||s} parsed successfully`)}catch(r){console.error("Failed to parse artifact:",r),x.error("Failed to parse document. Please try again."),ze(i=>i.map(o=>o.artifactKey===s?{...o,parseStatus:"failed"}:o))}finally{Qt(null)}}},Pa=async()=>
1{if(!g){x.error("Please upload at least one document first.");return}try{const t=await Ie.readiness(g);if(Yt(t),!t.ready){const s=t.missing.map(a=>a.label).join(", ");x.error(`Missing required documents: ${s}`);return}N("scope-context")}catch(t){if(console.error("Failed to check readiness:",t),!yt){const s=ce.filter(a=>!te.find(r=>r.artifactKey===a.key&&r.parseStatus==="parsed"));x.error(`Please upload and parse all governance documents. Missing: ${s.map(a=>a.label).join(", ")}`);return}N("scope-context")}},Ra=async()=>{if(!g){x.error("No audit in progress");return}const t=m==="ISO27001"||m==="ISO27701"||m==="ISO42001";try{N(t?"run-audit":"processing"),W(30);const s=await ft.mutateAsync(g);W(100),setTimeout(()=>N(t?"results":"review"),500),x.success("Audit processing complete!")}catch(s){console.error("Error processing audit:",s),x.error("Failed to process audit. Please try again."),t?(N("review-readiness"),k("results")):N("validation-results")}};return e.jsx(Ea,{children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx(Ve,{href:"/dashboard",className:"text-sm text-slate-500 hover:text-slate-800 mb-2 inline-block","data-testid":"link-back-dashboard",children:"← Back to Dashboard"}),e.jsx("h1",{className:"text-3xl font-display font-bold text-slate-900 dark:text-white",children:"Run New Audit"}),e.jsx("p",{className:"text-slate-500 mt-2",children:d==="select-framework"?"Select the compliance framework you want to audit against.":d==="mandatory-docs"?"Upload the required governance and operational documents for ISO 27001 internal audit.":d==="scope-context"?"Define your audit scope, client details, and Statement of Applicability.":d==="upload-evidence"?"Upload evidence files to validate against your ISO 27001 controls.":d==="review-readiness"?"Review evidence validation before running the full audit.":d==="run-audit"?"Running ISO 27001 compliance audit analysis.":d==="results"?"Audit analysis complete. Review your compliance results.":d==="client-info"?"Enter client information for this audit.":d==="upload"?"Upload evidence files to validate.":d==="validating"?"Validating your evidence files...":d==="validation-results"?"Review evidence validation before running the full audit.":`Running ${at(m)} compliance audit.`})]}),d!=="select-framework"&&m==="ISO27001"&&e.jsxs("div",{className:"flex items-center mb-12 relative",children:[e.jsx("div",{className:"absolute left-0 top-1/2 w-full h-0.5 bg-slate-200 dark:bg-slate-700 -z-10"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="mandatory-docs"&&"font-bold text-primary"),"data-testid":"step-indicator-mandatory-docs",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["mandatory-docs","scope-context","upload-evidence","review-readiness","run-audit","results"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"1"}),e.jsx("span",{className:"text-xs uppercase tracking-wider whitespace-nowrap",children:"Required Docs"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="scope-context"&&"font-bold text-primary"),"data-testid":"step-indicator-scope-context",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["scope-context","upload-evidence","review-readiness","run-audit","results"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"2"}),e.jsx("span",{className:"text-xs uppercase tracking-wider whitespace-nowrap",children:"Scope & Context"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="upload-evidence"&&"font-bold text-primary"),"data-testid":"step-indicator-upload-evidence",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["upload-evidence","review-readiness","run-audit","results"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"3"}),e.jsx("span",{className:"text-xs uppercase tracking-wider whitespace-nowrap",children:"Upload Evidence"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="review-readiness"&&"font-bold text-primary"),"data-testid":"step-indicator-review-readiness",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["review-readiness","run-audit","results"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider whitespace-nowrap",children:"Review Readiness"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="run-audit"&&"font-bold text-primary"),"data-testid":"step-indicator-run-audit",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["run-audit","results"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"5"}),e.jsx("span",{className:"text-xs uppercase tracking-wider whitespace-nowrap",children:"Run Audit"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="results"&&"font-bold text-primary"),"data-testid":"step-indicator-results-iso",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",d==="results"?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"6"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Results"})]})]}),d!=="select-framework"&&m==="SOC2"&&e.jsxs("div",{className:"flex items-center mb-12 relative",children:[e.jsx("div",{className:"absolute left-0 top-1/2 w-full h-0.5 bg-slate-200 dark:bg-slate-700 -z-10"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10"),"data-testid":"step-indicator-framework",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2","border-primary bg-primary text-white"),children:"1"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Framework"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="client-info"&&"font-bold text-primary"),"data-testid":"step-indicator-client",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["client-info","upload","validating","validation-results","processing","review"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"2"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Client"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="upload"&&"font-bold text-primary"),"data-testid":"step-indicator-upload",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["upload","validating","validation-results","processing","review"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"3"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Upload"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",(d==="validating"||d==="validation-results")&&"font-bold text-primary"),"data-testid":"step-indicator-validate",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["validating","validation-results","processing","review"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Validate"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="processing"&&"font-bold text-primary"),"data-testid":"step-indicator-analysis",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",["processing","review"].includes(d)?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"5"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Analysis"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:l("flex flex-col items-center gap-2 bg-slate-50 dark:bg-slate-900 px-4 z-10",d==="review"&&"font-bold text-primary"),"data-testid":"step-indicator-results",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center text-sm border-2",d==="review"?"border-primary bg-primary text-white":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-500"),children:"6"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Results"})]})]}),d==="select-framework"&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[{key:"ISO27001",label:"ISO 27001",desc:"Information Security Management Systems (ISMS) — ISO/IEC 27001:2022.",icon:Pe,color:"indigo"},{key:"ISO27701",label:"ISO 27701",desc:"Privacy Information Management — extension to ISO 27001 for GDPR & privacy.",icon:X,color:"purple"},{key:"ISO42001",label:"ISO 42001",desc:"AI Management System — responsible development and use of AI systems.",icon:Dt,color:"cyan"},{key:"SOC2",label:"SOC 2 Type I / II",desc:"AICPA Trust Services Criteria — Security, Availability, Confidentiality, Privacy.",icon:Z,color:"blue"},{key:"SOX_ITGC",label:"SOX ITGCs",desc:"IT General Controls for Sarbanes-Oxley financial reporting compliance.",icon:ys,color:"amber"},{key:"NIST_CSF",label:"NIST CSF",desc:"Cybersecurity Framework — Identify, Protect, Detect, Respond, Recover.",icon:X,color:"emerald"},{key:"NIST_RMF_AI",label:"NIST RMF AI",desc:"AI Risk Management Framework — governance, mapping, measurement, management of AI risk.",icon:Tt,color:"rose"},{key:"HIPAA_HITRUST",label:"HIPAA / HITRUST",desc:"Healthcare data protection — HIPAA Security Rule with HITRUST CSF mapping.",icon:re,color:"teal"}].map(t=>{const s=t.icon,a={indigo:{bg:"bg-indigo-50 dark:bg-indigo-900/30",hover:"group-hover:bg-indigo-100 dark:group-hover:bg-indigo-900/50",text:"text-indigo-600 dark:text-indigo-400"},purple:{bg:"bg-purple-50 dark:bg-purple-900/30",hover:"group-hover:bg-purple-100 dar
1k:group-hover:bg-purple-900/50",text:"text-purple-600 dark:text-purple-400"},cyan:{bg:"bg-cyan-50 dark:bg-cyan-900/30",hover:"group-hover:bg-cyan-100 dark:group-hover:bg-cyan-900/50",text:"text-cyan-600 dark:text-cyan-400"},blue:{bg:"bg-blue-50 dark:bg-blue-900/30",hover:"group-hover:bg-blue-100 dark:group-hover:bg-blue-900/50",text:"text-blue-600 dark:text-blue-400"},amber:{bg:"bg-amber-50 dark:bg-amber-900/30",hover:"group-hover:bg-amber-100 dark:group-hover:bg-amber-900/50",text:"text-amber-600 dark:text-amber-400"},emerald:{bg:"bg-emerald-50 dark:bg-emerald-900/30",hover:"group-hover:bg-emerald-100 dark:group-hover:bg-emerald-900/50",text:"text-emerald-600 dark:text-emerald-400"},rose:{bg:"bg-rose-50 dark:bg-rose-900/30",hover:"group-hover:bg-rose-100 dark:group-hover:bg-rose-900/50",text:"text-rose-600 dark:text-rose-400"},teal:{bg:"bg-teal-50 dark:bg-teal-900/30",hover:"group-hover:bg-teal-100 dark:group-hover:bg-teal-900/50",text:"text-teal-600 dark:text-teal-400"}},r=a[t.color]||a.blue;return e.jsx(b,{className:"cursor-pointer hover:border-primary hover:shadow-md transition-all group",onClick:()=>pa(t.key),"data-testid":`card-framework-${t.key.toLowerCase()}`,children:e.jsxs(f,{className:"p-6 flex flex-col items-center text-center",children:[e.jsx("div",{className:l("w-12 h-12 rounded-full flex items-center justify-center mb-4 transition-colors",r.bg,r.hover,r.text),children:e.jsx(s,{className:"h-6 w-6"})}),e.jsx("h3",{className:"text-base font-bold text-slate-900 dark:text-white mb-1.5",children:t.label}),e.jsx("p",{className:"text-xs text-slate-500 mb-4 leading-relaxed",children:t.desc}),e.jsxs(p,{className:"w-full",variant:"outline",size:"sm",children:["Select ",t.label.split(" ")[0]]})]})},t.key)})}),d==="mandatory-docs"&&(()=>{const t=s=>{const a=te.find(C=>C.artifactKey===s.key),r=Gs.get(s.key),i=qs===s.key,o=s.icon,u=a?.parseStatus||"not_uploaded",y=Vs===s.key;return e.jsxs("div",{className:l("border rounded-lg p-4 transition-all",u==="parsed"?"border-green-200 bg-green-50 dark:border-green-800 dark:bg-green-950/30":u==="failed"?"border-red-200 bg-red-50 dark:border-red-800 dark:bg-red-950/30":i?"border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-950/30":r||a?.fileName?"border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30":"border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-800"),"data-testid":`mandatory-artifact-${s.key}`,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:l("w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",u==="parsed"?"bg-green-100 dark:bg-green-900/50":u==="failed"?"bg-red-100 dark:bg-red-900/50":i?"bg-blue-100 dark:bg-blue-900/50":"bg-slate-100 dark:bg-slate-700"),children:e.jsx(o,{className:l("h-5 w-5",u==="parsed"?"text-green-600":u==="failed"?"text-red-600":i?"text-blue-600":"text-slate-500")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100","data-testid":`text-artifact-label-${s.key}`,children:s.label}),u==="parsed"&&e.jsx(H,{className:"h-4 w-4 text-green-600"}),u==="failed"&&e.jsx(z,{className:"h-4 w-4 text-red-600"}),i&&e.jsx(D,{className:"h-4 w-4 text-blue-600 animate-spin"})]}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-0.5",children:s.description}),(r||a?.fileName)&&!i&&u!=="parsed"&&u!=="failed"&&e.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-400 mt-1 flex items-center gap-1",children:[e.jsx(_t,{className:"h-3 w-3"}),r?.name||a?.fileName]}),i&&e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-400 mt-1 flex items-center gap-1",children:[e.jsx(D,{className:"h-3 w-3 animate-spin"}),"Analyzing document with AI..."]}),u==="parsed"&&a?.parseSummary&&e.jsxs("button",{className:"text-xs text-green-700 dark:text-green-400 mt-1 flex items-center gap-1 hover:underline cursor-pointer",onClick:()=>Hs(y?null:s.key),"data-testid":`button-expand-artifact-${s.key}`,children:[y?e.jsx(rt,{className:"h-3 w-3"}):e.jsx(pe,{className:"h-3 w-3"}),y?"Hide details":"View analysis details"]}
1),u==="failed"&&e.jsx("p",{className:"text-xs text-red-700 dark:text-red-400 mt-1",children:"Parsing failed. Please try again."})]}),e.jsxs("div",{className:"flex-shrink-0",children:[u==="failed"&&e.jsxs(p,{size:"sm",variant:"outline",className:"text-red-600 border-red-300 hover:bg-red-50 dark:hover:bg-red-950/50",onClick:()=>gs(g||void 0,s.key),disabled:i,"data-testid":`button-retry-artifact-${s.key}`,children:[e.jsx(Cs,{className:"h-3 w-3 mr-1"}),"Retry"]}),u!=="parsed"&&!i&&u!=="failed"&&e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"file",className:"hidden",id:`mandatory-artifact-file-${s.key}`,accept:".pdf,.docx,.doc,.xlsx,.xls,.csv,.txt",onChange:C=>{const R=C.target.files?.[0];R&&us(s.key,R),C.target.value=""},"data-testid":`input-file-artifact-${s.key}`}),e.jsxs(p,{size:"sm",variant:"outline",onClick:()=>document.getElementById(`mandatory-artifact-file-${s.key}`)?.click(),"data-testid":`button-upload-artifact-${s.key}`,children:[e.jsx(Je,{className:"h-3 w-3 mr-1"}),r||a?.fileName?"Replace":"Upload"]})]}),u==="parsed"&&e.jsx("span",{className:"text-xs font-medium text-green-700 bg-green-100 dark:bg-green-900/50 dark:text-green-400 px-2 py-1 rounded-full","data-testid":`badge-parsed-${s.key}`,children:"✓ Parsed"})]})]}),y&&a&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-green-200 dark:border-green-800 space-y-3 animate-in fade-in slide-in-from-top-2 duration-300","data-testid":`artifact-details-${s.key}`,children:[a.parseSummary&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300 mb-1",children:"Summary"}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:a.parseSummary})]}),a.extractedData&&typeof a.extractedData=="object"&&Object.keys(a.extractedData).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300 mb-2",children:"Extracted Data"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Object.entries(a.extractedData).map(([C,R])=>e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded p-2 border border-green-100 dark:border-green-800",children:[e.jsx("p",{className:"text-xs font-medium text-slate-500 dark:text-slate-400 capitalize",children:C.replace(/([A-Z])/g," $1").replace(/_/g," ")}),e.jsx("p",{className:"text-sm text-slate-800 dark:text-slate-200 truncate",children:Array.isArray(R)?R.join(", "):String(R)})]},C))})]}),a.validationFlags&&a.validationFlags.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-slate-700 dark:text-slate-300 mb-1",children:"Warnings"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:a.validationFlags.map((C,R)=>e.jsxs("span",{className:"text-xs bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-400 px-2 py-0.5 rounded-full","data-testid":`badge-warning-${s.key}-${R}`,children:["⚠ ",C]},R))})]})]})]},s.key)};return e.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[e.jsx(b,{children:e.jsxs(f,{className:"p-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"w-10 h-10 bg-amber-100 rounded-full flex items-center justify-center",children:e.jsx(Z,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-slate-100","data-testid":"heading-mandatory-docs",children:"ISO 27001 Audit Document Checklist"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Upload governance documents (required) and operational evidence (recommended) for your internal audit."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-2",children:[e.jsxs("div",{"data-testid":"governance-progress",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:"Governance Documents"}),e.jsxs("span",{className:"text-slate-500",children:[Nt," of ",ce.length," ready"]})]}),e.jsx(J,{value:Nt/ce.length*100,className:"h-2"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:"Required to proceed"})]}),e.jsxs("div",{"data-testid":"operational-progress",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:"Operational Evidence"}),e.jsxs("span",{className:"text-slate-500",children:[kt," of ",Ae.length," ready"]})]}),e.jsx(J,{value:Ae.length>0?kt/Ae.length*100:0,className:"h-2"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:"Recommended for thorough audit"})]})]})]})}),e.jsxs("div",{className:l("border-2 border-dashed rounded-xl p-8 text-center transition-all cursor-pointer",Xs?"border-primary bg-primary/5 scale-[1.01] shadow-lg":"border-slate-300 dark:border-slate-600 hover:border-primary/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"),onDragOver:Sa,onDragLeave:Aa,onDrop:Ca,onClick:()=>es.current?.click(),"data-testid":"bulk-artifact-dropzone",children:[Zt>0?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(D,{className:"w-10 h-10 text-primary animate-spin"}),e.jsxs("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:["Uploading & matching ",Zt," file(s)..."]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-10 h-10 mx-auto mb-3 text-slate-400 dark:text-slate-500"}),e.jsx("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Drag & drop all your files here, or click to browse"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:'Files will be automatically matched to checklist items by name (e.g. "ISMS_Scope.pdf" → ISMS Scope Statement)'})]}),e.jsx("input",{ref:es,type:"file",multiple:!0,className:"hidden",accept:".pdf,.docx,.doc,.xlsx,.xls,.csv,.txt",onCh
1ange:Ia,"data-testid":"input-bulk-artifact-upload"})]}),e.jsx(b,{children:e.jsxs(f,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(X,{className:"h-5 w-5 text-blue-600"}),e.jsx("h4",{className:"font-bold text-slate-900 dark:text-slate-100","data-testid":"heading-governance-docs",children:"Governance Documents"}),e.jsx(O,{className:"bg-red-100 text-red-700 border-red-200 dark:bg-red-900/30 dark:text-red-400 dark:border-red-800 shadow-none text-xs",children:"Required"})]}),e.jsx("div",{className:"space-y-3",children:ce.map(s=>t(s))})]})}),e.jsx(b,{children:e.jsxs(f,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Q,{className:"h-5 w-5 text-purple-600"}),e.jsx("h4",{className:"font-bold text-slate-900 dark:text-slate-100","data-testid":"heading-operational-docs",children:"Operational Evidence"}),e.jsx(O,{className:"bg-blue-100 text-blue-700 border-blue-200 dark:bg-blue-900/30 dark:text-blue-400 dark:border-blue-800 shadow-none text-xs",children:"Recommended"})]}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mb-4",children:"These operational documents strengthen your audit. You can proceed without them, but they are recommended for a thorough assessment."}),e.jsx("div",{className:"space-y-3",children:Ae.map(s=>t(s))})]})}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx(p,{variant:"ghost",onClick:()=>{N("select-framework"),S(null)},className:"text-slate-500 dark:text-slate-400","data-testid":"button-back-from-mandatory-docs",children:"Back to Framework Selection"}),e.jsxs("div",{className:"flex items-center gap-3",children:[!yt&&kt>0&&e.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:"Complete all governance documents to proceed"}),e.jsxs(p,{size:"lg",onClick:Pa,disabled:!yt,className:"gap-2 shadow-lg shadow-primary/20","data-testid":"button-mandatory-docs-continue",children:["Continue to Scope & Context ",e.jsx(Re,{className:"h-4 w-4"})]})]})]})]})})(),d==="scope-context"&&e.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[V&&V.status!=="none"&&e.jsx(b,{"data-testid":"scope-profile-banner",className:l("border-2",V.status==="needs_confirmation"&&!ne?"border-amber-400 bg-amber-50 dark:border-amber-600 dark:bg-amber-900/20":"border-green-400 bg-green-50 dark:border-green-600 dark:bg-green-900/20"),children:e.jsx(f,{className:"p-6",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:V.status==="needs_confirmation"&&!ne?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-5 w-5 text-amber-600"}),e.jsx("h3",{className:"font-semibold text-amber-900",children:"Scope Profile — Needs Confirmation"})]}):e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"h-5 w-5 text-green-600"}),e.jsx("h3",{className:"font-semibold text-green-900",children:ne?"Scope Profile — Confirmed":"Scope Profile — Auto-filled"})]})}),e.jsxs("p",{className:"text-sm text-slate-600 dark:text-slate-400 mb-1",children:["AI extracted scope data from your uploaded documents.",V.confidence!==null&&e.jsxs("span",{className:l("ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",V.confidence>=70?"bg-green-100 text-green-800":"bg-amber-100 text-amber-800"),children:["Confidence: ",V.confidence,"%"]})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Fields below have been pre-filled from the scope document. You can edit any values before proceeding."})]}),V.status==="needs_confirmation"&&!ne&&e.jsxs(p,{"data-testid":"btn-confirm-scope-profile",onClick:Js,className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),"Confirm Scope"]})]})})}),Zs&&e.jsx(b,{className:"border-blue-200 dark:border-blue-800/50 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs(f,{className:"p-4 flex items-center gap-3",children:[e.jsx(D,{className:"h-5 w-5 animate-spin text-blue-600"}),e.jsx("span",{className:"text-sm text-blue-800",children:"Loading scope profile..."})]})}),e.jsx(b,{children:e.jsxs(f,{className:"p-8 space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{htmlFor:"scope-client-name",children:"Organization Name"}),e.jsx(xe,{id:"scope-client-name","data-testid":"input-scope-client-name",placeholder:"e.g., Acme Corporation",value:j,onChange:t=>T(t.target.value),className:"text-lg"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Enter the name of the organization being audited."})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-white mb-2",children:"Selected Framework"}),e.jsx("p",{className:"text-lg text-primary font-bold",children:"ISO 27001:2022"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"Audit Perio
1d Start"}),e.jsxs(He,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:l("w-full justify-start text-left font-normal",!v&&"text-muted-foreground"),"data-testid":"button-scope-period-start",children:[e.jsx(et,{className:"mr-2 h-4 w-4"}),v?tt(v,"PPP"):"Select start date"]})}),e.jsx(Ke,{className:"w-auto p-0",align:"start",children:e.jsx(We,{mode:"single",selected:v,onSelect:Te,startMonth:Qe(new Date,5),endMonth:new Date})})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"When the audit period begins."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"Audit Period End"}),e.jsxs(He,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:l("w-full justify-start text-left font-normal",!h&&"text-muted-foreground"),"data-testid":"button-scope-period-end",children:[e.jsx(et,{className:"mr-2 h-4 w-4"}),h?tt(h,"PPP"):"Select end date"]})}),e.jsx(Ke,{className:"w-auto p-0",align:"start",children:e.jsx(We,{mode:"single",selected:h,onSelect:_e,startMonth:Qe(ne
1w Date,5),endMonth:new Date,disabled:t=>v?t<v:!1})})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"When the audit period ends."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{htmlFor:"scope-isms-scope",children:"ISMS Scope Statement"}),e.jsx(Rt,{id:"scope-isms-scope","data-testid":"input-scope-isms-scope",placeholder:"Describe the scope of your Information Security Management System...",value:he,onChange:t=>ct(t.target.value),rows:4}),e.jsx("p",{className:"text-xs text-slate-500",children:"Define the boundaries and applicability of your ISMS."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"Sites / Locations"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xe,{"data-testid":"input-scope-new-site",placeholder:"e.g., HQ - London, UK",value:fe,onChange:t=>mt(t.target.value),onKeyDown:t=>{t.key==="Enter"&&fe.trim()&&(t.preventDefault(),be(s=>[...s,fe.trim()]),mt(""))}}),e.jsx(p,{type:"button",variant:"outline",size:"icon","data-testid":"button-scope-add-site",onClick:()=>{fe.trim()&&(be(t=>[...t,fe.trim()]),mt(""))},children:e.jsx(st,{className:"h-4 w-4"})})]}),ie.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:ie.map((t,s)=>e.jsxs("span",{"data-testid":`tag-site-${s}`,className:"inline-flex items-center gap-1 bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200 text-sm px-3 py-1 rounded-full",children:[t,e.jsx("button",{type:"button",onClick:()=>be(a=>a.filter((r,i)=>i!==s)),className:"text-slate-500 hover:text-red-500",children:e.jsx(me,{className:"h-3 w-3"})})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"In-scope Systems / Applications"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xe,{"data-testid":"input-scope-new-system",placeholder:"e.g., AWS Cloud Infrastructure",value:ve,onChange:t=>xt(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ve.trim()&&(t.preventDefault(),je(s=>[...s,ve.trim()]),xt(""))}}),e.jsx(p,{type:"button",variant:"outline",size:"icon","data-testid":"button-scope-add-system",onClick:()=>{ve.trim()&&(je(t=>[...t,ve.trim()]),xt(""))},children:e.jsx(st,{className:"h-4 w-4"})})]}),le.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:le.map((t,s)=>e.jsxs("span",{"data-testid":`tag-system-${s}`,className:"inline-flex items-center gap-1 bg-blue-50 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300 text-sm px-3 py-1 rounded-full",children:[t,e.jsx("button",{type:"button",onClick:()=>je(a=>a.filter((r,i)=>i!==s)),className:"text-blue-500 hover:text-red-500",children:e.jsx(me,{className:"h-3 w-3"})})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"In-scope Business Processes"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xe,{"data-testid":"input-scope-new-process",placeholder:"e.g., Software Development Lifecycle",value:ke,onChange:t=>pt(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ke.trim()&&(t.preventDefault(),Oe(s=>[...s,ke.trim()]),pt(""))}}),e.jsx(p,{type:"button",variant:"outline",size:"icon","data-testid":"button-scope-add-process",onClick:()=>{ke.trim()&&(Oe(t=>[...t,ke.trim()]),pt(""))},children:e.jsx(st,{className:"h-4 w-4"})})]}),Ne.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:Ne.map((t,s)=>e.jsxs("span",{"data-testid":`tag-process-${s}`,className:"inline-flex items-center gap-1 bg-green-50 dark:bg-green-900/30 text-green-800 dark:text-green-300 text-sm px-3 py-1 rounded-full",children:[t,e.jsx("button",{type:"button",onClick:()=>Oe(a=>a.filter((r,i)=>i!==s)),className:"text-green-500 hover:text-red-500",children:e.jsx(me,{className:"h-3 w-3"})})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"Out-of-scope Items"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xe,{"data-testid":"input-scope-new-outofscope",placeholder:"e.g., Physical security of third-party data centers",value:ye,onChange:t=>ut(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ye.trim()&&(t.preventDefault(),$e(s=>[...s,ye.trim()]),ut(""))}}),e.jsx(p,{type:"button",variant:"outline",size:"icon","data-testid":"button-scope-add-outofscope",onClick:()=>{ye.trim()&&($e(t=>[...t,ye.trim()]),ut(""))},children:e.jsx(st,{className:"h-4 w-4"})})]}),Ee.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:Ee.map((t,s)=>e.jsxs("span",{"data-testid":`tag-outofscope-${s}`,className:"inline-flex items-center gap-1 bg-amber-50 dark:bg-amber-900/30 text-amber-800 dark:text-amber-300 text-sm px-3 py-1 rounded-full",children:[t,e.jsx("button",{type:"button",onClick:()=>$e(a=>a.filter((r,i)=>i!==s)),className:"text-amber-500 hover:text-red-500",children:e.jsx(me,{className:"h-3 w-3"})})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{htmlFor:"scope-interested-parties",children:"Interested Parties (Optional)"}),e.jsx(Rt,{id:"scope-interested-parties","data-testid":"input-scope-interested-parties",placeholder:"List interested parties and their requirements...",value:Kt,onChange:t=>Ls(t.target.value),rows:3}),e.jsx("p",{className:"text-xs text-slate-500",children:"Identify interested parties and their information security requirements."})]}),e.jsxs("div",{className:"border-t border-slate-200 dark:border-slate-700 pt-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"w-12 h-12 bg-indigo-100 text-indigo-600 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx(Fe,{className:"h-6 w-6"})}),e.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-white mb-1","data-testid":"heading-scope-soa-upload",children:"Statement of Applicability (Optional)"}),e.jsx("p",{className:"text-sm text-slate-500","data-testid":"text-scope-soa-description",children:"Upload your SoA to define which Annex A controls are in scope"})]}),e.jsxs("div",{className:l("border-2 border-dashed rounded-xl p-8 text-center transition-all duration-200 cursor-pointer",_s?"border-primary bg-indigo-50/50 dark:bg-indigo-900/20 scale-[1.01]":"border-slate-300 dark:border-slate-600 hover:border-slate-400 bg-slate-50 dark:bg-slate-800/50"),onDragOver:ba,onDragLeave:fa,onDrop:ja,onClick:()=>document.getElementById("scope-soa-file-upload")?.click(),"data-testid":"dropzone-scope-soa",children:[e.jsx("input",{type:"file",id:"scope-soa-file-upload",accept:".pdf,.docx,.xls,.xlsx,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",className:"hidden",onChange:va,"data-testid":"input-scope-soa-file"}),G?e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-indigo-100 text-indigo-600 rounded-full flex items-center justify-center",children:e.jsx(_t,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900 dark:text-white","data-testid":"text-scope-soa-filename",children:G.name}),e.jsxs("p",{className:"text-xs text-slate-500",children:[(G.size/1024).toFixed(0)," KB"]}
1)]}),e.jsxs(p,{variant:"ghost",size:"sm",className:"text-red-500",onClick:t=>{t.stopPropagation(),lt(null),ge(null)},"data-testid":"button-scope-remove-soa",children:[e.jsx(me,{className:"h-4 w-4 mr-1"}),"Remove"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-12 h-12 bg-indigo-100 text-indigo-600 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Je,{className:"h-6 w-6"})}),e.jsx("h4",{className:"font-bold text-slate-900 dark:text-white mb-1",children:"Click or drag file to upload"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Accepts PDF, DOCX, XLS, XLSX files"})]})]}),G&&!w&&e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx(p,{size:"lg",onClick:Na,disabled:Se.isPending||B.isPending,className:"gap-2","data-testid":"button-scope-parse-soa",children:Se.isPending?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 animate-spin"}),"Parsing SoA..."]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-4 w-4"}),"Parse SoA"]})})}),w&&e.jsxs("div",{className:"mt-6 bg-emerald-50 dark:bg-emerald-900/20 border border-emerald-200 dark:border-emerald-800/50 rounded-lg p-6","data-testid":"scope-soa-parse-results",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-emerald-100 dark:bg-emerald-900/40 rounded-full flex items-center justify-center",children:e.jsx(H,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-bold text-emerald-900 dark:text-emerald-200","data-testid":"text-soa-success-title",children:"SoA Parsed Successfully"}),w.summary&&e.jsx("p",{className:"text-sm text-emerald-700 mt-1","data-testid":"text-scope-soa-summary",children:w.summary})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center mb-4",children:[e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-3 border border-emerald-200 dark:border-emerald-800/50",children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-700 dark:text-emerald-400","data-testid":"text-scope-total-applicable",children:w.applicableControls||w.totalApplicable||0}),e.jsx("div",{className:"text-xs text-emerald-600 dark:text-emerald-500",children:"Total Applicable"})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-3 border border-emerald-200 dark:border-emerald-800/50",children:[e.jsx("div",{className:"text-2xl font-bold text-indigo-700 dark:text-indigo-400","data-testid":"text-scope-isms-controls",children:w.ismsClauseControls??w.controls?.filter(t=>t.isIsmsClause).length??0}),e.jsx("div",{className:"text-xs text-indigo-600 dark:text-indigo-400",children:"ISMS Clause"})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-3 border border-emerald-200 dark:border-emerald-800/50",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-700 dark:text-blue-400","data-testid":"text-scope-annex-controls",children:w.annexAControls??w.controls?.filter(t=>!t.isIsmsClause&&t.isApplicable).length??0}),e.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:"Annex A"})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-3 border border-red-100 dark:border-red-800/50",children:[e.jsx("div",{className:"text-2xl font-bold text-red-600 dark:text-red-400","data-testid":"text-scope-excluded-controls",children:w.excludedControls||0}),e.jsx("div",{className:"text-xs text-red-500 dark:text-red-400",children:"Excluded"})]})]}),e.jsx(p,{variant:"ghost",size:"sm",className:"w-full text-emerald-700 hover:text-emerald-900 hover:bg-emerald-100 gap-2",onClick:()=>Us(!gt),"data-testid":"button-toggle-soa-details",children:gt?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"h-4 w-4"}),"Collapse Details"]}):e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"h-4 w-4"}),"View Detailed Analysis"]})}),gt&&w.controls&&w.controls.length>0&&e.jsx("div",{className:"mt-4 space-y-6 animate-in fade-in slide-in-from-top-2 duration-300","data-testid":"soa-details-expanded",children:(()=>{const t=w.controls.filter(a=>a.isIsmsClause),s=w.controls.filter(a=>!a.isIsmsClause);return e.jsxs(e.Fragment,{children:[t.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Z,{className:"h-4 w-4 text-indigo-600"}),e.jsxs("h5",{className:"font-semibold text-indigo-900","data-testid":"text-isms-section-header",children:["ISMS Clauses (",t.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:t.map(a=>e.jsxs("div",{className:l("flex items-start gap-3 p-3 rounded-lg border text-sm",a.isApplicable?"bg-white dark:bg-slate-800 border-emerald-200 dark:border-emerald-800/50":"bg-gray-50 dark:bg-slate-800/50 border-gray-200 dark:border-slate-700"),"data-testid":`soa-control-${a.controlId||a.id}`,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a.isApplicable?e.jsx(Y,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}):e.jsx(z,{className:"h-4 w-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono font-medium text-slate-800 dark:text-slate-200",children:a.controlInfo?.controlId||a.controlId}
1),e.jsx("span",{className:"text-slate-600 dark:text-slate-400 truncate",children:a.controlInfo?.title||""}),Le(a.controlInfo?.controlId||a.controlId||"")&&e.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-300 whitespace-nowrap","data-testid":`badge-crossmap-${a.controlId||a.id}`,children:Le(a.controlInfo?.controlId||a.controlId||"")})]}),a.justification&&e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:a.justification})]}),e.jsx("span",{className:l("flex-shrink-0 text-xs font-medium px-2 py-0.5 rounded-full",a.isApplicable?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400":"bg-gray-200 text-gray-600 dark:bg-slate-700 dark:text-slate-400"),"data-testid":`badge-control-${a.controlId||a.id}`,children:a.isApplicable?"Applicable":"Excluded"})]},a.id))})]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Q,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),e.jsxs("h5",{className:"font-semibold text-blue-900 dark:text-blue-200","data-testid":"text-annexa-section-header",children:["Annex A Controls (",s.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:s.map(a=>e.jsxs("div",{className:l("flex items-start gap-3 p-3 rounded-lg border text-sm",a.isApplicable?"bg-white dark:bg-slate-800 border-emerald-200 dark:border-emerald-800/50":"bg-gray-50 dark:bg-slate-800/50 border-gray-200 dark:border-slate-700"),"data-testid":`soa-control-${a.controlId||a.id}`,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a.isApplicable?e.jsx(Y,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}):e.jsx(z,{className:"h-4 w-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-mono font-medium text-slate-800 dark:text-slate-200",children:a.controlInfo?.controlId||a.controlId}),e.jsx("span",{className:"text-slate-600 dark:text-slate-400 truncate",children:a.controlInfo?.title||""}),Le(a.controlInfo?.controlId||a.controlId||"")&&e.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-300 whitespace-nowrap","data-testid":`badge-crossmap-annexa-${a.controlId||a.id}`,children:Le(a.controlInfo?.controlId||a.controlId||"")})]}),a.justification&&e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:a.justification})]}),e.jsx("span",{className:l("flex-shrink-0 text-xs font-medium px-2 py-0.5 rounded-full",a.isApplicable?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-600"),"data-testid":`badge-control-${a.controlId||a.id}`,children:a.isApplicable?"Applicable":"Excluded"})]},a.id))})]})]})})()})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx(p,{variant:"ghost",onClick:()=>{N("mandatory-docs")},className:"text-slate-500","data-testid":"button-back-from-scope-context",children:"Back to Required Documents"}),e.jsx(p,{size:"lg",onClick:ga,disabled:!ua||B.isPending,className:"gap-2 shadow-lg shadow-primary/20","data-testid":"button-scope-context-continue",children:B.isPending?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:["Continue to Upload Evidence ",e.jsx(Re,{className:"h-4 w-4"})]})})]})]}),d==="client-info"&&e.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[e.jsx(b,{children:e.jsxs(f,{className:"p-8 space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{htmlFor:"client-name",children:"Client Name"}),e.jsx(xe,{id:"client-name","data-testid":"input-client-name",placeholder:"e.g., Acme Corporation",value:j,onChange:t=>T(t.target.value),className:"text-lg"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Enter the name of the organization being audited."})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-white mb-2",children:"Selected Framework"}),e.jsx("p",{className:"text-lg text-primary font-bold",children:at(m||"")})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"Audit Perio
1d Start"}),e.jsxs(He,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:l("w-full justify-start text-left font-normal",!v&&"text-muted-foreground"),"data-testid":"button-period-start",children:[e.jsx(et,{className:"mr-2 h-4 w-4"}),v?tt(v,"PPP"):"Select start date"]})}),e.jsx(Ke,{className:"w-auto p-0",align:"start",children:e.jsx(We,{mode:"single",selected:v,onSelect:Te,startMonth:Qe(new Date,5),endMonth:new Date})})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"When the audit period begins."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"Audit Period End"}),e.jsxs(He,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:l("w-full justify-start text-left font-normal",!h&&"text-muted-foreground"),"data-testid":"button-period-end",children:[e.jsx(et,{className:"mr-2 h-4 w-4"}),h?tt(h,"PPP"):"Select end date"]})}),e.jsx(Ke,{className:"w-auto p-0",align:"start",children:e.jsx(We,{mode:"single",selected:h,onSelect:_e,startMonth:Qe(new Date,5),endMonth:new Date,disabled:t=>v?t<v:!1})})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"When the audit period ends."})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx(p,{variant:"ghost",onClick:()=>N("select-framework"),className:"text-slate-500","data-testid":"button-back-framework",children:"Back to Framework Selection"}),e.jsx(p,{size:"lg",onClick:ha,disabled:B.isPending,className:"gap-2 shadow-lg shadow-primary/20","data-testid":"button-next-upload",children:B.isPending?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:["Continue to Upload ",e.jsx(Re,{className:"h-4 w-4"})]})})]})]}),(d==="upload"||d==="upload-evidence")&&e.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[!1,F&&(F.blockingMissing.length>0||F.nonBlockingMissing.length>0)&&e.jsx(b,{className:"border-slate-200 dark:border-slate-700/50 mb-4","data-testid":"missing-artifacts-panel",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2","data-testid":"heading-missing-artifacts",children:[e.jsx(Ba,{className:"h-5 w-5 text-orange-600"}),"What I Still Need"]}),e.jsxs("p",{className:"text-sm text-slate-500 mt-1",children:["Documents needed for ",m==="SOC2"?"readiness assessment":"Stage 1 audit readiness"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-2xl font-bold text-indigo-600","data-testid":"text-completion-percent",children:[F.completionPercent,"%"]}),e.jsx("div",{className:"text-xs text-slate-500",children:"Complete"})]})]}),e.jsx(J,{value:F.completionPercent,className:"h-2 mb-4","data-testid":"progress-completion"}),F.blockingMissing.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h4",{className:"text-sm font-semibold text-red-700 mb-2 flex items-center gap-1",children:[e.jsx(z,{className:"h-4 w-4"}),m==="SOC2"?"Required (Blocking Readiness)":"Required (Blocking Stage 1)"]}),e.jsx("div",{className:"space-y-2",children:F.blockingMissing.map(t=>e.jsxs("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/50 rounded-lg","data-testid":`missing-blocking-${t.artifactType}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-red-800 dark:text-red-300",children:t.label}),e.jsx(O,{variant:"destructive",className:"text-xs",children:"Required"})]}),e.jsx("p",{className:"text-xs text-red-600 mt-1",children:t.reason}),t.suggestedFileNames.length>0&&e.jsxs("p",{className:"text-xs text-red-500 mt-1 italic",children:["Example filenames: ",t.suggestedFileNames.slice(0,2).join(", ")]})]},t.artifactType))})]}),F.nonBlockingMissing.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h4",{className:"text-sm font-semibold text-amber-700 mb-2 flex items-center gap-1",children:[e.jsx(I,{className:"h-4 w-4"}),"Recommended (Non-Blocking)"]}),e.jsx("div",{className:"space-y-2",children:F.nonBlockingMissing.map(t=>e.jsxs("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50 rounded-lg","data-testid":`missing-nonblocking-${t.artifactType}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-300",children:t.label}),e.jsx(O,{variant:"outline",className:"text-xs text-amber-700 border-amber-300",children:"Recommended"})]}),e.jsx("p",{className:"text-xs text-amber-600 mt-1",children:t.reason})]},t.artifactType))})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-slate-200 dark:border-slate-700",children:[e.jsx(p,{variant:"outline",className:"w-full",onClick:()=>{navigator.clipboard.writeText(F.requestMessage),is(!0),x.success("Request message copied to clipboard!"),setTimeout(()=>is(!1),3e3)},"data-testid":"btn-copy-request-message",children:Qs?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 text-green-600"}),"Copied!"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Copy Request Message"]})}),e.jsx("p",{className:"text-xs text-slate-400 mt-2 text-center",children:"Copy a pre-formatted message listing all missing documents to share with your team"})]})]})}),c&&e.jsxs("div",{className:"space-y-4","data-testid":"stage1-readiness-dashboard",children:[e.jsx(b,{className:"border-slate-200 dark:border-slate-700/50 bg-gradient-to-r from-slate-50 to-indigo-50/30 dark:from-slate-900 dark:to-indigo-950/30","data-testid":"readiness-overview-card",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xl font-bold text-slate-900 dark:text-white flex items-center gap-2","data-testid":"heading-readiness-dashboard",children:[e.jsx($a,{className:"h-6 w-6 text-indigo-600"}),m==="SOC2"?"Readiness Assessment Dashboard":"Stage 1 Readiness Dashboard"]}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:m==="SOC2"?"Comprehensive SOC 2 readiness asse
1ssment":"Comprehensive readiness assessment for Stage 1 audit"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:l("text-3xl font-bold",c.readinessScore>=80?"text-green-600":c.readinessScore>=50?"text-yellow-600":"text-red-600"),"data-testid":"text-readiness-score",children:[c.readinessScore,"%"]}),e.jsx("div",{className:"text-xs text-slate-500",children:"Overall Readiness"})]})]}),e.jsx(J,{value:c.readinessScore,className:"h-3 mb-4","data-testid":"progress-readiness"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:"Core Artifacts"}),e.jsxs("span",{className:l("text-lg font-bold",(c.artifactScore??0)>=80?"text-green-600":(c.artifactScore??0)>=50?"text-yellow-600":"text-red-600"),"data-testid":"text-artifact-score",children:[c.artifactScore??0,"%"]})]}),e.jsx("div",{className:"text-xs text-slate-400 mt-0.5",children:"50% weight"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:"Clause Coverage"}),e.jsxs("span",{className:l("text-lg font-bold",(c.clauseScore??0)>=80?"text-green-600":(c.clauseScore??0)>=50?"text-yellow-600":"text-red-600"),"data-testid":"text-clause-score",children:[c.clauseScore??0,"%"]})]}),e.jsx("div",{className:"text-xs text-slate-400 mt-0.5",children:"50% weight"})]})]})]})}),e.jsx(b,{className:"border-slate-200 dark:border-slate-700/50","data-testid":"core-artifacts-card",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("h4",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2 mb-4",children:[e.jsx(re,{className:"h-5 w-5 text-indigo-600"}),"Core Artifacts Detected"]}),e.jsx("div",{className:"space-y-2",children:c.coreArtifacts.map(t=>e.jsxs("div",{className:l("flex items-center justify-between py-2 px-3 rounded-lg border",t.status==="FOUND"?"bg-green-50 border-green-200 dark:bg-green-900/20 dark:border-green-800/50":"bg-red-50 border-red-200 dark:bg-red-900/20 dark:border-red-800/50"),"data-testid":`readiness-artifact-${t.type}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t.status==="FOUND"?e.jsx(H,{className:"h-5 w-5 text-green-600"}):e.jsx(z,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-slate-800 dark:text-slate-200",children:t.type})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.files&&t.files.length>0&&e.jsx("span",{className:"text-xs text-slate-500 max-w-48 truncate",children:t.files.map(s=>s.fileName).join(", ")}),e.jsx(O,{variant:t.status==="FOUND"?"default":"destructive",className:"text-xs","data-testid":`badge-artifact-status-${t.type}`,children:t.status==="FOUND"?"Detected":"Missing"})]})]},t.type))})]})}),c.clauseReadiness&&c.clauseReadiness.length>0&&e.jsx(b,{className:"border-slate-200 dark:border-slate-700/50","data-testid":"clause-readiness-card",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("h4",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2 mb-4",children:[e.jsx(qa,{className:"h-5 w-5 text-indigo-600"}),"Clause 4–10 Readiness"]}),e.jsx("div",{className:"space-y-1.5",children:c.clauseReadiness.map(t=>e.jsxs("div",{className:l("flex items-center justify-between py-1.5 px-3 rounded-md border text-sm",{"bg-green-50 border-green-200 dark:bg-green-900/20 dark:border-green-800/50":t.status==="READY","bg-amber-50 border-amber-200 dark:bg-amber-900/20 dark:border-amber-800/50":t.status==="PARTIAL","bg-red-50 border-red-200 dark:bg-red-900/20 dark:border-red-800/50":t.status==="NOT_READY"}),"data-testid":`clause-readiness-${t.clause}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t.status==="READY"?e.jsx(H,{className:"h-4 w-4 text-green-600"}):t.status==="PARTIAL"?e.jsx(I,{className:"h-4 w-4 text-amber-500"}):e.jsx(z,{className:"h-4 w-4 text-red-500"}),e.jsxs("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:["Clause ",t.clause]}),e.jsxs("span",{className:"text-slate-500 hidden sm:inline",children:["— ",t.clauseName]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-slate-500",children:[t.evidenceCount," file",t.evidenceCount!==1?"s":""]}),e.jsx(O,{variant:t.status==="READY"?"default":t.status==="PARTIAL"?"outline":"destructive",className:"text-xs",children:t.status})]})]},t.clause))})]})}),(c.topGaps&&c.topGaps.length>0||c.topFollowups&&c.topFollowups.length>0)&&e.jsx(b,{className:"border-slate-200 dark:border-slate-700/50","data-testid":"gaps-followups-card",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("h4",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2 mb-4",children:[e.jsx(Ft,{className:"h-5 w-5 text-amber-600"}),"Top Gaps & Follow-ups"]}),c.topGaps&&c.topGaps.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h5",{className:"text-sm font-semibold text-slate-700 dark:text-slate-300 mb-2",children:"Evidence Gaps"}),e.jsx("div",{className:"space-y-1.5",children:c.topGaps.map((t,s)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-red-50 dark:bg-red-900/20 border border-red-100 dark:border-red-800/50 text-sm text-red-700 dark:text-red-300","data-testid":`gap-item-${s}`,children:[e.jsx(z,{className:"h-4 w-4 text-red-500 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:t})]},s))})]}),c.topFollowups&&c.topFollowups.length>0&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-sm font-semibold text-slate-700 dark:text-slate-300 mb-2",children:"Follow-up Questions"}),e.jsx("div",{className:"space-y-1.5",children:c.topFollowups.map((t,s)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-indigo-50 dark:bg-indigo-900/20 border border-indigo-100 dark:border-indigo-800/50 text-sm","data-testid":`followup-item-${s}`,children:[e.jsx(ws,{className:"h-4 w-4 text-indigo-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-700 dark:text-slate-300",children:t.question}),e.jsxs("span",{className:"text-xs text-slate-500 ml-2",children:["(Clause ",t.clause,")"]})]})]},s))})]})]})}),c.soaAutoParseStatus==="parsed"&&c.applicableControlsCount!=null&&e.jsx(b,{className:"border-green-200 dark:border-green-800/50 bg-green-50/30 dark:bg-green-900/20","data-testid":"soa-auto-parse-status",children:e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{className:"text-sm font-semibold text-green-700",children:"SoA Auto-Parsed"}),e.jsxs("span",{className:"text-sm text-green-600 ml-1",children:["— ",c.applicableControlsCount," applicable controls"]}
1)]}),e.jsx(p,{variant:"link",size:"sm",className:"mt-1 text-green-700 p-0 h-auto",onClick:()=>M(`/soa-editor?auditId=${g}`),"data-testid":"btn-open-soa-editor",children:"Open SoA Editor"})]})}),c.soaAutoParseStatus==="pending"&&e.jsx(b,{className:"border-blue-200 dark:border-blue-800/50 bg-blue-50/30 dark:bg-blue-900/20","data-testid":"soa-parse-pending",children:e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-4 w-4 text-blue-600 animate-spin"}),e.jsx("span",{className:"text-sm font-semibold text-blue-700",children:"SoA Parsing In Progress"})]}),e.jsx("p",{className:"text-sm text-blue-600 ml-6 mt-1",children:"Statement of Applicability detected. Auto-parsing applicable controls..."})]})}),c.soaAutoParseStatus==="failed"&&e.jsx(b,{className:"border-red-200 dark:border-red-800/50 bg-red-50/30 dark:bg-red-900/20","data-testid":"soa-parse-failed",children:e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-red-600"}),e.jsx("span",{className:"text-sm font-semibold text-red-700",children:"SoA Auto-Parse Failed"})]}),e.jsx("p",{className:"text-sm text-red-600 ml-6 mt-1",children:"SoA was detected but auto-parsing failed. Try re-uploading or manually trigger parsing."}),e.jsx(p,{variant:"link",size:"sm",className:"ml-6 mt-1 text-red-700 p-0 h-auto",onClick:()=>M(`/soa-editor?auditId=${g}`),"data-testid":"btn-open-soa-editor-failed",children:"Open SoA Editor to review controls"})]})}),c.riskAlignment&&e.jsx(b,{className:l("border",{"border-green-200 bg-green-50/30 dark:border-green-800/50 dark:bg-green-900/20":c.riskAlignment.status==="aligned","border-amber-200 bg-amber-50/30 dark:border-amber-800/50 dark:bg-amber-900/20":c.riskAlignment.status==="partial","border-red-200 bg-red-50/30 dark:border-red-800/50 dark:bg-red-900/20":c.riskAlignment.status==="misaligned","border-slate-200 bg-slate-50/30 dark:border-slate-700/50 dark:bg-slate-800/30":c.riskAlignment.status==="not_evaluated"}),"data-testid":"risk-alignment-panel",children:e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(X,{className:l("h-4 w-4",{"text-green-600":c.riskAlignment.status==="aligned","text-amber-600":c.riskAlignment.status==="partial","text-red-600":c.riskAlignment.status==="misaligned","text-slate-500":c.riskAlignment.status==="not_evaluated"})}),e.jsxs("span",{className:l("text-sm font-semibold",{"text-green-700":c.riskAlignment.status==="aligned","text-amber-700":c.riskAlignment.status==="partial","text-red-700":c.riskAlignment.status==="misaligned","text-slate-600 dark:text-slate-400":c.riskAlignment.status==="not_evaluated"}),children:["Risk Alignment: ",c.riskAlignment.status==="aligned"?"Aligned":c.riskAlignment.status==="partial"?"Partial Alignment":c.riskAlignment.status==="misaligned"?"Misaligned":"Not Evaluated"]})]}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400 ml-6 mb-2",children:c.riskAlignment.summary}),(c.riskAlignment.highRisksIdentified>0||c.riskAlignment.rtpControlsTotal>0)&&e.jsxs("div",{className:"ml-6 flex gap-4 text-xs text-slate-500 mb-2",children:[c.riskAlignment.highRisksIdentified>0&&e.jsxs("span",{"data-testid":"risk-alignment-high-risks",children:["High Risks: ",c.riskAlignment.highRisksAddressedInRtp,"/",c.riskAlignment.highRisksIdentified," addressed"]}),c.riskAlignment.rtpControlsTotal>0&&e.jsxs("span",{"data-testid":"risk-alignment-soa-mapping",children:["RTP→SoA: ",c.riskAlignment.rtpControlsMappedToSoa,"/",c.riskAlignment.rtpControlsTotal," mapped"]})]}),c.riskAlignment.mismatches.length>0&&e.jsx("div",{className:"ml-6 space-y-1",children:c.riskAlignment.mismatches.map((t,s)=>e.jsxs("div",{className:"flex items-start gap-1.5","data-testid":`risk-mismatch-${s}`,children:[e.jsx(I,{className:l("h-3.5 w-3.5 mt-0.5 flex-shrink-0",{"text-red-500":t.severity==="high","text-amber-500":t.severity==="medium","text-slate-400":t.severity==="low"})}),e.jsx("span",{className:"text-xs text-slate-600 dark:text-slate-400",children:t.description})]},s))})]})}),e.jsx(b,{className:"border-indigo-200 bg-indigo-50/30","data-testid":"run-audit-card",children:e.jsxs(f,{className:"p-6",children:[e.jsx(p,{onClick:async()=>
1{if(g){ns(!0);try{const t=await La.run(g);Ys(t),x.success(m==="SOC2"?"Readiness assessment completed":"Stage 1 audit completed")}catch{x.error(m==="SOC2"?"Readiness assessment failed":"Stage 1 audit failed")}finally{ns(!1)}}},disabled:ls||F&&F.blockingMissing.length>0||V?.status==="needs_confirmation"&&!ne,className:"w-full",size:"lg","data-testid":"btn-run-stage1-audit",children:ls?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}),m==="SOC2"?"Running Readiness Assessment...":"Running Stage 1 Audit..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),m==="SOC2"?"Run SOC 2 Readiness Assessment":"Run Stage 1 Internal Audit"]})}),F&&F.blockingMissing.length>0&&e.jsxs("div",{className:"mt-3 p-3 rounded-md bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/50","data-testid":"blocking-missing-warning",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(z,{className:"h-4 w-4 text-red-600"}),e.jsx("span",{className:"text-sm font-semibold text-red-700",children:"Cannot run audit — blocking documents missing:"})]}),e.jsx("ul",{className:"list-disc list-inside text-sm text-red-600 ml-6",children:F.blockingMissing.map((t,s)=>e.jsx("li",{children:t.label},s))})]}),V?.status==="needs_confirmation"&&!ne&&e.jsxs("p",{className:"text-xs text-amber-600 mt-2 flex items-center gap-1","data-testid":"scope-confirmation-warning",children:[e.jsx(I,{className:"h-3 w-3"}),"Scope profile needs confirmation before running the ",m==="SOC2"?"Readiness Assessment":"Stage 1 Audit",". Go to Scope & Context step to confirm."]})]})})]}),A&&e.jsx(b,{className:"border-slate-200 dark:border-slate-700/50","data-testid":"stage1-audit-results",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2",children:[e.jsx(Z,{className:"h-5 w-5 text-indigo-600"}),m==="SOC2"?"Readiness Assessment Results":"Stage 1 Audit Results"]}),e.jsx(O,{variant:A.overallStage1Status==="READY"?"default":"destructive",className:"text-sm px-3 py-1","data-testid":"badge-stage1-status",children:A.overallStage1Status})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"text-center p-2 rounded-md bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/50",children:[e.jsx("div",{className:"text-lg font-bold text-red-700","data-testid":"count-major-findings",children:A.majorFindings.length}),e.jsx("div",{className:"text-xs text-red-600",children:"Major Findings"})]}),e.jsxs("div",{className:"text-center p-2 rounded-md bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50",children:[e.jsx("div",{className:"text-lg font-bold text-amber-700","data-testid":"count-minor-findings",children:A.minorFindings.length}),e.jsx("div",{className:"text-xs text-amber-600",children:"Minor Findings"})]}),e.jsxs("div",{className:"text-center p-2 rounded-md bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800/50",children:[e.jsx("div",{className:"text-lg font-bold text-blue-700","data-testid":"count-observations",children:A.observations.length}),e.jsx("div",{className:"text-xs text-blue-600",children:"Observations"})]})]}),e.jsx("div",{className:"space-y-2 mb-4 max-h-72 overflow-y-auto",children:A.clauseResults.map(t=>e.jsxs("div",{className:l("p-3 rounded-md border",{"bg-green-50 border-green-200 dark:bg-green-900/20 dark:border-green-800/50":t.status==="PASS","bg-amber-50 border-amber-200 dark:bg-amber-900/20 dark:border-amber-800/50":t.status==="PARTIAL","bg-red-50 border-red-200 dark:bg-red-900/20 dark:border-red-800/50":t.status==="FAIL"}),"data-testid":`clause-result-${t.clause}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-sm font-semibold text-slate-800",children:["Clause ",t.clause,": ",t.clauseName]}),e.jsx(O,{variant:t.status==="PASS"?"default":t.status==="PARTIAL"?"outline":"destructive",className:"text-xs",children:t.status})]}
1),t.rationale&&e.jsx("p",{className:"text-xs text-slate-600 dark:text-slate-400 mt-1 italic",children:t.rationale}),t.citations.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-500",children:"Evidence Citations:"}),e.jsx("div",{className:"space-y-1 mt-1",children:t.citations.map((s,a)=>e.jsxs("div",{className:"flex items-start gap-2 text-xs bg-white dark:bg-slate-800 p-1.5 rounded border border-slate-200 dark:border-slate-700",children:[e.jsx(P,{className:"h-3 w-3 text-indigo-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:s.fileName}),s.excerptRef&&e.jsxs("span",{className:"text-slate-500 ml-1",children:["— ",s.excerptRef]}),e.jsx("p",{className:"text-slate-500",children:s.relevance})]})]},a))})]}),t.gaps.length>0&&e.jsxs("div",{className:"mt-1",children:[e.jsx("span",{className:"text-xs font-medium text-slate-500",children:"Gaps:"}),e.jsx("ul",{className:"list-disc list-inside text-xs text-slate-600 dark:text-slate-400 ml-2",children:t.gaps.map((s,a)=>e.jsx("li",{children:s},a))})]}),t.followups&&t.followups.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-500",children:"Follow-up Questions:"}),e.jsx("ul",{className:"list-none text-xs text-slate-600 dark:text-slate-400 mt-1 space-y-1",children:t.followups.map((s,a)=>e.jsxs("li",{className:"flex items-start gap-2 bg-indigo-50 p-1.5 rounded border border-indigo-100",children:[e.jsx(ws,{className:"h-3 w-3 text-indigo-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:s.question}),e.jsx("span",{className:"text-slate-500 block",children:s.reason}),e.jsx(O,{variant:"outline",className:"text-[10px] mt-0.5 px-1",children:s.priority})]})]},a))})]})]},t.clause))}),A.evidenceIndex&&A.evidenceIndex.length>0&&e.jsxs("div",{className:"mb-4 p-3 rounded-md bg-indigo-50 border border-indigo-200","data-testid":"evidence-index",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Va,{className:"h-4 w-4 text-indigo-600"}),e.jsx("span",{className:"text-sm font-semibold text-indigo-700",children:"Evidence Index — File Traceability"}),e.jsxs(O,{variant:"outline",className:"text-xs",children:[A.evidenceIndex.length," files"]})]}),e.jsx("div",{className:"space-y-2",children:A.evidenceIndex.map(t=>e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-2 rounded border border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-slate-500"}),e.jsx("span",{className:"text-sm font-medium text-slate-800",children:t.fileName}),e.jsxs(O,{variant:"outline",className:"text-[10px]",children:["Used in ",t.usedInClauses.length," clause",t.usedInClauses.length!==1?"s":""]})]}),e.jsx("div",{className:"ml-5 space-y-0.5",children:t.usedInClauses.map((s,a)=>e.jsxs("div",{className:"text-xs text-slate-600 dark:text-slate-400",children:[e.jsxs("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:["Clause ",s.clause]}),": ",s.relevance,s.excerptRef&&e.jsxs("span",{className:"text-slate-400 ml-1",children:["(",s.excerptRef,")"]})]},a))})]},t.fileId))})]}),A.majorFindings.length>0&&e.jsxs("div",{className:"mb-3 p-3 rounded-md bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/50","data-testid":"major-findings-list",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(z,{className:"h-4 w-4 text-red-600"}),e.jsx("span",{className:"text-sm font-semibold text-red-700",children:"Major Findings"})]}),e.jsx("ul",{className:"list-disc list-inside text-sm text-red-600 ml-6",children:A.majorFindings.map((t,s)=>e.jsx("li",{children:t},s))})]}),A.minorFindings.length>0&&e.jsxs("div",{className:"mb-3 p-3 rounded-md bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50","data-testid":"minor-findings-list",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(I,{className:"h-4 w-4 text-amber-600"}),e.jsx("span",{className:"text-sm font-semibold text-amber-700",children:"Minor Findings"})]}),e.jsx("ul",{className:"list-disc list-inside text-sm text-amber-600 ml-6",children:A.minorFindings.map((t,s)=>e.jsx("li",{children:t},s))})]}),A.observations.length>0&&e.jsxs("div",{className:"p-3 rounded-md bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800/50","data-testid":"observations-list",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ft,{className:"h-4 w-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-semibold text-blue-700",children:"Observations"})]}),e.jsx("ul",{className:"list-disc list-inside text-sm text-blue-600 ml-6",children:A.observations.map((t,s)=>e.jsx("li",{children:t},s))})]})]})}),w&&ee.length>0&&e.jsx(b,{className:"border-indigo-200/50 dark:border-indigo-800/30 bg-white dark:bg-slate-900",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{children:e.jsxs("h3",{className:"text-lg font-bold text-slate-900 dark:text-white flex items-center gap-2","data-testid":"heading-evidence-checklist",children:[e.jsx(X,{className:"h-5 w-5 text-indigo-600"}),"Controls & Evidence",e.jsxs(O,{variant:"outline",className:"ml-1 text-xs font-medium",children:[ee.length," controls"]}
1)]})}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-2xl font-bold text-indigo-600","data-testid":"text-coverage-percent",children:[Math.round(ee.filter(t=>t.status==="complete").length/ee.length*100),"%"]}),e.jsx("div",{className:"text-xs text-slate-500",children:"Coverage"})]})]}),e.jsx(J,{value:ee.filter(t=>t.status==="complete").length/ee.length*100,className:"h-2 mb-6","data-testid":"progress-coverage"}),e.jsx(lr,{controls:ee})]})}),e.jsxs("div",{className:l("border-2 border-dashed rounded-xl p-12 text-center transition-all duration-200 cursor-pointer bg-slate-50 dark:bg-slate-800/50",Fs?"border-primary bg-blue-50/50 dark:bg-blue-900/20 scale-[1.01]":"border-slate-300 dark:border-slate-600 hover:border-slate-400"),onDragOver:da,onDragLeave:oa,onDrop:ca,onClick:()=>document.getElementById("file-upload")?.click(),"data-testid":"dropzone-evidence",children:[e.jsx("input",{type:"file",id:"file-upload",multiple:!0,className:"hidden",onChange:ma,"data-testid":"input-file-upload"}),e.jsx("div",{className:"w-16 h-16 bg-blue-100 text-primary rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(Je,{className:"h-8 w-8"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 dark:text-white mb-2",children:"Click or drag files here to upload"}),e.jsx("p",{className:"text-slate-500 max-w-sm mx-auto mb-6",children:"Support for PDF, DOCX, XLSX, and CSV. You can upload multiple evidence files at once."}),e.jsx(p,{variant:"outline",className:"min-w-[140px]",children:"Select Files"})]}),L.length>0&&e.jsxs("div",{className:"bg-white dark:bg-slate-900/80 border border-slate-200 dark:border-slate-700/50 rounded-xl p-6 shadow-sm dark:shadow-none",children:[e.jsxs("h4",{className:"font-bold text-slate-900 dark:text-white mb-4 flex items-center justify-between",children:[e.jsxs("span",{"data-testid":"text-file-count",children:["Selected Files (",L.length,")"]}),e.jsx(p,{variant:"ghost",size:"sm",className:"text-red-500 h-8",onClick:()=>ue([]),disabled:Ms,"data-testid":"button-clear-files",children:"Clear All"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[400px] overflow-y-auto pr-2",children:L.map((t,s)=>{const a=Ut.find(E=>E.fileName===t.name),r=a?.classificationStatus,i=r==="CLASSIFIED",o=r==="REVIEW_REQUIRED",u=r==="UNCLASSIFIED"||!r&&!!a,y=a?.classification,C=y?.evidenceType||a?.evidenceType,R=y?.supportType||a?.supportType,St=y?.approvalStatus||a?.approvalStatus,hs=y?.scopeMatchStatus||a?.scopeMatchStatus,bs=y?.riskTreatmentStatus||a?.riskTreatmentStatus,At=y?.freshnessStatus||a?.freshnessStatus,q=y?.smartIntakeNotes||a?.smartIntakeNotes,Ue=a?.documentType,ae=a?.documentConfidence,Ge=a?.mappedClauses,Ct=a?.classificationNotes,It=Ks===s,Fa={policy:"bg-blue-100 text-blue-700 border-blue-200",procedure:"bg-indigo-100 text-indigo-700 border-indigo-200",record:"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 border-slate-200 dark:border-slate-700",log:"bg-amber-100 text-amber-700 border-amber-200",screenshot:"bg-cyan-100 text-cyan-700 border-cyan-200",configuration_export:"bg-orange-100 text-orange-700 border-orange-200",certificate:"bg-purple-100 text-purple-700 border-purple-200",training_record:"bg-emerald-100 text-emerald-700 border-emerald-200"},Da={policy:e.jsx(Ps,{className:"h-3 w-3"}),procedure:e.jsx(P,{className:"h-3 w-3"}),record:e.jsx(Q,{className:"h-3 w-3"}),log:e.jsx(Tt,{className:"h-3 w-3"}),screenshot:e.jsx(Ya,{className:"h-3 w-3"}),configuration_export:e.jsx(Wa,{className:"h-3 w-3"}),certificate:e.jsx(za,{className:"h-3 w-3"}),training_record:e.jsx(Ps,{className:"h-3 w-3"})},Be=(E,qe,Ta)=>{if(!E)return"bg-gray-300";const fs=E.toLowerCase();return qe.some(Pt=>fs.includes(Pt))?"bg-emerald-500":Ta.some(Pt=>fs.includes(Pt))?"bg-red-500":"bg-gray-300"};return e.jsxs("div",{className:"flex flex-col","data-testid":`file-item-${s}`,children:[e.jsxs("div",{className:l("flex flex-col p-3 rounded-lg border group transition-colors",i?"bg-emerald-50 border-emerald-200":o?"bg-amber-50 border-amber-200":u?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800/50":"bg-slate-50 dark:bg-slate-800/50 border-slate-100 dar
1k:border-slate-700",(i||o)&&"cursor-pointer hover:bg-emerald-100/60"),onClick:()=>(i||o)&&Ws(It?null:s),"data-testid":`file-card-${s}`,children:[e.jsxs("div",{className:"flex items-center",children:[i?e.jsx(H,{className:"h-5 w-5 text-emerald-500 mr-3 shrink-0"}):o?e.jsx(I,{className:"h-5 w-5 text-amber-500 mr-3 shrink-0"}):u?e.jsx(D,{className:"h-5 w-5 text-blue-500 mr-3 shrink-0 animate-spin"}):e.jsx(_t,{className:"h-5 w-5 text-blue-500 mr-3 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 truncate",children:t.name}),i&&a?.mappedControlIds?e.jsx("p",{className:"text-xs text-emerald-600",children:a.mappedControlIds.length>0?`Mapped to: ${a.mappedControlIds.slice(0,3).join(", ")}${a.mappedControlIds.length>3?"...":""}`:"No controls matched"}):o?e.jsx("p",{className:"text-xs text-amber-600",children:"Needs Review"}):u?e.jsx("p",{className:"text-xs text-blue-500",children:"Classifying..."}):e.jsxs("p",{className:"text-xs text-slate-400",children:[(t.size/1024).toFixed(0)," KB"]})]}),!a&&e.jsx("button",{onClick:E=>{E.stopPropagation(),xa(s)},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-slate-200 rounded transition-opacity","data-testid":`button-remove-file-${s}`,children:e.jsx(me,{className:"h-4 w-4 text-slate-500"})}),(i||o)&&e.jsx(pe,{className:l("h-4 w-4 text-slate-400 ml-2 transition-transform",It&&"rotate-180")})]}),(i||o)&&(C||R||At||St||Ue)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-2 ml-8",children:[Ue&&e.jsxs("span",{className:l("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold border",ae&&ae>=80?"bg-green-100 text-green-700 border-green-200":ae&&ae>=60?"bg-yellow-100 text-yellow-700 border-yellow-200":"bg-red-100 text-red-700 border-red-200"),"data-testid":`badge-doc-type-${s}`,title:`Document Type: ${Ue} (${ae||0}% confidence)`,children:[e.jsx(P,{className:"h-3 w-3"}),Ue,ae!=null&&e.jsxs("span",{className:"opacity-70",children:[ae,"%"]})]}),C&&e.jsxs("span",{className:l("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold border",Fa[C.toLowerCase()]||"bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400 border-slate-200 dark:border-slate-700"),"data-testid":`badge-evidence-type-${s}`,children:[Da[C.toLowerCase()]||e.jsx(Ss,{className:"h-3 w-3"}),C.replace(/_/g," ").replace(/\b\w/g,E=>E.toUpperCase())]}),R&&e.jsxs("span",{className:l("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold border",R.toLowerCase()==="both"?"bg-violet-100 text-violet-700 border-violet-200":R.toLowerCase()==="design"?"bg-sky-100 text-sky-700 border-sky-200":"bg-teal-100 text-teal-700 border-teal-200"),"data-testid":`badge-support-type-${s}`,children:[e.jsx(X,{className:"h-3 w-3"}),R.replace(/\b\w/g,E=>E.toUpperCase())]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-1",children:[e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-slate-500",title:`Freshness: ${At||"unknown"}`,children:[e.jsx(As,{className:"h-3 w-3"}),e.jsx("span",{className:l("h-2 w-2 rounded-full inline-block",Be(At,["fresh"],["stale"]))})]}),e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-slate-500",title:`Approval: ${St||"unknown"}`,children:[e.jsx(Y,{className:"h-3 w-3"}),e.jsx("span",{className:l("h-2 w-2 rounded-full inline-block",Be(St,["approved"],["unapproved","not_approved"]))})]}),e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-slate-500",title:`Scope: ${hs||"unknown"}`,children:[e.jsx(Dt,{className:"h-3 w-3"}),e.jsx("span",{className:l("h-2 w-2 rounded-full inline-block",Be(hs,["in_scope","in scope"],["out_of_scope","out of scope"]))})]}),e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-slate-500",title:`Risk Treatment: ${bs||"unknown"}`,children:[e.jsx(X,{className:"h-3 w-3"}),e.jsx("span",{className:l("h-2 w-2 rounded-full inline-block",Be(bs,["consistent"],["inconsistent"]))})]})]})]})]}),It&&(q||Ct||Ge)&&e.jsxs("div",{className:"bg-white border border-t-0 border-slate-200 rounded-b-lg px-4 py-3 space-y-2 text-xs text-slate-600","data-testid":`file-details-${s}`,children:[Ct&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-slate-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-700",children:"Classification:"})," ",Ct]})]}),Ge&&Ge.length>0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ss,{className:"h-3.5 w-3.5 text-slate-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-700",children:"Mapped Clauses:"})," ",e.jsx("span",{className:"inline-flex flex-wrap gap-1",children:Ge.map((E,qe)=>e.jsx("span",{className:"bg-blue-50 text-blue-700 px-1.5 py-0.5 rounded text-[10px] font-medium border border-blue-200","data-testid":`clause-badge-${s}-${qe}`,children:E},qe))})]})]}),q?.stalenessReason&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(As,{className:"h-3.5 w-3.5 text-slate-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-700",children:"Freshness:"})," ",q.stalenessReason]})]}),q?.approvalNotes&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{className:"h-3.5 w-3.5 text-slate-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-700",children:"Approval:"})," ",q.approvalNotes]})]}),q?.scopeNotes&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Dt,{className:"h-3.5 w-3.5 text-slate-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-700",children:"Scope:"})," ",q.scopeNotes]})]}),q?.riskTreatmentNotes&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(X,{className:"h-3.5 w-3.5 text-slate-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-700",children:"Risk Treatment:"})," ",q.riskTreatmentNotes]})]}),q?.recommendations&&e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-slate-100",children:[e.jsx(Ft,{className:"h-3.5 w-3.5 text-amber-500 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-slate-700",children:"Recommendations:"})," ",q.recommendations]})]})]})]},s)})})]}),g&&Ut.length>0&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(p,{variant:"outline",onClick:()=>window.location.href=`/ingestion-review?auditId=${g}`,className:"gap-2","data-testid":"button-ingestion-review",children:[e.jsx(P,{className:"h-4 w-4"}),"Review Evidence Classifications"]})}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-slate-500",children:[e.jsx("div",{className:"h-px flex-1 bg-slate-200"}),e.jsx("span",{children:"Or import from cloud storage"}),e.jsx("div",{className:"h-px flex-1 bg-slate-200"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 justify-center",children:[e.jsxs(p,{variant:"outline",onClick:()=>jt("Google Drive"),"data-testid":"button-import-google-drive",className:l("gap-2 relative",!oe("Google Drive")&&"opacity-60"),children:[e.jsx(Mt,{className:"h-4 w-4"}),"Google Drive",oe("Google Drive")?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-600",children:[e.jsx(Y,{className:"h-3 w-3"}),"Connected"]}):e.jsx("span",{className:"text-xs text-slate-400",children:"Not Connected"})]}),e.jsxs(p,{variant:"outline",onClick:()=>jt("OneDrive"),"data-testid":"button-import-onedrive",className:l("gap-2 relative",!oe("OneDrive")&&"opacity-60"),children:[e.jsx(Mt,{className:"h-4 w-4"}),"OneDrive",oe("OneDrive")?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-600",children:[e.jsx(Y,{className:"h-3 w-3"}),"Connected"]}):e.jsx("span",{className:"text-xs text-slate-400",children:"Not Connected"})]}),e.jsxs(p,{variant:"outline",onClick:()=>jt("SharePoint"),"data-testid":"button-import-sharepoint",className:l("gap-2 relative",!oe("SharePoint")&&"opacity-60"),children:[e.jsx(Mt,{className:"h-4 w-4"}),"SharePoint",oe("SharePoint")?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-600",children:[e.jsx(Y,{className:"h-3 w-3"}),"Connected"]}):e.jsx("span",{className:"text-xs text-slate-400",children:"Not Connected"})]})]}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx(p,{variant:"ghost",onClick:()=>N(d==="upload-evidence"?"scope-context":"client-info"),className:"text-slate-500","data-testid":"button-back-from-upload",children:d==="upload-evidence"?"Back to Scope & Context":"Back to Client Info"}),e.jsx(p,{size:"lg",disabled:L.length===0||Bt||B.isPending,onClick:ka,className:"gap-2 shadow-lg shadow-primary/20","data-testid":"button-validate-evidence",children:Bt?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 animate-spin"}),"Validating..."]}):B.isPending?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-4 w-4"}),"Validate Evidence"]})})]})]}),(d==="validating"||d==="review-readiness"&&De==="validating")&&e.jsx("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:e.jsx(b,{className:"dark:bg-slate-800 dark:border-slate-700",children:e.jsxs(f,{className:"p-12 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-blue-100 dar
1k:bg-blue-900/30 rounded-full flex items-center justify-center mx-auto mb-8",children:e.jsx(D,{className:"h-10 w-10 text-primary animate-spin"})}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900 dark:text-white mb-3",children:"Validating Evidence"}),e.jsx("p",{className:"text-slate-500 dark:text-slate-400 max-w-md mx-auto mb-8",children:"Our AI is reviewing your uploaded files to identify which controls they apply to and check if they meet compliance standards."}),e.jsxs("div",{className:"w-full max-w-md mx-auto space-y-3",children:[e.jsx(J,{value:U,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-slate-500 dark:text-slate-400",children:[e.jsxs("span",{children:[Math.round(U),"%"]}),e.jsx("span",{"data-testid":"text-validation-status",children:ra()})]})]}),e.jsx("p",{className:"text-sm text-slate-400 dark:text-slate-500 mt-6",children:"This may take a few moments..."})]})})}),(d==="validation-results"||d==="review-readiness"&&De==="results")&&_&&e.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[(()=>{const t=xs();return e.jsx(b,{className:"dark:bg-slate-800 dark:border-slate-700",children:e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsx("span",{className:"font-medium text-slate-900 dark:text-white",children:"Review Progress:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"px-2 py-1 rounded-full bg-slate-100 dark:bg-slate-700 text-slate-600 dark:text-slate-300",children:[t.pending," pending"]}),e.jsxs("span",{className:"px-2 py-1 rounded-full bg-emerald-100 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-400",children:[t.approved," approved"]}),e.jsxs("span",{className:"px-2 py-1 rounded-full bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400",children:[t.rejected," rejected"]}),e.jsxs("span",{className:"px-2 py-1 rounded-full bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400",children:[t.hold," on hold"]}),e.jsxs("span",{className:"px-2 py-1 rounded-full bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400",children:[t.needsEdit," needs edit"]})]}),e.jsxs("span",{className:"text-slate-500 dark:text-slate-400 ml-auto",children:[t.reviewed," of ",t.total," reviewed"]})]})})})})(),(()=>{const t=_.results.filter(r=>r.applicableControls.length===0),s=_.results.flatMap(r=>r.recommendations||[]);return _.results.filter(r=>{const i=r.applicableControls.map(o=>o.supportType||"unknown");return i.length>0&&i.every(o=>o==="design")}),_.results.filter(r=>{const i=r.applicableControls.map(o=>o.supportType||"unknown");return i.length>0&&i.every(o=>o==="operation")}),t.length>0||s.length>0?e.jsx(b,{className:"border-amber-200 dark:border-amber-800 bg-amber-50/50 dark:bg-amber-900/10","data-testid":"card-missing-artifacts",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-amber-100 dark:bg-amber-900/30 rounded-full flex items-center justify-center shrink-0",children:e.jsx(I,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-amber-800 dark:text-amber-300","data-testid":"heading-missing-artifacts",children:"Missing or Insufficient Artifacts"}),e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-400",children:"The AI identified potential gaps in your evidence. Address these before running the audit for best results."})]})]}),e.jsxs("div",{className:"space-y-3",children:[t.length>0&&e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-4 border border-amber-200 dark:border-amber-700","data-testid":"section-unmapped-files",children:[e.jsxs("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 mb-2",children:[e.jsx(z,{className:"h-4 w-4 inline mr-1.5 text-red-500"}),t.length," file",t.length!==1?"s":""," not mapped to any control"]}),e.jsxs("ul",{className:"text-sm text-slate-600 dark:text-slate-400 space-y-1 ml-6",children:[t.slice(0,5).map((r,i)=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:r.fileName})]},i)),t.length>
15&&e.jsxs("li",{className:"text-amber-600 dark:text-amber-400",children:["...and ",t.length-5," more"]})]})]}),s.length>0&&e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-4 border border-amber-200 dark:border-amber-700","data-testid":"section-recommendations",children:[e.jsxs("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 mb-2",children:[e.jsx(I,{className:"h-4 w-4 inline mr-1.5 text-amber-500"}),"AI Recommendations"]}),e.jsxs("ul",{className:"text-sm text-slate-600 dark:text-slate-400 space-y-1.5 ml-6",children:[s.slice(0,8).map((r,i)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"•"}),e.jsx("span",{children:r})]},i)),s.length>8&&e.jsxs("li",{className:"text-amber-600 dark:text-amber-400",children:["...and ",s.length-8," more recommendations"]})]})]})]})]})}):null})(),e.jsx(b,{className:"dark:bg-slate-800 dark:border-slate-700",children:e.jsxs(f,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-slate-900 dark:text-white",children:"Evidence Validation Results"}),e.jsxs("p",{className:"text-slate-500 dark:text-slate-400 text-sm mt-1",children:[_.validFiles," of ",_.totalFiles," files validated successfully"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:l("px-3 py-1 rounded-full text-sm font-medium",_.validFiles===_.totalFiles?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400"),children:_.validFiles===_.totalFiles?"All Valid":"Review Required"})})]}),e.jsx("div",{className:"space-y-3",children:_.results.map(t=>e.jsxs("div",{className:"border border-slate-200 dark:border-slate-700 rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>na(t.fileId),className:"w-full flex items-center justify-between p-4 hover:bg-slate-50 dark:hover:bg-slate-700/50 transition-colors text-left","data-testid":`button-expand-file-${t.fileId}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:l("w-10 h-10 rounded-full flex items-center justify-center",t.isValid?"bg-emerald-100 dark:bg-emerald-900/30":"bg-amber-100 dark:bg-amber-900/30"),children:t.isValid?e.jsx(H,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"}):e.jsx(I,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900 dark:text-white",children:t.fileName}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:t.fileType})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:l("text-sm px-2 py-0.5 rounded",t.applicableControls.length>0?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"bg-slate-100 text-slate-500 dark:bg-slate-700 dark:text-slate-400"),children:[t.applicableControls.length," control",t.applicableControls.length!==1?"s":""]}),zt.has(t.fileId)?e.jsx(rt,{className:"h-5 w-5 text-slate-400"}):e.jsx(pe,{className:"h-5 w-5 text-slate-400"})]})]}),zt.has(t.fileId)&&e.jsxs("div",{className:"border-t border-slate-200 dark:border-slate-700 p-4 bg-slate-50 dark:bg-slate-900/50 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h5",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 mb-2",children:"Assessment"}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:t.overallAssessment})]}),t.applicableControls.length>0&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 mb-2",children:"Applicable Controls"}),e.jsx("div",{className:"space-y-2",children:t.applicableControls.map((s,a)=>{const r=ms(t.fileId,s.controlId),i=de(t.fileId,s.controlId),o=zs.has(i);return e.jsxs("div",{className:l("bg-white dark:bg-slate-800 p-3 rounded border",r==="approved"?"border-emerald-300 dark:border-emerald-700":r==="rejected"?"border-red-300 dark:border-red-700":r==="hold"?"border-amber-300 dark:border-amber-700":r==="needs-edit"?"border-blue-300 dark:border-blue-700":"border-slate-200 dark:border-slate-700"),
1children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-slate-900 dark:text-white text-sm",children:s.controlId}),r!=="pending"&&e.jsx("span",{className:l("text-xs px-2 py-0.5 rounded-full font-medium",r==="approved"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":r==="rejected"?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":r==="hold"?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"),children:r==="approved"?"Approved":r==="rejected"?"Rejected":r==="hold"?"On Hold":"Needs Edit"})]}),e.jsxs("span",{className:l("text-xs px-2 py-0.5 rounded-full",s.relevance==="high"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":s.relevance==="medium"?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"bg-slate-100 text-slate-600 dark:bg-slate-700 dark:text-slate-400"),children:[s.relevance," relevance"]})]}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:s.controlTitle}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-500 mt-1",children:s.reasoning}),e.jsxs("div",{className:"flex items-center gap-1 mt-3 pt-3 border-t border-slate-100 dark:border-slate-700",children:[e.jsx(p,{size:"sm",variant:r==="approved"?"default":"outline",className:l("h-7 px-2",r==="approved"?"bg-emerald-600 hover:bg-emerald-700":"text-emerald-600 hover:text-emerald-700 hover:bg-emerald-50 dark:hover:bg-emerald-900/30"),onClick:()=>we(t.fileId,s.controlId,"approved"),"data-testid":`button-approve-${i}`,children:e.jsx(Y,{className:"h-3.5 w-3.5"})}),e.jsx(p,{size:"sm",variant:r==="rejected"?"default":"outline",className:l("h-7 px-2",r==="rejected"?"bg-red-600 hover:bg-red-700":"text-red-600 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/30"),onClick:()=>we(t.fileId,s.controlId,"rejected"),"data-testid":`button-reject-${i}`,children:e.jsx(z,{className:"h-3.5 w-3.5"})}),e.jsx(p,{size:"sm",variant:"outline",className:"h-7 px-2 text-slate-600 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-700",onClick:()=>aa(t.fileId,s.controlId,s.controlTitle),"data-testid":`button-rerun-${i}`,children:e.jsx(Cs,{className:"h-3.5 w-3.5"})}),e.jsx(p,{size:"sm",variant:r==="hold"?"default":"outline",className:l("h-7 px-2",r==="hold"?"bg-amber-600 hover:bg-amber-700":"text-amber-600 hover:text-amber-700 hover:bg-amber-50 dark:hover:bg-amber-900/30"),onClick:()=>we(t.fileId,s.controlId,"hold"),"data-testid":`button-hold-${i}`,children:e.jsx(tr,{className:"h-3.5 w-3.5"})}),e.jsx(p,{size:"sm",variant:r==="needs-edit"||o?"default":"outline",className:l("h-7 px-2",r==="needs-edit"||o?"bg-blue-600 hover:bg-blue-700":"text-blue-600 hover:text-blue-700 hover:bg-blue-50 dark:hover:bg-blue-900/30"),onClick:()=>{sa(t.fileId,s.controlId),o||we(t.fileId,s.controlId,"needs-edit")},"data-testid":`button-edit-${i}`,children:e.jsx(Ha,{className:"h-3.5 w-3.5"})})]}),o&&e.jsx("div",{className:"mt-3 space-y-2",children:e.jsx(Rt,{placeholder:"Add notes for this control...",value:ta(t.fileId,s.controlId),onChange:u=>ea(t.fileId,s.controlId,u.target.value),className:"text-sm dark:bg-slate-900 dark:border-slate-600",rows:3,"data-testid":`textarea-notes-${i}`})})]},a)})})]}),t.recommendations.length>0&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 mb-2",children:"Recommendations"}),e.jsx("ul",{className:"text-sm text-slate-600 dark:text-slate-400 space-y-1",children:t.recommendations.map((s,a)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500 mt-0.5",children:"•"}),s]},a))})]})]})]},t.fileId))}),e.jsxs("div",{className:"flex justify-between pt-6 mt-6 border-t border-slate-200 dark:border-slate-700",children:[e.jsx(p,{variant:"ghost",onClick:()=>{N(m==="ISO27001"?"upload-evidence":"upload"),$t(null),m!=="ISO27001"&&Et(null),Vt(new Map),Ht(new Map),Xt(new Set)},className:"text-slate-500 dark:text-slate-400","data-testid":"button-back-upload",children:m==="ISO27001"?"Back to Upload Evidence":"Back to Upload"}),e.jsx("div",{className:"flex items-center gap-3",children:(()=>{const t=xs(),s=t.pending>0||t.rejected>0;return e.jsxs(e.Fragment,{children:[s&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-amber-100 dar
1k:bg-amber-900/30 text-amber-700 dark:text-amber-400 text-sm font-medium",children:[e.jsx(I,{className:"h-4 w-4"}),t.pending>0&&t.rejected>0?`${t.pending} pending, ${t.rejected} rejected`:t.pending>0?`${t.pending} pending review`:`${t.rejected} rejected`]}),e.jsx(p,{size:"lg",onClick:Ra,disabled:ft.isPending,className:"gap-2 shadow-lg shadow-primary/20","data-testid":"button-run-full-audit",children:ft.isPending?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Run Full Audit ",e.jsx(Re,{className:"h-4 w-4"})]})})]})})()})]})]})})]}),(d==="processing"||d==="run-audit")&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center animate-in fade-in duration-500",children:[e.jsxs("div",{className:"relative mb-8",children:[e.jsx("div",{className:"absolute inset-0 bg-blue-100 rounded-full animate-ping opacity-75"}),e.jsx("div",{className:"relative bg-white p-4 rounded-full shadow-xl border-4 border-blue-50",children:e.jsx(D,{className:"h-12 w-12 text-primary animate-spin"})})]}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900 mb-3",children:"Analyzing Evidence..."}),e.jsxs("p",{className:"text-slate-500 max-w-md mx-auto mb-8",children:["Our AI is currently mapping your documents to ",at(m)," controls and verifying compliance."]}
1),e.jsxs("div",{className:"w-full max-w-md space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-xs font-medium text-slate-600",children:[e.jsx("span",{children:"Processing Files"}),e.jsxs("span",{"data-testid":"text-progress",children:[Math.round(U),"%"]})]}),e.jsx(J,{value:U,className:"h-2"}),e.jsxs("div",{className:"text-xs text-slate-400 text-left pt-2",children:[U<40&&"Creating audit record...",U>=40&&U<80&&"Uploading evidence files...",U>=80&&"Running AI analysis..."]})]})]}),(d==="review"||d==="results")&&Me&&g&&e.jsxs("div",{className:"space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[e.jsxs("div",{className:"bg-emerald-50 border border-emerald-100 rounded-xl p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-emerald-100 text-emerald-600 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(H,{className:"h-8 w-8"})}),e.jsx("h2",{className:"text-2xl font-bold text-emerald-900 mb-2",children:"Audit Analysis Complete"}),e.jsxs("p",{className:"text-emerald-700 max-w-lg mx-auto",children:["Successfully analyzed ",L.length," documents against ",at(m)," controls. Generated ",Me.findingsCount," findings."]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsx(b,{children:e.jsxs(f,{className:"pt-6 text-center",children:[e.jsxs("div",{className:"text-4xl font-bold text-slate-900 mb-1","data-testid":"text-compliance-score",children:[Me.complianceScore,"%"]}),e.jsx("div",{className:"text-sm font-medium text-slate-500",children:"Compliance Score"})]})}),e.jsx(b,{children:e.jsxs(f,{className:"pt-6 text-center",children:[e.jsx("div",{className:"text-4xl font-bold text-primary mb-1","data-testid":"text-findings-count",children:Me.findingsCount}),e.jsx("div",{className:"text-sm font-medium text-slate-500",children:"Total Findings"})]})}),e.jsx(b,{children:e.jsxs(f,{className:"pt-6 text-center",children:[e.jsx("div",{className:"text-4xl font-bold text-blue-600 mb-1","data-testid":"text-evidence-count",children:L.length}),e.jsx("div",{className:"text-sm font-medium text-slate-500",children:"Evidence Files"})]})})]}),e.jsxs("div",{className:"flex justify-center gap-4 pt-4",children:[e.jsx(p,{variant:"outline",size:"lg",onClick:()=>{N(m==="ISO27001"?"upload-evidence":"upload"),ue([])},"data-testid":"button-upload-more",children:"Upload More Evidence"}),e.jsx(Ve,{href:`/documents?auditId=${g}`,asChild:!0,children:e.jsxs(p,{variant:"outline",size:"lg",className:"gap-2","data-testid":"button-view-documents",children:[e.jsx(Xa,{className:"h-4 w-4"})," View Document Library"]})}),e.jsx(Ve,{href:`/report?auditId=${g}`,asChild:!0,children:e.jsxs(p,{size:"lg",className:"gap-2 shadow-lg shadow-primary/20","data-testid":"button-view-report",children:["View Full Report ",e.jsx(Re,{className:"h-4 w-4"})]})}),e.jsx(Ve,{href:`/internal-audit-report?auditId=${g}`,asChild:!0,children:e.jsxs(p,{variant:"outline",size:"lg",className:"gap-2","data-testid":"button-internal-report",children:[e.jsx(re,{className:"h-4 w-4"})," Internal Audit Report"]})})]})]})]})})}function at(M){return M?{ISO27001:"ISO 27001",ISO27701:"ISO 27701",ISO42001:"ISO 42001",SOC2:"SOC 2",SOX_ITGC:"SOX ITGCs",NIST_CSF:"NIST CSF",NIST_RMF_AI:"NIST RMF AI",HIPAA_HITRUST:"HIPAA / HITRUST",FEDRAMP_LOW:"FedRAMP Low",FEDRAMP_MODERATE:"FedRAMP Moderate",FEDRAMP_HIGH:"FedRAMP High",FEDRAMP_TAILORED:"FedRAMP LI-SaaS",CMMC_L1:"CMMC Level 1",CMMC_L2:"CMMC Level 2",CMMC_L3:"CMMC Level 3"}[M]||M:"Unknown"}const ar={4:"Context of the Organization",5:"Leadership",6:"Planning",7:"Support",8:"Operation",9:"Performance Evaluation",10:"Improvement"},rr={"A.5":"Organizational Controls","A.6":"People Controls","A.7":"Physical Controls","A.8":"Technological Controls"};function ir(M){if(M.startsWith("A.")){const d=M.split(".").slice(0,2).join(".");return{groupKey:d,groupName:rr[d]||d}}const K=M.split(".")[0];return{groupKey:K,groupName:ar[K]||`Clause ${K}`}}function lr({controls:M}){const[K,d]=n.useState(new Set),N=n.useMemo(()=>{const k=new Map;return M.forEach(m=>{const{groupKey:S,groupName:j}=ir(m.controlId);k.has(S)||k.set(S,{name:j,controls:[],order:k.size}),k.get(S).controls.push(m)}),Array.from(k.entries()).sort((m,S)=>{const j=parseFloat(m[0].replace("A.","")),T=parseFloat(S[0].replace("A.",""));return!isNaN(j)&&!isNaN(T)?j-T:m[1].order-S[1].order})},[M]),De=k=>{d(m=>{const S=new Set(m);return S.has(k)?S.delete(k):S.add(k),S})};return e.jsx("div",{className:"space-y-2","data-testid":"control-grouped-checklist",children:N.map(([k,m])=>{const S=m.controls.filter(h=>h.status==="complete").length,j=m.controls.length,T=j>0?Math.round(S/j*100):0,v=K.has(k),Te=(()=>{const h=m.controls.map(_e=>_e.controlId);return h.length===0?"":`${h[0]} – ${h[h.length-1]}`})();return e.jsxs("div",{className:"border rounded-xl overflow-hidden bg-slate-50/50 dark:bg-slate-800/30 border-slate-200 dark:border-slate-700/50","data-testid":`control-group-${k}`,children:[e.jsxs("button",{onClick:()=>De(k),className:"w-full flex items-center gap-3 p-4 hover:bg-slate-100/70 dark:hover:bg-slate-800/50 transition-colors text-left","data-testid":`button-toggle-group-${k}`,children:[e.jsx("div",{className:"shrink-0",children:v?e.jsx(rt,{className:"h-4 w-4 text-slate-400"}):e.jsx(pe,{className:"h-4 w-4 text-slate-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-sm text-slate-900 dark:text-white",children:m.name}),e.jsx(O,{variant:"outline",className:"text-[10px] font-medium px-1.5 py-0",children:j})]}),e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-0.5",children:Te})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("div",{className:"w-24",children:e.jsx(J,{value:T,className:"h-1.5"})}),e.jsxs("span",{className:l("text-xs font-semibold min-w-[40px] text-right",T===100?"text-emerald-600":T>0?"text-indigo-600":"text-slate-400"),children:[T,"%"]}),e.jsxs("span",{className:"text-xs text-slate-400 min-w-[36px] text-right",children:[S,"/",j]})]})]}),v&&e.jsx("div",{className:"border-t border-slate-200 dark:border-slate-700/50 bg-white dark:bg-slate-900/50 divide-y divide-slate-100 dar
1k:divide-slate-800 animate-in fade-in slide-in-from-top-1 duration-200",children:m.controls.map(h=>e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 hover:bg-slate-50 dark:hover:bg-slate-800/30 transition-colors","data-testid":`checklist-item-${h.controlId}`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:l("w-5 h-5 rounded-full flex items-center justify-center shrink-0",h.status==="complete"?"bg-emerald-100 dark:bg-emerald-900/40":"bg-slate-100 dark:bg-slate-800"),children:h.status==="complete"?e.jsx(Y,{className:"h-3 w-3 text-emerald-600"}):e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-slate-300"})}),e.jsx("span",{className:"font-mono text-xs font-medium text-slate-700 dark:text-slate-300 w-12 shrink-0",children:h.controlId}),e.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400 truncate",children:h.controlTitle})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 ml-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:[h.evidenceCollected," files"]}),e.jsx("span",{className:l("text-xs font-medium px-2 py-0.5 rounded-full",h.status==="complete"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400":"bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-400"),children:h.status==="complete"?"Complete":"Not Started"}),e.jsx(pe,{className:"h-3.5 w-3.5 text-slate-300"})]})]},h.controlId))})]},k)})})}export{oi as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.