@wcag-checkr/ci 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/assets/ErrorBoundary-CGD9kz0E.js +594 -0
  2. package/dist/assets/{ai-usage-log-CYuyLsU4.js → ai-usage-log-C9Opn0x0.js} +1 -1
  3. package/dist/assets/{content-script.ts-CsBWyYDh.js → content-script.ts-DxtHl1_w.js} +1 -1
  4. package/dist/assets/{content-script.ts-loader-H5dU9ywW.js → content-script.ts-loader-CdztdNRK.js} +1 -1
  5. package/dist/assets/{copy-ai-fixer-prompt-CPoiD1Jp.js → copy-ai-fixer-prompt-DYAVFhB3.js} +2 -2
  6. package/dist/assets/{crash-reporter-KD5f4utB.js → crash-reporter-DAZnNefT.js} +1 -1
  7. package/dist/assets/{devtools-panel-DnGlvUWo.js → devtools-panel-BCDqUAiS.js} +1 -1
  8. package/dist/assets/{diff-Dc5xUcCG.js → diff-CECbooHD.js} +1 -1
  9. package/dist/assets/{options-BXcWL5FW.js → options-Bm-ovz5q.js} +1 -1
  10. package/dist/assets/{parallel-tab-flow-BmRaOzXY.js → parallel-tab-flow-f0rYsTcq.js} +1 -1
  11. package/dist/assets/{rubric-config-client-VUdHdJxq.js → rubric-config-client-CEBmuFV7.js} +1 -1
  12. package/dist/assets/{scheduled-audit-runner-D_ZjzHg0.js → scheduled-audit-runner-EQBltZPz.js} +15 -15
  13. package/dist/assets/{service-worker.ts-CnfhezBo.js → service-worker.ts-BcgJ4Lq9.js} +2 -2
  14. package/dist/assets/side-panel-Bgh2EbIa.js +4 -0
  15. package/dist/assets/{site-report-renderer-Cy-J72oi.js → site-report-renderer-C3U9cFY3.js} +1 -1
  16. package/dist/assets/{styles-Bik0yRU1.js → styles-DlQee1FU.js} +1 -1
  17. package/dist/assets/{tier-config-client-CT-oOti3.js → tier-config-client-CGmK5CXV.js} +1 -1
  18. package/dist/devtools/panel.html +7 -7
  19. package/dist/manifest.json +5 -5
  20. package/dist/options/options.html +5 -5
  21. package/dist/service-worker-loader.js +1 -1
  22. package/dist/side-panel/side-panel.html +10 -10
  23. package/package.json +1 -1
  24. package/dist/assets/ErrorBoundary-Dio2MH5c.js +0 -594
  25. package/dist/assets/side-panel-D3xkdQNu.js +0 -4
@@ -0,0 +1,594 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-EQBltZPz.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-DAZnNefT.js","assets/diff-CECbooHD.js","assets/ai-usage-log-C9Opn0x0.js","assets/copy-ai-fixer-prompt-DYAVFhB3.js","assets/site-report-renderer-C3U9cFY3.js"])))=>i.map(i=>d[i]);
2
+ var jn=Object.defineProperty;var kn=(t,s,a)=>s in t?jn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var ws=(t,s,a)=>kn(t,typeof s!="symbol"?s+"":s,a);import{R as Ye,k as he,r as m,j as e,M as Ve,C as Ge,A as js}from"./styles-DlQee1FU.js";import{k as Zt,m as Nn,n as Sn,o as ks,p as fa,q as me,r as es,t as Ee,S as Fe,u as Ns,b as _e,v as Ae,w as Te,x as ts,y as ba,z as An,A as Cn,B as In,D as En,E as Rn,f as Tn,F as $n,g as Un,s as ss,G as Ln,H as _n,N as Dn,I as as,J as On,K as Wt,L as va,M as Bt,l as Ze,O as ya,P as Fn,Q as Mn,R as Pn,T as Gn,h as Vn,U as Wn,V as Bn,W as Hn,X as zn,Y as Kn,Z as qn,_ as Qn,$ as wa,a0 as Yn,a1 as Jn,a2 as Je,a3 as bt,a4 as Xn,a5 as Zn,a6 as Ss,a7 as er,a8 as As,a9 as tr,aa as sr,ab as ar,ac as nr,ad as rr,ae as ir,af as or,ag as lr,ah as cr,ai as ja,aj as dr,ak as Cs,al as Is,am as Ut,an as ur,ao as Es,ap as pr,aq as hr,ar as mr,i as xr,j as gr}from"./scheduled-audit-runner-EQBltZPz.js";import{o as ge,r as ie,e as we,s as Q,c as ka,f as be,h as Re,j as Na,T as fr}from"./crash-reporter-DAZnNefT.js";import{_ as ve}from"./preload-helper-D7HrI6pR.js";import{g as Sa,f as At,t as nt,r as br,B as Me,h as vr,i as ns,j as xe,e as rs,k as yr,o as De,m as Aa,u as wr,n as Ct,p as jr,q as kr,W as Ca,v as Nr,w as Sr,T as Ar,x as Cr}from"./ai-usage-log-C9Opn0x0.js";import{g as Ia,a as Ir,b as Ea}from"./diff-CECbooHD.js";import{s as Er,t as Rr}from"./design-system-audit-DpxJrxnb.js";const Rs=t=>{let s;const a=new Set,n=(p,c)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=c??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(g=>g(s,h))}},r=()=>s,o={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,o);return o},Tr=t=>t?Rs(t):Rs,$r=t=>t;function Ur(t,s=$r){const a=Ye.useSyncExternalStore(t.subscribe,Ye.useCallback(()=>s(t.getState()),[t,s]),Ye.useCallback(()=>s(t.getInitialState()),[t,s]));return Ye.useDebugValue(a),a}const Ts=t=>{const s=Tr(t),a=n=>Ur(s,n);return Object.assign(a,s),a},Lr=t=>t?Ts(t):Ts,b=Lr(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"free",seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",findingsLens:"overview",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,crawlDiscoveryStatus:"idle",crawlDiscoveryUrls:[],crawlDiscoveryFound:0,crawlDiscoveryLastUrl:null,crawlNavContext:null,resolutionsByUrl:{},pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,pendingAreaExpand:null,auditStartedAtMs:null,lastAuditWallClockMs:null,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,auditStartedAtMs:Date.now(),crawlNavContext:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t(r=>{const i=r.auditStartedAtMs?Date.now()-r.auditStartedAtMs:null;return{results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0,lastAuditWallClockMs:i,auditStartedAtMs:null}}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setFindingsLens:s=>t({findingsLens:s}),setPendingAreaExpand:s=>t({pendingAreaExpand:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setCrawlNavContext:s=>t({crawlNavContext:s}),setResolutionsForUrl:(s,a)=>t(n=>({resolutionsByUrl:{...n.resolutionsByUrl,[s]:a}})),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Zt(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),setCrawlDiscoveryStatus:s=>t({crawlDiscoveryStatus:s}),setCrawlDiscoveryProgress:(s,a)=>t({crawlDiscoveryFound:s,crawlDiscoveryLastUrl:a}),setCrawlDiscoveryUrls:s=>t({crawlDiscoveryUrls:s}),resetCrawlDiscovery:()=>t({crawlDiscoveryStatus:"idle",crawlDiscoveryUrls:[],crawlDiscoveryFound:0,crawlDiscoveryLastUrl:null}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),dismissedKeys:new Set,setDismissedKeys:s=>t({dismissedKeys:s}),markDismissed:s=>t(a=>({dismissedKeys:new Set(a.dismissedKeys).add(s)})),markUndismissed:s=>t(a=>{const n=new Set(a.dismissedKeys);return n.delete(s),{dismissedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(o=>o.id!==s?o:a==="seen"?{...o,seen:!0}:a==="dismissed"?{...o,dismissed:!0}:a==="acknowledged"?{...o,acknowledged:!0}:a==="clicked"?{...o,clicked:!0}:o).filter(o=>o.severity==="critical"?!o.acknowledged:!o.dismissed),i=r.filter(o=>!o.seen).length,l=r.some(o=>o.severity==="critical"&&!o.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:l}})})),vt="sidePanel:lastAudit";function _r(){const t=[];return t.push(ge("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState(),n=a.status==="running",r=a.siteCrawlStatus==="running";a.setProgress({current:s.current,total:s.total,currentState:s.currentState}),r||(a.setStatus("running"),n||he.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`))})),t.push(ge("AUDIT_COMPLETE_EVENT",s=>{var o;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((d,p)=>d+p.violations.length,0),n=((o=s.delta)==null?void 0:o.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;he.polite(r);const i=b.getState().view;["compliance","guided","crawl"].includes(i)||(b.getState().setView("report"),b.getState().setFindingsLens("overview")),Or({results:s.results,delta:s.delta,componentId:s.componentId}),Dr(s.results,s.delta,s.componentId)})),t.push(ge("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(ge("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||he.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(ge("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(ge("SCORECARD_UPDATED_EVENT",()=>{yt()})),t.push(ge("LICENSE_CHANGED_EVENT",()=>{Ra()})),t.push(ge("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&he.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(ge("SITE_CRAWL_COMPLETE_EVENT",s=>{var n;const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),he.polite(s.report.siteGrade==="pending"?`Site crawl complete. Grade pending — answer the ${((n=s.report.spotCheckGate)==null?void 0:n.total)??8} content-meaning spot-checks to finalize. ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`:`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`),(async()=>{try{const{loadSiteCrawlPerUrlResults:r}=await ve(async()=>{const{loadSiteCrawlPerUrlResults:d}=await import("./scheduled-audit-runner-EQBltZPz.js").then(p=>p.b3);return{loadSiteCrawlPerUrlResults:d}},__vite__mapDeps([0,1,2,3,4])),{getResolutionsForPage:i}=await ve(async()=>{const{getResolutionsForPage:d}=await import("./scheduled-audit-runner-EQBltZPz.js").then(p=>p.b5);return{getResolutionsForPage:d}},__vite__mapDeps([0,1,2,3,4])),l=await r();if(!l||l.length===0)return;const o=b.getState().setResolutionsForUrl;await Promise.all(l.map(async d=>{try{const p=await i(d.url);o(d.url,p)}catch{}}))}catch(r){console.warn("[site-crawl] failed to pre-warm resolutions cache",r)}})()})),t.push(ge("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),he.assertive(`Site crawl failed: ${s.error.message}`)})),t.push(ge("CRAWL_DISCOVERY_PROGRESS_EVENT",s=>{const a=b.getState();a.crawlDiscoveryStatus!=="discovering"&&a.setCrawlDiscoveryStatus("discovering"),a.setCrawlDiscoveryProgress(s.found,s.url),s.found===1&&he.polite("Discovering pages to review.")})),t.push(ge("CRAWL_DISCOVERY_COMPLETE_EVENT",s=>{const a=b.getState();a.setCrawlDiscoveryUrls(s.urls),a.setCrawlDiscoveryStatus("reviewing"),he.polite(`Discovery complete. ${s.urls.length} page${s.urls.length===1?"":"s"} found — review and choose which to audit.`)})),t.push(ge("CRAWL_DISCOVERY_FAILED_EVENT",s=>{const a=b.getState();a.resetCrawlDiscovery(),a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),he.assertive(`Page discovery failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Dr(t,s,a){var n,r;if(t.length!==0)try{const i=await Sa();if(!i.enabled)return;const l=b.getState().tier;if(fa(l)||!we(l,"autoExportAuditReports"))return;const o=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",d=[],p=b.getState().lastAuditWallClockMs??void 0;for(const c of i.formats)try{const u=await ie({type:"EXPORT_REQUEST",format:c,results:t,delta:s??void 0,wallClockMs:p});if(typeof u.content!="string"||u.content.length<200)continue;const h=At(c,a??null);nt(u.content,h),o&&await br({url:o,exportedAt:new Date().toISOString(),format:c,filename:h}),d.push(h)}catch(u){console.warn(`[auto-export] format ${c} failed:`,u)}d.length>0&&he.polite(`Audit auto-exported ${d.length} file${d.length===1?"":"s"}.`)}catch(i){console.warn("[auto-export] failed:",i)}}async function Or(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[vt]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Fr(){const s=(await chrome.storage.local.get(vt))[vt];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Mr(){await chrome.storage.local.remove(vt)}async function It(){const t=b.getState();t.clearResults(),t.setSiteCrawlReport(null),t.setSiteCrawlError(null),t.setSiteCrawlStatus("idle"),await Mr();const{saveSiteCrawlReport:s}=await ve(async()=>{const{saveSiteCrawlReport:i}=await import("./scheduled-audit-runner-EQBltZPz.js").then(l=>l.b3);return{saveSiteCrawlReport:i}},__vite__mapDeps([0,1,2,3,4]));await s(null);const{clearAllCachedAudits:a}=await ve(async()=>{const{clearAllCachedAudits:i}=await import("./ai-usage-log-C9Opn0x0.js").then(l=>l.R);return{clearAllCachedAudits:i}},__vite__mapDeps([4,2]));await a();const{clearAllResolutions:n}=await ve(async()=>{const{clearAllResolutions:i}=await import("./scheduled-audit-runner-EQBltZPz.js").then(l=>l.b5);return{clearAllResolutions:i}},__vite__mapDeps([0,1,2,3,4])),{clearAllInteractiveAuditResults:r}=await ve(async()=>{const{clearAllInteractiveAuditResults:i}=await import("./scheduled-audit-runner-EQBltZPz.js").then(l=>l.b6);return{clearAllInteractiveAuditResults:i}},__vite__mapDeps([0,1,2,3,4]));await Promise.all([n(),r()])}async function yt(){const t=await ie({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function Ra(t){const s=await ie({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Ta()}async function Ta(){const{fetchMessages:t}=await ve(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Yr);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Pr(){async function t(){const s=await Nn();if(!s||Sn(s)==="expired"){ks(null);return}ks(s.config)}await t(),chrome.storage.onChanged.addListener((s,a)=>{a!=="local"||!("rubricConfigCache"in s)||t()})}async function Gr(){const s=(await ie({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="power"||s==="dev"?s:null;b.getState().setUserMode(a)}function Vr(){return chrome.runtime.connect({name:"audit-keepalive"})}let wt=null;async function Wr(){if(wt===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(wt=t.id)}catch{}}function is(){if(wt===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:wt}).catch(()=>{})}function je(t){is(),b.getState().setSiteCrawlReport(null),Zt(null).catch(()=>{}),Q(t)}function Br(t){is(),b.getState().setSiteCrawlReport(null),Zt(null).catch(()=>{}),Q(t)}const Ht="dismissedFindings";function Et(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function et(t){return`reading-order::${t}`}function tt(t){return`tab-order::${t}`}function os(t){return`violation::${t}`}async function Rt(){try{const t=await chrome.storage.local.get(Ht),s=t==null?void 0:t[Ht];if(s&&typeof s=="object")return s}catch{}return{}}async function ls(t){await chrome.storage.local.set({[Ht]:t})}async function cs(t){return(await Rt())[Et(t)]??{}}async function ds(t,s,a,n){const r=await Rt(),i=Et(t),l=r[i]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=l,await ls(r)}async function st(t,s){if(s.length===0)return;const a=await Rt(),n=Et(t),r=a[n]??{},i=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:i,snippet:l.snippet};a[n]=r,await ls(a)}async function us(t,s){const a=await Rt(),n=Et(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await ls(a))}const nu=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:ds,addDismissals:st,dismissalKeyForReadingOrder:et,dismissalKeyForTabOrder:tt,dismissalKeyForViolation:os,getDismissalsForUrl:cs,removeDismissal:us},Symbol.toStringTag,{value:"Module"}));function Hr({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[i,l]=m.useState(!0),[o,d]=m.useState(""),[p,c]=m.useState(!1),[u,h]=m.useState(null);async function g(f){var v;if(f.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const w=await ie({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:o.trim()||void 0});w.success?(h({ok:!0,msg:`Sent (ref: ${w.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((v=w.error)==null?void 0:v.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:g,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:f=>a(f.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:n,onChange:f=>r(f.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:o,onChange:f=>d(f.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:f=>l(f.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function $s({onClick:t,ariaLabel:s,title:a,children:n,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:a??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:n})}const jt=ka("messages-client"),zr="https://api.wcagcheckr.com",$a="wcagcheckr",Kr=1e4;function qr(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Ua(t,s){const a=await Ia();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":qr()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${zr}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Kr)})}async function Qr(t){if(!await Ia())return null;try{const s=await Ua(`/v1/products/${$a}/messages`,{userMode:t??null});return s.ok?await s.json():(jt.warn("fetchMessages http",s.status),null)}catch(s){return jt.warn("fetchMessages failed",s),null}}async function Pe(t,s){try{const a=await Ua(`/v1/products/${$a}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(jt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return jt.warn("ackMessage failed",a),!1}}const Yr=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Pe,fetchMessages:Qr},Symbol.toStringTag,{value:"Module"})),Jr=["http:","https:"];function Xr(t){try{const s=new URL(t);return Jr.includes(s.protocol)}catch{return!1}}function Us(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const l=t.indexOf(")",i+2);if(l!==-1){const o=t.slice(a+1,i),d=t.slice(i+2,l);Xr(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:o},`l-${n++}`)):s.push(e.jsx(m.Fragment,{children:o},`l-${n++}`)),a=l+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(m.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function La({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function l(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Us(d)},`p-${i++}`)),r=[]}function o(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,p)=>e.jsx("li",{children:Us(d)},p))},`u-${i++}`)),n=[])}for(const d of s){const p=d.trimEnd();if(p===""){l(),o();continue}const c=/^[-*]\s+(.*)$/.exec(p);if(c){l(),n.push(c[1]);continue}o(),r.push(p)}return l(),o(),e.jsx("div",{className:"space-y-1.5",children:a})}const Zr={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},ei={critical:"bg-rose-50 border-rose-200"};function _a(){const t=b(h=>h.unreadMessageCount),s=b(h=>h.messages),a=b(h=>h.applyMessageAck),[n,r]=m.useState(!1),i=m.useRef(-1),[l,o]=m.useState(!1);m.useEffect(()=>{const h=s.filter(f=>!f.seen);if(h.length===0)return;const g=Math.max(...h.map(f=>f.id));if(g>i.current){i.current=g,o(!0);const f=setTimeout(()=>o(!1),1500);return()=>clearTimeout(f)}},[s]);async function d(){const h=s.filter(g=>!g.seen);if(h.length!==0)for(const g of h)a(g.id,"seen"),Pe(g.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function c(h){a(h.id,"dismissed"),await Pe(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),Pe(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(ti,{active:t>0}),t>0&&e.jsx("span",{"aria-hidden":"true",className:"absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-rose-500 ring-2 ring-white"})]}),n&&e.jsx(si,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function ti({active:t}){return e.jsx("svg",{viewBox:"0 0 20 20",width:"16",height:"16","aria-hidden":"true",fill:"currentColor",className:t?"text-rose-500":"",children:e.jsx("path",{d:"M10 2a5 5 0 00-5 5v3l-1.6 2.4a1 1 0 00.84 1.6h11.52a1 1 0 00.84-1.6L15 10V7a5 5 0 00-5-5zm-1.5 13a1.5 1.5 0 003 0h-3z"})})}function si({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=m.useRef(null);return m.useEffect(()=>{const i=o=>{r.current&&(r.current.contains(o.target)||s())},l=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{Ta()},className:"text-[11px] text-brand-700 hover:underline",children:"Refresh"})]}),t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-[11px]",children:"No messages."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(i=>e.jsx("li",{className:`p-3 ${i.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${Zr[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(La,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function Da(){const t=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await Pe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),Pe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${ei.critical} px-3 py-2 text-xs flex items-start gap-2`,children:[e.jsx("span",{"aria-hidden":"true",className:"text-rose-600 text-sm leading-none mt-0.5",children:"⚠"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-rose-900",children:a.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(La,{source:a.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[a.ctaLabel&&a.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:a.ctaLabel}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const ai=[{id:"owner",label:"Owner",tooltip:"Site owners. Focuses on the specific issues demand-letter mills flag, with plain-language fix recipes per issue. Goal: get off the lawsuit-bot radar."},{id:"power",label:"Power user",tooltip:"Compliance verdict + full audit findings without the granular surfaces. Streamlined for people who want the answer, not the deep dive."},{id:"dev",label:"Dev",tooltip:"Everything. Multi-state matrix, baselines + delta, all exports, all specialized views (forensic log, schedules, ax-tree, design tokens, etc.)."}];function Oa(){const t=b(n=>n.userMode)??"owner",s=b(n=>n.setUserMode);function a(n){n!==t&&(s(n),chrome.storage.local.set({userMode:n,v2UiEnabled:n==="power"}),Q({type:"SETTINGS_SET",key:"userMode",value:n}))}return e.jsx("div",{className:"inline-flex rounded-md border border-slate-300 bg-white p-0.5 text-[11px] font-medium",role:"tablist","aria-label":"View mode",children:ai.map(n=>{const r=t===n.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":r,onClick:()=>a(n.id),title:n.tooltip,className:r?"px-2.5 py-1 rounded bg-slate-900 text-white":"px-2.5 py-1 rounded text-slate-600 hover:bg-slate-100",children:n.label},n.id)})})}const ni=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function ri(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function ii(){var p,c;const t=b(u=>u.view),s=b(u=>u.setView);b(u=>u.setUserMode);const a=b(u=>u.results),n=b(u=>u.status),[r,i]=m.useState(!1),l=((p=a[0])==null?void 0:p.pageUrl)??((c=a[0])==null?void 0:c.scope),o=ri(l),d=a.length>0&&n!=="running";return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(Oa,{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_a,{}),e.jsx($s,{onClick:()=>void Q({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx($s,{onClick:()=>i(!0),ariaLabel:"Send support message",children:"?"})]})]}),e.jsx("div",{className:"flex items-baseline justify-between mb-2",children:e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]})}),d&&o&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${o}`,children:o}),e.jsx("button",{type:"button",onClick:()=>void It(),className:"shrink-0 text-[11px] px-2 py-0.5 rounded border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 hover:border-slate-400",title:"Clear these results so you can run a fresh audit",children:"Clear"})]}),e.jsx(oi,{view:t,setView:s}),e.jsx(Ve,{open:r,onClose:()=>i(!1),title:"Send support message",children:e.jsx(Hr,{onClose:()=>i(!1)})})]})}function oi({view:t,setView:s}){const a=m.useRef([]),n=b(o=>o.results),r=ni.filter(o=>!o.hideWhenIdle||n.length>0);function i(o){var c;const d=(o+r.length)%r.length,p=r[d];p&&(s(p.slug),(c=a.current[d])==null||c.focus())}function l(o,d){switch(o.key){case"ArrowRight":o.preventDefault(),i(d+1);break;case"ArrowLeft":o.preventDefault(),i(d-1);break;case"Home":o.preventDefault(),i(0);break;case"End":o.preventDefault(),i(r.length-1);break}}return e.jsx("nav",{className:"flex gap-1","aria-label":"Primary navigation",role:"tablist",children:r.map((o,d)=>{const p=t===o.slug;return e.jsx("button",{ref:c=>{a.current[d]=c},role:"tab","aria-selected":p,tabIndex:p?0:-1,onClick:()=>s(o.slug),onKeyDown:c=>l(c,d),className:p?"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md bg-slate-900 text-white shadow-sm":"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md text-slate-600 hover:bg-slate-100 border border-transparent hover:border-slate-200",children:o.label},o.slug)})})}function li({feature:t,upgradeUrl:s}){const[a,n]=m.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Ge,{open:a,onClose:()=>n(!1)})]})}const ci="https://wcagcheckr.com/upgrade";function di(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,i]=m.useState(null),[l,o]=m.useState(null),[d,p]=m.useState(Me),[c,u]=m.useState(Me[0].id),[h,g]=m.useState("none"),[f,v]=m.useState(null),w=b(U=>U.status),S=b(U=>U.tier),I=b(U=>U.results.length>0),C=w==="running";m.useEffect(()=>{Promise.all([ie({type:"SETTINGS_GET",key:"matrixPresets"}),ie({type:"SETTINGS_GET",key:"activePresetId"})]).then(([U,M])=>{const P=Array.isArray(U.data)?U.data:null;p(P&&P.length>0?P:Me),typeof M.data=="string"&&u(M.data)})},[]);function N(U){const M=d.find(P=>P.id===U);M&&(u(U),Q({type:"SETTINGS_SET",key:"activePresetId",value:U}),Q({type:"SETTINGS_SET",key:"stateMatrix",value:M.matrix}))}const k=we(S,"storybookAutoIterate");m.useEffect(()=>{const U=ge("ELEMENT_PICKED_EVENT",(P,T)=>{n(!1);const ee=T.frameId;W(ee),i({selector:P.selector,frameId:ee,speech:P.speech})}),M=ge("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{U(),M()}},[]);async function x(){const U=await me();U&&(n(!0),await be(U,{type:"PICKER_ACTIVATE_REQUEST",tabId:U}))}function y(){r&&(W(r.frameId),je({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function R(){if(!k){o("storybook:auto-iterate");return}W(),je({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function A(){W(),je({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function $(){W(),je({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function _(){W(),je({type:"START_AUDIT",mode:"full-page",verifyFixesOnly:!0}),b.getState().startNewScan()}function H(){W(),je({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function oe(){W(),je({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function G(){Q({type:"CANCEL_AUDIT"})}async function W(U){b.getState().setPinned(null);const M=await me();if(M)try{await be(M,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:M},U)}catch{}}async function E(U){v(null);const M=await me();if(!M){v("No audited tab; open a page first.");return}if(U==="none"){const T=await ie({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:M});T.ok||v(T.error??"Failed to clear throttle."),g("none");return}const P=await ie({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:M,profile:U});if(!P.ok){v(P.error??"Failed to apply throttle.");return}g(U)}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:U=>s(U.target.value),disabled:C||a,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",k?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:U=>N(U.target.value),disabled:C||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(U=>e.jsx("option",{value:U.id,children:U.name},U.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:U=>void E(U.target.value),disabled:C||a,title:"Apply CDP network + CPU throttling to the audited tab. Catch contrast / focus / loading-state issues that only manifest under realistic conditions.",className:`text-xs border rounded px-2 py-1 ${h==="none"?"border-slate-300":"border-amber-400 bg-amber-50"}`,children:[e.jsx("option",{value:"none",children:"⚡ Throttle: off"}),e.jsx("option",{value:"3g-slow",children:"⚡ Slow 3G + 6× CPU"}),e.jsx("option",{value:"3g-fast",children:"⚡ Fast 3G + 4× CPU"}),e.jsx("option",{value:"4g",children:"⚡ 4G LTE + 2× CPU"}),e.jsx("option",{value:"cpu-2x",children:"⚡ CPU 2× only"}),e.jsx("option",{value:"cpu-4x",children:"⚡ CPU 4× only"})]}),t==="single-element"?e.jsx(pi,{picking:a,picked:r,isRunning:C,onPick:x,onRun:y,onClearPick:()=>i(null)}):t==="full-page"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:$,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Scan page"}),e.jsx("button",{onClick:_,disabled:C||!I,className:"text-xs px-3 py-1 border border-emerald-400 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed",title:I?"Re-runs the audit but skips walkthroughs that already passed or are human-acked. Faster + cheaper after a fix/ack pass.":"Run a full Scan page first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.",children:C?"Auditing…":"Verify fixes (skip passed)"})]}):t==="quick-scan"?e.jsx("button",{onClick:H,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:C?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:oe,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:C?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:A,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:R,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all stories"}),C&&e.jsx("button",{onClick:G,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!C&&I&&e.jsx("button",{type:"button",onClick:()=>void It(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),f&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",f]}),t==="single-element"&&r&&!a&&!C&&e.jsx(hi,{selector:r.selector,onRepick:x,onClear:()=>i(null)})]}),e.jsx(Ve,{open:l!==null,onClose:()=>o(null),title:"Upgrade to continue",children:e.jsx(li,{feature:l??"",upgradeUrl:ci})})]})}function ui({speech:t}){if(!t)return null;const s=[];if(t.name&&s.push(t.name),t.role&&!["none","presentation","generic"].includes(t.role)&&s.push(t.role),s.push(...t.states),t.group&&s.push(t.group),s.length===0)return e.jsxs("span",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-0.5",title:"A screen reader would announce nothing for this element. Either it has no accessible name + a silent role (generic/presentation), or it's hidden from AT entirely.","data-testid":"sr-speech-preview",children:["SR: ",e.jsx("em",{children:"(silent)"})]});const a=s.join(", ");return e.jsxs("span",{className:"text-[10px] text-slate-700 bg-slate-100 border border-slate-200 rounded px-2 py-0.5 max-w-[280px] truncate",title:`Predicted screen-reader announcement when this element receives focus: "${a}"`,"data-testid":"sr-speech-preview",children:["SR: ",e.jsx("strong",{children:a})]})}function pi({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}),e.jsx(ui,{speech:s.speech})]}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function hi({selector:t,onRepick:s,onClear:a}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:a,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const mi={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},xi={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function gi(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[l,o]=m.useState("off"),d=b(f=>f.results),p=b(f=>f.tier),c=d.flatMap(f=>f.violations);if(!we(p,"visualizers"))return null;async function u(f){const v=await me();v&&(o(f),f==="off"?await be(v,{type:"VISION_SIMULATOR_CLEAR",tabId:v}).catch(()=>{}):await be(v,{type:"VISION_SIMULATOR_APPLY",tabId:v,mode:f}).catch(()=>{}))}async function h(f){const v=await me();if(v){if(t&&await be(v,{type:mi[t],tabId:v}).catch(()=>{}),t===f){s(null);return}await be(v,{type:xi[f],tabId:v}).catch(()=>{}),s(f)}}async function g(){const f=await me();if(f){if(a){await be(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),n(!1),i(null);return}if(c.length===0){i("Run an audit first.");return}try{const v=await Re(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:c});n(!0),i(`Previewing ${v.visualFixCount} visual fix${v.visualFixCount===1?"":"es"} + ${v.annotationCount} annotation${v.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(Be,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>h("outline")}),e.jsx(Be,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>h("tab-order")}),e.jsx(Be,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>h("reading-order")}),e.jsx(Be,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>h("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(Be,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:g}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:l,onChange:f=>void u(f.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${l==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function Be({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Ne({feature:t,label:s,children:a}){const n=b(r=>r.tier);return we(n,t)?e.jsx(e.Fragment,{children:a}):e.jsxs("div",{className:"p-6 text-center",children:[e.jsxs("div",{className:"mb-2 text-sm font-semibold text-slate-700",children:[s," isn’t available on your current plan"]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Upgrade your plan to unlock this feature."})]})}function fi(t){if(!t)return"";const s=[t.pseudoState];return t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),s.join(" · ")}function bi(){const t=b(d=>d.status),s=b(d=>d.progress),a=b(d=>d.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":fi(s.currentState),l=n?100:s.current/s.total*100,o=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(Ls,{label:r,detail:i,pct:l,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),o&&e.jsx(Ls,{label:`AI augmentation… ${a.current}/${a.total}`,detail:a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel,pct:a.current/a.total*100,valuenow:a.current,valuemax:a.total,ariaLabel:`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`,barClass:"bg-violet-100",fillClass:"bg-violet-500"})]})}function Ls({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:l,fillClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${l}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${o}`,style:{width:`${a}%`}})})]})}function _s(t){if(!t)return"";try{return new URL(t).host}catch{return t}}function vi({onView:t,viewingRun:s,crawlOnly:a}){var d,p;const n=b(c=>c.siteCrawlReport),r=b(c=>c.results),i=b(c=>c.siteCrawlStatus)==="running",l=b(c=>c.status)==="running";if(s||i||l)return null;let o=null;if(n)o=`Last crawl · ${_s(n.startUrl)} · ${n.pagesAudited} page${n.pagesAudited===1?"":"s"} · grade ${n.siteGrade==="pending"?"pending (spot-checks)":n.siteGrade}`;else if(!a&&r.length>0){const c=((d=r[0])==null?void 0:d.pageUrl)??((p=r[0])==null?void 0:p.scope),u=r.reduce((h,g)=>h+g.violations.length,0);o=`Last audit · ${_s(c)} · ${u} finding${u===1?"":"s"}`}return o?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-brand-50 border-b border-brand-200 text-[11px] text-brand-900",children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{className:"flex-1 min-w-0 truncate",title:o,children:o}),e.jsx("button",{type:"button",onClick:t,className:"shrink-0 px-2 py-0.5 rounded bg-brand-600 text-white hover:bg-brand-700 font-medium",children:"View"})]}):null}function yi(){const t=new Set;for(const s of Fe)for(const a of s.axeRules)t.add(a);return t}function Fa(t,s,a={}){const n=a.excludeAckedMatchKeys?t.filter(o=>!a.excludeAckedMatchKeys.has(o.matchKey)):t,r=es(n),i=new Set(r.map(o=>Ee(o.ruleId,o.target.selector)));let l=0;for(const o of s){if(o.verdict!=="fail")continue;const d=Ee(o.ruleId,o.selector);i.has(d)||(i.add(d),l++)}return r.length+l}function Ma(t,s,a,n){const r=new Set;for(const i of t)a.has(i.matchKey)||n.has(`violation::${i.matchKey}`)||r.add(`${i.ruleId}::${i.target.selector}`);for(const i of s)i.verdict==="fail"&&r.add(`${i.ruleId}::${i.selector}`);return r.size}function wi(t,s,a,n){const r=new Set;for(const i of t)a.has(i.matchKey)||n.has(`violation::${i.matchKey}`)||i.wcagCriterion&&r.add(i.wcagCriterion);for(const i of s)i.verdict==="fail"&&i.wcagCriterion&&r.add(i.wcagCriterion);return Array.from(r).sort()}function ji(t,s,a={}){const n=yi(),i=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),l=es(i),o={critical:0,serious:0,moderate:0,minor:0};for(const c of l)o[c.impact]++;const d=new Set(l.map(c=>Ee(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const u=Ee(c.ruleId,c.selector);d.has(u)||(d.add(u),o.serious++)}return{total:o.critical+o.serious+o.moderate+o.minor,counts:o,representatives:l}}function ps(t){var i,l;const s=((i=t[0])==null?void 0:i.pageUrl)??((l=t[0])==null?void 0:l.scope)??"",a=b(o=>o.setResolutionsForUrl),[n,r]=m.useState(()=>{if(!s)return[];const o=b.getState().resolutionsByUrl[s];return o?Ns(o,t):[]});return m.useEffect(()=>{if(!s){r([]);return}let o=!1;return _e(s).then(d=>{o||(a(s,d),r(Ns(d,t)))}),()=>{o=!0}},[s,t,a]),n}const ki=[{slug:"delta",label:"Delta",blurb:"Compare against the last baseline; export the prompt",marker:"Δ"},{slug:"guided",label:"Guided",blurb:"Step through manual IGT workflows",marker:"G"},{slug:"compliance",label:"Compliance",blurb:"WCAG-EM report builder + sign-and-seal",marker:"§"},{slug:"scorecard",label:"Components",blurb:"Every tracked component baseline at a glance",marker:"◍"},{slug:"forensic",label:"Forensic",blurb:"Audit history + RFC 3161 timestamps",marker:"⧉"},{slug:"schedules",label:"Schedules",blurb:"Recurring audits + alerts",marker:"⟳"},{slug:"risk",label:"Risk",blurb:"Posture summary across scheduled audits",marker:"⌖"},{slug:"crawl",label:"Site crawl",blurb:"Audit a multi-page site",marker:"↺"},{slug:"flows",label:"Flows",blurb:"Record + replay user-action sequences",marker:"▷"},{slug:"copilot",label:"Co-pilot",blurb:"Chat with AI grounded on the current audit",marker:"✦"},{slug:"ax-tree",label:"AX tree",blurb:"Browser's accessibility-tree viewer",marker:"⌥"},{slug:"tokens",label:"Design tokens",blurb:"CSS custom-properties usage map",marker:"#"}];function Ni(){const t=b(n=>n.results),s=b(n=>n.status),a=b(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(Si,{results:t,status:s,setView:a}),e.jsx(Ai,{setView:a})]})}function Si({results:t,status:s,setView:a}){var v,w;const n=ps(t),r=b(S=>S.acknowledgedKeys),i=b(S=>S.dismissedKeys);if(s==="running")return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"audit in progress"}),e.jsxs("p",{className:"text-sm font-medium text-slate-900 mt-1",children:["The matrix is iterating. Progress is shown above; results land in ",e.jsx("strong",{children:"Findings"})," when done."]})]});if(t.length===0)return e.jsxs("section",{className:"border border-dashed border-slate-300 rounded-lg bg-slate-50 px-4 py-5 text-center",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"no audit yet"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-1",children:"Pick an audit mode above and run a scan."}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 max-w-md mx-auto",children:"Or jump into a specialized tool below — site crawl, multi-page schedules, IGT workflows, the AI co-pilot, the forensic log."})]});const l=t.flatMap(S=>S.violations),o=es(l),d=((v=t[0])==null?void 0:v.pageUrl)??((w=t[0])==null?void 0:w.scope)??"audited page",p=t.length,c=Ma(l,n,r,i),u=l.filter(S=>!r.has(S.matchKey)&&!i.has(`violation::${S.matchKey}`)),h=Fa(u,n),g=3,f=c>0&&c<=g?o.slice(0,g):[];return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 truncate",children:["last audit · ",p," state",p===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate mt-0.5",title:d,children:c===0?"No issues found by automation":h===c?`${h} issue${h===1?"":"s"} to fix`:`${h} issue${h===1?"":"s"} across ${c} instance${c===1?"":"s"}`})]}),e.jsx("button",{type:"button",onClick:()=>a("report"),className:"shrink-0 text-xs font-medium px-3.5 py-1.5 bg-slate-900 text-white rounded-md hover:bg-slate-800",children:"View findings →"})]}),f.length>0&&e.jsx("ul",{className:"border-t border-slate-200 divide-y divide-slate-100","aria-label":"Violations inline list",children:f.map(S=>{var N;const I=((N=S.target)==null?void 0:N.selector)??"(no selector)",C=I.length>50?I.slice(0,47)+"…":I;return e.jsx("li",{className:"px-3.5 py-2",children:e.jsxs("button",{type:"button",onClick:()=>a("report"),className:"w-full text-left flex items-center gap-2 hover:bg-slate-50 -mx-3.5 -my-2 px-3.5 py-2 transition-colors",title:`${S.description??S.ruleId} — ${I}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${S.impact==="critical"?"bg-rose-200 text-rose-900":S.impact==="serious"?"bg-orange-200 text-orange-900":S.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:S.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:S.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:C})]})},`${S.ruleId}::${I}`)})})]})}function Ai({setView:t}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ki.map(s=>e.jsxs("button",{type:"button",onClick:()=>t(s.slug),className:"text-left rounded-lg border border-slate-200 bg-white hover:bg-slate-50 hover:border-slate-300 transition-colors px-3 py-2.5 flex flex-col gap-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1",children:[e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-slate-600",children:[e.jsx("span",{className:"text-slate-700 mr-1.5",children:s.marker}),s.slug]}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 leading-tight mt-0.5",children:s.label}),e.jsx("span",{className:"text-[11px] text-slate-500 leading-snug",children:s.blurb})]},s.slug))})]})}const rt="aiConfig";function hs(){const[t,s]=m.useState(!1);return m.useEffect(()=>{function a(r){s(!!(r&&r.enabled&&r.apiKey))}chrome.storage.local.get(rt).then(r=>a(r[rt])).catch(()=>s(!1));const n=(r,i)=>{var l;i!=="local"||!(rt in r)||a((l=r[rt])==null?void 0:l.newValue)};return chrome.storage.onChanged.addListener(n),()=>chrome.storage.onChanged.removeListener(n)},[]),t}const Ci={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function Ii({violations:t,componentId:s}){var K,te,de,L,z,O,ne,ae;const[a,n]=m.useState([]),[r,i]=m.useState({}),[l,o]=m.useState([]),[d,p]=m.useState([]),[c,u]=m.useState(new Set),[h,g]=m.useState(null),[f,v]=m.useState({}),[w,S]=m.useState(new Set),[I,C]=m.useState(null),N=b(F=>F.status),k=b(F=>F.progress),x=b(F=>F.freshThisSession),y=b(F=>F.results),R=b(F=>F.acknowledgedKeys),A=(K=y[0])==null?void 0:K.startedAt,$=((te=y[0])==null?void 0:te.pageUrl)??((de=y[0])==null?void 0:de.scope)??null;m.useEffect(()=>{if(!s){n([]),i({});return}let F=!1;return chrome.storage.local.get("igtRuns").then(q=>{if(F)return;const J=((q==null?void 0:q.igtRuns)??{})[s]??{};n(Object.values(J))}),Promise.all([Ae(s),Te([s])]).then(([q,ce])=>{if(F)return;const J=new Set(ce.map(re=>re.criterionId)),se={},fe=[];for(const re of q){const ue=J.has(re.criterionId)?"pass":re.verdict;re.criterionId==="2.4.3"?se.focusOrder=ue:re.criterionId==="2.1.2"?se.keyboardTrap=ue:re.criterionId==="2.4.7"?se.focusVisible=ue:re.criterionId==="1.3.2"?se.readingOrder=ue:re.criterionId==="1.4.11"&&(se.nonTextContrast=ue),fe.push({criterionId:re.criterionId,ruleId:`ai-walkthrough-${re.criterionId}`,pageUrl:re.pageUrl,verdict:ue,reasoning:J.has(re.criterionId)?`Human verified: ${re.reasoning}`:re.reasoning})}i(se),o(fe)}),()=>{F=!0}},[s]),m.useEffect(()=>{if(!$){p([]);return}let F=!1;return _e($).then(q=>{F||p(q)}),()=>{F=!0}},[$,y]);const _=ps(y),H=ts({violations:t,auditRan:y.length>0,manualRuns:a,workflows:xe,heuristicCounts:{tabOrder:((z=(L=y[0])==null?void 0:L.tabOrderIssues)==null?void 0:z.length)??0,readingOrder:((ne=(O=y[0])==null?void 0:O.readingOrderIssues)==null?void 0:ne.length)??0},interactiveAuditVerdicts:r,aiResolvedFails:_.map(F=>({ruleId:F.ruleId,impact:"serious",selector:F.selector}))}),G=new Set(y.map(F=>F.pageUrl??F.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",W=y.length>0?ba(y,{runs:a,workflows:xe},"2.1","AA",R,d,l,G):void 0,E=y.length>0?vr(ns({audits:y,igtRuns:a,workflows:xe,acknowledgedMatchKeys:R,incompleteResolutions:d,interactiveAuditResults:l,auditScope:G}),xe):void 0,M=(W?W.failingCriteria.length+W.inconclusiveCriteria.length+W.untestedCriteria.length:0)===0&&!!W;async function P(F){var fe;if(!$||!((fe=W==null?void 0:W.inconclusiveReasons)!=null&&fe[F]))return;const ce=W.inconclusiveReasons[F].filter(re=>re.source==="axe-incomplete"&&re.elements&&re.elements.length>0);if(ce.length===0)return;u(re=>new Set(re).add(F)),g(null);const J=[];let se=0;try{for(const ue of ce){const ke=await Q({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:ue.ruleOrStepId,pageUrl:ue.pageUrl??$,wcagCriterion:F,elements:ue.elements??[],targetLevel:"AA"});if(ke!=null&&ke.unavailableReason){g(ke.unavailableReason);break}ke!=null&&ke.resolutions&&(J.push(...ke.resolutions),se+=ke.totalCostUsd??0)}if($){const ue=await _e($);p(ue)}const re={total:J.length,pass:J.filter(ue=>ue.verdict==="pass").length,fail:J.filter(ue=>ue.verdict==="fail").length,uncertain:J.filter(ue=>ue.verdict==="uncertain").length,costUsd:se,resolutions:J};v(ue=>({...ue,[F]:re}))}finally{u(re=>{const ue=new Set(re);return ue.delete(F),ue})}}function T(F){S(q=>{const ce=new Set(q);return ce.has(F)?ce.delete(F):ce.add(F),ce})}const ee=((ae=y[0])==null?void 0:ae.startedAt)??null,X=s&&ee?`${s}::${ee}`:null;if(m.useEffect(()=>{if(!X||!W||I===X||N!=="complete")return;const F=W.inconclusiveCriteria.filter(q=>{var J;return(((J=W.inconclusiveReasons)==null?void 0:J[q])??[]).some(se=>se.source==="axe-incomplete"&&se.elements&&se.elements.length>0)});if(F.length===0){C(X);return}C(X),(async()=>{for(const q of F)try{await P(q)}catch{}})()},[X,W,N]),N==="running")return e.jsx(_i,{current:k==null?void 0:k.current,total:k==null?void 0:k.total});async function D(F){var ke,ys;if(!$)return;const q=((ke=W==null?void 0:W.inconclusiveReasons)==null?void 0:ke[F])??[],ce=((ys=W==null?void 0:W.failingReasons)==null?void 0:ys[F])??[],J=[],se=new Set;for(const pe of q){if(pe.source!=="axe-incomplete"||!pe.elements)continue;const Ce=pe.pageUrl??$;for(const Ie of pe.elements){const We=`${Ce}::${pe.ruleOrStepId}::${Ie.selector}`;se.has(We)||(se.add(We),J.push({ruleId:pe.ruleOrStepId,pageUrl:Ce,selector:Ie.selector}))}}for(const pe of ce){if(pe.source!=="ai"||!pe.selector)continue;const Ce=pe.ruleOrStepId.startsWith("ai-resolved::")?pe.ruleOrStepId.slice(13):pe.ruleOrStepId,Ie=pe.pageUrl??$,We=`${Ie}::${Ce}::${pe.selector}`;se.has(We)||(se.add(We),J.push({ruleId:Ce,pageUrl:Ie,selector:pe.selector}))}if(J.length===0)return;const fe=new Date().toISOString(),re=[];for(const pe of J){const Ce=d.find(Ie=>Ie.pageUrl===pe.pageUrl&&Ie.ruleId===pe.ruleId&&Ie.selector===pe.selector);Ce&&Ce.verdict==="pass"&&Ce.reasoning.startsWith("Marked as visually verified")||re.push({pageUrl:pe.pageUrl,ruleId:pe.ruleId,selector:pe.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${fe.slice(0,10)}.`,resolvedAt:fe,costUsd:0,wcagCriterion:F})}if(re.length===0)return;await An(re);const ue=await _e($);p(ue),v(pe=>({...pe,[F]:{total:re.length,pass:re.length,fail:0,uncertain:0,costUsd:0,resolutions:re}}))}const Y=(()=>{if(!W)return null;if(M)return{kind:"conformant",text:`WCAG ${W.targetLevel} Status: Conformant`,detail:"All applicable criteria pass automated + AI checks."};const F=W.inconclusiveCriteria.length,q=W.failingCriteria.length,ce=W.untestedCriteria.length,J=[];if(q>0){const fe=W.failingCriteria.slice(0,4).join(", ")+(q>4?`, +${q-4}`:"");J.push(`${q} ${q===1?"criterion":"criteria"} failing (${fe})`)}if(F>0){const fe=W.inconclusiveCriteria.slice(0,4).join(", ")+(F>4?`, +${F-4}`:"");J.push(`${F} inconclusive (${fe})`)}if(ce>0){const fe=W.untestedCriteria.slice(0,4).join(", ")+(ce>4?`, +${ce-4}`:"");J.push(`${ce} untested (${fe})`)}const se=q>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":ce>0?"Mark untested via Guided Tests, OR confirm the tool gap (no axe rule + no AI walkthrough + no IGT step).":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return{kind:"not-conformant",text:`WCAG ${W.targetLevel} Status: Not conformant`,detail:`${J.join(" · ")}. ${se}`}})();let Z=0;for(const F of xe){const q=a.find(J=>J.workflowId===F.id);if(!q)continue;F.steps.every(J=>{const se=q.steps[J.id];return(se==null?void 0:se.status)==="pass"||(se==null?void 0:se.status)==="fail"||(se==null?void 0:se.status)==="skip"||(se==null?void 0:se.status)==="not-applicable"})&&Z++}const j=new Set;for(const F of t)R.has(F.matchKey)||j.add(`${F.ruleId}::${F.target.selector}`);for(const F of _)F.verdict==="fail"&&j.add(`${F.ruleId}::${F.selector}`);const V=j.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!x&&A&&e.jsx(Di,{scannedAt:A}),Y&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${Y.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[Y.kind==="conformant"?"✓ ":"✗ ",Y.text]}),e.jsx("p",{className:"mt-0.5",children:Y.detail})]}),H.isLawsuitRisk&&e.jsx(Ti,{areas:H.warningAreas}),e.jsx($i,{grades:H.subGrades,uncategorized:ji(t,d,{excludeAckedMatchKeys:R})}),W&&e.jsx(Ei,{coverage:W,onResolveWithAi:P,onMarkVisuallyVerified:D,resolving:c,resolveError:h,lastResolveResult:f,expandedResultFor:w,onToggleResultDetail:T,violations:t}),E&&e.jsx(Ri,{layers:E}),e.jsx(Li,{violationsRemaining:V,manualCompleted:Z,manualTotal:xe.length}),Z>0||y.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:Z})," of ",e.jsx("strong",{children:xe.length})," workflows complete"]}),e.jsx("div",{className:"flex h-1 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500",style:{width:`${Z/xe.length*100}%`}})})]}):null]})}function Ei({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:l,onToggleResultDetail:o,violations:d}){const p=b(C=>C.setView),c=b(C=>C.setFindingsLens),u=b(C=>C.setPendingAreaExpand);function h(C){const N=Cn(C,d);p("report"),N?(c("per-area"),u(N)):c("violations")}const g=t.untestedCriteria.length+t.inconclusiveCriteria.length,[f,v]=m.useState(g>0&&g<=3),w=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),S=t.canClaimConformance,I=[];return t.failingCriteria.length>0&&I.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&I.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&I.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${S?"border-emerald-200 bg-emerald-50":"border-amber-200 bg-amber-50"} px-3 py-2 text-[11px] leading-snug`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-2 ${S?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",w,"%)"]}),S&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:["Every applicable criterion has been evaluated and either passes or is N/A. This audit can be presented as a conformance-claim for ",t.targetVersion," ",t.targetLevel," for the audited URL(s)."]}),!S&&(()=>{const C=[];t.failingCriteria.length>0&&C.push("failing"),t.inconclusiveCriteria.length>0&&C.push("inconclusive"),t.untestedCriteria.length>0&&C.push("untested");const N=C.length===0?"unresolved":C.length===1?C[0]:C.length===2?`${C[0]} or ${C[1]}`:`${C.slice(0,-1).join(", ")}, or ${C[C.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",N,"."]})})(),!S&&t.untestedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.untestedCriteria.length," untested"]})," ",t.untestedCriteria.length===1?"criterion":"criteria"," — mark Pass / Fail / N/A in Guided Tests below."]}),!S&&t.inconclusiveCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.inconclusiveCriteria.length," inconclusive"]})," ",t.inconclusiveCriteria.length===1?"criterion":"criteria"," — axe couldn't fully determine OR an IGT step was skipped. Resolve before claiming conformance."]})]}),!S&&I.length>0&&e.jsx("button",{type:"button",onClick:()=>v(C=>!C),className:"text-[11px] underline shrink-0 self-start",children:f?"hide":"show list"})]}),f&&!S&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[I.map(C=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${C.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[C.kind==="untested"?"Untested":C.kind==="inconclusive"?"Inconclusive":"Failing"," (",C.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:C.ids.map(N=>{var H,oe;const k=C.kind==="inconclusive"?(H=t.inconclusiveReasons)==null?void 0:H[N]:void 0,x=C.kind==="failing"?(oe=t.failingReasons)==null?void 0:oe[N]:void 0,y=k==null?void 0:k.some(G=>G.source==="axe-incomplete"&&G.elements&&G.elements.length>0),R=x==null?void 0:x.some(G=>G.source==="ai"),A=(n==null?void 0:n.has(N))??!1,$=i==null?void 0:i[N],_=(l==null?void 0:l.has(N))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>h(N),className:"font-mono text-[11px] text-left underline-offset-2 hover:underline text-brand-700 hover:text-brand-800 cursor-pointer",title:`Jump to the verification area covering ${N}`,children:["· ",N]}),(C.kind==="inconclusive"&&y||C.kind==="failing"&&R)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[C.kind==="inconclusive"&&s&&N!=="1.4.3"&&N!=="1.4.6"&&e.jsx("button",{type:"button",disabled:A,onClick:()=>s(N),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:A?"Resolving…":$?"✨ Resolve again →":"✨ Resolve with AI →"}),C.kind==="inconclusive"&&(N==="1.4.3"||N==="1.4.6")&&e.jsx("span",{className:"text-[10px] text-slate-500 italic",title:"The pixel-contrast sampler runs automatically and produces the authoritative verdict for color-contrast. Mark visually verified if the AI was wrong about a specific element.",children:"Pixel sampler ran automatically — use Mark visually verified if needed"}),a&&e.jsx("button",{type:"button",disabled:A,onClick:()=>a(N),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:C.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),$&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",$.total," ",$.total===1?"verdict":"verdicts",":",$.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",$.pass," pass"]}),$.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",$.fail," fail"]}),$.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",$.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",$.costUsd.toFixed(4)]}),o&&e.jsx("button",{type:"button",onClick:()=>o(N),className:"ml-auto text-[10px] underline text-brand-700",children:_?"hide reasoning":"show reasoning"})]}),$.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",$.uncertain," ",$.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),$.pass===$.total&&$.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),_&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:$.resolutions.map((G,W)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:G.verdict==="pass"?"text-emerald-700 font-semibold":G.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:G.verdict==="pass"?"✓":G.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:G.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:G.reasoning})]},W))})]}),x&&x.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:x.map((G,W)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[G.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:G.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),G.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:G.ruleOrStepId})," fail — "]}),G.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:G.ruleOrStepId})," fail — "]}),G.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:G.selector}),G.notes&&e.jsx("span",{className:"text-rose-700",children:G.notes})]},W))}),k&&k.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:k.map((G,W)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[G.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:G.ruleOrStepId})," — "]}),G.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:G.ruleOrStepId})," skipped — "]}),G.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:G.ruleOrStepId})," — "]}),G.resolutionHint,G.elements&&G.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",G.elements.length===1?"element":`${G.elements.length} elements`,":"," ",G.elements.slice(0,3).map((E,U,M)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:E.selector}),U<M.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},U)),G.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",G.elements.length-3," more"]})]})]},W))}):C.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},N)})})]},C.kind)),r&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:r})]})]})}const Ds={automation:{label:"Automation",hint:"axe-core rules — runs on every scan."},ai:{label:"AI judgment",hint:"wcagcheckr AI analyzers (alt-text, contrast, vision)."},human:{label:"Human verification",hint:"Independent Guided Tests — manual checks."}};function Ri({layers:t}){const s=b(i=>i.setView),a=b(i=>i.setFindingsLens);function n(){s("report"),a("violations")}const r=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:r.map(i=>{const l=t[i],o=l.coveredCriteria.length,d=l.failing.length,p=l.inconclusive.length,c=l.unevaluated.length,u=l.cleared,h=d>0||p>0,g=o>0&&!h&&c===0,f=g?"text-emerald-700":d>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${g?"bg-emerald-500 text-white":d>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:g?"✓":d>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:Ds[i].label}),e.jsx("span",{className:`font-mono text-[10px] ${f}`,children:o===0?"no coverage yet":`${u}/${o}`}),d>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-rose-700 hover:underline cursor-pointer",title:`Confirmed fails (action: fix the underlying issue + re-audit, OR mark visually verified): ${l.failing.join(", ")}`,children:["· ",d," failing"]}),p>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-amber-700 hover:underline cursor-pointer",title:`Inconclusive — this layer couldn't determine (action: try "Resolve with AI" below, OR mark via Guided Tests): ${l.inconclusive.join(", ")}`,children:["· ",p," inconclusive"]}),c>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",c," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:Ds[i].hint}),i==="human"&&c>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},i)})})]})}function Ti({areas:t}){const s=t.map(a=>a.label);return e.jsxs("div",{className:"border-t border-rose-200 bg-rose-50 px-3 py-2 text-[11px] text-rose-900 leading-snug",children:[e.jsx("p",{className:"font-semibold mb-0.5",children:"⚠ Not lawsuit-safe"}),e.jsx("p",{children:s.length===1?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s[0]})," scored ",t[0].letter,". Even a high overall grade doesn't help if one area is failing — demand-letter mills target the weakest link."]}):e.jsxs(e.Fragment,{children:[s.length," areas are at lawsuit-risk:"," ",s.map((a,n)=>e.jsxs("span",{children:[e.jsx("strong",{children:a}),n<s.length-1?", ":""]},a)),". Fix these before relying on the overall grade."]})})]})}function $i({grades:t,uncategorized:s}){const a=b(o=>o.setView),n=b(o=>o.setFindingsLens),r=b(o=>o.setPendingAreaExpand);function i(o){a("report"),n("per-area"),r(o)}function l(o){const d=o.counts;return d.critical+d.serious+d.moderate+d.minor>0}return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsxs("ul",{className:"grid grid-cols-1 gap-1.5",children:[t.map(o=>{const d=l(o),p="flex items-center gap-2 text-[11px] w-full text-left rounded px-1 py-0.5 -mx-1",c=d?"cursor-pointer hover:bg-slate-100":"cursor-default",u=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${Ci[o.letter]}`,"aria-label":`Grade ${o.letter}`,children:o.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:o.label}),e.jsx(Ui,{grade:o,onOpenGuided:()=>a("guided")})]});return e.jsx("li",{children:d?e.jsx("button",{type:"button",onClick:()=>i(o.id),className:`${p} ${c}`,"aria-label":`Open ${o.label} violations`,children:u}):e.jsx("div",{className:p,children:u})},o.id)}),s&&s.total>0&&e.jsxs("li",{className:"flex items-center gap-2 text-[11px] mt-1 pt-1.5 border-t border-dashed border-slate-200",title:`These findings come from rules not mapped to any of the ${t.length} verification areas above. Listing them here so the headline count and the area cards agree. Rules: ${s.representatives.map(o=>o.ruleId).join(", ")}`,children:[e.jsx("span",{className:"w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold bg-slate-300 text-slate-700","aria-label":"Other findings",children:"?"}),e.jsxs("span",{className:"font-medium text-slate-700 flex-1 min-w-0",children:["Other findings",e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal italic",children:"rules not mapped to a category"})]}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:(()=>{const o=[];return s.counts.critical>0&&o.push(`${s.counts.critical} critical`),s.counts.serious>0&&o.push(`${s.counts.serious} serious`),s.counts.moderate>0&&o.push(`${s.counts.moderate} moderate`),s.counts.minor>0&&o.push(`${s.counts.minor} minor`),o.join(" · ")})()})]})]})]})}function Ui({grade:t,onOpenGuided:s}){const a=o=>{if(!o)return"";const d=xe.find(p=>p.id===o);return(d==null?void 0:d.name)??o};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const o=t.verifiedAt?Pa(Date.now()-new Date(t.verifiedAt).getTime()):null;return e.jsxs("span",{className:"text-emerald-700 text-[10px]",title:t.suppressedHeuristicCount>0?`Heuristic flagged ${t.suppressedHeuristicCount} issue${t.suppressedHeuristicCount===1?"":"s"}, but you verified this area in Guided Tests — those are treated as noise unless you re-verify.`:"Verified via Guided Tests",children:["✓ verified",o?` ${o} ago`:""]})}const{critical:n,serious:r,moderate:i,minor:l}=t.counts;if(n>0||r>0||i>0||l>0){const o=[];return n>0&&o.push({label:"critical",n,cls:"text-rose-700"}),r>0&&o.push({label:"serious",n:r,cls:"text-orange-700"}),i>0&&o.push({label:"moderate",n:i,cls:"text-amber-700"}),l>0&&o.push({label:"minor",n:l,cls:"text-slate-600"}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:o.map((d,p)=>e.jsxs("span",{children:[p>0&&" · ",e.jsxs("span",{className:d.cls,children:[d.n," ",d.label]})]},d.label))})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function Li({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(l=>l.setView),r=b(l=>l.setFindingsLens),i=[{status:t===0?"done":"next",label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:t>0?()=>{n("report"),r("violations")}:void 0,tooltip:t>0?"Open the Violations list — each finding card has inline Acknowledge / Not a real issue / Locate / Fix recipe affordances.":void 0},{status:"optional",label:a>0?`Optional: spot-check via Guided Tests (${s}/${a} done — AI walkthroughs cover most)`:"Optional: spot-check via Guided Tests (AI walkthroughs cover most)",action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The 5 AI walkthroughs auto-run after every audit and verdict the criteria that previously required manual keyboard / vision checks. Run these workflows only for belt-and-suspenders confidence on a formal conformance claim."},{status:t===0?"next":"pending",label:"Export AI fix prompt → sign-and-seal in Compliance",action:()=>n("delta"),tooltip:'Switches to the Delta lens. Export menu → "AI fix prompt" produces markdown for ChatGPT / Claude / Copilot with code-level fix recipes for every automated finding, including false-positive guidance. Then jump to the Compliance tile from Dashboard to sign-and-seal the audit for a chain-of-custody record.'}];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:i.map((l,o)=>{const d=l.status==="done"?"text-emerald-700":l.status==="next"?"text-brand-600 font-semibold":l.status==="optional"?"text-slate-500":"text-slate-400";return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:`font-mono shrink-0 ${d}`,"aria-hidden":"true",children:[o+1,"."]}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:l.status==="next"?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[l.label," →"]}):e.jsx("span",{className:l.status==="done"?"text-slate-500 line-through leading-snug":l.status==="next"?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label}),l.status==="done"&&e.jsx("span",{className:"text-emerald-700 shrink-0 font-mono","aria-label":"step complete",children:"✓"})]},o)})})]})}function _i({current:t,total:s}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg bg-white p-4 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:typeof t=="number"&&typeof s=="number"?`State ${t} of ${s}. Grade will appear when the scan completes.`:"Grade will appear when the scan completes."})]})]})}function Di({scannedAt:t}){const s=Date.now()-new Date(t).getTime();return e.jsxs("div",{className:"bg-amber-50 border-b border-amber-200 px-3 py-1.5 text-[11px] text-amber-900 flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),e.jsxs("span",{children:["Showing a previous scan (",Pa(s)," old). Re-scan to grade the current page state."]})]})}function Pa(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const a=Math.floor(s/86400);return a===1?"1 day":`${a} days`}function Oi(t){if(!t)return null;const s=t.untestedCriteria.length,a=t.inconclusiveCriteria.length,n=s+a,r=t.failingCriteria.length;return{kind:n>0?"incomplete":r>0?"failing":"clean",evaluated:t.evaluated,totalApplicable:t.totalApplicable,untested:s,inconclusive:a,remaining:n,failing:r,target:`${t.targetVersion} ${t.targetLevel}`}}function Fi({coverage:t}){const s=Oi(t);if(!s)return null;const{untested:a,inconclusive:n,remaining:r,failing:i,target:l}=s;if(s.kind==="incomplete"){const o=[];return a>0&&o.push(`${a} not yet checked`),n>0&&o.push(`${n} need human review`),e.jsxs("div",{className:"border-t border-amber-300 bg-amber-50 px-3.5 py-2 text-[11px] leading-snug text-amber-900",role:"note",children:[e.jsxs("p",{className:"font-semibold",children:["⚠ Not a conformance claim yet — ",s.evaluated," of ",s.totalApplicable," WCAG ",l," criteria evaluated."]}),e.jsxs("p",{className:"mt-0.5",children:[r," still need a verdict (",o.join(", "),") before this can be claimed as ",l," conformant. Automation checked everything it can — finish the rest under ",e.jsx("strong",{children:"Compliance → Guided Tests"}),"."]})]})}return s.kind==="failing"?e.jsxs("div",{className:"border-t border-amber-300 bg-amber-50 px-3.5 py-2 text-[11px] leading-snug text-amber-900",role:"note",children:[e.jsxs("p",{className:"font-semibold",children:["All ",s.totalApplicable," WCAG ",l," criteria evaluated — ",i," failing."]}),e.jsxs("p",{className:"mt-0.5",children:["Fix the findings below to reach ",l," conformance for the audited page(s)."]})]}):e.jsxs("div",{className:"border-t border-emerald-200 bg-emerald-50 px-3.5 py-2 text-[11px] leading-snug text-emerald-900",role:"note",children:[e.jsxs("p",{className:"font-semibold",children:["All ",s.totalApplicable," WCAG ",l," criteria evaluated — no outstanding failures."]}),e.jsxs("p",{className:"mt-0.5",children:["This audit substantiates a ",l," conformance claim for the audited page(s)."]})]})}function Ga(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Os(t){if(!Ga())return!1;const s=chrome.devtools;return await new Promise(a=>{const r=`(function(){
3
+ try {
4
+ var el = document.querySelector(${JSON.stringify(t)});
5
+ if (el) { inspect(el); return true; }
6
+ return false;
7
+ } catch (err) { return false; }
8
+ })()`;s.inspectedWindow.eval(r,(i,l)=>{a(l?!1:i===!0)})})}const Fs=.022,Mi=1.414,Lt=2.4,Pi=.2126729,Gi=.7151522,Vi=.072175,Wi=.56,Bi=.57,Hi=.62,zi=.65,Ms=1.14,Ps=.1,Ki=.027,qi=.027,Qi=5e-4;function Gs(t,s,a){const n=t/255,r=s/255,i=a/255;return Pi*Math.pow(n,Lt)+Gi*Math.pow(r,Lt)+Vi*Math.pow(i,Lt)}function Vs(t){return t<0?0:t<Fs?t+Math.pow(Fs-t,Mi):t}function Yi(t,s){const a=Vs(Gs(t[0],t[1],t[2])),n=Vs(Gs(s[0],s[1],s[2]));if(Math.abs(n-a)<Qi)return 0;let r=0;return n>a?(r=(Math.pow(n,Wi)-Math.pow(a,Bi))*Ms,r<Ps?0:(r-Ki)*100):(r=(Math.pow(n,zi)-Math.pow(a,Hi))*Ms,r>-Ps?0:(r+qi)*100)}function Ws(t){const s=t.trim().replace(/^#/,"");if(s.length===3){const a=parseInt(s[0]+s[0],16),n=parseInt(s[1]+s[1],16),r=parseInt(s[2]+s[2],16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}if(s.length===6){const a=parseInt(s.slice(0,2),16),n=parseInt(s.slice(2,4),16),r=parseInt(s.slice(4,6),16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}return null}function Ji(t,s,a=75){const n=Ws(t),r=Ws(s);if(!n||!r)return null;const i=Yi(n,r);return{lc:i,passes:Math.abs(i)>=a,threshold:a}}const He={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Xi(t){return/^wcag\d/.test(t.wcagCriterion)?[He["ada-iii"],He[508],He.eaa,He["en-301-549"],He.aoda]:[]}const Zi={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function at({violation:t,alreadyAcknowledged:s}){const a=b(x=>x.pinnedMatchKey),n=b(x=>x.pinnedFound),r=b(x=>x.setPinned),i=b(x=>{var y;return(y=x.results[0])==null?void 0:y.frameId}),l=b(x=>{var y;return(y=x.results[0])==null?void 0:y.scope}),o=b(x=>x.results),d=b(x=>x.acknowledgedKeys.has(t.matchKey)),p=b(x=>x.markAcknowledged),c=b(x=>x.markUnacknowledged),u=s||d,h=os(t.matchKey),g=b(x=>x.dismissedKeys.has(h)),f=b(x=>x.markDismissed),v=b(x=>x.markUndismissed),w=a===t.matchKey,S=w&&!n;async function I(x){try{return(await Re(x,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:x,selector:t.target.selector},i)).found}catch{return!0}}async function C(){const x=await me();if(!x)return;if(w){r(null);try{await be(x,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:x},i)}catch{}return}const y=await I(x);r(t.matchKey,y)}function N(x){x.stopPropagation(),t.currentState.breakpoint.width<=640&&is(),(async()=>{const y=await me();if(!y)return;try{await ie({type:"STATE_DRIVE_REQUEST",tabId:y,state:t.currentState,scope:l,frameId:i})}catch{}const R=await I(y);r(t.matchKey,R)})()}async function k(x){x.stopPropagation();const y=await me();if(!y)return;try{await ie({type:"STATE_DRIVE_REQUEST",tabId:y,state:ro(),scope:l,frameId:i})}catch{Q({type:"STATE_RESET_REQUEST",tabId:y})}const R=await I(y);r(t.matchKey,R)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:C,"aria-pressed":w,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
9
+ ${w?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx(ho,{violation:t}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Zi[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(io,{violation:t}),e.jsx(co,{violation:t}),e.jsx(lo,{violation:t}),e.jsx(oo,{text:t.target.failureSummary}),e.jsx(mo,{ruleId:t.ruleId}),w&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",eo(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:N,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),N(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:k,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),k(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),Ga()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:x=>{x.preventDefault(),x.stopPropagation(),Os(t.target.selector)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),Os(t.target.selector))},title:"Focus this element in the DevTools Elements tab",className:"text-brand-600 hover:underline cursor-pointer","data-testid":"reveal-in-elements",children:"Reveal in Elements"})]}),S&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap text-xs",children:[t.needsReview&&(u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Verified OK"}),e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),c(t.matchKey),so(t,o)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),p(t.matchKey),to(t,o)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},title:"The rule was right to flag this — I verified the content is fine. Surfaces in the AI fix prompt's 'Previously verified by human' section.",className:"px-2 py-0.5 border border-emerald-300 bg-emerald-50 text-emerald-800 rounded hover:bg-emerald-100 cursor-pointer",children:"✓ Verified OK"})),g?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700 font-semibold",children:"✗ Dismissed"}),e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),v(h),no(t,o)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),f(h),ao(t,o,h)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},title:"The rule itself is wrong about this page — false positive. Suppresses this finding from future audits on this URL + filters it from the AI fix prompt.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"✗ Not a real issue"})]}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function eo(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function to(t,s){await Tn({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Tt(t.componentId,s)}async function so(t,s){await Rn(t.componentId,t.matchKey),await Tt(t.componentId,s)}async function ao(t,s,a){var l,o;const n=((l=s[0])==null?void 0:l.pageUrl)??((o=s[0])==null?void 0:o.scope)??"";if(!n)return;const r=(t.target.outerHTML??t.target.selector).slice(0,200),i=`Marked "not a real issue" via Findings UI (${t.ruleId} on ${t.target.selector})`;await ds(n,a,i,r),await Tt(t.componentId,s)}async function no(t,s){var n,r;const a=((n=s[0])==null?void 0:n.pageUrl)??((r=s[0])==null?void 0:r.scope)??"";a&&(await us(a,os(t.matchKey)),await Tt(t.componentId,s))}async function Tt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await ie({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function ro(){const t=rs.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Va(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function io({violation:t}){const s=Va(t);if(!s)return null;const a=s.ratio>=s.required,n=Ji(s.fg,s.bg,75),r=(n==null?void 0:n.passes)??!1;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] flex-wrap",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]}),n&&e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${r?"border-emerald-300 bg-emerald-50 text-emerald-800":"border-amber-300 bg-amber-50 text-amber-800"}`,title:"APCA Lc — the contrast algorithm WCAG 3 is built around. Signed: positive = dark text on light, negative = light on dark. |Lc| ≥ 75 typically required for body text.","data-testid":"apca-lc",children:["APCA Lc ",n.lc.toFixed(1)]})]})}function oo({text:t}){return t?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-slate-500 cursor-pointer hover:text-slate-700",children:"Show failure detail"}),e.jsx("pre",{className:"text-[11px] text-slate-600 whitespace-pre-wrap mt-1 bg-slate-50 p-1.5 rounded",children:t})]}):null}function lo({violation:t}){const s=Xi(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function co({violation:t}){const s=Va(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let i=!1;return En(t.matchKey).then(l=>{l&&!i&&n({kind:"ready",suggestion:l})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await ie({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),o=l.results.find(d=>d.matchKey===t.matchKey);o?(await $n(o),n({kind:"ready",suggestion:o})):n({kind:"empty",reason:l.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}const uo={high:"bg-emerald-100 text-emerald-700","ai-verified":"bg-sky-100 text-sky-700",medium:"bg-amber-100 text-amber-700","needs-review":"bg-slate-100 text-slate-600"},po={high:"high confidence","ai-verified":"AI",medium:"verify","needs-review":"review"};function ho({violation:t}){if(t.flakyAcrossRuns)return null;const s=In(t),a=s.level==="ai-verified"?s.label.replace("AI-verified ","AI "):po[s.level];return e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${uo[s.level]}`,title:s.rationale||"Deterministic check — axe-core measured this directly.",children:a})}function mo({ruleId:t}){const s=Un(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}function ms({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:i,onChanged:l,ack:o}){const[d,p]=m.useState(!1),[c,u]=m.useState(""),[h,g]=m.useState(!1),[f,v]=m.useState(null),[w,S]=m.useState(!1),[I,C]=m.useState(!1),N=hs(),k=i.verdict,x=k==="pass"?"bg-emerald-200 text-emerald-900":k==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function y(){g(!0),v(null);try{if(!c.trim()){v("Note is required — explain how you manually verified this."),g(!1);return}if(k==="pass"){v("This walkthrough already passed — no acknowledgement needed."),g(!1);return}await ss({componentId:t,criterionId:a,pageUrl:s,note:c.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:k}),l()}catch(A){v(A instanceof Error?A.message:String(A))}finally{g(!1)}}async function R(){var A;C(!0),v(null);try{const _=(A=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:A.id;if(!_){v("No active tab — open the audited page first."),C(!1);return}const oe=await Q({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:_,componentId:t,pageUrl:s});oe.ok||v(oe.error??"Re-run failed."),l()}catch($){v($ instanceof Error?$.message:String($))}finally{C(!1)}}return o?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"shrink-0 font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase bg-emerald-500 text-white",children:"✓ verified"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-emerald-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-emerald-700 mr-1.5",children:a}),n??"Walkthrough"," — human verified"]}),e.jsxs("p",{className:"text-[11px] text-emerald-800 mt-0.5 leading-snug",children:[e.jsx("strong",{children:"Note:"})," ",o.note]}),e.jsxs("p",{className:"text-[10px] text-emerald-700 mt-0.5",children:["Recorded ",new Date(o.acknowledgedAt).toLocaleString(),". Original AI verdict: ",k,"."]})]})]})}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${x}`,children:k}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:a}),n??`Walkthrough verdict: ${k}`]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:k==="fail"?"AI walkthrough flagged a failure here. Fix the page and re-run, or verify manually and acknowledge.":k==="uncertain"?"AI walkthrough couldn't decide. Fix the underlying ambiguity, or verify manually and acknowledge.":"AI walkthrough passed — no action needed."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>S(A=>!A),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:w?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void R(),disabled:I||!N,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed",title:N?"Re-run AI walkthrough after fixing the page (uses the active tab)":"AI walkthroughs need an Anthropic API key. Open Settings → AI to add one.",children:I?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{p(A=>!A),v(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",children:"Mark verified manually"})]}),w&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"What the walkthrough does"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:r})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"AI reasoning"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap font-mono",children:i.reasoning})]}),d&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"How did you verify? (required, goes into the forensic record)"}),e.jsx("textarea",{value:c,onChange:A=>u(A.target.value),placeholder:"e.g., Verified live page via curl + screenshot — 2px white borders visible on both inputs against dark card.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),f&&e.jsx("p",{className:"text-[10px] text-rose-700",children:f}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void y(),disabled:h,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:h?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{p(!1),u(""),v(null)},disabled:h,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}),f&&!d&&e.jsx("p",{className:"text-[10px] text-rose-700",children:f})]})}function xo(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Wa(t){return`${Ee(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function go(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Wa(n),i=s.get(r);i?i.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const Bs={critical:0,serious:1,moderate:2,minor:3},fo={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function bo({results:t,interactiveVerdicts:s,aiResolvedFails:a}){var N;const n=t.length,r=t.flatMap(k=>k.violations),i=go(t);i.sort((k,x)=>{const y=Bs[k.representative.impact]??99,R=Bs[x.representative.impact]??99;return y!==R?y-R:x.states.length-k.states.length});const l=ts({violations:r,auditRan:!0,manualRuns:[],workflows:xe,heuristicCounts:{},interactiveAuditVerdicts:s}),o=new Map;for(const k of Fe)o.set(k.id,[]);const d=[];for(const k of i){let x=!1;for(const y of Fe)if(y.axeRules.includes(k.representative.ruleId)){o.get(y.id).push(k),x=!0;break}x||d.push(k)}const p=new Map;for(const k of Fe)p.set(k.id,[]);const c=[];for(const k of a??[]){let x=!1;for(const y of Fe)if(y.axeRules.includes(k.ruleId)){p.get(y.id).push(k),x=!0;break}x||c.push(k)}const u=((N=t[0])==null?void 0:N.componentId)??null,[h,g]=m.useState([]),[f,v]=m.useState({}),[w,S]=m.useState(0);m.useEffect(()=>{let k=!1;return(async()=>{if(!u){g([]),v({});return}const[x,y]=await Promise.all([Ae(u),Te([u])]);if(k)return;g(x);const R={};for(const A of y)R[A.criterionId]=A;v(R)})(),()=>{k=!0}},[u,w]);const I=new Map;for(const k of Fe)I.set(k.id,[]);const C={"2.4.3":"tab-order","2.1.2":"keyboard","2.4.7":"keyboard","1.3.2":"reading-order","1.4.11":"contrast","2.5.3":"aria"};for(const k of h){if(k.verdict==="pass")continue;const x=C[k.criterionId];if(!x)continue;const y=I.get(x);y&&y.push({record:k,ack:f[k.criterionId]??null})}return e.jsxs("div",{className:"space-y-1.5",children:[l.subGrades.map(k=>e.jsx(Hs,{subGrade:k,groups:o.get(k.id)??[],totalStates:n,aiFails:p.get(k.id)??[],walkthroughIssues:I.get(k.id)??[],componentId:u,onWalkthroughChanged:()=>S(x=>x+1)},k.id)),(d.length>0||c.length>0)&&e.jsx(Hs,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:d,totalStates:n,aiFails:c,walkthroughIssues:[],componentId:u,onWalkthroughChanged:()=>S(k=>k+1)})]})}function Hs({subGrade:t,groups:s,totalStates:a,aiFails:n,walkthroughIssues:r,componentId:i,onWalkthroughChanged:l}){const[o,d]=m.useState(!1),p=b(x=>x.pendingAreaExpand),c=b(x=>x.setPendingAreaExpand);m.useEffect(()=>{p===t.id&&(d(!0),c(null),requestAnimationFrame(()=>{const x=document.querySelector(`[data-area-card="${t.id}"]`);x==null||x.scrollIntoView({behavior:"smooth",block:"start"})}))},[p,t.id,c]);const[u,h]=m.useState("idle"),[g,f]=m.useState(null),[v,w]=m.useState(0),S=s.length>0||n.length>0||r.length>0,I=fo[t.letter],C=s.filter(x=>x.representative.ruleId==="color-contrast"||x.representative.ruleId==="color-contrast-enhanced"),N=C.length>=2;async function k(x){x.stopPropagation(),h("loading"),f(null);try{const y=C.map(A=>{const $=A.representative.target.outerHTML,_=A.representative.target.failureSummary,H=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(_),oe=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(_);if(!H||!oe)return null;const G=A.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:A.representative.matchKey,foreground:H[1],background:oe[1],fontSize:16,fontWeight:400,targetLevel:G,_html:$}}).filter(A=>A!==null);if(y.length===0){h("error"),f("Could not parse fg/bg colors from the violation failure summaries.");return}const R=await ie({type:"AI_COLOR_SUGGEST_REQUEST",inputs:y.map(({_html:A,...$})=>$)});if(R.unavailableReason&&R.results.length===0){h("error"),f(R.unavailableReason);return}await Ln(R.results),h("done"),w(A=>A+1),o||d(!0)}catch(y){h("error"),f(y instanceof Error?y.message:String(y))}}return e.jsxs("div",{"data-area-card":t.id,className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>d(x=>!x),"aria-expanded":o,disabled:!S,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold font-display ${I}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:S?(()=>{const x=s.length+n.length+r.length,y=[];return s.length>0&&y.push(`${s.length} axe`),n.length>0&&y.push(`${n.length} AI-resolved`),r.length>0&&y.push(`${r.length} walkthrough`),`${x} ${x===1?"issue":"issues"} to fix (${y.join(" + ")})`})():"No issues found"})]}),N&&e.jsx("span",{role:"button",tabIndex:0,onClick:x=>void k(x),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),k(x))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${C.length} contrast issues at once`,children:u==="loading"?"Asking AI…":u==="done"?`✓ Suggested for all ${C.length}`:`✨ Suggest for all ${C.length}`}),S&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0 font-mono","aria-hidden":"true",children:o?"−":"+"})]}),u==="error"&&g&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:g}),o&&S&&e.jsxs("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:[s.map(x=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(at,{violation:x.representative}),e.jsx(vo,{states:x.states,totalStates:a})]},`${Wa(x.representative)}::${v}`)),n.length>0&&e.jsxs(e.Fragment,{children:[s.length>0&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI-resolved fails (",n.length,")"]}),n.map(x=>e.jsx(yo,{fail:x},`${x.ruleId}::${x.selector}`))]}),r.length>0&&e.jsxs(e.Fragment,{children:[(s.length>0||n.length>0)&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI walkthrough findings (",r.length,")"]}),r.map(x=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(ms,{componentId:i??"",pageUrl:x.record.pageUrl,criterionId:x.record.criterionId,record:x.record,ack:x.ack,onChanged:l})},x.record.criterionId))]})]})]})}function vo({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(xo))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
10
+ `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}function yo({fail:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(!1);async function i(){a(!0);try{const{saveResolutions:l}=await ve(async()=>{const{saveResolutions:o}=await import("./scheduled-audit-runner-EQBltZPz.js").then(d=>d.b5);return{saveResolutions:o}},__vite__mapDeps([0,1,2,3,4]));await l([{...t,verdict:"pass",reasoning:`[Human override — visually verified by user] ${t.reasoning}`,resolvedAt:new Date().toISOString()}]),r(!0)}finally{a(!1)}}return e.jsxs("div",{className:`border rounded-md bg-white p-2 text-[11px] ${n?"border-emerald-200 bg-emerald-50":"border-rose-200"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[10px] text-rose-700",children:t.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold ${n?"bg-emerald-100 text-emerald-800":"bg-rose-100 text-rose-900"}`,children:n?"✓ Resolved":"AI verdict: FAIL"})]}),e.jsx("p",{className:"font-mono text-[10px] text-slate-700 mb-1 break-all",children:t.selector}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:t.reasoning}),!n&&e.jsx("button",{type:"button",onClick:()=>void i(),disabled:s,className:"px-2 py-1 text-[11px] font-medium bg-white border border-emerald-300 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50",title:"Override the AI's fail determination — your human visual judgment is the highest authority per WCAG-EM. Use when you've verified the contrast / labeling is actually fine.",children:"✓ Mark as resolved (override AI)"})]})}const zs="igtRuns";async function wo(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(zs))[zs];return s&&typeof s=="object"?s:{}}async function jo(t,s){var l,o;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await wo())[t];if(i)for(const d of xe){const p=i[d.id];if(p)for(const c of d.steps){if(!c.autoDismissActivity||((o=(l=p.steps)==null?void 0:l[c.id])==null?void 0:o.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const g=a.tabOrderIssues??[];if(g.length===0)continue;await st(n,g.map(f=>({key:tt(f.selector),reason:h,snippet:`${f.selector} — ${f.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const g=a.readingOrderIssues??[];if(g.length===0)continue;await st(n,g.map(f=>({key:et(f.selector),reason:h,snippet:`${f.selector} — ${f.textSnippet||"(no text)"}`})))}}}}const ko=new Set(["heading-order","page-has-heading-one","empty-heading","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","landmark-banner-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-complementary-is-top-level","landmark-unique","region","bypass","duplicate-id","duplicate-id-aria","duplicate-id-active"]),No=new Set(["label","label-content-name-mismatch","label-title-only","form-field-multiple-labels","input-button-name","input-image-alt","autocomplete-valid","aria-required-attr","aria-required-children","aria-required-parent","aria-input-field-name","aria-toggle-field-name","select-name","button-name"]);function So(t){return ko.has(t.ruleId)}function Ao(t){return No.has(t.ruleId)}function Co(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ba(){var H,oe,G,W;const t=b(E=>E.results),s=b(E=>E.delta),a=b(E=>E.componentId),n=((H=t[0])==null?void 0:H.pageUrl)??((oe=t[0])==null?void 0:oe.scope)??"",[r,i]=m.useState({}),[l,o]=m.useState(!1),[d,p]=m.useState(!1);m.useEffect(()=>{if(!a){o(!1),p(!1);return}let E=!1;return(async()=>{const U=await Ae(a);if(E)return;const M=U.some(T=>T.criterionId==="2.1.2"&&T.verdict==="pass"),P=U.some(T=>T.criterionId==="1.3.2");o(M),p(P)})(),()=>{E=!0}},[a]);const[c,u]=m.useState(0);m.useEffect(()=>{if(!n)return;let E=!1;return(async()=>{if(a&&t.length>0)try{await jo(a,t)}catch{}if(E)return;const U=await cs(n);E||i(U)})(),()=>{E=!0}},[n,c,a,t]);async function h(E,U){if(!n)return;const M=window.prompt(`Why is this finding a false positive?
11
+
12
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");M!==null&&(await ds(n,E,M||"(no reason given)",U),u(P=>P+1))}async function g(E){n&&(await us(n,E),u(U=>U+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const f=t.reduce((E,U)=>{var M;return E+(((M=U.announcements)==null?void 0:M.length)??0)},0),v=t.reduce((E,U)=>{var M;return E+(((M=U.focusEvents)==null?void 0:M.length)??0)},0),w=t.reduce((E,U)=>{var M;return E+(((M=U.focusEvents)==null?void 0:M.filter(P=>P.isFocusReset).length)??0)},0),S=Ks(t,So),I=Ks(t,Ao),C=S.length,N=I.length,k=d?[]:((G=t[0])==null?void 0:G.readingOrderIssues)??[],x=l?[]:((W=t[0])==null?void 0:W.tabOrderIssues)??[],y=k.filter(E=>!(et(E.selector)in r)),R=k.filter(E=>et(E.selector)in r),A=x.filter(E=>!(tt(E.selector)in r)),$=x.filter(E=>tt(E.selector)in r);if(f===0&&v===0&&C===0&&N===0&&y.length===0&&A.length===0&&R.length===0&&$.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const _=R.length+$.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[C," structural · ",N," form ·"," ",A.length," tab-order ·"," ",y.length," reading-order ·"," ",f," ",f===1?"announcement":"announcements"," ·"," ",v," focus ",v===1?"event":"events",w>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",w," focus reset",w===1?"":"s"]}),_>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",_," dismissed"]})]}),A.length>0&&e.jsx(Ro,{issues:A,onDismiss:h}),y.length>0&&e.jsx(To,{issues:y,onDismiss:h}),_>0&&e.jsx($o,{dismissedReadingOrder:R,dismissedTabOrder:$,dismissals:r,onRestore:g}),C>0&&e.jsx(qs,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:S}),N>0&&e.jsx(qs,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:I}),e.jsx(Io,{delta:s}),t.map((E,U)=>{const M=E.announcements??[],P=E.focusEvents??[];return M.length===0&&P.length===0?null:e.jsx(Eo,{state:E.state,announcements:M,focusEvents:P},U)})]})}function Io({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function Ks(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=Ee(r.ruleId,r.target.selector),l=a.get(i);l?l.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function qs({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function Eo({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Co(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Ro({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function To({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function $o({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=m.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(o=>{const d=`tab-order::${o.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(o=>{const d=`reading-order::${o.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Uo={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Lo({ruleId:t,violations:s}){const[a,n]=m.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,l=r.description,o=s.length;return o===1?e.jsx(at,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Uo[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",o]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(at,{violation:d},p))})]})}function _o(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const Do={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function Ha({open:t,onClose:s,format:a,content:n,filename:r}){const i=yr(new Blob([n]).size);function l(){nt(n,r),s()}function o(){De(n),s()}return e.jsxs(Ve,{open:t,onClose:s,title:Do[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Oo={json:"exportJson",sarif:"exportSarif",junit:"exportJunit","html-print":"exportHtmlPrint","developer-letter":"exportDeveloperLetter","owner-report":"exportOwnerReport","ticket-bundle":"exportTicketBundle",vpat:"exportVpat","defense-bundle":"exportDefenseBundle","evidence-bundle":"exportEvidenceBundle","deposition-packet":"exportDepositionPacket","methodology-doc":"exportMethodologyDoc","conformance-crosswalk":"exportConformanceCrosswalk","executive-report":"exportExecutiveReport","accessibility-statement-markdown":"exportEaaStatement","accessibility-statement-html":"exportEaaStatement","ai-prompt":"exportAiPrompts","ai-prompt-owner":"exportAiPrompts","ai-prompt-site-crawl":"exportAiPrompts"};function Le(t,s){const a=Oo[s];return a?we(t,a):!0}const Qs=7800;function Fo(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=r.find(f=>`${f.ruleId}::${f.target.selector}`===u);if(g){g._states.includes(h)||g._states.push(h);continue}r.push({...c,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const c of r)l.push(`### \`${c.ruleId}\` — ${c.impact}`),l.push(""),l.push(c.description),l.push(""),l.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),l.push(`- **Selector:** \`${c.target.selector}\``),l.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&l.push(`- **More info:** ${c.helpUrl}`),l.push(""),l.push("```html"),l.push(c.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
13
+ `),d=new URLSearchParams({title:i,body:o});let p=`${n}/issues/new?${d.toString()}`;return p.length>Qs&&(p=p.slice(0,Qs)),{url:p,title:i,body:o}}const Ys=7800;function Mo(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=r.find(f=>`${f.ruleId}::${f.target.selector}`===u);if(g){g._states.includes(h)||g._states.push(h);continue}r.push({...c,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`Component: ${s??"unknown"}`),l.push(""),l.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const c of r)l.push(`Rule: ${c.ruleId} (${c.impact})`),l.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),l.push(`Description: ${c.description}`),l.push(`Selector: ${c.target.selector}`),l.push(`Found in state(s): ${c._states.join(", ")}`),c.helpUrl&&l.push(`More info: ${c.helpUrl}`),l.push(""),l.push(`HTML: ${c.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const o=l.join(`
14
+ `),d=new URLSearchParams({summary:i,description:o});let p=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return p.length>Ys&&(p=p.slice(0,Ys)),{url:p,summary:i,description:o}}const Js=7800;function Po(t,s,a,n="Bug"){const r=t.replace(/\/$/,""),i=[];for(const u of a){const h=`${u.ruleId}::${u.target.selector}`,g=`:${u.currentState.pseudoState} · ${u.currentState.theme} · ${u.currentState.direction}`,f=i.find(v=>`${v.ruleId}::${v.target.selector}`===h);if(f){f._states.includes(g)||f._states.push(g);continue}i.push({...u,_states:[g]})}const l=`a11y: ${i.length} new violation${i.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const u of i)o.push(`### \`${u.ruleId}\` — ${u.impact}`),o.push(""),o.push(u.description),o.push(""),o.push(`- **WCAG:** ${u.wcagCriterion} (${u.wcagLevel})`),o.push(`- **Selector:** \`${u.target.selector}\``),o.push(`- **Found in state(s):** ${u._states.join(", ")}`),u.helpUrl&&o.push(`- **More info:** ${u.helpUrl}`),o.push(""),o.push("```html"),o.push(u.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const d=o.join(`
15
+ `),p=new URLSearchParams({"[Title]":l,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${p.toString()}`;return c.length>Js&&(c=c.slice(0,Js)),{url:c,title:l,description:d}}const Xs=7800;function Go(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=r.find(f=>`${f.ruleId}::${f.target.selector}`===u);if(g){g._states.includes(h)||g._states.push(h);continue}r.push({...c,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const c of r)l.push(`### \`${c.ruleId}\` — ${c.impact}`),l.push(""),l.push(c.description),l.push(""),l.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),l.push(`- **Selector:** \`${c.target.selector}\``),l.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&l.push(`- **More info:** ${c.helpUrl}`),l.push(""),l.push("```html"),l.push(c.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
16
+ `),d=new URLSearchParams({"issue[title]":i,"issue[description]":o});let p=`${n}/-/issues/new?${d.toString()}`;return p.length>Xs&&(p=p.slice(0,Xs)),{url:p,title:i,description:o}}const Zs=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Vo=["wcag-component-auditor","wcag-forensic-log"];async function Wo(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Zs);s=Object.keys(n).length,await chrome.storage.local.remove(Zs)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Vo)try{await Bo(n),a.push(n)}catch(r){t.push(`IndexedDB ${n}: ${r instanceof Error?r.message:String(r)}`)}return{chromeStorageKeysCleared:s,indexedDbsCleared:a,errors:t}}function Bo(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}const zt="accessibilityStatementInputs:v1";async function Ho(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(zt))[zt];return s&&typeof s=="object"?s:null}async function zo(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[zt]:t})}function za({open:t,onClose:s,results:a,siteCrawlSource:n}){const[r,i]=m.useState("eaa"),[l,o]=m.useState(""),[d,p]=m.useState(""),[c,u]=m.useState("partial"),[h,g]=m.useState(""),[f,v]=m.useState(""),[w,S]=m.useState(""),[I,C]=m.useState(""),[N,k]=m.useState("English"),[x,y]=m.useState("wcagcheckr (self-evaluation)"),[R,A]=m.useState("2.1"),[$,_]=m.useState("AA"),[H,oe]=m.useState(!1),[G,W]=m.useState(null),E=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var ee,X,D,Y;const T=await Ho();if(T&&(T.framing&&i(T.framing),T.organizationName&&o(T.organizationName),T.siteUrl&&p(T.siteUrl),T.conformanceStatus&&u(T.conformanceStatus),(ee=T.contact)!=null&&ee.email&&g(T.contact.email),(X=T.contact)!=null&&X.phone&&v(T.contact.phone),(D=T.contact)!=null&&D.formUrl&&S(T.contact.formUrl),T.countryCode&&C(T.countryCode),T.language&&k(T.language),T.auditedBy&&y(T.auditedBy),T.wcagVersion&&A(T.wcagVersion),T.wcagLevel&&_(T.wcagLevel)),!(T!=null&&T.siteUrl)&&((Y=a[0])!=null&&Y.pageUrl))try{const Z=new URL(a[0].pageUrl);p(`${Z.protocol}//${Z.host}/`)}catch{}T!=null&&T.conformanceStatus||u(_n(a)),setTimeout(()=>{var Z;return(Z=E.current)==null?void 0:Z.focus()},50)})()},[t,a]),!t)return null;function U(){var D;const T=new Date().toISOString().slice(0,10),ee=(D=a[0])!=null&&D.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):T,X={};return h.trim()&&(X.email=h.trim()),f.trim()&&(X.phone=f.trim()),w.trim()&&(X.formUrl=w.trim()),{framing:r,organizationName:l.trim(),siteUrl:d.trim(),conformanceStatus:c,preparedAt:T,evaluatedAt:ee,contact:X,countryCode:I||null,language:N.trim()||"English",auditedBy:x.trim()||"wcagcheckr (self-evaluation)",wcagVersion:R,wcagLevel:$}}function M(T){if(!T.organizationName)return"Organization name is required.";if(!T.siteUrl)return"Site URL is required.";try{new URL(T.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!T.contact.email&&!T.contact.phone&&!T.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function P(T){var D;W(null);const ee=U(),X=M(ee);if(X){W(X);return}oe(!0);try{await zo(ee);const Y=await ie({type:"EXPORT_REQUEST",format:T==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:n?[]:a,siteCrawlSource:n||void 0,statementInputs:ee}),Z=(Y==null?void 0:Y.content)??"";if(!Z||Z.startsWith("# Accessibility statement — error")){W(Z||"Export failed — no response.");return}try{await navigator.clipboard.writeText(Z)}catch{}const j=new Blob([Z],{type:T==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),V=URL.createObjectURL(j);typeof chrome<"u"&&((D=chrome.tabs)!=null&&D.create)?await chrome.tabs.create({url:V,active:!0}).catch(()=>{window.open(V,"_blank","noopener,noreferrer")}):window.open(V,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(V),6e4),s()}catch(Y){W(Y instanceof Error?Y.message:String(Y))}finally{oe(!1)}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40",role:"dialog","aria-modal":"true","aria-labelledby":"statement-dialog-title",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto m-4",onClick:T=>T.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked:r==="eaa",onChange:()=>i("eaa"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"EAA"})," (Directive 2019/882) — private sector. E-commerce, banking, transport, telecom, e-readers, media. Enforceable June 2025."]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"wad",checked:r==="wad",onChange:()=>i("wad"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"WAD"})," (Directive 2016/2102) — EU public sector. Government, public bodies, education."]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-org",className:"block font-medium mb-1",children:["Organization name ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-org",ref:E,type:"text",value:l,onChange:T=>o(T.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:d,onChange:T=>p(T.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:c,onChange:T=>u(T.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:R,onChange:T=>A(T.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:$,onChange:T=>_(T.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:h,onChange:T=>g(T.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:f,onChange:T=>v(T.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:w,onChange:T=>S(T.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:I,onChange:T=>C(T.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(Dn).map(([T,ee])=>e.jsxs("option",{value:T,children:[T," — ",ee.name.replace(/^[A-Z]+\s*—\s*/,"")]},T))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:N,onChange:T=>k(T.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:x,onChange:T=>y(T.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),G&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:G})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void P("markdown"),disabled:H,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:H?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void P("html"),disabled:H,className:"text-xs px-3 py-1.5 border border-brand-500 text-brand-700 hover:bg-brand-50 rounded disabled:opacity-50 font-medium",children:H?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:H,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function Ka(){const t=b(j=>j.delta),s=b(j=>j.componentId),a=b(j=>j.results),n=b(j=>j.tier),r=b(j=>j.baselineList),i=b(j=>j.siteCrawlReport),[l,o]=m.useState(""),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,g]=m.useState(""),[f,v]=m.useState(!1),[w,S]=m.useState(!1),[I,C]=m.useState(null),[N,k]=m.useState(null),[x,y]=m.useState(!1),[R,A]=m.useState(!1),[$,_]=m.useState(!1),[H,oe]=m.useState(null),[G,W]=m.useState(!1);m.useEffect(()=>{Promise.all([ie({type:"SETTINGS_GET",key:"githubRepoUrl"}),ie({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),ie({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),ie({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([j,V,K,te])=>{o(typeof j.data=="string"?j.data:""),p(typeof V.data=="string"?V.data:""),u(typeof K.data=="string"?K.data:""),g(typeof te.data=="string"?te.data:"")})},[]),m.useEffect(()=>ge("BADGE_CLICKED_EVENT",V=>{const K=`viol-row-${V.violationId}`,te=document.getElementById(K);te&&(te.scrollIntoView({behavior:"smooth",block:"center"}),te.classList.add("ring-2","ring-rose-500"),setTimeout(()=>te.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const j=await me();j&&($&&await be(j,{type:"BADGES_HIDE_REQUEST",tabId:j}).catch(()=>{}),G&&await be(j,{type:"HEATMAP_HIDE_REQUEST",tabId:j}).catch(()=>{}))})()},[]);async function E(){const j=await me();if(!j){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if($){await be(j,{type:"BADGES_HIDE_REQUEST",tabId:j}).catch(()=>{}),_(!1),oe(null);return}const V={critical:4,serious:3,moderate:2,minor:1},K=new Map;for(const z of a)for(const O of z.violations)K.has(O.matchKey)||K.set(O.matchKey,O);const de=Array.from(K.values()).sort((z,O)=>V[O.impact]-V[z.impact]).map((z,O)=>({id:z.matchKey,index:O+1,selector:z.target.selector,impact:z.impact,ruleId:z.ruleId,wcagCriterion:z.wcagCriterion}));if(de.length===0){he.polite("No violations to badge.");return}const L=await Re(j,{type:"BADGES_SHOW_REQUEST",tabId:j,violations:de}).catch(()=>null);L&&(_(!0),oe({rendered:L.rendered,requested:L.requested,clustered:L.clustered}),he.polite(`${L.rendered} violation badges shown on the page.`))}async function U(){const j=await me();if(!j){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(G){await be(j,{type:"HEATMAP_HIDE_REQUEST",tabId:j}).catch(()=>{}),W(!1);return}const V=new Map;for(const de of a)for(const L of de.violations)V.has(L.matchKey)||V.set(L.matchKey,L);const K=Array.from(V.values()).map(de=>({selector:de.target.selector,impact:de.impact}));if(K.length===0){he.polite("No violations to heatmap.");return}const te=await Re(j,{type:"HEATMAP_SHOW_REQUEST",tabId:j,violations:K}).catch(()=>null);te&&(W(!0),he.polite(`Heatmap shown with ${te.rendered} violation blobs.`))}const M=we(n,"exportJson"),P=we(n,"issueTrackers"),T=Na(n).maxBaselines,ee=r.some(j=>j.componentId===s),X=ee||r.length<T;if(!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit to see the delta against your baseline."});async function D(){if(!s||a.length===0)return;const j=a.flatMap(O=>O.violations),V=a.flatMap(O=>O.announcements??[]),K=a.flatMap(O=>O.focusEvents??[]),te=a[0],L=(await ie({type:"SETTINGS_GET",key:"stateMatrix"})).data??rs;await Q({type:"BASELINE_SET",componentId:s,violations:j,announcements:V,focusEvents:K,snapshotMeta:{url:window.location.href,axeVersion:te.axeVersion,matrixConfig:L,capturedAt:new Date().toISOString()}});const z=await ie({type:"BASELINE_COMPARE",componentId:s,currentViolations:j,announcements:V,focusEvents:K,currentMatrix:L});b.getState().setDelta(z.delta),he.polite(`Baseline saved for ${s}.`)}async function Y(){if(!s||!ee||!window.confirm(`Remove the saved baseline for "${s}"?
17
+
18
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await Q({type:"BASELINE_DELETE",componentId:s});const V=a.flatMap(z=>z.violations),K=a.flatMap(z=>z.announcements??[]),te=a.flatMap(z=>z.focusEvents??[]),de=await ie({type:"BASELINE_COMPARE",componentId:s,currentViolations:V,announcements:K,focusEvents:te});b.getState().setDelta(de.delta);const L=await ie({type:"BASELINE_LIST"});b.getState().setBaselineList(L.items),he.polite(`Baseline cleared for ${s}.`)}async function Z(j,V=!1){if(a.length===0)return;if(j==="ai-prompt"){const{copyAiFixerPrompt:J}=await ve(async()=>{const{copyAiFixerPrompt:se}=await import("./copy-ai-fixer-prompt-DYAVFhB3.js");return{copyAiFixerPrompt:se}},__vite__mapDeps([5,1,2]));await J({results:a,componentId:s,delta:V?void 0:t,siteCrawlReport:i});return}let K;if((j==="defense-bundle"||j==="evidence-bundle"||j==="deposition-packet")&&s){const J=await chrome.storage.local.get("igtRuns"),fe=((J==null?void 0:J.igtRuns)??{})[s]??{};K=Object.values(fe)}const L=await ie({type:"EXPORT_REQUEST",format:j,results:a,delta:V?void 0:t??void 0,manualRuns:K,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:b.getState().lastAuditWallClockMs??void 0});if(j==="defense-bundle"||j==="evidence-bundle"||j==="deposition-packet"){const J=At(j,s);await Aa()?nt(L.content,J):k({open:!0,format:j,content:L.content,filename:J});return}if(j==="html-print"||j==="vpat"||j==="methodology-doc"||j==="conformance-crosswalk"||j==="executive-report"){De(L.content);return}const z=j==="json"?"application/json":j==="sarif"?"application/sarif+json":j==="ticket-bundle"?"text/markdown":"application/xml",O=j==="junit"?"xml":j==="ticket-bundle"?"md":j,{body:ne,type:ae}=wr(L.content,z),F=new Blob([ne],{type:ae}),q=URL.createObjectURL(F),ce=document.createElement("a");ce.href=q,ce.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${O}`,ce.click(),URL.revokeObjectURL(q)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("button",{onClick:D,disabled:!X,title:X?void 0:`Free tier limits you to ${T} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),ee&&e.jsx("button",{onClick:Y,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>v(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx("button",{type:"button",onClick:()=>void E(),"aria-pressed":$,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:$?"text-xs px-2 py-1 bg-rose-600 hover:bg-rose-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:$?"Hide badges":"Show badges 🎯"}),$&&H&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[H.rendered," of ",H.requested," rendered",H.clustered>0?` · ${H.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void U(),"aria-pressed":G,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:G?"text-xs px-2 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:G?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(Xo,{disabled:!M,onExport:Z,onAccessibilityStatement:()=>y(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta),canExport:j=>Le(n,j),onUpgrade:()=>A(!0)}),!X&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const j=_t(t.new),V=_t(t.persistent),K=_t(t.fixed),te=[...j.review,...V.review];return e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"New",violations:j.findings,count:j.findings.length,accent:"red",actions:[...P&&l&&j.findings.length>0?[{label:"File GitHub issue",onClick:()=>qo(l,s,j.findings)}]:[],...P&&d&&j.findings.length>0?[{label:"File Jira issue",onClick:()=>Qo(d,s,j.findings)}]:[],...P&&c&&j.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Yo(c,s,j.findings)}]:[],...P&&h&&j.findings.length>0?[{label:"File GitLab issue",onClick:()=>Jo(h,s,j.findings)}]:[]]}),e.jsx(ze,{title:"Persistent",violations:V.findings,count:V.findings.length,accent:"slate"}),e.jsx(ze,{title:"Fixed",violations:K.findings,count:t.fixedCount,accent:"green"}),te.length>0&&e.jsx(ze,{title:"Needs review (does not affect grade)",violations:te,count:te.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ze,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),N&&e.jsx(Ha,{open:N.open,onClose:()=>k(null),format:N.format,content:N.content,filename:N.filename}),e.jsx(za,{open:x,onClose:()=>y(!1),results:a}),e.jsx(Ge,{open:R,onClose:()=>A(!1)}),f&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),I&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",I.chromeStorageKeysCleared," chrome.storage key",I.chromeStorageKeysCleared===1?"":"s"," + ",I.indexedDbsCleared.length," database",I.indexedDbsCleared.length===1?"":"s",".",I.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",I.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:I?e.jsx("button",{type:"button",onClick:()=>{v(!1),C(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>v(!1),disabled:w,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{S(!0);try{const j=await Wo();C(j),await It(),he.polite("Audit data reset. Ready for a fresh scan.")}catch(j){C({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[j instanceof Error?j.message:String(j)]})}finally{S(!1)}},disabled:w,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:w?"Resetting…":"Reset everything"})]})})]})})]})}const Ko={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function _t(t){const s=[],a=[];for(const n of t)n.needsReview?a.push(n):s.push(n);return{findings:s,review:a,fixed:0}}function ze({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[l,o]=m.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${Ko[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>o(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:l?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),l?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,p)=>e.jsx(at,{violation:d,alreadyAcknowledged:!0},p)):_o(s).map(d=>e.jsx(Lo,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function qo(t,s,a){if(a.length===0)return;const{url:n}=Fo(t,s,a);Ct(n)}function Qo(t,s,a){if(a.length===0)return;const{url:n}=Mo(t,s,a);Ct(n)}function Yo(t,s,a){if(a.length===0)return;const{url:n}=Po(t,s,a);Ct(n)}function Jo(t,s,a){if(a.length===0)return;const{url:n}=Go(t,s,a);Ct(n)}function Xo({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n,canExport:r,onUpgrade:i}){const[l,o]=m.useState(!1),[d,p]=m.useState(!1);function c(u){if(o(!1),!r(u)){i();return}s(u,d)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>o(u=>!u),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),l&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>o(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 w-[260px] max-w-[calc(100vw-1rem)] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:u=>p(u.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ye,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ye,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ye,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ye,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ye,{onClick:()=>c("vpat"),locked:!r("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ye,{onClick:()=>c("defense-bundle"),locked:!r("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ye,{onClick:()=>c("evidence-bundle"),locked:!r("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx(ye,{onClick:()=>c("deposition-packet"),locked:!r("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(ye,{onClick:()=>c("methodology-doc"),locked:!r("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(ye,{onClick:()=>c("conformance-crosswalk"),locked:!r("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ye,{onClick:()=>c("ai-prompt"),locked:!r("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ye,{onClick:()=>c("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx(ye,{onClick:()=>c("executive-report"),locked:!r("executive-report"),title:"Single-page executive HTML report: grade hero, top 3 risks, recommended next steps. Print-ready (Ctrl+P → Save as PDF). For stakeholder distribution rather than developer remediation.",children:"Executive report 📊"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ye,{locked:!r("accessibility-statement-html"),onClick:()=>{if(o(!1),!r("accessibility-statement-html")){i();return}a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function ye({onClick:t,title:s,children:a,locked:n=!1}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:n?"Paid feature — upgrade to generate this export":s,className:n?"flex w-full items-center justify-between gap-2 text-left text-xs px-3 py-1 hover:bg-amber-50 text-slate-600":"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:["🔒 ",a]}),e.jsx("span",{className:"text-[10px] text-amber-700 font-medium shrink-0",children:"Upgrade"})]}):a})}const Zo="2024-07-25",el="Based on the W3C WCAG 3 Working Draft published 2024-07-25. Outcomes may shift before WCAG 3.0 reaches Recommendation; treat this view as a directional preview, not a conformance claim.",qa=[{id:"text-alternatives",category:"perceive",title:"Non-text content has a text alternative",description:"Images, icons, audio, and video have descriptive text alternatives so users who cannot perceive the original modality still get the meaning.",wcag2Criteria:["1.1.1","1.2.1","1.2.2","1.2.3","1.2.4","1.2.5"]},{id:"visual-distinction",category:"perceive",title:"Visual content is distinguishable",description:"Foreground content has sufficient contrast from background, both for text (APCA Lc thresholds in 3.0) and for non-text UI elements.",wcag2Criteria:["1.4.3","1.4.6","1.4.11"]},{id:"adaptable-presentation",category:"perceive",title:"Content adapts to user preferences",description:"Text spacing, zoom, reflow, and orientation respect user-agent and OS preferences without breaking layout or losing functionality.",wcag2Criteria:["1.3.4","1.4.4","1.4.10","1.4.12"]},{id:"meaningful-structure",category:"perceive",title:"Content structure is programmatically determinable",description:"Headings, lists, tables, regions, and other semantic structures are exposed in the accessibility tree so assistive technology can navigate them.",wcag2Criteria:["1.3.1","1.3.2","2.4.1","2.4.6"]},{id:"keyboard-operable",category:"operate",title:"All functionality is keyboard-operable",description:"Every interaction (including drag, pointer-gesture-driven, and complex widget interactions) has a keyboard equivalent that does not require timing or precision.",wcag2Criteria:["2.1.1","2.1.2","2.1.4","2.5.1","2.5.2","2.5.7"]},{id:"focus-management",category:"operate",title:"Focus is visible, ordered, and never obscured",description:"Keyboard focus is visually distinct, moves in a sensible order, never moves unexpectedly, and is never hidden by sticky headers or modals.",wcag2Criteria:["2.4.3","2.4.7","2.4.11","2.4.12"]},{id:"enough-time",category:"operate",title:"Users have enough time to complete tasks",description:"Time limits are adjustable, pauseable, or absent. Moving / blinking content can be paused. No content flashes more than three times per second.",wcag2Criteria:["2.2.1","2.2.2","2.3.1"]},{id:"navigable-content",category:"operate",title:"Content is navigable",description:"Pages have titles, link text describes the destination, multiple ways exist to find content, and skip-links bypass repeated blocks.",wcag2Criteria:["2.4.2","2.4.4","2.4.5"]},{id:"target-size",category:"operate",title:"Pointer targets are sufficiently sized",description:"Interactive targets are large enough to operate without precision-tap difficulty. Drag operations have a single-pointer alternative.",wcag2Criteria:["2.5.8","2.5.7"]},{id:"language-of-content",category:"understand",title:"Language of content is identified",description:"Page and language-of-parts are programmatically determinable so text-to-speech and other AT can pronounce content correctly.",wcag2Criteria:["3.1.1","3.1.2"]},{id:"predictable-behavior",category:"understand",title:"UI behavior is predictable",description:"Focusing or selecting an element does not cause unexpected context changes. Navigation and identification of repeated components is consistent across pages.",wcag2Criteria:["3.2.1","3.2.2","3.2.3","3.2.4","3.2.6"]},{id:"input-assistance",category:"understand",title:"Forms help users avoid and correct errors",description:"Required fields are labeled, errors are identified clearly, suggestions are offered when possible, and legal / financial forms have prevention mechanisms.",wcag2Criteria:["3.3.1","3.3.2","3.3.3","3.3.4","3.3.7"]},{id:"accessible-auth",category:"understand",title:"Authentication does not require cognitive function tests",description:"Login flows do not depend on memorizing characters, transcribing puzzles, or other cognitive function tests with no accessible alternative.",wcag2Criteria:["3.3.8","3.3.9"]},{id:"name-role-value",category:"robust",title:"UI components expose name, role, and value",description:"Every interactive element has a programmatically determinable name, role, and current state. Status messages reach assistive technology without focus changes.",wcag2Criteria:["4.1.2","4.1.3"]}];new Set(qa.flatMap(t=>t.wcag2Criteria));function tl(t,s){return qa.map(a=>{const n=a.wcag2Criteria.filter(l=>t.has(l)),r=a.wcag2Criteria.some(l=>s.has(l));let i;return n.length>0?i="has-violations":r?i="clean":i="not-evaluated",{outcome:a,violatedCriteria:n,status:i}})}const sl={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Qa(){const t=b(c=>c.results),s=b(c=>c.acknowledgedKeys),a=b(c=>c.dismissedKeys);if(t.length===0)return e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"wcag3-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. This view re-projects the audit's WCAG 2.x findings onto the WCAG 3 outcome structure."})]});const n=new Set,r=new Set;for(const c of t){for(const h of c.violations){if(h.needsReview){r.add(h.wcagCriterion);continue}if(s.has(h.matchKey)){r.add(h.wcagCriterion);continue}if(a.has(`violation::${h.matchKey}`)){r.add(h.wcagCriterion);continue}n.add(h.wcagCriterion),r.add(h.wcagCriterion)}const u=c.axeRulesEvaluated;if(u){for(const h of u.passed)r.add(h.wcagCriterion);for(const h of u.inapplicable)r.add(h.wcagCriterion);for(const h of u.incomplete)r.add(h.wcagCriterion)}}const i=tl(n,r),l=new Map;for(const c of i){const u=l.get(c.outcome.category)??[];u.push(c),l.set(c.outcome.category,u)}const o=i.filter(c=>c.status==="clean").length,d=i.filter(c=>c.status==="has-violations").length,p=i.filter(c=>c.status==="not-evaluated").length;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"wcag3-view-root",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-1",children:"Re-projects this audit's WCAG 2.x findings onto the WCAG 3 outcome structure."}),e.jsxs("p",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-1 mt-2",role:"status","data-testid":"wcag3-source-badge",children:["⚠ Preview based on WCAG 3 Working Draft ",e.jsx("strong",{children:Zo}),"."," ",el]})]}),e.jsxs("div",{className:"flex gap-2 text-[11px]",children:[e.jsxs("span",{className:"px-2 py-1 rounded bg-emerald-100 text-emerald-800",children:[o," clean"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-rose-100 text-rose-900",children:[d," with violations"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-slate-100 text-slate-700",children:[p," not evaluated"]})]}),["perceive","operate","understand","robust"].map(c=>{const u=l.get(c)??[];return e.jsxs("section",{className:"border border-slate-200 rounded bg-white","data-testid":`wcag3-category-${c}`,children:[e.jsxs("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:[sl[c]," · ",u.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:u.map(h=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(al,{status:h.status}),e.jsx("strong",{className:"text-xs",children:h.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:h.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",h.outcome.wcag2Criteria.join(", ")]}),h.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:h.violatedCriteria.join(", ")})]})]},h.outcome.id))})]},c)})]})}function al({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}function nl(t,s,a){var o,d;const n=b(p=>p.acknowledgedKeys),[r,i]=m.useState(null),l=((o=s[0])==null?void 0:o.pageUrl)??((d=s[0])==null?void 0:d.scope)??"";return m.useEffect(()=>{if(s.length===0){i(null);return}let p=!1;return(async()=>{const c=await chrome.storage.local.get("igtRuns"),u=(c==null?void 0:c.igtRuns)??{},h=t?Object.values(u[t]??{}):[],g=s.map(k=>k.componentId).filter(Boolean),[f,v,w,S]=await Promise.all([t?Ae(t):Promise.resolve([]),Te(g),as(g),l?_e(l):Promise.resolve([])]);if(p)return;const C=new Set(s.map(k=>k.pageUrl??k.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",N=f.map(k=>({criterionId:k.criterionId,ruleId:`ai-walkthrough-${k.criterionId}`,pageUrl:k.pageUrl,verdict:k.verdict,reasoning:k.reasoning}));i(On(a,{runs:h,workflows:xe},s,n,N,v,w,C,S))})(),()=>{p=!0}},[t,l,s,a,n]),r}const rl=[{id:"overview",label:"Overview",hint:"Verification areas + WCAG coverage + evidence layers"},{id:"per-area",label:"Per-area",hint:"Drill into the 9 verification areas"},{id:"violations",label:"Violations",hint:"Flat list of every unique finding"},{id:"activity",label:"Activity",hint:"Live regions · focus events · tab/reading order"},{id:"delta",label:"Delta",hint:"Compared to the last accepted baseline"},{id:"wcag3",label:"WCAG 3",hint:"Forward-looking projection on the WCAG 3 outcome map"}],il={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function ol(){const t=b(u=>u.results),s=b(u=>u.componentId),a=b(u=>u.findingsLens),n=b(u=>u.setFindingsLens),r=b(u=>u.setView),i=b(u=>u.status),[l,o]=m.useState({});m.useEffect(()=>{if(!s)return;let u=!1;return(async()=>{const h=await Ae(s),g=await Te([s]);if(u)return;const f=new Set(g.map(w=>w.criterionId)),v={};for(const w of h){const S=f.has(w.criterionId)?"pass":w.verdict;w.criterionId==="2.4.3"?v.focusOrder=S:w.criterionId==="2.1.2"?v.keyboardTrap=S:w.criterionId==="2.4.7"?v.focusVisible=S:w.criterionId==="1.3.2"?v.readingOrder=S:w.criterionId==="1.4.11"&&(v.nonTextContrast=S)}o(v)})(),()=>{u=!0}},[s]);const d=ps(t),[p,c]=m.useState([]);return m.useEffect(()=>{if(!s){c([]);return}let u=!1;return chrome.storage.local.get("igtRuns").then(h=>{if(u)return;const f=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(f))}),()=>{u=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(ea,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:i==="running"?"Audit in progress. Findings appear here when the matrix completes.":i==="failed"||i==="interrupted"?"Last audit didn't complete. Re-run the scan from the controls above.":"No audit results yet. Run a scan from the controls above."})})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(ea,{setView:r}),e.jsx(cl,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:d}),e.jsx(ll,{results:t}),e.jsx(dl,{lens:a,setLens:n}),e.jsx(ul,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:d})]})}function ea({setView:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>t("matrix"),className:"text-xs text-slate-600 hover:text-slate-900 hover:underline font-mono px-0.5",children:"← Dashboard"}),e.jsx("span",{className:"text-[11px] font-mono uppercase tracking-widest text-slate-400",children:"findings"})]})}function ll({results:t}){const s=b(p=>p.crawlNavContext),a=b(p=>p.setCrawlNavContext),n=b(p=>p.setView);if(t.length===0)return null;const r=new Set(t.map(p=>p.pageUrl??p.scope??"").filter(Boolean)),i=r.size>1,l=i?null:Array.from(r)[0]??"(unknown)",o=(s==null?void 0:s.mode)==="page";function d(){a(null),n("crawl")}return e.jsxs("div",{className:`border rounded-lg px-3 py-2 text-[11px] leading-snug ${i?"border-blue-200 bg-blue-50 text-blue-900":o?"border-amber-200 bg-amber-50 text-amber-900":"border-slate-200 bg-slate-50 text-slate-700"}`,role:"note","aria-label":"Audit scope",children:[o&&e.jsx("button",{type:"button",onClick:()=>d(),className:"float-right text-[10px] font-semibold px-2 py-0.5 rounded border border-amber-400 bg-white text-amber-900 hover:bg-amber-100",children:"← Back to crawl report"}),i?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Site crawl · ",r.size," pages."]})," ","This grade reflects the site overall, not any individual page. Per-page drilldown is available in the Crawl tab."]}):o?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["One page from site crawl · ",l,"."]})," ",'This is the full per-page audit data for this URL — same lenses as a fresh single-page audit. Use the "Back to crawl report" button to return to the do-the-work report covering all crawled pages.']}):e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Single-page audit · ",l,"."]})," ","This grade reflects this page only. Multi-page criteria (3.2.3 Consistent Navigation, 3.2.4 Consistent Identification, 3.2.6 Consistent Help) are treated as N/A here — run a"," ",e.jsx("strong",{children:"Site Crawl"})," to evaluate them for the whole site."]})]})}function cl({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var S,I,C,N,k,x;const r=t.flatMap(y=>y.violations),i=b(y=>y.lastAuditWallClockMs),l=b(y=>y.acknowledgedKeys),o=b(y=>y.dismissedKeys),d=nl(((S=t[0])==null?void 0:S.componentId)??null,t,r),p=ts({violations:r,auditRan:!0,manualRuns:a,workflows:xe,heuristicCounts:{tabOrder:((C=(I=t[0])==null?void 0:I.tabOrderIssues)==null?void 0:C.length)??0,readingOrder:((k=(N=t[0])==null?void 0:N.readingOrderIssues)==null?void 0:k.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(y=>({ruleId:y.ruleId,impact:"serious",selector:y.selector}))}),c=(d==null?void 0:d.combined)??p.overallLetter,u=Ma(r,n,l,o),h=r.filter(y=>!l.has(y.matchKey)&&!o.has(`violation::${y.matchKey}`)),g=Fa(h,n),f=wi(r,n,l,o),v=t.length,w=i??t.reduce((y,R)=>y+R.durationMs,0);return e.jsxs("section",{className:"sticky top-0 z-10 border border-slate-200 rounded-lg bg-white overflow-hidden shadow-sm","aria-label":"Audit grade summary",children:[e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${il[c]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:c})}),e.jsxs("div",{className:"flex-1 px-3.5 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"overall grade · WCAG 2.1 AA"}),d&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:[e.jsxs("strong",{children:["Severity ",d.severity]})," (worst finding) ·"," ",e.jsxs("strong",{children:["Breadth ",d.breadth]})," (","of 9 areas) → combined ",e.jsx("strong",{children:d.combined}),". Same grade in Power view and in every exported report."]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:u===0?"No issues found by automation":g===u?`${g} issue${g===1?"":"s"} to fix`:`${g} issue${g===1?"":"s"} across ${u} instance${u===1?"":"s"}`}),u>0&&f.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",f.length," WCAG criteri",f.length===1?"on":"a"," (",f.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[v," state",v===1?"":"s"," tested · ",(w/1e3).toFixed(1),"s"]})]})]}),e.jsx(Fi,{coverage:(x=d==null?void 0:d.score)==null?void 0:x.coverage})]})}function dl({lens:t,setLens:s}){return e.jsx("nav",{className:"flex flex-wrap gap-1 border-b border-slate-200 pb-1.5",role:"tablist","aria-label":"Findings lens",children:rl.map(a=>{const n=t===a.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>s(a.id),title:a.hint,className:n?"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md bg-slate-900 text-white":"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md text-slate-600 hover:bg-slate-100",children:a.label},a.id)})})}function ul({lens:t,results:s,componentId:a,interactiveVerdicts:n,aiResolvedFails:r}){var i,l;return t==="overview"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(pl,{componentId:a,results:s}),e.jsx(gl,{componentId:a}),e.jsx(Ii,{violations:s.flatMap(o=>o.violations),componentId:a}),e.jsx(wl,{pageUrl:((i=s[0])==null?void 0:i.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(fl,{})]}):t==="per-area"?e.jsx(bo,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(vl,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ba,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ka,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Qa,{})}):null}const kt={critical:0,serious:1,moderate:2,minor:3};function Kt(t){return`${Ee(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function pl({componentId:t,results:s}){var f,v;const a=b(w=>w.setFindingsLens),[n,r]=m.useState({}),[i,l]=m.useState({}),[o,d]=m.useState(0);m.useEffect(()=>{let w=!1;return(async()=>{if(!t){r({}),l({});return}const S=await Ae(t);if(w)return;const I={};for(const k of S)I[k.criterionId]=k;r(I);const C=await Te([t]);if(w)return;const N={};for(const k of C)N[`${k.criterionId}::${k.pageUrl}`]=k;l(N)})(),()=>{w=!0}},[t,o]);const p=((f=s[0])==null?void 0:f.pageUrl)??((v=s[0])==null?void 0:v.scope)??"",c=xt.map(w=>({crit:w,record:n[w.id]??null})).filter(({record:w})=>w&&(w.verdict==="fail"||w.verdict==="uncertain")).filter(({crit:w})=>!i[`${w.id}::${p}`]),u=new Set,h=[];for(const w of s)for(const S of w.violations){if(S.needsReview)continue;const I=Ee(S.ruleId,S.target.selector);u.has(I)||(u.add(I),h.push(S))}h.sort((w,S)=>(kt[w.impact]??99)-(kt[S.impact]??99));const g=c.length+h.length;return g===0?e.jsxs("section",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"✓"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Nothing needs your attention on this page."})]}),e.jsx("p",{className:"text-[11px] text-emerald-800 mt-1 leading-snug",children:"No axe violations, no AI walkthrough fails, no uncertain findings. The sub-grades and WCAG coverage below are informational — you've done the work here. Move on to the next page or export your defense bundle."})]}):e.jsxs("section",{className:"border border-rose-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 bg-rose-50 border-b border-rose-200",children:[e.jsxs("p",{className:"text-sm font-semibold text-rose-900",children:[g," item",g===1?"":"s"," need",g===1?"s":""," your attention"]}),e.jsx("p",{className:"text-[11px] text-rose-800 mt-0.5 leading-snug",children:"Each row below is one thing to fix or sign off on. Use the inline buttons — you don't need to leave this view."})]}),e.jsxs("ul",{className:"divide-y divide-slate-100",children:[c.map(({crit:w,record:S})=>e.jsx(hl,{componentId:t??"",pageUrl:p,criterionId:w.id,label:w.label,blurb:w.blurb,record:S,onChanged:()=>d(I=>I+1)},`wt::${w.id}`)),h.map(w=>e.jsx(ml,{violation:w,onOpen:()=>a("violations")},`axe::${Kt(w)}`))]})]})}function hl({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:i,onChanged:l}){const[o,d]=m.useState(!1),[p,c]=m.useState(""),[u,h]=m.useState(!1),[g,f]=m.useState(null),[v,w]=m.useState(!1),[S,I]=m.useState(!1),C=hs(),N=i.verdict,k=N==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function x(){h(!0),f(null);try{if(!p.trim()){f("Note is required — explain how you manually verified this."),h(!1);return}await ss({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:N}),l()}catch(R){f(R instanceof Error?R.message:String(R))}finally{h(!1)}}async function y(){var R;I(!0),f(null);try{const $=(R=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:R.id;if(!$){f("No active tab — open the audited page first."),I(!1);return}const H=await Q({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:$,componentId:t,pageUrl:s});H.ok||f(H.error??"Re-run failed."),l()}catch(A){f(A instanceof Error?A.message:String(A))}finally{I(!1)}}return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${k}`,children:N}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:a}),n]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:N==="fail"?"AI walkthrough flagged a failure here. Fix the page and re-run, or verify manually and acknowledge.":"AI walkthrough couldn't decide. Fix the underlying ambiguity, or verify manually and acknowledge."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>w(R=>!R),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:v?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void y(),disabled:S||!C,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed",title:C?"Re-run AI walkthrough after fixing the page (will switch to the active tab)":"AI walkthroughs need an Anthropic API key. Add one in Settings → AI.",children:S?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{d(R=>!R),f(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",children:"Mark verified manually"})]}),v&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2 mt-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"What the walkthrough does"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:r}),e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"AI reasoning"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap font-mono",children:i.reasoning})]}),o&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5 mt-1",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"How did you verify? (required, goes into the forensic record)"}),e.jsx("textarea",{value:p,onChange:R=>c(R.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),g&&e.jsx("p",{className:"text-[10px] text-rose-700",children:g}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void x(),disabled:u,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:u?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{d(!1),c(""),f(null)},disabled:u,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}),g&&!o&&e.jsx("p",{className:"text-[10px] text-rose-700",children:g})]})}function ml({violation:t,onOpen:s}){const a=t.impact==="critical"?"bg-rose-200 text-rose-900":t.impact==="serious"?"bg-orange-200 text-orange-900":t.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700";return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${a}`,children:t.impact}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:t.wcagCriterion||"wcag"}),e.jsx("code",{className:"text-[11px] text-slate-700 bg-slate-100 px-1 rounded",children:t.ruleId})]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:t.description}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-0.5 font-mono break-all",children:t.target.selector})]})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("button",{type:"button",onClick:s,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Open in Violations →"})})]})}const xt=[{id:"2.4.3",label:"Focus order",blurb:"AI walks Tab/Shift+Tab and judges screenshot-by-screenshot whether focus reaches every interactive element."},{id:"2.1.2",label:"No keyboard trap",blurb:"AI Tab-cycles forward then Shift+Tab back; verifies every focusable can be left."},{id:"2.4.7",label:"Focus visible",blurb:"AI inspects each focus-state screenshot for a visible indicator (outline/ring/underline)."},{id:"1.3.2",label:"Meaningful sequence",blurb:"AI vision over the page screenshot judges whether DOM-flagged divergences are real reading-order breaks or layout artifacts."},{id:"1.4.11",label:"Non-text contrast",blurb:"AI vision evaluates UI controls + state indicators for adequate contrast against their adjacent colors."},{id:"2.5.3",label:"Label in Name",blurb:"DOM walker collects {visibleText, accessibleName} pairs across every interactive control; AI judges ambiguous cases (icons, plurals, smart-quotes)."}],xl={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function gl({componentId:t}){const[s,a]=m.useState({}),[n,r]=m.useState({});m.useEffect(()=>{let u=!1;return(async()=>{if(!t){a({}),r({});return}const[h,g]=await Promise.all([Ae(t),Te([t])]);if(u)return;const f={};for(const w of h)f[w.criterionId]=w;a(f);const v={};for(const w of g)v[w.criterionId]=w;r(v)})(),()=>{u=!0}},[t]);const i={};for(const[u,h]of Object.entries(s))i[u]=n[u]?"pass":h.verdict;const l=Object.values(i).length,o=Object.values(i).filter(u=>u==="pass").length,d=Object.values(i).filter(u=>u==="fail").length,p=Object.values(i).filter(u=>u==="uncertain").length,c=Object.keys(n).length;return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 border-b border-slate-100 flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-900",children:"AI verified"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-500",children:l===0?`not configured · all ${xt.length} criteria pending human verification`:`${l}/${xt.length} · ${o} pass · ${d} fail · ${p} uncertain${c>0?` · ${c} human-verified`:""}`})]}),l===0?e.jsxs("div",{className:"px-3 py-2.5 text-[11px] text-slate-600 leading-snug",children:["When an Anthropic API key is set in ",e.jsx("strong",{children:"Settings → AI"}),', these 5 criteria run automatically after every audit — replacing manual keyboard and vision checks. Without a key, they show as "pending human verification" in the Evidence layers below.']}):e.jsx("ul",{className:"divide-y divide-slate-100",children:xt.map(u=>{const h=s[u.id],g=n[u.id],f=h==null?void 0:h.verdict,v=g?"pass":f,w=h?Wt(h.reasoning):!1,S=h?va(h.reasoning):!1,I=h?Bt(h.reasoning):null;return e.jsxs("li",{className:"px-3 py-2 flex items-start gap-2.5",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-medium rounded px-1.5 py-0.5 ${g?"bg-emerald-500 text-white":v?xl[v]:"bg-slate-200 text-slate-500"}`,title:g?`Human verified at ${new Date(g.acknowledgedAt).toLocaleString()} — note: "${g.note}". (AI verdict was: ${f})`:v?`AI verdict: ${v}${I?` (cascade ${I})`:""}`:"AI did not produce a verdict on this criterion",children:g?"✓ verified":v||"not run"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:u.id}),u.label,S&&e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal",children:"· manual override"})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:u.blurb}),w&&!S&&!g&&h&&e.jsxs("div",{className:"mt-1.5 bg-amber-50 border border-amber-300 rounded p-2 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-amber-900 font-medium",children:"AI cascade flagged this — fix the issue and re-audit."}),e.jsxs("details",{className:"text-[10px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-32 overflow-y-auto bg-white/50 p-1.5 rounded",children:h.reasoning})]})]}),g&&e.jsxs("div",{className:"mt-1.5 bg-emerald-50 border border-emerald-300 rounded p-2",children:[e.jsxs("p",{className:"text-[10px] text-emerald-900",children:[e.jsx("strong",{children:"Human verified:"})," ",g.note]}),e.jsxs("p",{className:"text-[10px] text-emerald-700 mt-0.5",children:["Recorded ",new Date(g.acknowledgedAt).toLocaleString(),". Original AI verdict: ",f,"."]})]})]})]},u.id)})})]})}function fl(){return e.jsxs("div",{className:"border-t border-slate-200 pt-3 space-y-1.5",children:[e.jsx("h3",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"how to read this"}),e.jsx($e,{title:"The overall grade",body:'Count-based aggregation of the 9 verification areas (rc.110). The headline letter is the worst sub-grade letter you have N of — one C drops the overall off A regardless of how clean the other 8 areas look. This keeps a single bad area from hiding behind a high arithmetic mean. It is separate from "WCAG 2.1 AA Status," which is the legal-conformance answer (binary: conformant or not). The grade can be A while AA Status says "Not conformant" if there are unresolved criterion-level items — those are different questions and both are reported.'}),e.jsx($e,{title:"WCAG 2.1 AA Status",body:"Separate from the letter grade. Says whether you can claim WCAG 2.1 AA conformance. It is binary: Conformant or Not conformant. When Not conformant, the breakdown shows how many criteria are failing (real axe/AI violations) and how many are inconclusive (items that need user disposition). Fix or mark verified to flip to Conformant."}),e.jsx($e,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Areas below A show "verify with X →" — but when an AI walkthrough has already produced a verdict for that criterion, the prompt is suppressed automatically.`}),e.jsx($e,{title:"AI does most of the human work",body:"Six AI walkthroughs auto-run when an Anthropic API key is configured: 2.4.3 Focus Order, 2.1.2 No Keyboard Trap, 2.4.7 Focus Visible, 1.3.2 Meaningful Sequence, 1.4.11 Non-text Contrast, 2.5.3 Label in Name. They drive real keyboard input + take screenshots + judge them with vision (and parse DOM accessible-name vs visible-text for 2.5.3) — exactly the work IGT manual workflows used to require. Their verdicts feed the Tab order / Keyboard / Reading order / Color & contrast / Forms sub-grades automatically. When AI returns a definitive pass or fail for an area, the heuristic findings for that area become supporting evidence rather than independent severity (rc.227). Humans only spot-check + attest before signing the formal report."}),e.jsx($e,{title:"Fix recipes",body:'Every finding includes specific remediation instructions in the AI fix prompt export (Delta lens → Export menu). The prompt also includes false-positive guidance (skip-links, multi-column layouts, portal-rendered modals) so AI can ask before "fixing" intentional patterns.'}),e.jsx($e,{title:"WCAG 2.1 AA coverage",body:"Of 50 applicable Level AA criteria, how many have a definite verdict from any layer (automation, AI, or human). Untested criteria don't cap your grade — automation did everything it could — but for a formal conformance claim, those still need explicit evaluation. Run a Site Crawl or open Compliance to fill the gaps."}),e.jsx($e,{title:"Path to full compliance",body:"The shortest sequence of actions: fix automated violations, let AI walkthroughs auto-resolve the keyboard/vision criteria, optionally spot-check via Compliance → Sign and seal. Export the AI fix prompt from the Delta lens for code-level walkthroughs of each issue."})]})}function $e({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded bg-slate-50",children:[e.jsx("summary",{className:"px-2.5 py-1.5 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded",children:t}),e.jsx("p",{className:"px-2.5 pb-2 text-[11px] text-slate-700 leading-snug",children:s})]})}function bl({componentId:t,records:s,stateCount:a}){const[n,r]=m.useState(0),[i,l]=m.useState({});return m.useEffect(()=>{if(!t){l({});return}let o=!1;return Te([t]).then(d=>{if(o)return;const p={};for(const c of d)p[c.criterionId]=c;l(p)}),()=>{o=!0}},[t,n]),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[s.length," AI walkthrough finding",s.length===1?"":"s"," · axe found none"]}),e.jsxs("p",{className:"text-[11px] text-slate-600 px-0.5 leading-snug",children:["axe-core ran clean across ",a," state",a===1?"":"s",", but AI walkthroughs flagged something axe can't detect. Use the inline buttons on each row — no need to navigate elsewhere."]}),s.map(o=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(ms,{componentId:t??"",pageUrl:o.pageUrl,criterionId:o.criterionId,record:o,onChanged:()=>r(d=>d+1),ack:i[o.criterionId]??null})},o.criterionId))]})}function vl({results:t}){const s=b(o=>o.dismissedKeys),a=b(o=>o.componentId),n=new Set,r=[];for(const o of t)for(const d of o.violations){if(s.has(`violation::${d.matchKey}`))continue;const p=Kt(d);n.has(p)||(n.add(p),r.push(d))}r.sort((o,d)=>{const p=kt[o.impact]??99,c=kt[d.impact]??99;return p-c});const[i,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let o=!1;return Ae(a).then(d=>{o||l(d.filter(p=>p.verdict!=="pass"))}),()=>{o=!0}},[a]),r.length===0&&i.length===0?e.jsxs("div",{className:"text-center text-sm text-slate-600 py-6",children:["No issues detected on this page — no axe violations and no AI walkthrough findings. The grade reflects sub-grading on areas that may have heuristic observations (visible under ",e.jsx("strong",{children:"Per-area"}),")."]}):r.length===0&&i.length>0?e.jsx(bl,{componentId:a,records:i,stateCount:t.length}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[r.length," unique violation",r.length===1?"":"s"," · sorted by impact"]}),r.map(o=>e.jsx(at,{violation:o},Kt(o)))]})}const yl={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function wl({pageUrl:t}){const s=b(p=>p.tier),a=fa(),n=we(s,"autoExportAuditReports"),[r,i]=m.useState(null),[l,o]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await Sa();if(p||i(c),t){const u=await jr(t);p||o(u)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?yl[r.formats[0]].split(" · ")[0]:`${r.formats.length} formats`;return e.jsxs("div",{className:"border border-emerald-200 rounded-lg bg-emerald-50 p-2.5 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-[12px] font-semibold text-emerald-900",children:"✓ Remediation trail active"}),e.jsx("span",{className:"text-[10px] text-emerald-800 font-mono",children:d})]}),l?e.jsxs("p",{className:"text-[10px] text-emerald-800 leading-snug",children:["Last exported ",e.jsx("span",{className:"font-mono",children:new Date(l.exportedAt).toLocaleString()})," ","as ",e.jsx("span",{className:"font-mono",children:l.filename})]}):e.jsx("p",{className:"text-[10px] text-emerald-800 italic",children:"No audit has auto-exported on this page yet. Your next audit will download to Downloads automatically."})]})}const qt="igtRuns";async function jl(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const l=n.tabOrderIssues??[];if(l.length===0)return;await st(r,l.map(o=>({key:tt(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await st(r,l.map(o=>({key:et(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}}const kl={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},Nl={outline:{type:"OUTLINE_HIDE_REQUEST"},"tab-order":{type:"TAB_ORDER_HIDE_REQUEST"},"reading-order":{type:"READING_ORDER_HIDE_REQUEST"},targets:{type:"TARGET_SIZE_HIDE_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_HIDE_REQUEST"}},Sl={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ta(t,s){const a=await me();if(!a)return;const n=s?kl[t]:Nl[t];try{await be(a,n)}catch{}}async function Al(){const s=(await chrome.storage.local.get(qt))[qt];return s&&typeof s=="object"?s:{}}async function sa(t){await chrome.storage.local.set({[qt]:t})}function Cl(t,s){if(!t.relatedAxeRule||s.length===0)return null;const a=s.flatMap(n=>n.violations.filter(r=>r.ruleId===t.relatedAxeRule));if(a.length>0){const n=Array.from(new Set(a.map(r=>`${r.currentState.pseudoState}·${r.currentState.theme}·${r.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:a.length,states:n}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function Il(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=m.useState({}),[r,i]=m.useState(null);if(m.useEffect(()=>{Al().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const l=a[t]??{};function o(c,u,h){var f;const g={...a,[t]:{...l,[c]:{...l[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((f=l[c])==null?void 0:f.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(g),sa(g),h.status==="pass"){const v=xe.find(S=>S.id===c),w=v==null?void 0:v.steps.find(S=>S.id===u);w!=null&&w.autoDismissActivity&&jl(w.autoDismissActivity,s,u)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...l};delete u[c];const h={...a,[t]:u};n(h),sa(h)}const p=xe.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(El,{workflow:p,run:c,results:s,onAnswer:(u,h)=>o(p.id,u,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),xe.map(c=>{const u=l[c.id],h=u?kr(u,c):null,g=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",f={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[g];return e.jsxs("button",{type:"button",onClick:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${f}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),g==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),g==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),u&&e.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function El({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=m.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=Cl(p,a);return d},[t,a]);function l(){for(const d of t.steps){const p=i[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const o=t.steps.filter(d=>{var p;return((p=i[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),o>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[o," step",o===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:l,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",o," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,p)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=i[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ta(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Sl[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ta(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(it,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(it,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(it,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(it,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:u=>n(d.id,{status:c.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const Rl={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function it({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?Rl[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const gt="savedFlows";async function Tl(){const t=await chrome.storage.local.get(gt);return Array.isArray(t[gt])?t[gt]:[]}async function aa(t){await chrome.storage.local.set({[gt]:t})}function $l(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,i]=m.useState(null);m.useEffect(()=>{Tl().then(s)},[]);async function l(){const c=await me();if(!c){i("No audit-target tab found.");return}try{await be(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function o(){const c=await me();if(c)try{const u=await Re(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const g={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},f=[g,...t];s(f),await aa(f),i(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await me();if(u){i(`Replaying "${c.name}"…`);try{const h=await Re(u,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==c);s(u),await aa(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function Ul(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),l=n.slice(r+1);return i==="story"?{primary:l.split("--").map(d=>d.split("-").map(Ll).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||i}}function Ll(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function _l(){const t=b(o=>o.baselineList),s=b(o=>o.tier),a=fr[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=m.useState(!1);if(m.useEffect(()=>{yt().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(o=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},o))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function l(o){await Q({type:"BASELINE_DELETE",componentId:o}),await yt()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(o=>{const d=Ul(o.componentId),p=o.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:o.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[o.violationCount," ",o.violationCount===1?"violation":"violations"," ·"," ",new Date(o.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[o.seenOnUrlsCount&&o.seenOnUrlsCount>1&&e.jsxs(Ue,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",o.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(Ue,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(Ue,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(Ue,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(Ue,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(Ue,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(Ue,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(o.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},o.componentId)})]})}const Dl={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function Ue({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Dl[t]}`,children:a})}const Ya={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Ol={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ya]},Fl={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ya]};function $t(t){return t==="thorough"?Fl:Ol}function Qt(t){const s=$t(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Ja({depth:t,onChange:s,disabled:a}){return e.jsxs("fieldset",{className:"mt-2",children:[e.jsx("legend",{className:"sr-only",children:"Scan depth"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsx(na,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Qt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(na,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Qt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function na({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:i}){return e.jsxs("button",{type:"button",onClick:a,disabled:s,"aria-pressed":t,className:`text-left rounded p-2 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"} disabled:opacity-50`,children:[e.jsx("div",{className:"font-medium text-slate-900",children:n}),e.jsx("div",{className:"text-slate-600 text-[10px]",children:r}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:i})]})}const xs={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"};function Xa(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return(async()=>{const r=await Ze(),i=(r??[]).flatMap(o=>o.results),l=await ya(i);n||a(Fn(r??[],l.acknowledgedMatchKeys))})(),()=>{n=!0}},[t.startUrl,t.finishedAt]),s}function Ml(t){var s;return((s=Xa(t))==null?void 0:s.site)??null}function Za(){const t=b(d=>d.siteCrawlReport),s=b(d=>d.results),a=b(d=>d.delta),n=b(d=>d.componentId),r=b(d=>d.status),i=b(d=>d.siteCrawlStatus),[l,o]=m.useState({report:null,resolvedFails:[]});return m.useEffect(()=>{var u;let d=!1;async function p(h){return h.length===0?[]:(await Promise.all(h.map(f=>_e(f)))).flat().map(Pn).map(Gn).filter(f=>f.verdict==="fail")}if(i==="running"||r==="running"){o({report:null,resolvedFails:[]});return}if(t)return(async()=>{const h=t.pages.map(f=>f.url),g=await p(h);d||o({report:t,resolvedFails:g})})(),()=>{d=!0};if(s.length===0||!n){o({report:null,resolvedFails:[]});return}const c=(u=s[0])==null?void 0:u.pageUrl;if(!c){o({report:null,resolvedFails:[]});return}return(async()=>{try{const[h,g]=await Promise.all([ya(s,[c]),p([c])]),f=new Date().toISOString(),v=Mn(c,[{url:c,results:s,delta:a,componentId:n,durationMs:0}],f,f,0,h.walkthroughsByComponent,h.walkthroughAcksByComponent,h.ackedKeysByComponent,h.humanVerdictsByComponent,h.incompleteResolutionsByComponent,h.attestations);d||o({report:v,resolvedFails:g})}catch(h){console.warn("[view-model] synthesize single-page report failed",h),d||o({report:null,resolvedFails:[]})}})(),()=>{d=!0}},[t,s,a,n,r,i]),l}function en(t){var s;return t.storeComponentId?t.storeComponentId:(s=t.storeCrawlReport)!=null&&s.startUrl?t.storeCrawlReport.startUrl:t.pageUrls[0]?t.pageUrls[0]:null}function Pl(t){var s;return((s=Ca.find(a=>a.id===t))==null?void 0:s.title)??t}const Gl={"attested-conforms":"Conforms (attested)","attested-na":"N/A (attested)","not-addressed":"Not addressed"},Vl={"attested-conforms":"#34d399","attested-na":"#94a3b8","not-addressed":"#fbbf24"};function Wl(){var k;const{report:t}=Za(),s=b(x=>x.componentId),a=b(x=>x.siteCrawlReport),[n,r]=m.useState({}),[i,l]=m.useState(!1),[o,d]=m.useState(null),[p,c]=m.useState(""),[u,h]=m.useState("operator"),g=(t==null?void 0:t.startUrl)??en({storeComponentId:s,storeCrawlReport:a,pageUrls:(t==null?void 0:t.pages.map(x=>x.url))??[]});m.useEffect(()=>{(async()=>{var R;const x=await Ir().catch(()=>null),y=(R=x==null?void 0:x.response)==null?void 0:R.email;y&&h(y)})()},[]),m.useEffect(()=>{let x=!1;return(async()=>{if(!g){x||r({});return}const y=await Vn([g]).catch(()=>[]);if(x)return;const R={};for(const A of y)R[A.criterionId]=A;r(R)})(),()=>{x=!0}},[g]);const f=((k=t==null?void 0:t.spotCheckGate)==null?void 0:k.status)==="pending";if(m.useEffect(()=>{f&&l(!0)},[f]),!t||!g)return null;const v=t.spotCheckGate;if(!v||v.status==="none")return null;const w=v.status==="pending",S=()=>{Q({type:"REGRADE_SITE_CRAWL"}).catch(()=>{})},I=async(x,y,R)=>{const A={componentId:g,criterionId:x,kind:y,note:R.trim(),operator:u,timestamp:new Date().toISOString(),toolVersion:chrome.runtime.getManifest().version};await Kn(A),r($=>({...$,[x]:A})),d(null),c(""),S()},C=async x=>{await zn(g,x),r(y=>{const R={...y};return delete R[x],R}),S()},N=Object.keys(n).length;return e.jsxs("div",{style:{marginTop:"var(--v2-pad-3, 16px)",border:"1px solid #334155",borderRadius:8,overflow:"hidden"},children:[e.jsxs("button",{onClick:()=>l(x=>!x),style:{width:"100%",textAlign:"left",background:"#0f172a",color:"#e2e8f0",border:"none",padding:"12px 14px",cursor:"pointer",fontSize:13,fontWeight:600},children:[i?"▾":"▸"," ",w?"Required to finalize your grade — spot checks":"Spot checks (content-meaning criteria)",e.jsxs("span",{style:{color:w?"#fbbf24":"#94a3b8",fontWeight:w?600:400},children:[" — ",N," of ",v.total," answered",w?" · grade is PENDING until all are answered":v.displayGrade==="A"?" · grade A":" · grade B"]})]}),i&&e.jsxs("div",{style:{padding:"12px 14px",background:"#0b1220"},children:[w&&e.jsxs("p",{style:{margin:"0 0 12px",fontSize:11,color:"#fde68a",lineHeight:1.6,padding:"10px 12px",background:"rgba(251,191,36,0.08)",border:"1px solid rgba(251,191,36,0.3)",borderRadius:6},children:[e.jsx("strong",{children:"Your grade is withheld (pending)."})," Automation is clean — you're on track for an A — but these content-meaning criteria depend on meaning the tool can't judge, so the A isn't issued until you answer all ",v.total,". ",e.jsxs("strong",{children:[v.unanswered.length," still unanswered."]})," When all are answered: all ",e.jsx("strong",{children:"Conforms / N-A"})," → A; any ",e.jsx("strong",{children:"Not addressed"})," → B."]}),e.jsx("p",{style:{margin:"0 0 12px",fontSize:11,color:"#94a3b8",lineHeight:1.6,padding:"10px 12px",background:"#0f172a",border:"1px solid #334155",borderRadius:6},children:Wn}),e.jsxs("p",{style:{margin:"0 0 12px",fontSize:11,color:"#cbd5e1",lineHeight:1.5},children:["These are the content-meaning criteria automation can verify presence but not correctness — caption accuracy, alt-text ",e.jsx("em",{children:"meaning"}),", audio-description quality, sensory cues, color-only information. Each is your ",e.jsx("strong",{children:"own statement"}),' (identity + timestamp, marked "not tool-verified"). ',e.jsx("strong",{children:"Conforms"})," = you checked it and it passes; ",e.jsx("strong",{children:"N/A"})," = it doesn't apply to your pages (e.g. no audio/video) — both reach ",e.jsx("strong",{children:"A"}),".",e.jsx("strong",{children:" Not addressed"})," = you didn't verify it, which honestly keeps the grade at",e.jsx("strong",{children:" B"}),". The grade stays ",e.jsx("strong",{children:"pending"})," until every one is answered."]}),Bn.map(x=>{const y=n[x.id],R=Pl(x.id);return e.jsxs("div",{style:{borderTop:"1px solid #1e293b",padding:"10px 0"},children:[e.jsxs("div",{style:{fontSize:12,color:"#e2e8f0",fontWeight:600},children:["WCAG ",x.id," — ",R]}),e.jsx("div",{style:{fontSize:11,color:"#94a3b8",margin:"2px 0 8px",lineHeight:1.5},children:x.reason}),y?e.jsxs("div",{style:{fontSize:11,color:"#cbd5e1"},children:[e.jsxs("span",{style:{color:Vl[y.kind],fontWeight:700},children:["● ",Gl[y.kind]]}),y.note?e.jsxs("span",{style:{color:"#94a3b8"},children:[' — "',y.note,'"']}):null,e.jsxs("div",{style:{color:"#64748b",marginTop:2},children:[y.operator," · ",y.timestamp.slice(0,10)," · self-attested, not tool-verified"]}),e.jsx("button",{onClick:()=>void C(x.id),style:ra,children:"un-attest"})]}):(o==null?void 0:o.id)===x.id?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic",margin:"0 0 6px",lineHeight:1.5},children:['"',Hn(R,new Date().toISOString(),o.kind),'"']}),e.jsx("textarea",{value:p,onChange:A=>c(A.target.value),placeholder:"What did you check? (required)",rows:2,style:{width:"100%",boxSizing:"border-box",background:"#0f172a",color:"#e2e8f0",border:"1px solid #334155",borderRadius:4,fontSize:11,padding:6}}),e.jsxs("div",{style:{marginTop:6,display:"flex",gap:8},children:[e.jsx("button",{disabled:!p.trim(),onClick:()=>void I(x.id,o.kind,p),style:{...Bl,opacity:p.trim()?1:.5},children:"Record attestation"}),e.jsx("button",{onClick:()=>{d(null),c("")},style:ra,children:"cancel"})]})]}):e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>{d({id:x.id,kind:"attested-conforms"}),c("")},style:Dt,children:"Conforms…"}),e.jsx("button",{onClick:()=>{d({id:x.id,kind:"attested-na"}),c("")},style:Dt,children:"N/A…"}),e.jsx("button",{onClick:()=>void I(x.id,"not-addressed",""),style:Dt,children:"Not addressed"})]})]},x.id)})]})]})}const Dt={background:"#1e293b",color:"#cbd5e1",border:"1px solid #334155",borderRadius:4,fontSize:11,padding:"4px 8px",cursor:"pointer"},Bl={background:"#2563eb",color:"#fff",border:"none",borderRadius:4,fontSize:11,padding:"5px 10px",cursor:"pointer"},ra={background:"none",color:"#64748b",border:"none",fontSize:11,padding:"2px 0",cursor:"pointer",textDecoration:"underline"},Hl={"1.2.1":{howToCheck:"Confirm any audio-only or video-only media has a text alternative (transcript, captions, descriptive title). If the page has no audio or video at all, mark N/A with that note."},"1.2.2":{howToCheck:"For every prerecorded video with audio, verify captions are present and synchronized. Open each video, turn captions on, and spot-check 10–15 seconds. If the page has no video with audio, mark N/A."},"1.2.3":{howToCheck:"For every prerecorded video, confirm an audio description track OR a full text alternative is available. If no prerecorded video, mark N/A."},"1.2.4":{howToCheck:"For any live streaming media with audio, verify live captions are provided. If the page has no live media, mark N/A."},"1.2.5":{howToCheck:"For prerecorded video, confirm an audio description track is provided (separate from the main audio). If no prerecorded video, mark N/A."},"1.3.1":{howToCheck:"Inspect headings, lists, tables, and form labels. Programmatic structure should match visual structure: h1→h2→h3, real <ul>/<ol>, real <table> with <th>, every form field has a <label> or aria-label. Tabbing through the page should reveal the same structure a screen reader would announce."},"1.4.3":{howToCheck:"Open the inconclusive elements. Most commonly axe failed because the background is transparent, a gradient, or an image. Identify the EFFECTIVE background color a user sees and compute the contrast ratio against the foreground; needs ≥4.5:1 for normal text, ≥3:1 for large text (18pt+ or 14pt+ bold)."},"1.4.4":{howToCheck:"Zoom the page to 200% (Ctrl+Plus four times in most browsers). Verify all content remains visible and functional — no overlapping text, no clipped buttons, no horizontal scrollbar at 1280×1024 viewport."},"1.4.10":{howToCheck:"Resize the browser to 320 CSS px wide (or use devtools mobile emulation at 320×256). Confirm content reflows without two-dimensional scrolling — vertical scroll only, no horizontal scroll except for genuinely two-dimensional content (data tables, images, complex maps)."},"1.4.11":{howToCheck:"Verify every UI component's boundary (button borders, form field outlines, focus indicators) has ≥3:1 contrast against its adjacent color. Same for meaningful graphics (icons, infographic elements). Decorative graphics are exempt."},"1.4.12":{howToCheck:"Apply this CSS via devtools and confirm no content is clipped or hidden: line-height: 1.5; letter-spacing: 0.12em; word-spacing: 0.16em; paragraph spacing 2× font-size. If layout breaks, the page fails."},"2.1.1":{howToCheck:"Tab through every interactive element. Every button, link, form field, and custom control must be reachable AND operable via keyboard alone (Enter, Space, arrow keys as appropriate). Mouse-only affordances fail."},"2.1.2":{howToCheck:"Tab into every interactive component. Confirm Tab/Shift+Tab moves focus out. No element should trap focus (typical offenders: poorly-coded modals, embedded players)."},"2.4.1":{howToCheck:"Verify a skip-to-main-content link exists (typically first focusable element, visible on focus) OR landmark regions (<main>, <nav>) are present. Either lets keyboard users bypass repeated nav."},"2.4.3":{howToCheck:"Tab through the page in source order. Focus must move in a sequence that preserves meaning — usually left-to-right, top-to-bottom. Particularly check skip links and modals."},"2.4.4":{howToCheck:`Read each link's text WITH its surrounding context (parent paragraph, list item, table cell). The combined text must convey where the link goes. "Click here" alone is ambiguous; "Click here to read our pricing" passes when context is included.`},"2.4.5":{howToCheck:"Confirm at least two ways to find a given page exist: site search, sitemap, A-Z index, table of contents, or persistent navigation. Single-page sites and process-step pages (checkout) are exempt."},"2.4.6":{howToCheck:"Read each heading and form-field label in isolation. Each should describe the topic of its section or the purpose of its field WITHOUT requiring the surrounding content to make sense."},"2.4.7":{howToCheck:"Tab through every focusable element. The current focus must be VISUALLY distinct from neighbors — an outline, a box-shadow, a background change. The default browser outline counts; CSS that removes it without replacing fails."},"2.5.3":{howToCheck:"For every control with both a visible text label and an accessible name (aria-label, alt, etc.), verify the visible label appears (verbatim, or as a substring) in the accessible name. Otherwise voice-control users can't target it by saying its visible label."},"3.1.1":{howToCheck:'View source. Confirm <html lang="..."> is present with a valid language tag (e.g. "en", "en-US", "fr").'},"3.1.2":{howToCheck:"Find any passage of foreign-language text on the page (a quote, a borrowed phrase, an entire alternate-language section). Confirm it's wrapped with the appropriate lang attribute. If the entire page is in one language, mark N/A."},"3.2.1":{howToCheck:"Tab to each focusable element. Confirm receiving focus alone does NOT trigger a context change: no navigation, no modal opening, no form submission. Action only on explicit activation (click, Enter)."},"3.2.2":{howToCheck:"In each form, change one input value (type in a field, check a checkbox, change a select). Confirm this does NOT submit the form, navigate the page, or open a modal without first warning the user."},"3.2.3":{howToCheck:"Open at least three different pages on the site. Confirm the main navigation, footer navigation, and any breadcrumb appear in the SAME relative order on each. Reordering items between pages is a fail; adding or removing items based on auth state is acceptable."},"3.2.4":{howToCheck:"Identify a few common functional elements on the site (e.g., the search input, login button, cart button, social-share icons). Verify each appears with the SAME accessible name, label, and icon on every page where it appears. Inconsistent naming is the fail mode."},"3.3.1":{howToCheck:"Submit a form with invalid data. Confirm errors are identified in text (not just color), describe what went wrong, and ideally indicate which field. Browser-default validation messages count."},"3.3.2":{howToCheck:"Every form input should have a visible label (or visible placeholder + accessible name combination) AND an instruction when format matters (date format, password rules). Placeholder-only labels fail because they disappear on focus."},"3.3.3":{howToCheck:'Submit a form with invalid data. Confirm the error message describes HOW to fix the problem (e.g., "Email must contain @" not just "Invalid email"). Exempts cases where suggestion would compromise security (password rules).'},"3.3.4":{howToCheck:"For any form that submits a legal commitment, financial transaction, or modifies/deletes user data: confirm submissions are reversible, validated for errors before commit, OR show a confirmation step before final commit."},"4.1.3":{howToCheck:'Trigger any status update (form submitted, item added to cart, search completed, error appeared). Confirm screen-reader users receive the update via an aria-live region or role="status"/"alert" — without moving focus to the update.'}};function zl(t){return Hl[t]??null}const Kl={"1.1.1":{whatAiAdds:'alt-text descriptiveness (catches generic alts like "image", "figure 1")',mode:"per-finding"},"1.3.3":{whatAiAdds:'sensory-language detection ("click the green button")',mode:"per-finding"},"1.4.1":{whatAiAdds:"color-only meaning detection",mode:"per-finding"},"1.4.5":{whatAiAdds:"image-of-text identification",mode:"per-finding"},"2.4.4":{whatAiAdds:'generic link text ("click here", "read more")',mode:"per-finding"},"2.4.6":{whatAiAdds:"heading clarity vs section content",mode:"per-finding"},"3.1.1":{whatAiAdds:"declared-language vs actual content",mode:"per-finding"},"3.1.2":{whatAiAdds:"declared-language vs actual content (parts)",mode:"per-finding"},"3.1.5":{whatAiAdds:"wall-of-text / readability",mode:"per-finding"},"4.1.2":{whatAiAdds:"ARIA role semantic correctness",mode:"per-finding"},"1.3.2":{whatAiAdds:"reading-order DOM vs visual (AI vision walkthrough)",mode:"walkthrough"},"1.4.11":{whatAiAdds:"non-text contrast against backgrounds",mode:"walkthrough"},"2.1.2":{whatAiAdds:"no keyboard trap (Tab cycle walkthrough)",mode:"walkthrough"},"2.4.3":{whatAiAdds:"focus order vs visual layout",mode:"walkthrough"},"2.4.7":{whatAiAdds:"focus visibility (screenshot walkthrough)",mode:"walkthrough"},"2.5.3":{whatAiAdds:"visible label vs accessible name match",mode:"walkthrough"}};function ot(t){return Kl[t]??null}const ql="https://api.anthropic.com/v1/messages",Ql="2023-06-01",Yl="claude-sonnet-4-6",Jl={input:3/1e6,output:15/1e6},Xl={input:1/1e6,output:5/1e6},Zl=`You are wcagcheckr's accessibility-audit co-pilot.
19
+
20
+ You answer the user's questions about THEIR audit results. You will be given the audit's structured data (violations, WCAG criteria, severities, components) in the user-supplied <audit-context> block.
21
+
22
+ Rules:
23
+ - Reference ONLY the audit data you were given. Do NOT invent findings, fabricate WCAG criteria, or claim the audit checked something it didn't.
24
+ - If the user asks about something not in the audit data, say "that wasn't in this audit" and suggest the next step (re-run with more state coverage, run an IGT manual workflow, etc.).
25
+ - Keep answers tight. 2-5 short sentences for most questions; a code snippet only when the user asks "how do I fix X".
26
+ - When you cite a WCAG criterion, use the dotted SC number (e.g. 1.4.3).
27
+ - Don't be cheerful or evangelical. Be factual.
28
+ - If the user asks for the impact-priority order, sort: critical > serious > moderate > minor.
29
+ - The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function ec(t,s,a){const n=a.includes("haiku")?Xl:Jl;return t*n.input+s*n.output}async function tn(t){const s=t.model||Yl,a=t.maxTokens??800;if(t.messages.length===0||t.messages[t.messages.length-1].role!=="user")throw new Error("chatComplete: messages must end with a user turn");let n=t.system??Zl;!t.system&&t.auditContext&&(n+=`
30
+
31
+ <audit-context>
32
+ ${t.auditContext}
33
+ </audit-context>`);const r=await fetch(ql,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":Ql,"anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:s,max_tokens:a,system:n,messages:t.messages}),signal:t.signal});if(!r.ok){const c=await r.text().catch(()=>"");throw new Error(`Anthropic API ${r.status}: ${c.slice(0,300)}`)}const i=await r.json(),l=i.content.filter(c=>c.type==="text").map(c=>c.text).join(`
34
+ `).trim(),o=i.usage.input_tokens,d=i.usage.output_tokens,p=ec(o,d,s);if(t.maxCostUsd!==void 0&&p>t.maxCostUsd)throw new Error(`chat turn cost $${p.toFixed(4)} exceeded maxCostUsd $${t.maxCostUsd.toFixed(4)}`);return{text:l,inputTokens:o,outputTokens:d,costUsd:p,model:i.model}}function tc(t){const s=[];t.pageUrl&&s.push(`page: ${t.pageUrl}`),t.componentId&&s.push(`component: ${t.componentId}`),s.push(`violations: ${t.violations.length}`),s.push("");const a=new Set;for(const n of t.violations){const r=`${n.ruleId}::${n.target.selector}`;if(a.has(r))continue;a.add(r);const i=n.target.outerHTML.length>200?n.target.outerHTML.slice(0,197)+"...":n.target.outerHTML;s.push(`- [${n.impact}] ${n.ruleId} (WCAG ${n.wcagCriterion} ${n.wcagLevel})`),s.push(` selector: ${n.target.selector}`),s.push(` html: ${i}`),s.push(` axe says: ${n.description}`),s.push("")}return s.join(`
35
+ `)}const ia="aiConfig";function sc(t){return`https://www.w3.org/WAI/WCAG22/Understanding/${t}`}const ac=new Map(Ca.map(t=>[t.id,t]));async function nc(t){const a=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];if(!(a!=null&&a.id))return{ok:!1,error:"No active tab."};const n=a.id,r=Nt(t.pageUrl),i=Nt(a.url??"");if(!(a.url===t.pageUrl)){try{await chrome.tabs.update(n,{url:t.pageUrl})}catch(c){return{ok:!1,error:c instanceof Error?c.message:"Failed to navigate tab."}}if(!await rc(n,t.pageUrl,12e3))return{ok:!1,error:"Page did not finish loading in time."}}if(!t.selector)return{ok:!0,found:!1,matchCount:0};const o=[120,250,500,800,1200,800];let d="";for(let p=0;p<=o.length;p++)try{const c=await Re(n,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:n,selector:t.selector,scrollIntoView:!0});return{ok:!0,found:c.found,matchCount:c.matchCount}}catch(c){const u=c instanceof Error?c.message:String(c);if(d=u,!(u.includes("Could not establish connection")||u.includes("Receiving end does not exist")))break;const g=o[p];if(g===void 0)break;await new Promise(f=>setTimeout(f,g))}return{ok:!1,error:r!==i?`Navigated to ${t.pageUrl} — but the in-page highlighter couldn't attach (${d}).`:d}}function Nt(t){try{return new URL(t).origin}catch{return""}}function rc(t,s,a){return new Promise(n=>{let r=!1;const i=setTimeout(()=>{r||(r=!0,chrome.tabs.onUpdated.removeListener(l),n(!1))},a);function l(o,d,p){if(o!==t||d.status!=="complete")return;const c=Nt(p.url??""),u=Nt(s);u&&c&&c!==u||r||(r=!0,clearTimeout(i),chrome.tabs.onUpdated.removeListener(l),n(!0))}chrome.tabs.onUpdated.addListener(l)})}function oa(t){try{const s=new URL(t),a=s.pathname+s.search+s.hash||"/";return a.length>60?a.slice(0,57)+"...":a}catch{return t}}function ic(t){return t.length>70?t.slice(0,67)+"...":t}function oc(t){try{const s=new Date(t),a=new Date,n=s.toDateString()===a.toDateString(),r=new Date(a);r.setDate(r.getDate()-1);const i=s.toDateString()===r.toDateString(),l=s.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return n?`today, ${l}`:i?`yesterday, ${l}`:`${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${l}`}catch{return t}}function lc(){const{report:t}=Za(),s=b(w=>w.componentId),a=b(w=>w.siteCrawlReport),[n,r]=m.useState(!1),[i,l]=m.useState(new Set),[o,d]=m.useState(0),p=m.useRef(""),[c,u]=m.useState(!1),[h,g]=m.useState("claude-sonnet-4-6");m.useEffect(()=>{(async()=>{const S=(await chrome.storage.local.get(ia))[ia];p.current=(S==null?void 0:S.apiKey)??"",u(!!(S!=null&&S.apiKey)),S!=null&&S.model&&g(S.model)})()},[]);const f=en({storeComponentId:s,storeCrawlReport:a,pageUrls:(t==null?void 0:t.pages.map(w=>w.url))??[]});if(m.useEffect(()=>{let w=!1;return(async()=>{if(!f){w||l(new Set);return}try{const S=await as([f]);if(w)return;l(new Set(S.map(I=>I.criterionId)))}catch{w||l(new Set)}})(),()=>{w=!0}},[f,o]),!t)return null;const v=t.blockingCriteria;return!v||v.length===0||t.siteGrade!=="A"&&t.siteGrade!=="B"&&t.siteGrade!=="pending"?null:e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border)",borderRadius:4,background:"var(--v2-bg-elev)"},children:[e.jsxs("button",{type:"button",onClick:()=>r(w=>!w),"aria-expanded":n,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-ink-primary)",fontSize:13,fontWeight:500,textAlign:"left",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--v2-pad-3)",width:"100%"},children:[e.jsx("span",{children:(()=>{const w=v.length,S=v.filter(C=>i.has(C.criterionId)).length,I=w-S;return S===0?`${w} criteri${w===1?"on":"a"} need${w===1?"s":""} your judgment`:I===0?`${w} criteri${w===1?"on":"a"} verified — re-crawl to lift the grade`:`${S} of ${w} verified · ${I} remaining`})()}),e.jsx("span",{"aria-hidden":"true",style:{fontSize:11,color:"var(--v2-ink-tertiary)"},children:n?"▾":"▸"})]}),n&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:"Each criterion below has no affirmative evidence yet. Mark it Pass / N/A / Fail with a note about what you checked. Verdicts persist as forensic evidence and contribute to the audit's chain of custody."}),v.map(w=>e.jsx(cc,{criterionId:w.criterionId,title:w.title,state:w.state,evidence:w.evidence,targetComponentId:f,apiKeyRef:p,apiKeyPresent:c,model:h,onVerdictChange:()=>d(S=>S+1)},w.criterionId))]})]})}function cc({criterionId:t,title:s,state:a,evidence:n,targetComponentId:r,apiKeyRef:i,apiKeyPresent:l,model:o,onVerdictChange:d}){var ee,X;const[p,c]=m.useState(null),[u,h]=m.useState(""),[g,f]=m.useState(!1),[v,w]=m.useState(null),[S,I]=m.useState(null),[C,N]=m.useState(!0),[k,x]=m.useState(!1),[y,R]=m.useState(null),[A,$]=m.useState(null),[_,H]=m.useState(null),oe={untested:"No evidence — automation has no rule for this criterion",inconclusive:"Inconclusive — axe / AI ran but couldn't determine",failing:"Failing — at least one fail signal across the audit"};m.useEffect(()=>{let D=!1;return(async()=>{if(!r){D||N(!1);return}try{const Z=(await as([r])).find(j=>j.criterionId===t);if(D)return;I(Z?{verdict:Z.verdict,note:Z.note,verifiedAt:Z.verifiedAt}:null)}catch{D||I(null)}finally{D||N(!1)}})(),()=>{D=!0}},[t,r]);async function G(){if(r){f(!0),w(null);try{await qn(r,t),I(null),d()}catch(D){w(D instanceof Error?D.message:String(D))}finally{f(!1)}}}const W=ac.get(t),E=W==null?void 0:W.shortDescription,U=W==null?void 0:W.understandingSlug,M=zl(t);async function P(){if(!i.current){$("Set an Anthropic API key in extension Options first.");return}x(!0),$(null);try{const Y=`Explain WCAG ${t} (${s}) in the context of this audit. State: ${a==="untested"?"no automated evidence (no axe rule covers it)":a==="inconclusive"?"inconclusive — axe or AI ran but could not produce a definitive pass/fail":"failing — at least one fail signal across the audit"}. Cover: (1) what the criterion actually requires in plain language, (2) common failure modes a developer should look for, (3) how to manually verify it on this site, (4) when to mark N/A vs Pass vs Fail. Keep it tight — 5–8 sentences total.`,Z=await tn({apiKey:i.current,model:o,messages:[{role:"user",content:Y}],system:`You are wcagcheckr's WCAG explainer. The user is sitting in front of a forensic-grade audit tool and needs to record a manual verdict on a criterion the automation can't decide. Be precise. No marketing tone. When citing a verification step, name the exact device/browser/devtool action (e.g., "Resize Chrome devtools to 320 CSS px").`,maxTokens:600,maxCostUsd:.05});R(Z.text),H(Z.costUsd)}catch(D){$(D instanceof Error?D.message:String(D))}finally{x(!1)}}async function T(D){if(!r){w("No componentId available — re-run an audit first.");return}if(!u.trim()){w("Note is required — describe what you checked and why this verdict applies.");return}f(!0),w(null);const Y=new Date().toISOString(),Z=u.trim();try{await Qn({componentId:r,criterionId:t,verdict:D,note:Z,verifiedAt:Y}),I({verdict:D,note:Z,verifiedAt:Y}),c(null),h(""),d()}catch(j){w(j instanceof Error?j.message:String(j))}finally{f(!1)}}if(S){const Y={pass:{bg:"rgba(15, 143, 94, 0.08)",border:"var(--v2-verified)",ink:"var(--v2-verified)",label:"Pass"},na:{bg:"rgba(100, 116, 139, 0.10)",border:"var(--v2-border-strong)",ink:"var(--v2-ink-secondary)",label:"N/A"},fail:{bg:"rgba(207, 44, 44, 0.06)",border:"var(--v2-critical)",ink:"var(--v2-critical)",label:"Fail"}}[S.verdict];return e.jsxs("div",{role:"status",style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:Y.bg,border:`1px solid ${Y.border}`,borderRadius:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:11,fontWeight:600,color:"var(--v2-ink-tertiary)"},children:["WCAG ",t]}),e.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:s}),e.jsxs("span",{className:"v2-mono",style:{fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",padding:"2px 6px",borderRadius:3,color:"var(--v2-bg)",background:Y.ink},children:["✓ ",Y.label]})]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.5,whiteSpace:"pre-wrap"},children:S.note}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-3)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:10,color:"var(--v2-ink-tertiary)"},children:["verified ",oc(S.verifiedAt)]}),e.jsx("button",{type:"button",onClick:G,disabled:g,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:g?"wait":"pointer",fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:g?"Un-marking…":"Un-mark this criterion"}),v&&e.jsx("span",{role:"alert",style:{fontSize:11,color:"var(--v2-critical)"},children:v})]})]})}return C?e.jsx("div",{"aria-hidden":"true",style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4,minHeight:56}}):e.jsxs("div",{style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:11,fontWeight:600,color:"var(--v2-ink-tertiary)"},children:["WCAG ",t]}),e.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:s}),!l&&ot(t)&&e.jsx("span",{title:`AI would add: ${(ee=ot(t))==null?void 0:ee.whatAiAdds}. Add an API key in Settings → AI to enable.`,style:{fontSize:10,fontWeight:600,padding:"1px 6px",borderRadius:3,background:"var(--v2-bg-elev)",color:"var(--v2-ink-tertiary)",border:"1px solid var(--v2-border)",letterSpacing:"0.02em"},children:"AI skipped"})]}),E&&e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.5},children:E}),!l&&ot(t)&&e.jsxs("p",{style:{margin:"4px 0 0",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5,fontStyle:"italic"},children:["AI would judge: ",(X=ot(t))==null?void 0:X.whatAiAdds]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:oe[a]}),M&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-2)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,fontSize:10},children:"how to check"}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.5},children:M.howToCheck})]}),n.length>0&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)"},children:[e.jsxs("p",{className:"v2-eyebrow",style:{margin:0,fontSize:10},children:["suspect locations · ",n.length]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:"4px 0 0",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:n.map((D,Y)=>e.jsx(dc,{ev:D},`${D.pageUrl}::${D.selector??""}::${Y}`))})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-3)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap",alignItems:"center"},children:[U&&e.jsx("a",{href:sc(U),target:"_blank",rel:"noreferrer noopener",style:{fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:"Read W3C guidance ↗"}),l&&e.jsx("button",{type:"button",onClick:P,disabled:k,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:k?"wait":"pointer",fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:k?"Explaining…":y?"Re-explain with AI":"Explain with AI ↗"})]}),(y||A)&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-2)",padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:4},children:[y&&e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.55,whiteSpace:"pre-wrap"},children:y}),A&&e.jsx("p",{role:"alert",style:{margin:0,fontSize:11,color:"var(--v2-critical)"},children:A}),_!==null&&e.jsxs("p",{className:"v2-mono",style:{margin:"4px 0 0",fontSize:10,color:"var(--v2-ink-tertiary)"},children:["$",_.toFixed(4)," · ",o]})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",marginTop:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{c(p==="pass"?null:"pass"),w(null)},"aria-expanded":p==="pass",children:p==="pass"?"Cancel":"Mark Pass"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{c(p==="na"?null:"na"),w(null)},"aria-expanded":p==="na",children:p==="na"?"Cancel":"Mark N/A"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{c(p==="fail"?null:"fail"),w(null)},"aria-expanded":p==="fail",children:p==="fail"?"Cancel":"Mark Fail"})]}),p&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0},children:"verification note · required"}),e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:p==="na"?'Describe why this criterion does not apply to this audit (e.g., "no audio/video content on this page").':p==="pass"?'Describe what you checked to verify pass (e.g., "manually browsed page in keyboard-only mode, no focus traps").':'Describe the failure (e.g., "modal does not return focus to the trigger when closed").'}),e.jsx("textarea",{value:u,onChange:D=>h(D.target.value),rows:3,style:{width:"100%",fontFamily:"var(--v2-body)",fontSize:12,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",color:"var(--v2-ink-primary)",border:"1px solid var(--v2-border-strong)",borderRadius:4,resize:"vertical",minHeight:56},placeholder:p==="na"?"e.g., No audio or video content present on this page; criterion is not applicable.":p==="pass"?"e.g., Manually verified — page resizes correctly at 200% zoom without horizontal scroll.":"e.g., Focus visible indicator missing on dark-mode buttons."}),v&&e.jsx("p",{role:"alert",style:{margin:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"rgba(207, 44, 44, 0.06)",border:"1px solid var(--v2-critical)",borderRadius:4,color:"var(--v2-critical)",fontSize:11},children:v}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>T(p),disabled:g||!u.trim(),children:g?"Saving…":`Confirm ${p.toUpperCase()}`})})]})]})}function dc({ev:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(null);async function i(){a(!0),r(null);try{const l=await nc({pageUrl:t.pageUrl,selector:t.selector});l.ok?t.selector?l.found?r({kind:"ok",text:`Element highlighted (${l.matchCount} match${l.matchCount===1?"":"es"}).`}):r({kind:"warn",text:"Page opened but the selector matched zero elements — DOM may have changed since the audit."}):r({kind:"ok",text:`Opened ${oa(t.pageUrl)} — no element selector available; verify manually.`}):r({kind:"err",text:l.error})}finally{a(!1)}}return e.jsxs("li",{style:{padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4,display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-2)",flexWrap:"wrap"},children:[e.jsx("span",{className:"v2-mono",title:t.pageUrl,style:{fontSize:11,color:"var(--v2-ink-secondary)",overflowWrap:"anywhere"},children:oa(t.pageUrl)}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:i,disabled:s,children:s?"Opening…":t.selector?"Show on page":"Open page"})]}),t.selector&&e.jsx("span",{className:"v2-mono",title:t.selector,style:{fontSize:11,color:"var(--v2-ink-tertiary)",overflowWrap:"anywhere"},children:ic(t.selector)}),t.notes&&e.jsx("span",{style:{fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:t.notes}),n&&e.jsx("span",{role:n.kind==="err"?"alert":"status",style:{fontSize:11,color:n.kind==="err"?"var(--v2-critical)":n.kind==="warn"?"var(--v2-needs-review)":"var(--v2-verified)"},children:n.text})]})}const ft="wcagcheckr";function le(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Xe(t){try{const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1,timeZoneName:"short"})}catch{return t}}function uc(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function pc(t){if(t.length===0)return null;const s=[...t].sort((a,n)=>a.capturedAt.localeCompare(n.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function hc(t){const s=new Map;for(const a of t){const n=s.get(a.componentId);n?(n.entries.push(a),a.receipt&&n.anchoredCount++,a.capturedAt>n.latest.capturedAt&&(n.latest=a,n.pageUrl=a.pageUrl)):s.set(a.componentId,{componentId:a.componentId,pageUrl:a.pageUrl,entries:[a],latest:a,anchoredCount:a.receipt?1:0})}for(const a of s.values())a.entries.sort((n,r)=>r.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function mc(t){switch(t){case"A":return"grade-a";case"B":return"grade-b";case"C":return"grade-c";case"D":return"grade-d";case"F":return"grade-f"}}function xc(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${le(t.receipt.tsaName)}) — anchored ${le(Xe(t.receipt.anchoredAt))}</td></tr>
36
+ <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${le(t.receipt.serverKeyFingerprint)}</code></td></tr>
37
+ ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${le(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${le(ft)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
38
+ <article class="entry">
39
+ <header class="entry-header">
40
+ <span class="grade-badge ${mc(t.grade)}">${le(t.grade)}</span>
41
+ <div class="entry-headline">
42
+ <div class="entry-time">${le(Xe(t.capturedAt))}</div>
43
+ <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
44
+ </div>
45
+ </header>
46
+ <table class="entry-fields">
47
+ <tr><th>Audit identity hash</th><td><code class="hash">${le(t.hash)}</code></td></tr>
48
+ <tr><th>Page URL</th><td><code>${le(t.pageUrl)}</code></td></tr>
49
+ <tr><th>Scope</th><td><code>${le(t.scope)}</code></td></tr>
50
+ <tr><th>axe-core version</th><td>${le(t.axeVersion)}</td></tr>
51
+ <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
52
+ ${n}
53
+ </table>
54
+ </article>`}function gc(t){return`
55
+ <section class="component-section">
56
+ <h2>
57
+ <span class="component-id">${le(t.componentId)}</span>
58
+ <span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
59
+ </h2>
60
+ <p class="component-url"><strong>Page audited:</strong> <code>${le(t.pageUrl)}</code></p>
61
+ ${t.entries.map(xc).join("")}
62
+ </section>`}function sn(t){const{entries:s,extensionVersion:a}=t,n=hc(s),r=pc(s),i=(t.axeVersions??uc(s)).join(", "),l=s.length,o=s.filter(c=>c.receipt).length,d=l-o,p=Xe(new Date().toISOString());return wa(`<!doctype html>
63
+ <html lang="en">
64
+ <head>
65
+ <meta charset="utf-8" />
66
+ <title>Pre-litigation accessibility audit report — ${le(t.matterReference??p)}</title>
67
+ <style>
68
+ *, *::before, *::after { box-sizing: border-box; }
69
+ :root {
70
+ --ink: #0f172a;
71
+ --muted: #475569;
72
+ --rule: #cbd5e1;
73
+ --hairline: #e2e8f0;
74
+ --accent: #1e293b;
75
+ --crit: #b91c1c;
76
+ --serious: #c2410c;
77
+ --mod: #b45309;
78
+ --minor: #1e40af;
79
+ --clean: #15803d;
80
+ }
81
+ html, body { background: #fff; }
82
+ body {
83
+ font: 11pt/1.55 "Charter", "Iowan Old Style", Georgia, serif;
84
+ color: var(--ink);
85
+ max-width: 7.25in;
86
+ margin: 0.6in auto;
87
+ padding: 0 0.3in;
88
+ }
89
+ h1 { font-size: 26pt; margin: 0 0 6pt; letter-spacing: -0.01em; }
90
+ h2 {
91
+ font-size: 14pt; margin: 28pt 0 10pt; padding-bottom: 6pt;
92
+ border-bottom: 1px solid var(--rule);
93
+ display: flex; justify-content: space-between; align-items: baseline; gap: 10pt;
94
+ }
95
+ h2 .component-stats { font-size: 10pt; color: var(--muted); font-weight: 400; }
96
+ .cover {
97
+ border-top: 3px solid var(--accent);
98
+ border-bottom: 1px solid var(--rule);
99
+ padding: 18pt 0 14pt;
100
+ margin-bottom: 24pt;
101
+ }
102
+ .eyebrow {
103
+ font-size: 9pt; letter-spacing: 0.08em; text-transform: uppercase;
104
+ color: var(--muted); font-family: "Helvetica Neue", Arial, sans-serif;
105
+ margin: 0 0 4pt;
106
+ }
107
+ .cover-meta { font-size: 10.5pt; color: var(--muted); margin-top: 12pt; }
108
+ .cover-meta dt {
109
+ font-size: 9pt; letter-spacing: 0.06em; text-transform: uppercase;
110
+ color: var(--muted); font-family: "Helvetica Neue", Arial, sans-serif;
111
+ margin-top: 8pt;
112
+ }
113
+ .cover-meta dd { margin: 2pt 0 0; color: var(--ink); }
114
+ .attestation {
115
+ margin: 18pt 0 24pt; padding: 14pt 16pt;
116
+ background: #f8fafc; border-left: 4px solid var(--accent);
117
+ font-size: 10.5pt; page-break-inside: avoid;
118
+ }
119
+ .attestation h3 { font-size: 11pt; margin: 0 0 6pt; letter-spacing: 0.04em; text-transform: uppercase; }
120
+ .summary-table {
121
+ width: 100%; border-collapse: collapse; margin: 12pt 0 24pt;
122
+ font-size: 11pt; page-break-inside: avoid;
123
+ }
124
+ .summary-table th, .summary-table td {
125
+ text-align: left; padding: 6pt 10pt; border-bottom: 1px solid var(--hairline);
126
+ }
127
+ .summary-table th { font-weight: 600; color: var(--muted); width: 38%; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 10pt; text-transform: uppercase; letter-spacing: 0.04em; }
128
+ .component-section { margin-bottom: 8pt; page-break-inside: auto; }
129
+ .component-id { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13pt; }
130
+ .component-url { font-size: 10pt; color: var(--muted); margin: 0 0 10pt; word-break: break-all; }
131
+ .entry {
132
+ border: 1px solid var(--hairline);
133
+ border-radius: 2pt;
134
+ padding: 10pt 12pt;
135
+ margin: 6pt 0 10pt;
136
+ page-break-inside: avoid;
137
+ }
138
+ .entry-header { display: flex; align-items: center; gap: 12pt; margin-bottom: 8pt; }
139
+ .grade-badge {
140
+ width: 28pt; height: 28pt; border-radius: 4pt;
141
+ display: inline-flex; align-items: center; justify-content: center;
142
+ font-family: "Helvetica Neue", Arial, sans-serif;
143
+ font-weight: 700; font-size: 14pt;
144
+ }
145
+ .grade-badge.grade-a { background: #dcfce7; color: #166534; }
146
+ .grade-badge.grade-b { background: #ecfccb; color: #4d7c0f; }
147
+ .grade-badge.grade-c { background: #fef9c3; color: #a16207; }
148
+ .grade-badge.grade-d { background: #fed7aa; color: #c2410c; }
149
+ .grade-badge.grade-f { background: #fecaca; color: #b91c1c; }
150
+ .entry-headline { display: flex; flex-direction: column; gap: 2pt; }
151
+ .entry-time { font-weight: 600; font-size: 11pt; }
152
+ .entry-states { font-size: 9.5pt; color: var(--muted); }
153
+ table.entry-fields { width: 100%; border-collapse: collapse; font-size: 10pt; }
154
+ table.entry-fields th, table.entry-fields td {
155
+ text-align: left; vertical-align: top; padding: 3pt 6pt;
156
+ }
157
+ table.entry-fields th {
158
+ width: 32%; color: var(--muted); font-weight: 600;
159
+ font-family: "Helvetica Neue", Arial, sans-serif; font-size: 9pt;
160
+ text-transform: uppercase; letter-spacing: 0.04em;
161
+ }
162
+ table.entry-fields td.local-only { color: var(--muted); font-style: italic; }
163
+ code, .hash {
164
+ font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 9.5pt;
165
+ background: #f1f5f9; padding: 1pt 3pt; border-radius: 2pt;
166
+ }
167
+ .hash { word-break: break-all; }
168
+ .sev-row span { margin-right: 8pt; font-weight: 600; }
169
+ .sev-crit { color: var(--crit); }
170
+ .sev-serious { color: var(--serious); }
171
+ .sev-mod { color: var(--mod); }
172
+ .sev-minor { color: var(--minor); }
173
+ .sev-clean { color: var(--clean); font-style: italic; font-weight: 400; }
174
+ .methodology {
175
+ margin: 28pt 0 16pt; padding-top: 12pt; border-top: 1px solid var(--rule);
176
+ font-size: 10.5pt; page-break-before: auto; page-break-inside: avoid;
177
+ }
178
+ .methodology h2 { border-bottom: none; padding-bottom: 0; margin-top: 0; }
179
+ .methodology ul { padding-left: 18pt; }
180
+ .methodology li { margin: 4pt 0; }
181
+ .verification {
182
+ margin: 18pt 0; padding: 12pt 16pt;
183
+ background: #f8fafc; border-radius: 3pt;
184
+ font-size: 10pt; page-break-inside: avoid;
185
+ }
186
+ .verification h3 { font-size: 10.5pt; margin: 0 0 6pt; }
187
+ .verification ol { padding-left: 18pt; margin: 0; }
188
+ .verification li { margin: 3pt 0; }
189
+ footer {
190
+ margin-top: 28pt; padding-top: 10pt; border-top: 1px solid var(--rule);
191
+ font-size: 8.5pt; color: var(--muted);
192
+ display: flex; justify-content: space-between; gap: 12pt;
193
+ }
194
+ @media print {
195
+ body { margin: 0; max-width: none; }
196
+ h2 { page-break-after: avoid; }
197
+ .entry, .attestation, .verification, .methodology { break-inside: avoid; }
198
+ .component-section { break-inside: auto; }
199
+ }
200
+ </style>
201
+ </head>
202
+ <body>
203
+ <section class="cover">
204
+ <p class="eyebrow">Accessibility audit — pre-litigation report</p>
205
+ <h1>Audit history &amp; chain-of-custody</h1>
206
+ <dl class="cover-meta">
207
+ ${t.matterReference?`<dt>Matter reference</dt><dd>${le(t.matterReference)}</dd>`:""}
208
+ ${t.preparedBy?`<dt>Prepared by</dt><dd>${le(t.preparedBy)}</dd>`:""}
209
+ ${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${le(t.jurisdiction)}</dd>`:""}
210
+ <dt>Report generated</dt><dd>${le(p)}</dd>
211
+ <dt>Audit period</dt><dd>${r?`${le(Xe(r.earliest))} — ${le(Xe(r.latest))}`:"No audits recorded"}</dd>
212
+ </dl>
213
+ </section>
214
+
215
+ <aside class="attestation">
216
+ <h3>Attestation</h3>
217
+ <p>The audit records summarized below were captured by the <strong>${le(ft)}</strong> Chrome extension, version <strong>${le(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${le(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
218
+ <p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
219
+ <p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
220
+ </aside>
221
+
222
+ <table class="summary-table">
223
+ <tr><th>Total audits recorded</th><td>${l}</td></tr>
224
+ <tr><th>RFC 3161-anchored audits</th><td>${o}</td></tr>
225
+ <tr><th>Local-only audits</th><td>${d}</td></tr>
226
+ <tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
227
+ <tr><th>axe-core version(s) observed</th><td>${le(i||"n/a")}</td></tr>
228
+ <tr><th>Tool</th><td>${le(ft)} ${le(a)}</td></tr>
229
+ </table>
230
+
231
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(gc).join("")}
232
+
233
+ <section class="methodology">
234
+ <h2>Methodology</h2>
235
+ <p>Each audit drives the target component through the full WCAG-relevant rendering-state matrix (pseudo-classes <code>:hover</code>, <code>:focus</code>, <code>:focus-visible</code>, <code>:active</code>, <code>:disabled</code>; ARIA state permutations; light / dark / forced-colors themes; LTR / RTL writing direction; multiple viewport breakpoints) via the Chrome DevTools Protocol, runs axe-core's rule engine at each state, and aggregates results into a per-component scorecard with sub-grades for the nine accessibility areas: contrast, keyboard, focus, semantics, names &amp; labels, language &amp; reading, structure, navigation, and media.</p>
236
+ <ul>
237
+ <li><strong>Hash algorithm:</strong> SHA-256 over a canonical JSON serialization of audit identity fields (object keys sorted alphabetically, no whitespace, JSON-escaped strings per RFC 8259).</li>
238
+ <li><strong>Trusted timestamping:</strong> RFC 3161 TimeStampTokens obtained from FreeTSA (freetsa.org). Tokens are verifiable against FreeTSA's published certificate.</li>
239
+ <li><strong>Server signature:</strong> ed25519 signature over the concatenation of the audit hash, anchor time (ISO-8601), TSA name, product slug, and (on chain-receipt v2 entries) the previous anchor's hash. Verifiable offline against the published server public key (fingerprint per receipt).</li>
240
+ <li><strong>Anchor chain:</strong> v2 receipts include the preceding anchor's hash for the same product, forming a tamper-evident chain. Removing or altering any historical anchor breaks the signature on every subsequent anchor.</li>
241
+ </ul>
242
+ </section>
243
+
244
+ <section class="verification">
245
+ <h3>Verifying this report</h3>
246
+ <ol>
247
+ <li>For any audit, recompute the SHA-256 hash from the listed identity fields (component, page URL, scope, grade, severity totals, axe-core version, capture timestamp, state count). It must equal the listed audit identity hash.</li>
248
+ <li>For RFC 3161-anchored audits, extract the embedded TimeStampToken from the receipt and verify it against the TSA's published certificate. The token's hashed-message must equal the listed audit identity hash.</li>
249
+ <li>For RFC 3161-anchored audits, fetch the server public key matching the listed fingerprint from <code>https://api.wcagcheckr.com/v1/forensic/public-key</code>. Verify the ed25519 signature over the canonical anchor payload.</li>
250
+ <li>For v2 chain receipts, verify that the listed chain predecessor equals the audit identity hash of the immediately preceding anchored audit for the same product.</li>
251
+ </ol>
252
+ </section>
253
+
254
+ <footer>
255
+ <span>Generated ${le(p)} by ${le(ft)} ${le(a)}</span>
256
+ <span>${l} audit${l===1?"":"s"} · ${o} anchored · ${n.length} component${n.length===1?"":"s"}</span>
257
+ </footer>
258
+ </body>
259
+ </html>`)}async function gs(t){const s=await Ea();if(!we(s,"exportPreLitigationReport"))return;const a=sn(t),n=new Blob([a],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n);await chrome.tabs.create({url:r})}const fc=Object.freeze(Object.defineProperty({__proto__:null,buildPreLitigationReportHtml:sn,openPreLitigationReport:gs},Symbol.toStringTag,{value:"Module"})),la={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},ca={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},bc={A:"bg-emerald-600",B:"bg-lime-600",C:"bg-amber-500",D:"bg-orange-600",F:"bg-rose-600"},vc={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function an({onBack:t,simplified:s=!1}){const a=b(j=>j.siteCrawlStatus),n=b(j=>j.siteCrawlProgress),r=b(j=>j.siteCrawlReport),i=b(j=>j.siteCrawlError),l=b(j=>j.crawlDiscoveryStatus),o=b(j=>j.crawlDiscoveryUrls),d=b(j=>j.crawlDiscoveryFound),p=b(j=>j.crawlDiscoveryLastUrl),[c,u]=m.useState(!0);m.useEffect(()=>{Q({type:"SETTINGS_GET",key:"crawlReviewEnabled"}).then(j=>{const V=j.data;typeof V=="boolean"&&u(V)})},[]);function h(j){u(j),Q({type:"SETTINGS_SET",key:"crawlReviewEnabled",value:j})}const[g,f]=m.useState(new Set);m.useEffect(()=>{l==="reviewing"&&f(new Set(o))},[l,o]);const[v,w]=m.useState("");m.useEffect(()=>{r!=null&&r.startUrl&&v===""&&w(r.startUrl)},[r==null?void 0:r.startUrl]);const[S,I]=m.useState(25),[C,N]=m.useState(Me),[k,x]=m.useState(Me[0].id);m.useEffect(()=>{Promise.all([Q({type:"SETTINGS_GET",key:"matrixPresets"}),Q({type:"SETTINGS_GET",key:"activePresetId"})]).then(([j,V])=>{const K=Array.isArray(j.data)?j.data:null;N(K&&K.length>0?K:Me),typeof V.data=="string"&&x(V.data)})},[]);function y(j){const V=C.find(K=>K.id===j);V&&(x(j),Q({type:"SETTINGS_SET",key:"activePresetId",value:j}),Q({type:"SETTINGS_SET",key:"stateMatrix",value:V.matrix}))}const[R,A]=m.useState("quick");m.useEffect(()=>{s&&Q({type:"SETTINGS_SET",key:"stateMatrix",value:$t(R)})},[s,R]);const[$,_]=m.useState(""),[H,oe]=m.useState(""),[G,W]=m.useState(!0);m.useEffect(()=>{Q({type:"SETTINGS_GET",key:"crawlRememberSettings"}).then(async j=>{const V=j.data!==!1;if(W(V),!V)return;const[K,te,de]=await Promise.all([Q({type:"SETTINGS_GET",key:"crawlMaxPages"}),Q({type:"SETTINGS_GET",key:"crawlIncludeRegex"}),Q({type:"SETTINGS_GET",key:"crawlExcludeRegex"})]),L=K.data;typeof L=="number"&&L>=1&&I(Math.min(200,L));const z=te.data,O=de.data;typeof z=="string"&&z&&_(z),typeof O=="string"&&O&&oe(O)})},[]);function E(j){I(j),G&&Q({type:"SETTINGS_SET",key:"crawlMaxPages",value:j})}function U(j){_(j),G&&Q({type:"SETTINGS_SET",key:"crawlIncludeRegex",value:j})}function M(j){oe(j),G&&Q({type:"SETTINGS_SET",key:"crawlExcludeRegex",value:j})}function P(j){W(j),Q({type:"SETTINGS_SET",key:"crawlRememberSettings",value:j}),j&&(Q({type:"SETTINGS_SET",key:"crawlMaxPages",value:S}),Q({type:"SETTINGS_SET",key:"crawlIncludeRegex",value:$.trim()}),Q({type:"SETTINGS_SET",key:"crawlExcludeRegex",value:H.trim()}))}v===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(j=>{var K;const V=(K=j[0])==null?void 0:K.url;V&&/^https?:\/\//.test(V)&&v===""&&w(V)});function T(){const j=$.trim(),V=H.trim();for(const[K,te]of[["Include",j],["Exclude",V]])if(te)try{new RegExp(te)}catch(de){return window.alert(`${K} regex is invalid:
260
+
261
+ ${de instanceof Error?de.message:String(de)}
262
+
263
+ Fix or clear the field and try again.`),null}return{include:j,exclude:V}}function ee(j,V){return j<5?!0:window.confirm(V?`Verify-fixes mode: ${j} crawled pages, but walkthroughs that already passed or were human-acked will be skipped. Estimated wall-clock: ~${Math.ceil(j*2.5)} minutes (vs. ${j*5} for a full re-crawl). Proceed?`:`Each of the ${j} pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this to take roughly ${j*5} minutes. Proceed?`)}function X(j=!1){if(!v)return;const V=T();if(V){if(c&&!j){b.getState().setSiteCrawlError(null),b.getState().setCrawlDiscoveryStatus("discovering"),Br({type:"START_CRAWL_DISCOVERY",startUrl:v,maxPages:S,...V.include?{includeRegex:V.include}:{},...V.exclude?{excludeRegex:V.exclude}:{}});return}ee(S,j)&&(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),je({type:"START_SITE_CRAWL",startUrl:v,maxPages:S,...V.include?{includeRegex:V.include}:{},...V.exclude?{excludeRegex:V.exclude}:{},...j?{verifyFixesOnly:!0}:{}}))}}function D(){const j=o.filter(V=>g.has(V));if(j.length===0){window.alert("Keep at least one page to audit.");return}ee(j.length,!1)&&(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),b.getState().resetCrawlDiscovery(),je({type:"START_SITE_CRAWL",startUrl:v,urls:j}))}function Y(){Q({type:"CANCEL_CRAWL_DISCOVERY"}),b.getState().resetCrawlDiscovery()}function Z(){Q({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[a==="complete"&&r&&e.jsx(yc,{report:r,simplified:s}),a==="complete"&&r&&!s&&e.jsxs(e.Fragment,{children:[e.jsx(lc,{}),e.jsx(Wl,{})]}),t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),e.jsxs("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Heads-up if you're logged in."})," ","The crawler follows whatever links appear in the rendered page — so if you're authenticated to the target site, it will walk into the authenticated nav (admin pages, dashboards, account pages) and try to audit them. Some of those may 404 or behave unexpectedly without specific context. For a clean public-site crawl, log out first or run from an incognito window."]}),a!=="running"&&l==="idle"&&e.jsx("div",{className:"border border-slate-200 bg-slate-50 rounded px-2.5 py-2 space-y-1.5",children:s?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-[11px] font-semibold text-slate-700",children:"Scan depth"}),e.jsx(Ja,{depth:R,onChange:A,disabled:!1}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:"Same depth options as a single-page scan, so a page grades the same whether you scan it alone or as part of the whole site. Every crawled page is checked at this depth."})]}):e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"crawl-preset",className:"block text-[11px] font-semibold text-slate-700",children:"Audit depth (state-matrix preset)"}),e.jsx("select",{id:"crawl-preset",value:k,onChange:j=>y(j.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5",title:"Each crawled page runs this preset's state matrix. Full = pseudo-states × themes × directions × breakpoints (slowest, most thorough). Quick = single state (fastest). Set this once and every page in the crawl uses it.",children:C.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug",children:["Each crawled page runs the same single-page audit pipeline you see on the Dashboard. This selector overrides the persisted preset for BOTH surfaces. AI walkthroughs + disabled-rules list are still in ",e.jsx("strong",{children:"Settings → AI"})," and ",e.jsx("strong",{children:"Settings → State Matrix"}),"."]})]})}),a!=="running"&&l==="idle"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:v,onChange:j=>w(j.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:S,onChange:j=>E(Math.min(200,Math.max(1,parseInt(j.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your configured single-page pipeline — see Settings → State Matrix for what that means."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-include",className:"block text-[11px] text-slate-500 mb-1",children:"Include only URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-include",type:"text",value:$,onChange:j=>U(j.target.value),placeholder:"^https://example\\.com/products/",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["When set, only URLs matching this regex get crawled. Useful for scoping a crawl to one section, e.g. ",e.jsx("code",{children:"/blog/"}),"."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-exclude",className:"block text-[11px] text-slate-500 mb-1",children:"Exclude URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-exclude",type:"text",value:H,onChange:j=>M(j.target.value),placeholder:"/admin|/dashboard|/account|/login",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"URLs matching this regex are skipped. Helpful when logged in to the target site — keep the crawl on the public surface."})]}),e.jsxs("label",{className:"flex items-start gap-2 text-[11px] text-slate-700 bg-slate-50 border border-slate-200 rounded px-2.5 py-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:G,onChange:j=>P(j.target.checked),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Remember these settings."})," Keep max pages + the include/exclude filters for next time (the audit-depth preset is always remembered)."]})]}),e.jsxs("label",{className:"flex items-start gap-2 text-[11px] text-slate-700 bg-slate-50 border border-slate-200 rounded px-2.5 py-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:j=>h(j.target.checked),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Review pages before auditing."})," First list every page that would be crawled, then let me remove any I don't want before the audit runs. Turn off to start auditing immediately (pages are discovered as it goes)."]})]}),e.jsx("button",{type:"button",onClick:()=>X(!1),disabled:!v,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:c?"Find pages to audit":"Start whole-site audit"}),(()=>{const j=r&&r.startUrl===v,V=!v||!j;return e.jsxs("button",{type:"button",onClick:()=>X(!0),disabled:V,className:"w-full text-sm px-4 py-2.5 border border-emerald-400 text-emerald-700 bg-white rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed font-medium",title:v?j?"Re-crawl after fixes/acks. Walkthroughs that previously passed or were human-acked are skipped per page — saves AI calls + wall-clock without changing axe coverage.":"Run a full crawl on this URL first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.":"Enter a start URL first.",children:["Verify fixes only (skip passed walkthroughs)",!j&&v&&e.jsx("span",{className:"block text-[10px] text-emerald-600 font-normal mt-0.5",children:"Run a full crawl first to enable this."})]})})()]}),l==="discovering"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Finding pages…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-1.5",children:[e.jsxs("p",{className:"text-xs",children:[e.jsx("strong",{children:d})," page",d===1?"":"s"," found so far"]}),p&&e.jsx("p",{className:"text-[11px] font-mono break-all text-slate-600",children:p}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:"Loading each page to read its links — no audit yet. You'll get to prune the list before anything is audited."})]}),e.jsx("button",{type:"button",onClick:Y,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),l==="reviewing"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Review pages to audit"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Found ",e.jsx("strong",{children:o.length})," page",o.length===1?"":"s",". Uncheck any you don't want, then audit the rest. ",e.jsx("strong",{children:g.size})," selected."]}),o.length===0?e.jsx("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900",children:"No pages were discovered from this URL. Check the start URL and any include/exclude filters, then try again."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(new Set(o)),className:"text-[11px] text-brand-600 hover:underline",children:"Select all"}),e.jsx("span",{className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:()=>f(new Set),className:"text-[11px] text-brand-600 hover:underline",children:"Select none"})]}),e.jsx("ul",{className:"border border-slate-200 rounded max-h-72 overflow-y-auto divide-y divide-slate-100 bg-white",children:o.map(j=>e.jsx("li",{children:e.jsxs("label",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11px] cursor-pointer hover:bg-slate-50",children:[e.jsx("input",{type:"checkbox",checked:g.has(j),onChange:V=>{f(K=>{const te=new Set(K);return V.target.checked?te.add(j):te.delete(j),te})},className:"mt-0.5"}),e.jsx("span",{className:"font-mono break-all text-slate-700",children:j})]})},j))})]}),e.jsxs("button",{type:"button",onClick:D,disabled:g.size===0,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:["Audit ",g.size," page",g.size===1?"":"s"]}),e.jsx("button",{type:"button",onClick:Y,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel — back to crawl settings"})]}),a==="running"&&n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:n.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${n.current/Math.max(1,n.total)*100}%`},role:"progressbar","aria-valuenow":n.current,"aria-valuemin":0,"aria-valuemax":n.total,"aria-label":`Page ${n.current} of ${n.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",n.current," of ",n.total,n.lastViolations!==void 0&&` · last had ${n.lastViolations} issue${n.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:Z,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),a==="failed"&&i&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",i]})]})}function yc({report:t,simplified:s=!1}){const a=Xa(t),n=(a==null?void 0:a.site)??null,r=s&&n&&a?{letter:n.letter,tier:n.tier,headline:n.headline,perUrlLetter:a.perUrlLetter}:void 0;function i(){ve(async()=>{const{renderSiteReportHtml:E}=await import("./site-report-renderer-C3U9cFY3.js");return{renderSiteReportHtml:E}},__vite__mapDeps([6,0,1,2,3,4])).then(({renderSiteReportHtml:E})=>{const U=E(t,r);De(U)})}const[l,o]=m.useState(!1),[d,p]=m.useState({state:"idle"});async function c(){if(window.confirm(`Save the current crawl as the site baseline?
264
+
265
+ Each of the ${t.pagesAudited} crawled page${t.pagesAudited===1?"":"s"} will be saved as its own baseline. Future audits + re-crawls will show delta against these snapshots. Any existing baselines for these same components will be overwritten.`)){p({state:"running",current:0,total:t.pagesAudited});try{const M=(await ie({type:"SETTINGS_GET",key:"stateMatrix"})).data??rs,P=await Ze();if(!P||P.length===0){p({state:"error",message:"No per-URL results found in storage. Re-run the crawl."});return}let T=0,ee=0;for(let X=0;X<P.length;X++){const D=P[X];if(p({state:"running",current:X,total:P.length}),D.error||D.results.length===0||!D.componentId){ee++;continue}try{const Y=D.results.flatMap(K=>K.violations),Z=D.results.flatMap(K=>K.announcements??[]),j=D.results.flatMap(K=>K.focusEvents??[]),V=D.results[0];await Q({type:"BASELINE_SET",componentId:D.componentId,violations:Y,announcements:Z,focusEvents:j,snapshotMeta:{url:D.url,axeVersion:V.axeVersion,matrixConfig:M,capturedAt:new Date().toISOString()}}),T++}catch(Y){console.warn("[site-crawl-panel] BASELINE_SET failed for",D.url,Y),ee++}}try{const X=await ie({type:"BASELINE_LIST"});b.getState().setBaselineList(X.items)}catch{}p({state:"done",saved:T,failed:ee})}catch(U){p({state:"error",message:U instanceof Error?U.message:String(U)})}}}const[u,h]=m.useState(null),[g,f]=m.useState(null),[v,w]=m.useState(!1),[S,I]=m.useState(!1),C=b(E=>E.tier),N=we(C,"exportPreLitigationReport"),[k,x]=m.useState(!1),y=()=>x(!0),R=(E,U)=>{const M=Le(C,E);return{busy:u===E,disabled:u!==null,locked:!M,onClick:M?()=>{G(E,U)}:y}};async function A(){f(null);try{const E=await Ze();if(!E||E.length===0){f("No per-URL results found. Re-run the crawl.");return}if(!E.some(M=>{var P;return(((P=M.results)==null?void 0:P.length)??0)>0})){f("Crawled pages have no audit results to use.");return}w(!0)}catch(E){f(E instanceof Error?E.message:String(E))}}const[$,_]=m.useState({state:"idle"});async function H(){var ee,X,D,Y,Z;const{createZip:E}=await ve(async()=>{const{createZip:j}=await import("./zip-encoder-CtULHXx_.js");return{createZip:j}},[]),{renderSiteReportHtml:U}=await ve(async()=>{const{renderSiteReportHtml:j}=await import("./site-report-renderer-C3U9cFY3.js");return{renderSiteReportHtml:j}},__vite__mapDeps([6,0,1,2,3,4])),M=[{format:"defense-bundle",filename:"defense-bundle.html"},{format:"deposition-packet",filename:"deposition-packet.html"},{format:"evidence-bundle",filename:"evidence-bundle.html"},{format:"vpat",filename:"vpat.html"},{format:"conformance-crosswalk",filename:"conformance-crosswalk.html"},{format:"methodology-doc",filename:"methodology-doc.html"},{format:"executive-report",filename:"executive-report.html"}],P=[],T=[];_({state:"running",current:"site-report.html",doneCount:0,totalCount:M.length+3});try{try{const O=U(t,r);T.push({name:"site-report.html",content:O})}catch{P.push("site-report.html")}_(O=>O.state==="running"?{...O,current:"ai-fix-prompt.md",doneCount:O.doneCount+1}:O);try{const O=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]});O!=null&&O.content&&O.content.length>50?T.push({name:"ai-fix-prompt.md",content:O.content}):P.push("ai-fix-prompt.md")}catch{P.push("ai-fix-prompt.md")}for(const{format:O,filename:ne}of M){_(ae=>ae.state==="running"?{...ae,current:ne,doneCount:ae.doneCount+1}:ae);try{const ae=await ie({type:"EXPORT_REQUEST",format:O,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});ae!=null&&ae.content&&ae.content.length>50?T.push({name:ne,content:ae.content}):P.push(ne)}catch(ae){console.warn(`[bulk-export] ${O} failed`,ae),P.push(ne)}}_(O=>O.state==="running"?{...O,current:"pre-litigation-report.html",doneCount:O.doneCount+1}:O);try{const O=await bt();if(O.length>0){const ne=typeof chrome<"u"&&((D=(X=(ee=chrome.runtime)==null?void 0:ee.getManifest)==null?void 0:X.call(ee))==null?void 0:D.version)||"1.0.0",{buildPreLitigationReportHtml:ae}=await ve(async()=>{const{buildPreLitigationReportHtml:q}=await Promise.resolve().then(()=>fc);return{buildPreLitigationReportHtml:q}},void 0),F=ae({entries:O,extensionVersion:ne});T.push({name:"pre-litigation-report.html",content:F})}else P.push("pre-litigation-report.html (no forensic entries yet)")}catch{P.push("pre-litigation-report.html")}const j=`wcagcheckr — Site-wide compliance bundle
266
+ ========================================
267
+
268
+ Generated: ${new Date().toISOString()}
269
+ Source crawl: ${t.startUrl}
270
+ Pages audited: ${t.pagesAudited}
271
+ Site grade: ${t.siteGrade==="pending"?`Pending (${((Y=t.spotCheckGate)==null?void 0:Y.answered)??0}/${((Z=t.spotCheckGate)==null?void 0:Z.total)??8} content-meaning spot-checks answered — no letter until all are)`:t.siteGrade}
272
+ Unique violations site-wide: ${t.totalUniqueViolations}
273
+
274
+ Contents:
275
+ `+T.map(O=>` - ${O.name}`).join(`
276
+ `)+`
277
+
278
+ `+(P.length>0?`Skipped (not included):
279
+ `+P.map(O=>` - ${O}`).join(`
280
+ `)+`
281
+
282
+ `:"")+`Each HTML report opens directly in a browser. Use
283
+ Ctrl+P → Save as PDF in the report you want sealed for legal
284
+ or compliance submission.
285
+ `;if(T.unshift({name:"README.txt",content:j}),T.length===0){_({state:"error",message:"No reports could be generated. Re-run the crawl and try again."});return}const V=E(T),K=new Date().toISOString().slice(0,10),te=t.startUrl.replace(/^https?:\/\//,"").replace(/[^a-z0-9]/gi,"-").replace(/-+/g,"-").slice(0,32).toLowerCase()||"crawl",de=`wcagcheckr-site-bundle-${K}-${te}.zip`,L=URL.createObjectURL(V),z=document.createElement("a");z.href=L,z.download=de,document.body.appendChild(z),z.click(),document.body.removeChild(z),setTimeout(()=>URL.revokeObjectURL(L),3e4),_({state:"done",included:T.length,skipped:P})}catch(j){_({state:"error",message:j instanceof Error?j.message:String(j)})}}async function oe(){var E,U,M;I(!0),f(null);try{const P=await bt();if(P.length===0){f("No forensic-log entries yet. Generate a defense bundle or deposition packet first — those create the anchored entries the pre-litigation report documents.");return}const T=typeof chrome<"u"&&((M=(U=(E=chrome.runtime)==null?void 0:E.getManifest)==null?void 0:U.call(E))==null?void 0:M.version)||"1.0.0";await gs({entries:P,extensionVersion:T})}catch(P){f(P instanceof Error?P.message:String(P))}finally{I(!1)}}async function G(E,U){h(E),f(null);try{const M=`site:${t.startUrl}`,P=await ie({type:"EXPORT_REQUEST",format:E,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});if(!(P!=null&&P.content)||P.content.length<50){f(`Generation returned empty content for ${E}.`);return}if(U==="download"){const T=At(E,M);nt(P.content,T)}else De(P.content)}catch(M){f(M instanceof Error?M.message:String(M))}finally{h(null)}}async function W(){o(!0);try{const E=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[],ownerLawfare:!!r}),U=(E==null?void 0:E.content)??"";if(!U){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(U)}catch{}De(U,"text/markdown;charset=utf-8")}finally{o(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${s?n?la[n.tier]:"bg-slate-50 border-slate-200":la[t.siteRisk]}`,children:[s?n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2.5",children:[e.jsx("div",{className:`flex items-center justify-center w-12 h-12 rounded shrink-0 text-white text-2xl font-bold font-display ${xs[n.letter]??"bg-slate-500"}`,children:n.letter}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:["lawsuit-target safety grade · ",t.pagesAudited," page",t.pagesAudited===1?"":"s"," · whole site"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Exposure to automated lawsuit-targeting scanners across the whole site — not a WCAG conformance grade. Scope: all ",t.pagesAudited," page",t.pagesAudited===1?"":"s"," plus site-wide checks a single page can’t assess."]})]})]}),e.jsxs("p",{className:`text-base font-semibold capitalize ${ca[n.tier]}`,children:[n.tier," risk"]}),e.jsx("p",{className:"text-xs mt-1 text-slate-700",children:n.headline})]}):e.jsx("p",{className:"text-xs text-slate-500",children:"Reading your crawl…"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2.5",children:[t.siteGrade==="pending"?e.jsx("div",{className:"flex items-center justify-center w-12 h-12 rounded shrink-0 bg-slate-600 text-white text-[10px] font-bold font-display leading-tight text-center px-1",children:"Pending"}):e.jsx("div",{className:`flex items-center justify-center w-12 h-12 rounded shrink-0 text-white text-2xl font-bold font-display ${bc[t.siteGrade]??"bg-slate-500"}`,children:t.siteGrade}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:["site grade · ",t.pagesAudited," page",t.pagesAudited===1?"":"s"," · WCAG 2.1 AA",t.siteGrade==="pending"&&t.spotCheckGate?` · ${t.spotCheckGate.answered}/${t.spotCheckGate.total} spot-checks`:""]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Your combined grade — severity (most serious finding) and breadth (how many of the 9 areas have issues) together. The lawsuit-risk grade is a separate lens. Scope: all ",t.pagesAudited," page",t.pagesAudited===1?"":"s"," plus site-wide checks a single page can’t assess — so this can differ from any one page’s grade."]})]})]}),e.jsx("p",{className:`text-base font-semibold ${ca[t.siteRisk]}`,children:Yn[t.siteRisk]})]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited",s?(()=>{const E=Jn(t.findingGroups??[]).length;return e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:E})," lawsuit-target finding",E===1?"":"s"]})})():(()=>{const E=t.totalUniqueViolations,U=t.totalWalkthroughFindings,M=t.totalNeedsReview,P=E+U,T=[];return E>0&&T.push(`${E} axe`),U>0&&T.push(`${U} AI walkthrough`),e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:P})," total finding",P===1?"":"s",T.length>0&&e.jsxs(e.Fragment,{children:[" (",T.join(" + "),")"]}),M>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:M})," need",M===1?"s":""," review"]})]})})(),!s&&t.walkthroughAcknowledgements.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{className:"text-emerald-700",children:t.walkthroughAcknowledgements.length})," human-verified"]}),t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:i,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 font-medium",children:"📊 Open full site report (standalone HTML)"}),Le(C,"ai-prompt-site-crawl")?e.jsx("button",{type:"button",onClick:W,disabled:l,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:l?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}):e.jsxs("button",{type:"button",onClick:y,className:"w-full text-sm px-4 py-2.5 border border-amber-300 bg-amber-50/50 text-slate-700 rounded hover:bg-amber-50 font-medium",title:"Paid feature — upgrade to generate the AI fix prompt",children:["🔒 Export AI fix prompt — ",e.jsx("span",{className:"text-amber-800",children:"Upgrade to unlock"})]}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:d.state==="running",className:"w-full text-sm px-4 py-2.5 border border-emerald-500 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 font-medium",title:"Save each crawled page's current state as its baseline. Future audits + re-crawls show delta against this snapshot.",children:d.state==="running"?`Saving baselines… ${d.current+1}/${d.total}`:"📌 Set this crawl as the site baseline"}),d.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Saved ",d.saved," baseline",d.saved===1?"":"s",d.failed>0&&` · ${d.failed} failed (re-crawl those pages and retry)`]}),d.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",d.message]}),e.jsxs("div",{className:"border border-slate-200 rounded-lg p-3 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-700",children:"Site-wide compliance documents"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Generate the same legal / compliance / industry docs you can produce from a single-page audit — but covering the whole crawled site. Use these to respond to demand letters, file VPATs, or document remediation history."}),s&&e.jsxs("p",{className:"text-[11px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-1.5 leading-snug",children:[e.jsx("strong",{children:"Heads-up — different lens."})," The grade and report above measure ",e.jsx("strong",{children:"lawsuit-target risk"})," (what automated demand-letter scanners flag). These documents are full ",e.jsx("strong",{children:"WCAG conformance"})," ","artifacts — a broader legal/accessibility standard. A clean lawsuit-target grade is ",e.jsx("em",{children:"not"})," the same as WCAG conformance, so a VPAT or conformance crosswalk here may still list items the risk grade above doesn’t. For the complete WCAG 2.1 AA picture, switch to Power or Dev mode."]}),Le(C,"defense-bundle")?e.jsx("button",{type:"button",onClick:()=>void H(),disabled:$.state==="running",className:"w-full text-sm px-4 py-2.5 bg-slate-900 text-white rounded hover:bg-slate-800 disabled:opacity-50 font-medium",title:"Generate all compliance docs at once and download as a single .zip file",children:$.state==="running"?`Generating ${$.current} (${$.doneCount}/${$.totalCount})…`:"📦 Download all reports as a zip"}):e.jsxs("button",{type:"button",onClick:y,className:"w-full text-sm px-4 py-2.5 border border-amber-300 bg-amber-50/50 text-slate-700 rounded hover:bg-amber-50 font-medium",title:"Paid feature — upgrade to generate the compliance bundle",children:["🔒 Download all reports as a zip — ",e.jsx("span",{className:"text-amber-800",children:"Upgrade to unlock"})]}),$.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Bundled ",$.included," file",$.included===1?"":"s"," into the zip",$.skipped.length>0&&e.jsxs(e.Fragment,{children:[" ","· skipped ",$.skipped.length,":",e.jsx("ul",{className:"mt-0.5 ml-3 list-disc",children:$.skipped.map(E=>e.jsx("li",{className:"break-all",children:E},E))})]})]}),$.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",$.message]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[e.jsx(Se,{label:"⚖ Defense bundle",sub:"Forensic-anchored HTML evidence — download + Ctrl+P to seal as PDF",...R("defense-bundle","download")}),e.jsx(Se,{label:"📜 Deposition packet",sub:"Court-grade — cover sheet, chain of custody, sworn declaration template",...R("deposition-packet","download")}),e.jsx(Se,{label:"📂 Evidence bundle",sub:"Same shape as Defense — neutral 'evidence' framing",...R("evidence-bundle","download")}),e.jsx(Se,{label:"📋 VPAT (Voluntary Product Accessibility Template)",sub:"Formal industry conformance template — opens in new tab",...R("vpat","open-in-tab")}),e.jsx(Se,{label:"🔄 Conformance crosswalk",sub:"WCAG 2.1 AA criterion-by-criterion conformance table",...R("conformance-crosswalk","open-in-tab")}),e.jsx(Se,{label:"🔬 Methodology doc",sub:"How this audit was conducted — defensibility documentation",...R("methodology-doc","open-in-tab")}),e.jsx(Se,{label:"📊 Executive report",sub:"Stakeholder summary — grade hero, top risks, next steps. Print-ready.",...R("executive-report","open-in-tab")}),e.jsx(Se,{label:"📃 Accessibility statement",sub:"Public WCAG conformance statement (HTML or Markdown) — opens a dialog for org info",busy:!1,disabled:u!==null,locked:!Le(C,"accessibility-statement-html"),onClick:Le(C,"accessibility-statement-html")?()=>void A():y}),N?e.jsx(Se,{label:"📋 Pre-litigation report",sub:"Audit-history record across time — requires anchored entries (generate a defense bundle first)",busy:S,disabled:u!==null||S,onClick:()=>void oe()}):e.jsx(Se,{label:"📋 Pre-litigation report",sub:"Audit-history record across time — anchored audit timeline for legal review",busy:!1,disabled:!1,locked:!0,onClick:y})]}),g&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",g]})]}),e.jsx(za,{open:v,onClose:()=>w(!1),results:[],siteCrawlSource:!0}),e.jsx(Ge,{open:k,onClose:()=>x(!1)}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"This report is your do-the-work list."})," ","Each finding below is grouped by whether it's likely a"," ",e.jsx("strong",{children:"shared resource"})," (a CSS rule, component, or layout that affects multiple pages — fix it once, helps everywhere) or ",e.jsx("strong",{children:"page-specific"})," (only that one URL). Click any affected URL to open that page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)."]}),e.jsx(Ot,{title:"Shared resources — fix once, helps multiple pages",sectionKind:"shared-actionable",groups:t.findingGroups.filter(E=>E.isShared&&!E.needsReview&&(!s||Je(E.ruleId))),openPage:Ke}),e.jsx(Ot,{title:"Page-specific — one-off; fix on that page",sectionKind:"local-actionable",groups:t.findingGroups.filter(E=>!E.isShared&&!E.needsReview&&(!s||Je(E.ruleId))),openPage:Ke}),s&&(()=>{const E=t.findingGroups.filter(U=>!U.needsReview&&!Je(U.ruleId)).length+t.consistencyFindings.length;return e.jsxs("div",{className:"border border-brand-200 bg-brand-50 rounded-lg p-3 text-xs text-slate-700 leading-snug",children:[e.jsx("p",{className:"font-semibold text-brand-900 mb-1",children:"This is your lawsuit-target risk — not a full WCAG check."}),e.jsxs("p",{children:["The grade + findings above cover only the issues automated demand-letter scanners flag.",E>0&&e.jsxs(e.Fragment,{children:[" This crawl also found ",e.jsx("strong",{children:E})," other accessibility ",E===1?"finding":"findings"," beyond demand-letter risk (hidden here to keep this view focused on lawsuit exposure)."]})," ","For the complete WCAG 2.1 AA assessment — every criterion graded across all ",t.pagesAudited," ",t.pagesAudited===1?"page":"pages"," — switch to ",e.jsx("strong",{children:"Power"})," or ",e.jsx("strong",{children:"Dev"})," mode (top of the panel)."]})]})})(),!s&&t.consistencyFindings.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700 mb-2",children:["Site-wide patterns (",t.consistencyFindings.length,")"]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:"Inconsistencies the comparators only see across pages — navigation order divergence, identification mismatches, redundant entry. WCAG 3.2.3 / 3.2.4 / 3.2.6."}),e.jsx("ul",{className:"space-y-2",children:t.consistencyFindings.map((E,U)=>e.jsxs("li",{className:"border border-blue-200 rounded p-2.5 bg-blue-50 text-xs",children:[e.jsxs("p",{className:"font-mono text-[10px] text-blue-700",children:[E.ruleId," · WCAG ",E.wcagCriterion," · ",E.impact]}),e.jsx("p",{className:"text-sm text-blue-900 mt-1",children:E.description}),E.details&&e.jsx("p",{className:"text-[11px] text-blue-800 mt-1 whitespace-pre-wrap leading-snug",children:E.details}),E.pages.length>0&&e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-blue-700",children:"Pages compared:"}),E.pages.map(M=>e.jsxs("button",{type:"button",onClick:()=>void Ke(M.url),className:"block w-full text-left text-[11px] font-mono text-blue-800 hover:text-blue-900 hover:underline truncate",children:["→ ",M.url]},M.url))]})]},U))})]}),e.jsx(Ot,{title:"Needs human review",sectionKind:"needs-review",groups:t.findingGroups.filter(E=>E.needsReview),openPage:Ke,hint:"AI flagged these as possibly failing but couldn't decide — you need to look + judge. They don't count toward the severity total above."}),t.findingGroups.length===0&&t.consistencyFindings.length===0&&e.jsxs("div",{className:"border border-emerald-200 rounded p-3 bg-emerald-50 text-xs text-emerald-900",children:[e.jsxs("strong",{children:["✓ No findings across the ",t.pagesAudited," crawled page",t.pagesAudited===1?"":"s","."]})," Per-page audits all completed cleanly. Drill into any page below to see the full per-page Findings if you want to verify or run guided manual checks."]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:[e.jsx("strong",{children:"Click any row"})," to expand it inline and see exactly what's wrong on that page — axe findings, AI walkthrough verdicts, and human acknowledgements with action buttons right there. Click the URL itself to open the audited page in a new tab."]}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:t.pages.map(E=>{const U=(t.findingGroups??[]).filter(M=>M.needsReview&&M.pages.some(P=>P.url===E.url)).length;return e.jsx(jc,{page:E,findingGroups:t.findingGroups??[],needsReviewCount:U,lawfareLetter:r?r.perUrlLetter[E.url]??"A":null,onOpenSinglePage:()=>void Ke(E.url)},E.url)})})]})]})}async function Ke(t){try{const s=await Ze(),a=s==null?void 0:s.find(n=>n.url===t);if(!a||a.results.length===0||!a.componentId){console.warn("[site-crawl-panel] no cached crawl results for",t);return}try{const{getResolutionsForPage:n}=await ve(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-EQBltZPz.js").then(l=>l.b5);return{getResolutionsForPage:i}},__vite__mapDeps([0,1,2,3,4])),r=await n(t);b.getState().setResolutionsForUrl(t,r)}catch{}b.getState().setResults(a.results,a.delta,a.componentId),b.getState().setCrawlNavContext({mode:"page",url:t});try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}b.getState().setView("report"),b.getState().setFindingsLens("overview")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}function Se({label:t,sub:s,busy:a,disabled:n,onClick:r,locked:i=!1}){return i?e.jsxs("button",{type:"button",onClick:r,className:"w-full text-left px-3 py-2 border border-amber-300 bg-amber-50/50 rounded hover:bg-amber-50",title:"Paid feature — upgrade to generate this document",children:[e.jsxs("div",{className:"text-xs font-medium text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"🔒"}),t]}),e.jsxs("div",{className:"text-[10px] text-amber-800 leading-snug mt-0.5",children:[e.jsx("strong",{children:"Upgrade to unlock"})," · ",s]})]}):e.jsxs("button",{type:"button",onClick:r,disabled:n,className:"w-full text-left px-3 py-2 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-medium text-slate-900",children:a?`Generating ${t.replace(/^[^a-zA-Z]+/,"")}…`:t}),e.jsx("div",{className:"text-[10px] text-slate-600 leading-snug mt-0.5",children:s})]})}function Ot({title:t,sectionKind:s,groups:a,openPage:n,hint:r}){if(a.length===0)return null;const i=s==="needs-review",l=i?"text-amber-700":"text-slate-500",o=i?"border-amber-200 bg-amber-50":"border-slate-200 bg-white",d=i?"bg-amber-200 text-amber-900":"";return e.jsxs("div",{children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wide mb-2 ${l}`,children:[t," (",a.length,")"]}),r&&e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:r}),e.jsx("ul",{className:"space-y-2",children:a.map((p,c)=>e.jsx(wc,{group:p,sectionKind:s,cardCls:o,labelCls:d,openPage:n},`${p.ruleId}::${p.representativeSelector}::${c}`))})]})}function wc({group:t,sectionKind:s,cardCls:a,labelCls:n,openPage:r}){const i=Xn(t.ruleId),o=i.whatsWrong&&i.whatsWrong!=="An accessibility rule failed on this page.",d=o?i.whatsWrong:t.axeDescription||`Rule "${t.ruleId}" was flagged — see axe-core docs for this rule.`,p=o?i.whyItMatters:null,c=o?i.howToFix:null,u=s==="needs-review",h=s==="shared-actionable",g=u?"review":t.impact,f=u?`${n} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`:`${vc[t.impact]} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`;return e.jsxs("li",{className:`border rounded p-2.5 text-xs ${a}`,children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:f,children:g}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 mt-0.5 break-all",children:[t.ruleId,t.wcagCriterion&&` · WCAG ${t.wcagCriterion}`]}),e.jsxs("p",{className:"text-[11px] text-slate-600 mt-1",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Shared"})," — found on"," ",e.jsx("strong",{children:t.pages.length})," page",t.pages.length===1?"":"s",". Likely a shared component or CSS rule — fix once."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Page-specific"})," — only on this one page."]}),t.totalOccurrences>t.pages.length&&e.jsxs(e.Fragment,{children:[" · ",t.totalOccurrences," matrix-state occurrences"]})]})]})]}),(p||c)&&e.jsxs("div",{className:"ml-7 mb-2 space-y-1.5",children:[p&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Why it matters"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:p})]}),c&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"How to fix"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:c})]})]}),t.representativeSelector&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Where to find it"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-700 break-all",children:t.representativeSelector}),t.representativeOuterHTML&&e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 break-all mt-0.5 line-clamp-2",children:[t.representativeOuterHTML.slice(0,200),t.representativeOuterHTML.length>200?"…":""]})]}),t.failureSummary&&!o&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Detail"}),e.jsxs("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:[t.failureSummary.slice(0,600),t.failureSummary.length>600?"…":""]})]}),e.jsxs("div",{className:"ml-7",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-0.5",children:u?"Open to review":"Affected pages"}),e.jsx("ul",{className:"space-y-0.5",children:t.pages.map(v=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(v.url),className:"block w-full text-left text-[11px] font-mono text-brand-700 hover:text-brand-900 hover:underline truncate",title:"Open this page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)",children:["→ ",v.url]})},v.url))})]}),u&&e.jsx("div",{className:"ml-7 mt-2 pt-2 border-t border-dashed border-slate-200",children:e.jsx(nn,{group:t})})]})}function nn({group:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(""),[i,l]=m.useState(!1),[o,d]=m.useState(null),[p,c]=m.useState(!1);async function u(){l(!0),d(null);try{if(!n.trim()){d("Note is required — explain your review judgment."),l(!1);return}const h=await Ze()??[],{acknowledgeFinding:g}=await ve(async()=>{const{acknowledgeFinding:v}=await import("./scheduled-audit-runner-EQBltZPz.js").then(w=>w.b4);return{acknowledgeFinding:v}},__vite__mapDeps([0,1,2,3,4]));let f=0;for(const v of t.pages){const w=h.find(S=>S.url===v.url);if(w)for(const S of w.results)for(const I of S.violations)I.ruleId===t.ruleId&&I.target.selector===v.selector&&(await g({componentId:w.componentId,matchKey:I.matchKey,ruleId:I.ruleId,note:n.trim()}),f++)}f===0?d("Could not find this finding in the persisted crawl data — re-run the crawl and try again."):(c(!0),a(!1))}catch(h){d(h instanceof Error?h.message:String(h))}finally{l(!1)}}return p?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2",children:e.jsxs("p",{className:"text-[11px] text-emerald-900",children:[e.jsx("strong",{children:"✓ Acknowledged."})," Re-run a crawl (or refresh the audit on the affected page) to see the finding drop out."]})}):s?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"Your review judgment (required, goes into the forensic record)"}),e.jsx("textarea",{value:n,onChange:h=>r(h.target.value),placeholder:"e.g., Verified — image is a portrait of the named founder; alt text correctly identifies subject and role.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),o&&e.jsx("p",{className:"text-[10px] text-rose-700",children:o}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:i?"Saving…":`Confirm — acknowledge on ${t.pages.length} page${t.pages.length===1?"":"s"}`}),e.jsx("button",{type:"button",onClick:()=>{a(!1),r(""),d(null)},disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{a(!0),d(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",title:"Mark this needsReview finding as human-verified across all affected pages. The ack persists across crawls as long as the underlying content's matchKey is stable (which it is for ai-alt-uncertain unless the alt text or image structure changes).",children:"Mark verified manually"})}function jc({page:t,findingGroups:s,needsReviewCount:a,lawfareLetter:n,onOpenSinglePage:r}){const[i,l]=m.useState(!1),o=t.walkthroughFindings??[],d=t.walkthroughAcknowledgements??[],p=Math.max(0,t.uniqueViolations-o.length-d.length),c=s.filter(k=>k.needsReview&&k.pages.some(x=>x.url===t.url)),u=s.filter(k=>!k.needsReview&&k.pages.some(x=>x.url===t.url)).map(k=>{var x;return{ruleId:k.ruleId,impact:k.impact,description:k.axeDescription,wcagCriterion:k.wcagCriterion,selector:((x=k.pages.find(y=>y.url===t.url))==null?void 0:x.selector)??k.representativeSelector}}).sort((k,x)=>{const y={critical:0,serious:1,moderate:2,minor:3};return(y[k.impact]??99)-(y[x.impact]??99)}),h=n!==null,g=h?u.filter(k=>Je(k.ruleId)):u,f=h?[]:o,v=h?[]:d,w=h?[]:c,S=h?g.length:p,I=g.length>0||f.length>0||v.length>0||w.length>0||!!t.error,C=n??t.grade,N=C==="A"?"text-emerald-700":C==="B"?"text-lime-700":C==="C"?"text-yellow-700":C==="D"?"text-orange-700":"text-rose-700";return e.jsxs("div",{className:"border-b border-slate-100 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>l(k=>!k),disabled:!I,className:"w-full flex items-center gap-2 text-left px-2 py-1.5 hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white text-xs","aria-expanded":i,children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${N}`,children:C}),e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",onClick:k=>k.stopPropagation(),className:"font-mono text-[11px] text-brand-700 hover:underline break-all flex-1",title:"Open this page in a new browser tab",children:t.url}),e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0 tabular-nums",title:h?"lawsuit-target findings":"axe violations only",children:[S," ",h?"finding":"axe",h&&S===1?"":h?"s":""]}),!h&&e.jsxs("span",{className:`text-[10px] shrink-0 tabular-nums font-medium ${o.length>0?"text-rose-700":d.length>0?"text-emerald-700":"text-slate-400"}`,children:[o.length," walkthru",d.length>0?` (${d.length}✓)`:""]}),!h&&a>0&&e.jsxs("span",{className:"text-[10px] shrink-0 tabular-nums font-medium text-amber-700",title:`${a} item${a===1?"":"s"} flagged for human review`,children:[a," review"]}),I&&e.jsx("span",{className:"text-[10px] text-slate-400 shrink-0 font-mono","aria-hidden":"true",children:i?"−":"+"})]}),i&&I&&e.jsx(kc,{page:t,axeFindings:g,needsReviewGroups:w,onOpenSinglePage:r})]})}function kc({page:t,axeFindings:s,needsReviewGroups:a,onOpenSinglePage:n}){const r=`${t.url}::dom:html`,[i,l]=m.useState([]),[o,d]=m.useState({}),[p,c]=m.useState(0);return m.useEffect(()=>{let u=!1;return Promise.all([Ae(r),Te([r])]).then(([h,g])=>{if(u)return;l(h.filter(v=>v.verdict!=="pass"));const f={};for(const v of g)f[v.criterionId]=v;d(f)}),()=>{u=!0}},[r,p]),e.jsxs("div",{className:"bg-slate-50 px-2 py-2 space-y-2 text-[11px]",children:[t.error&&e.jsxs("p",{className:"text-rose-700",children:["⚠ ",t.error]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["Axe findings (",s.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:s.map((u,h)=>e.jsxs("li",{className:"bg-white border border-slate-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:`font-mono text-[10px] font-bold uppercase px-1 rounded ${u.impact==="critical"?"bg-rose-200 text-rose-900":u.impact==="serious"?"bg-orange-200 text-orange-900":u.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:u.impact}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.description}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.selector})]},`${u.ruleId}::${u.selector}::${h}`))})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["AI walkthrough findings (",i.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.map(u=>e.jsx("div",{className:"bg-white border border-slate-200 rounded p-1.5",children:e.jsx(ms,{componentId:r,pageUrl:t.url,criterionId:u.criterionId,record:u,ack:o[u.criterionId]??null,onChanged:()=>c(h=>h+1)})},u.criterionId))})]}),Object.keys(o).length>0&&i.every(u=>o[u.criterionId])&&Object.keys(o).length>i.length&&e.jsx("p",{className:"text-[10px] text-emerald-700",children:"✓ All walkthroughs on this page either passed or are human-verified."}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-amber-700 mb-1",children:["Needs human review (",a.length,")"]}),e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"bg-white border border-amber-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"font-mono text-[10px] font-bold uppercase px-1 rounded bg-amber-200 text-amber-900",children:"review"}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.axeDescription}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.representativeSelector}),u.failureSummary&&e.jsxs("p",{className:"text-[10px] text-slate-600 mt-1 whitespace-pre-wrap",children:[u.failureSummary.slice(0,400),u.failureSummary.length>400?"…":""]}),e.jsx("div",{className:"mt-1.5",children:e.jsx(nn,{group:u})})]},`${u.ruleId}::${u.representativeSelector}`))})]}),e.jsx("div",{className:"pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-brand-600 hover:underline",children:"Open full single-page view (lenses, visualizers, guided checks) →"})})]})}const Ft="onboardingDismissed",Mt=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function Nc(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(Ft).then(o=>{o[Ft]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ft]:!0}),s(!1),n(0)}const i=a===Mt.length-1,l=Mt[a];return e.jsxs(Ve,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Mt.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(o=>o-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(o=>o+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Sc(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Ac(){const t=b(d=>d.aiFailure),s=b(d=>d.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",l="⚠",o=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:l})," ",o]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}const lt="aiConfig",Cc=[{key:"altText",label:"Alt-text descriptiveness"},{key:"headings",label:"Heading clarity vs section content"},{key:"sensory",label:'Sensory-language instructions ("click the green button")'},{key:"aria",label:"ARIA role semantic correctness"},{key:"imageOfText",label:"Image-of-text detection"},{key:"colorOnlyMeaning",label:"Color-only meaning"},{key:"genericLinkText",label:'Generic link text ("click here", "read more")'},{key:"wallOfText",label:"Wall-of-text / readability"},{key:"languageMismatch",label:"Declared-language mismatch"}];function rn(){const t=b(c=>c.results),s=b(c=>c.aiFailure),[a,n]=m.useState("unknown"),[r,i]=m.useState(!1);m.useEffect(()=>{function c(h){if(!h){n("off-no-key");return}if(!h.enabled){n("off-by-user");return}if(!h.apiKey){n("off-no-key");return}n("on")}chrome.storage.local.get(lt).then(h=>c(h[lt])).catch(()=>n("off-no-key"));const u=(h,g)=>{var f;g!=="local"||!(lt in h)||c((f=h[lt])==null?void 0:f.newValue)};return chrome.storage.onChanged.addListener(u),()=>chrome.storage.onChanged.removeListener(u)},[]);const l=t.length;if(m.useEffect(()=>{i(!1)},[l]),t.length===0||a==="on"||a==="unknown"||r||s)return null;const o=a==="off-by-user",d=o?"AI augmentation is off — semantic-quality checks did not run.":"No AI API key — semantic-quality checks did not run.",p=o?"You disabled AI in Settings. Structural checks (axe-core, DOM analyzers, state matrix) ran normally. The checks below would have added semantic quality verdicts.":"Structural checks (axe-core, DOM analyzers, state matrix) ran normally. The semantic-quality checks below would have added human-like content judgment — they need an Anthropic API key (BYO) to run.";return e.jsx("div",{role:"status",className:"px-3 py-2 border-b border-sky-200 bg-sky-50 text-xs text-sky-900 flex flex-col gap-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:"ℹ"})," ",d]}),e.jsx("div",{className:"mt-0.5",children:p}),e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"cursor-pointer hover:underline",children:"What didn't run"}),e.jsx("ul",{className:"mt-1 pl-4 list-disc text-[11px] leading-snug",children:Cc.map(c=>e.jsx("li",{children:c.label},c.key))})]}),e.jsx("div",{className:"mt-1.5 flex gap-2",children:e.jsx("button",{type:"button",onClick:()=>void Q({type:"OPEN_SETTINGS"}),className:"text-[11px] px-2 py-0.5 rounded bg-sky-600 text-white hover:bg-sky-700",children:"Enable in Settings"})})]}),e.jsx("button",{type:"button",onClick:()=>i(!0),className:"hover:opacity-70 leading-none text-sm","aria-label":"Dismiss AI-off notice for this audit",title:"Dismiss for this audit",children:"×"})]})})}function da(){const[t,s]=m.useState(!1);return m.useEffect(()=>ge("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(Ve,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function Ic(){var i;const[t,s]=m.useState(null);if(m.useEffect(()=>{Zn().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await Ss(),b.getState().startNewScan(),t.mode==="storybook-all"?je({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&je({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Ss(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Pt="storybook:hintDismissed";function Ec(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var o;if((await chrome.storage.local.get(Pt))[Pt])return;const l=await me();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((o=p.result)==null?void 0:o.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Pt]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function Rc(){var i;const t=b(l=>l.results),s=b(l=>l.baselineList),a=b(l=>l.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Tc(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function Tc(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<7?`${o}d ago`:a.toLocaleDateString()}function $c(){const t=b(o=>o.results),s=b(o=>o.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let o=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(o)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{o=!0}},[s]),t.length===0)return null;const r=t.flatMap(o=>o.violations),i=er(r,a.length>0?{runs:a,workflows:xe}:void 0),l=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function on(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,i]=m.useState(0),[l,o]=m.useState(!1),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,g]=m.useState(""),[f,v]=m.useState(!1),w=b(x=>x.tier);if(m.useEffect(()=>{let x=!1;return s(null),n(null),bt().then(y=>{x||s(y)}).catch(y=>{x||n(y instanceof Error?y.message:String(y))}),()=>{x=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const S=t.length,I=t.filter(x=>x.receipt).length,C=we(w,"exportPreLitigationReport");async function N(){if(!(!t||t.length===0)){v(!0);try{await gs({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),o(!1)}finally{v(!1)}}}async function k(){if(!t||t.length===0)return;const x={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},y=new Blob([JSON.stringify(x,null,2)],{type:"application/json"}),R=URL.createObjectURL(y),A=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,$=document.createElement("a");$.href=R,$.download=A,$.click(),setTimeout(()=>URL.revokeObjectURL(R),1e3)}return S===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[S," ",S===1?"entry":"entries",I>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[I," RFC 3161-anchored"]})]}),I===0&&S>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[C&&e.jsx("button",{type:"button",onClick:()=>o(x=>!x),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void k(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(x=>x+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:x=>p(x.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:c,onChange:x=>u(x.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:h,onChange:x=>g(x.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:f||S===0,onClick:N,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:f?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(x=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${x.grade==="A"?"bg-emerald-100 text-emerald-700":x.grade==="B"?"bg-lime-100 text-lime-700":x.grade==="C"?"bg-yellow-100 text-yellow-700":x.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:x.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:x.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${x.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:x.receipt?`Anchored to ${x.receipt.tsaName} at ${x.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:x.receipt?`RFC 3161 (${x.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:x.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:x.capturedAt}),(x.totals.critical>0||x.totals.serious>0)&&e.jsxs("span",{children:[x.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[x.totals.critical," crit"]}),x.totals.critical>0&&x.totals.serious>0&&" · ",x.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[x.totals.serious," sev"]})]}),e.jsxs("span",{children:[x.statesAudited," ",x.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:x.hash,children:[x.hash.slice(0,12),"…"]}),x.receipt&&e.jsxs("a",{href:As(x),onClick:y=>{y.preventDefault();const R=As(x);chrome.tabs.create({url:R,active:!0}).catch(()=>{window.open(R,"_blank","noopener,noreferrer")})},className:"text-brand-700 font-medium hover:underline","aria-label":`Verify this sealed audit (${x.pageUrl}) — opens the public verifier pre-filled with this receipt`,title:"Opens api.wcagcheckr.com/verify pre-filled with this entry and runs the RFC 3161 + signature checks independently of our server",children:["Verify",e.jsx("span",{"aria-hidden":"true",children:" ↗"})]})]})]},`${x.componentId}::${x.capturedAt}`))})]})}function Uc(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let d=!1;return bt().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],l=t.slice(0,3),o=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),o>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[o," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(Ve,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(on,{})})})]})}const Lc={eyebrow:"You're on the free tier",headline:"Audits run locally — but no forensic record is being kept.",body:"Upgrade to anchor every audit with court-grade trusted timestamps, unlock AI-powered fix suggestions, and build a third-party-verifiable history of your remediation effort."},_c={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Dc={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function ln(){const t=b(c=>c.tier),s=b(c=>c.seatsUsed),a=b(c=>c.seatsTotal),n=b(c=>c.planCode),r=b(c=>c.licenseDaysRemaining),i=b(c=>c.pastDue),[l,o]=m.useState(!1);if(t==="solo"&&n==="solo-single-month"){const c=r,u=c!==null&&c<=7,h=c===null?"":c===0?"expires today":c===1?"1 day left":`${c} days left`;return e.jsxs("aside",{"aria-label":"License status",className:u?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:u?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),h&&e.jsxs("span",{className:u?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",h]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>o(!0),className:u?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:u?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void Q({type:"OPEN_SETTINGS"}),className:u?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ge,{open:l,onClose:()=>o(!1)})]})}if(t==="solo"||t==="team"){const c=t==="team"?Dc:_c,u=t==="team"&&s!==null&&a!==null?`${s} of ${a} seats used`:c.perks,h=t==="team"&&s!==null&&a!==null&&s>a,g=t==="team"&&s!==null&&a!==null&&s===a,f=i?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:h?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:g?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${f.bg} border-b ${f.border} px-3 py-2 space-y-1 text-[11px] ${f.shadow}`,children:[e.jsxs("div",{className:f.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",c.label]}),e.jsxs("span",{className:f.subtitle,children:[" · ",u]})]}),i&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),h&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),g&&!h&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void Q({type:"OPEN_SETTINGS"}),className:f.link,children:"Manage license →"})})]})}const d=Lc;return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:d.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:"Free"})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:d.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:d.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void Q({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Ge,{open:l,onClose:()=>o(!1)})]})}const cn={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},St={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Oc={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"},ua={critical:0,serious:1,moderate:2,minor:3};function Fc(){b(p=>p.setUserMode);const t=b(p=>p.status),s=b(p=>p.setStatus),a=b(p=>p.errorMessage),n=b(p=>p.setError),[r,i]=m.useState(!1),[l,o]=m.useState(!1),d=m.useRef(t);return m.useEffect(()=>{if(d.current==="running"&&t==="complete"){o(!0);const p=setTimeout(()=>o(!1),3500);return d.current=t,()=>clearTimeout(p)}d.current=t},[t]),m.useEffect(()=>{if(t!=="running")return;const p=setTimeout(()=>{b.getState().status==="running"&&(s("idle"),n("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(p)},[t,s,n]),e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(ln,{}),e.jsx(Da,{}),e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(Oa,{}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_a,{}),e.jsx("button",{type:"button",onClick:()=>void Q({type:"OPEN_SETTINGS"}),"aria-label":"Open settings",title:"Settings",className:"text-slate-500 hover:text-slate-800 px-1.5 py-1 rounded hover:bg-slate-100 text-base leading-none",children:"⚙"})]})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"Lawsuit-target screener"}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-tight",children:"Find out if your site is on the ADA-targeting bots' radar"})]})]}),t==="running"&&e.jsx(Mc,{}),e.jsx(rn,{}),t==="failed"&&a&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:a}),e.jsx("button",{type:"button",onClick:()=>{b.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[r?e.jsx(an,{onBack:()=>i(!1),simplified:!0}):e.jsx(Gc,{onPickCrawl:()=>i(!0)}),l&&e.jsx(Pc,{})]}),e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsx("div",{className:"px-3 py-1.5 text-center leading-tight",children:"Risk indicator based on the same automated WCAG checks ADA-targeting tools use, plus our extended DOM analyzers and AI walkthroughs covering all 50 WCAG 2.1 AA criteria."}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})]})}function Mc(){const t=b(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void Q({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function Pc(){return e.jsxs("div",{role:"status",className:"absolute top-3 left-1/2 -translate-x-1/2 bg-emerald-600 text-white text-xs font-medium px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 pointer-events-none",style:{zIndex:50},children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{children:"Scan complete"})]})}function Gc({onPickCrawl:t}){const s=b(h=>h.status),a=b(h=>h.results),n=b(h=>h.siteCrawlReport),[r,i]=m.useState("quick"),[l,o]=m.useState("all"),d=s==="running",p=a.flatMap(h=>h.violations),c=a.length>0;function u(){je({type:"START_AUDIT",mode:"full-page",matrixOverride:$t(r)}),b.getState().startNewScan(),he.polite(`${r==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:u,disabled:d,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:d?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:d,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(Ja,{depth:r,onChange:i,disabled:d})]}),!c&&!d&&(n?e.jsx(Wc,{report:n,onView:t}):e.jsx(Vc,{})),c&&e.jsx(Bc,{violations:p,severityFilter:l,onSeverityFilterChange:o,scanDepth:r})]})}function Vc(){return e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex items-center justify-center w-24 bg-slate-300 text-white shrink-0","aria-label":"Not yet audited",children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:"X"})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"Not yet audited"}),e.jsxs("p",{className:"text-xs mt-1 leading-snug text-slate-600",children:["WCAG compliance level unknown. Open the page you want to check in this tab, then click ",e.jsx("strong",{children:"Scan this page"})," above. Use",e.jsx("strong",{children:" Whole site"})," for a multi-page report."]})]})]})})}function Wc({report:t,onView:s}){const a=b(d=>d.tier),n=we(a,"lawfareRisk"),r=Ml(t);let i=t.startUrl;try{i=new URL(t.startUrl).host}catch{}const l=`Whole-site crawl · ${t.pagesAudited} page${t.pagesAudited===1?"":"s"} · ${i}`,o=e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline font-medium",children:"View full report →"});return n?r?e.jsxs("div",{className:`border rounded-lg overflow-hidden ${cn[r.tier]}`,children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:l}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${xs[r.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${r.letter}, whole site`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:r.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade · whole site"}),e.jsxs("p",{className:`text-base font-semibold ${St[r.tier]} capitalize`,children:[r.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${St[r.tier]}`,children:r.headline}),r.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:r.flaggedRuleCount})," ",r.flaggedRuleCount===1?"issue type":"issue types"," flagged across ",t.pagesAudited," page",t.pagesAudited===1?"":"s",". ",o]}),r.flaggedRuleCount===0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:["No demand-letter-bait issues found site-wide. ",o]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"Scope:"})," ",t.pagesAudited," page",t.pagesAudited===1?"":"s"," · includes site-wide checks (consistent navigation, etc.) a single-page scan can’t assess. More pages + checks than a single-page scan, so this grade can differ from any one page’s."]}),e.jsxs("p",{className:"text-[10px] mt-1.5 text-slate-500 leading-snug",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners across the whole site. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade (open the full report or power/dev mode for that)."]})]})]})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:l}),e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Reading your last crawl…"})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:l}),e.jsxs("div",{className:"p-3 text-xs text-slate-600",children:["Whole-site crawl complete. ",o]})]})}function Bc({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var $;const r=b(_=>_.status),i=b(_=>_.results),l=b(_=>_.freshThisSession),o=b(_=>_.componentId),d=b(_=>_.tier),p=($=i[0])==null?void 0:$.startedAt,u=we(d,"lawfareRisk")?tr(t):null,h=r==="running",[g,f]=m.useState([]);m.useEffect(()=>{if(!o){f([]);return}let _=!1;return chrome.storage.local.get("igtRuns").then(H=>{if(_)return;const G=((H==null?void 0:H.igtRuns)??{})[o]??{};f(Object.values(G))}),()=>{_=!0}},[o]);const v=b(_=>_.acknowledgedKeys),w=i.length>0?ba(i,{runs:g,workflows:xe},"2.1","AA",v):void 0;function S(){je({type:"START_AUDIT",mode:"full-page",matrixOverride:$t(n)}),b.getState().startNewScan(),he.polite("Re-scanning this page now.")}const I=t.filter(_=>Je(_.ruleId)),C=t.length-I.length,N=s==="lawsuit-risk"?I.filter(_=>_.impact==="critical"||_.impact==="serious"):I,k=new Map;for(const _ of N){const H=Ee(_.ruleId,_.target.selector);k.has(H)||k.set(H,_)}const x=Array.from(k.values()),y=new Map;for(const _ of x){const H=y.get(_.ruleId)??[];H.push(_),y.set(_.ruleId,H)}const R=Array.from(y.entries()).sort((_,H)=>(ua[_[1][0].impact]??99)-(ua[H[1][0].impact]??99)),A=I.filter(_=>_.impact==="critical"||_.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[p&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Yc,{iso:p})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void It(),disabled:h,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:S,disabled:h,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:h?"Scanning…":"↻ Scan again"})]})]}),h?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):u?e.jsxs("div",{className:`border rounded-lg overflow-hidden ${cn[u.tier]}`,children:[!l&&p&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${xs[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${St[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${St[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"Scope:"})," this page · ",Qt(n)," ",n==="quick"?"state (default only)":"states (hover, focus, dark, RTL)",". Site-wide checks (consistent navigation, etc.) aren’t assessed on a single page — run a ",e.jsx("strong",{children:"Whole site"})," audit for those, which can change the grade."]}),e.jsxs("p",{className:"text-[10px] mt-1.5 text-slate-500 leading-snug",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 bg-slate-50",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Lawsuit-target risk grade isn’t available on your current plan"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Upgrade your plan to see the demand-letter exposure grade for this page."})]}),!h&&w&&!w.canClaimConformance&&e.jsx(Hc,{coverage:w}),!h&&w&&w.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",w.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(Qc,{}),e.jsx(Uc,{}),C>0&&e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug border border-slate-200 bg-slate-50 rounded px-2.5 py-1.5",children:[e.jsx("strong",{children:C})," more accessibility ",C===1?"finding":"findings"," beyond demand-letter risk ",C===1?"is":"are"," not shown here — this view is your lawsuit-risk lens. See ",e.jsx("strong",{children:"Path to full WCAG"})," above, or switch to Power/Dev mode for the complete assessment."]}),I.length>0&&e.jsx(zc,{filter:s,onChange:a,totalCount:I.length,lawsuitRiskCount:A}),e.jsxs("div",{className:"space-y-2",children:[R.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),R.map(([_,H])=>e.jsx(Kc,{ruleId:_,violations:H},_))]})]})}function Hc({coverage:t}){const s=b(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),Q({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function zc({filter:t,onChange:s,totalCount:a,lawsuitRiskCount:n}){return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Show"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("button",{type:"button",onClick:()=>s("all"),"aria-pressed":t==="all",className:`text-left rounded p-2 border transition-colors ${t==="all"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"All issues"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[a," total"]})]}),e.jsxs("button",{type:"button",onClick:()=>s("lawsuit-risk"),"aria-pressed":t==="lawsuit-risk",className:`text-left rounded p-2 border transition-colors ${t==="lawsuit-risk"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"Lawsuit risk only"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[n," critical/serious"]})]})]})]})}function Kc({ruleId:t,violations:s}){var u;const[a,n]=m.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,i=sr(t,r),l=s[0].impact,o=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&o.description?o.description:i.whatsWrong,c=o.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Oc[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,g)=>e.jsx(qc,{violation:h},g))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function qc({violation:t}){const s=b(i=>{var l;return(l=i.results[0])==null?void 0:l.frameId}),[a,n]=m.useState(null);async function r(i){i.stopPropagation();const l=await me();if(l)try{const o=await Re(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(o.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const ct=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function Qc(){const t=b(g=>g.results),s=b(g=>g.componentId),a=b(g=>g.tier),[n,r]=m.useState(null),[i,l]=m.useState(!1),[o,d]=m.useState(!1),[p,c]=m.useState(null);async function u(g,f){if(t.length!==0){r(g);try{const v=await ie({type:"EXPORT_REQUEST",format:g,results:t,wallClockMs:b.getState().lastAuditWallClockMs??void 0});if(g==="defense-bundle"||g==="evidence-bundle"){const w=At(g,s);await Aa()?nt(v.content,w):c({open:!0,format:g,content:v.content,filename:w})}else if(f)De(v.content);else{try{await navigator.clipboard.writeText(v.content),he.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const S=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
286
+ <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
287
+ .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
288
+ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
289
+ <div class="banner"><strong>✓ Copied to clipboard.</strong> Paste this into ChatGPT, Claude, or your favorite AI assistant. The AI will walk you through fixes for your specific situation.</div>
290
+ <pre>${v.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`;De(S,"text/html")}}finally{r(null)}}}const h=i?ct:ct.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:h.map(g=>{const f=!Le(a,g.id);return e.jsx("button",{type:"button",onClick:f?()=>d(!0):()=>void u(g.id,g.isHtml),disabled:!f&&n!==null,className:f?"w-full text-left p-2 rounded border border-amber-300 bg-amber-50/50 hover:bg-amber-50 transition-colors":"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",title:f?"Paid feature — upgrade to generate this report":void 0,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:f?"🔒":g.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:g.title}),e.jsx("div",{className:`text-[11px] leading-snug ${f?"text-amber-800":"text-slate-500"}`,children:f?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Upgrade to unlock"})," · ",g.desc]}):g.desc})]}),n===g.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},g.id)})}),!i&&e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",ct.length-2," more report option",ct.length-2===1?"":"s"," ↓"]}),p&&e.jsx(Ha,{open:p.open,onClose:()=>c(null),format:p.format,content:p.content,filename:p.filename}),e.jsx(Ge,{open:o,onClose:()=>d(!1)})]})}function Yc({iso:t}){const[,s]=m.useState(0);m.useEffect(()=>{const n=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(n)},[]);const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<5?e.jsx("span",{children:"just now"}):a<60?e.jsxs("span",{children:[a," seconds ago"]}):a<120?e.jsx("span",{children:"1 minute ago"}):a<3600?e.jsxs("span",{children:[Math.floor(a/60)," minutes ago"]}):a<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(a/3600)," hours ago"]})}function Jc(t,s,a){const n=new Set,r=[];let i=!1;for(const[l,o]of s)for(const d of o){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),i=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:l,selector:c.target.selector})}const p=d.axeRulesEvaluated;if(p){for(const c of p.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of p.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of p.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function Xc(t,s,a){const n=[];let r=0,i=0,l=0,o=0;for(const p of a){const c=p.steps.filter(u=>u.wcag===t);if(c.length!==0){r+=c.length;for(const[u,h]of s){const g=h[p.id];if(!g){i+=c.length;continue}for(const f of c){const v=g.steps[f.id];if(!v){i++;continue}v.status==="fail"?(l++,n.push({source:"igt",ruleOrStepId:`${p.id}.${f.id}`,description:f.question,pageUrl:u,notes:v.notes})):v.status==="skip"?i++:v.status==="not-applicable"?(l++,o++):l++}}}}const d=l>0&&o===l;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function Zc(t,s,a,n){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":n&&t.axeRulesFiringForCriterion===0?"not-applicable":"pass"}function ed(t,s,a){switch(s){case"pass":return`${a.axeRulesFiringForCriterion+a.igtStepsCoveringCriterion} signal(s) covered this criterion; no failures recorded.`;case"fail":return`${a.axeFailures.length} automated finding(s), ${a.igtFailures.length} manual finding(s) failed this criterion.`;case"inconclusive":return"Some manual checks for this criterion are unanswered or skipped; rerun the relevant IGT workflow to resolve.";case"not-evaluated":return"No automated rule and no guided-test step in the wcagcheckr ruleset maps to this criterion. Manual review required.";case"not-applicable":return"Marked not applicable by the evaluator."}}function td(t,s){var u;const a=[];for(const h of s.auditsByUrl.values())a.push(...h);const n=[];for(const h of s.igtRunsByUrl.values())n.push(...Object.values(h));const r=ns({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=Nr(t.targetVersion,t.targetLevel),l=[];for(const h of i){const g=Jc(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),f=Xc(h.id,s.igtRunsByUrl,s.workflows),v=g.rulesFiring.size===0&&f.stepsCovering===0,w={axeRulesFiringForCriterion:g.rulesFiring.size,axeFailures:g.failures,igtStepsCoveringCriterion:f.stepsCovering,igtFailures:f.failures,unmapped:v},S=(u=t.overrides)==null?void 0:u[h.id];let I,C,N=!1;if(S)I=S.verdict,C=S.rationale,N=!0;else{const k=r.get(h.id);k?I=k.state:I=Zc(w,f.unanswered,g.hasIncomplete,f.allNotApplicable),C=ed(h,I,w)}l.push({criterion:h,understandingUrl:Sr(h,t.targetVersion),verdict:I,signals:w,overridden:N,rationale:C})}const o={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of l)h.verdict==="pass"?o.pass++:h.verdict==="fail"?o.fail++:h.verdict==="inconclusive"?o.inconclusive++:h.verdict==="not-applicable"?o.notApplicable++:h.verdict==="not-evaluated"&&o.notEvaluated++;function d(h){const g={A:1,AA:2,AAA:3},f=g[h];return l.every(v=>g[v.criterion.level]>f?!0:v.verdict==="pass"||v.verdict==="not-applicable")}let p=null;d("AAA")?p="AAA":d("AA")?p="AA":d("A")&&(p="A");const c=p===t.targetLevel||p==="AAA"&&t.targetLevel==="AA"||p==="AAA"&&t.targetLevel==="A"||p==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:l,summary:{totalCriteria:l.length,pass:o.pass,fail:o.fail,inconclusive:o.inconclusive,notApplicable:o.notApplicable,notEvaluated:o.notEvaluated,levelAchieved:p,meetsTarget:c}}}const sd={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},pa={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function B(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function qe(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function ad(t,s,a,n){const{inputs:r,rows:i,summary:l,generatedAt:o}=t,d=l.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,p=new Map;for(const u of i){const h=u.criterion.id.split(".").slice(0,2).join("."),g=p.get(h)??[];g.push(u),p.set(h,g)}const c=Array.from(p.entries()).sort(([u],[h])=>u.localeCompare(h,void 0,{numeric:!0})).map(([u,h])=>`
291
+ <h3 class="guideline-h">Guideline ${B(u)}</h3>
292
+ <table class="criteria-table">
293
+ <thead>
294
+ <tr>
295
+ <th>SC</th><th>Title</th><th>Level</th><th>Verdict</th><th>Rationale</th>
296
+ </tr>
297
+ </thead>
298
+ <tbody>
299
+ ${h.map(g=>`
300
+ <tr class="${pa[g.verdict]}">
301
+ <td><a href="${B(g.understandingUrl)}" target="_blank" rel="noopener">${B(g.criterion.id)}</a></td>
302
+ <td>${B(g.criterion.title)}</td>
303
+ <td>${B(g.criterion.level)}</td>
304
+ <td><span class="verdict-badge ${pa[g.verdict]}">${sd[g.verdict]}</span>${g.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
305
+ <td class="rationale">${B(g.rationale)}</td>
306
+ </tr>
307
+ ${g.signals.axeFailures.length>0||g.signals.igtFailures.length>0?`
308
+ <tr class="evidence-row">
309
+ <td></td>
310
+ <td colspan="4">
311
+ <details>
312
+ <summary>${g.signals.axeFailures.length+g.signals.igtFailures.length} failure instance${g.signals.axeFailures.length+g.signals.igtFailures.length===1?"":"s"}</summary>
313
+ <ul>
314
+ ${[...g.signals.axeFailures,...g.signals.igtFailures].slice(0,20).map(f=>`
315
+ <li>
316
+ <code>${B(f.ruleOrStepId)}</code>
317
+ ${f.pageUrl?` on <a href="${B(f.pageUrl)}" target="_blank" rel="noopener"><code>${B(f.pageUrl)}</code></a>`:""}
318
+ — ${B(f.description)}
319
+ ${f.selector?`<br><span class="ev-selector"><code>${B(f.selector)}</code></span>`:""}
320
+ ${f.notes?`<br><em>${B(f.notes)}</em>`:""}
321
+ </li>
322
+ `).join("")}
323
+ ${g.signals.axeFailures.length+g.signals.igtFailures.length>20?`<li class="ev-more">…and ${g.signals.axeFailures.length+g.signals.igtFailures.length-20} more.</li>`:""}
324
+ </ul>
325
+ </details>
326
+ </td>
327
+ </tr>
328
+ `:""}
329
+ `).join("")}
330
+ </tbody>
331
+ </table>
332
+ `).join("");return wa(`<!doctype html>
333
+ <html lang="en">
334
+ <head>
335
+ <meta charset="utf-8" />
336
+ <title>WCAG ${B(r.targetVersion)} Level ${B(r.targetLevel)} Conformance Report — ${B(r.siteName)}</title>
337
+ <style>
338
+ *, *::before, *::after { box-sizing: border-box; }
339
+ body {
340
+ font: 11pt/1.55 "Charter", "Iowan Old Style", Georgia, serif;
341
+ color: #0f172a;
342
+ max-width: 7.5in;
343
+ margin: 0.55in auto;
344
+ padding: 0 0.3in;
345
+ background: #fff;
346
+ }
347
+ h1 { font-size: 24pt; margin: 0 0 4pt; letter-spacing: -0.01em; }
348
+ h2 { font-size: 15pt; margin: 24pt 0 8pt; padding-bottom: 4pt; border-bottom: 1px solid #cbd5e1; }
349
+ h3.guideline-h { font-size: 12pt; margin: 16pt 0 6pt; color: #475569; }
350
+ .eyebrow { font-family: "Helvetica Neue", Arial, sans-serif; font-size: 9pt; letter-spacing: 0.08em; text-transform: uppercase; color: #64748b; margin: 0 0 4pt; }
351
+ .cover { border-top: 3px solid #1e293b; border-bottom: 1px solid #cbd5e1; padding: 14pt 0 12pt; margin-bottom: 18pt; }
352
+ .conformance-banner {
353
+ margin: 14pt 0;
354
+ padding: 12pt 16pt;
355
+ border-radius: 3pt;
356
+ font-family: "Helvetica Neue", Arial, sans-serif;
357
+ font-weight: 700;
358
+ font-size: 13pt;
359
+ letter-spacing: 0.02em;
360
+ }
361
+ .conformance-banner.met { background: #dcfce7; color: #166534; border: 2px solid #16a34a; }
362
+ .conformance-banner.not-met { background: #fef3c7; color: #92400e; border: 2px solid #f59e0b; }
363
+ dl.meta { font-size: 10.5pt; }
364
+ dl.meta dt { font-family: "Helvetica Neue", Arial, sans-serif; font-size: 9pt; letter-spacing: 0.06em; text-transform: uppercase; color: #64748b; margin-top: 8pt; }
365
+ dl.meta dd { margin: 2pt 0 0; }
366
+ table.criteria-table, table.summary-table, table.sample-table {
367
+ width: 100%; border-collapse: collapse; font-size: 10pt; margin: 8pt 0 12pt;
368
+ }
369
+ table.criteria-table th, table.criteria-table td,
370
+ table.summary-table th, table.summary-table td,
371
+ table.sample-table th, table.sample-table td {
372
+ text-align: left; vertical-align: top; padding: 5pt 8pt;
373
+ border-bottom: 1px solid #e2e8f0;
374
+ }
375
+ table.criteria-table th, table.summary-table th, table.sample-table th {
376
+ font-family: "Helvetica Neue", Arial, sans-serif; font-size: 9pt;
377
+ text-transform: uppercase; letter-spacing: 0.04em; color: #475569;
378
+ background: #f8fafc;
379
+ }
380
+ .verdict-badge {
381
+ display: inline-block; padding: 1pt 6pt; border-radius: 2pt;
382
+ font-family: "Helvetica Neue", Arial, sans-serif; font-size: 8.5pt;
383
+ font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
384
+ }
385
+ .verdict-pass { background: #dcfce7; color: #166534; }
386
+ .verdict-fail { background: #fecaca; color: #b91c1c; }
387
+ .verdict-incomplete { background: #fef9c3; color: #a16207; }
388
+ .verdict-na { background: #e5e7eb; color: #475569; }
389
+ tr.verdict-fail td:first-child { border-left: 3px solid #b91c1c; }
390
+ tr.verdict-incomplete td:first-child { border-left: 3px solid #ca8a04; }
391
+ tr.verdict-pass td:first-child { border-left: 3px solid #16a34a; }
392
+ tr.evidence-row td { background: #f8fafc; font-size: 9pt; }
393
+ tr.evidence-row ul { margin: 4pt 0 0 0; padding-left: 16pt; }
394
+ tr.evidence-row li { margin: 3pt 0; }
395
+ tr.evidence-row .ev-selector { color: #475569; font-size: 8.5pt; }
396
+ .rationale { font-size: 9.5pt; color: #334155; }
397
+ .override-tag {
398
+ display: inline-block; margin-left: 4pt; padding: 0 4pt; border-radius: 2pt;
399
+ background: #dbeafe; color: #1e40af; font-size: 8pt; font-weight: 600;
400
+ text-transform: uppercase; letter-spacing: 0.04em;
401
+ }
402
+ code, .hash {
403
+ font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 9pt;
404
+ background: #f1f5f9; padding: 1pt 3pt; border-radius: 2pt;
405
+ }
406
+ .attestation, .methodology, .declaration, .anchor-block {
407
+ margin: 18pt 0; padding: 12pt 16pt;
408
+ background: #f8fafc; border-radius: 3pt;
409
+ font-size: 10pt;
410
+ }
411
+ .attestation h3, .methodology h3, .declaration h3, .anchor-block h3 { font-size: 11pt; margin: 0 0 6pt; }
412
+ .anchor-block { background: #f0f9ff; border-left: 3px solid #0ea5e9; }
413
+ .anchor-block.anchor-missing { background: #fef3c7; border-left-color: #f59e0b; }
414
+ .declaration-signed { background: #ecfdf5; border-left: 3px solid #10b981; }
415
+ table.anchor-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; margin-top: 6pt; }
416
+ table.anchor-table th, table.anchor-table td { text-align: left; vertical-align: top; padding: 3pt 6pt; }
417
+ table.anchor-table th { width: 35%; color: #475569; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 9pt; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
418
+ ul.methodology-list { padding-left: 18pt; }
419
+ ul.methodology-list li { margin: 4pt 0; }
420
+ footer.report-footer {
421
+ margin-top: 28pt; padding-top: 10pt; border-top: 1px solid #cbd5e1;
422
+ font-size: 8.5pt; color: #64748b;
423
+ display: flex; justify-content: space-between; gap: 12pt;
424
+ }
425
+ @media print {
426
+ body { margin: 0; max-width: none; }
427
+ h2, h3 { page-break-after: avoid; }
428
+ tr.evidence-row, .attestation, .methodology, .declaration { break-inside: avoid; }
429
+ .conformance-banner { break-inside: avoid; }
430
+ }
431
+ </style>
432
+ </head>
433
+ <body>
434
+ <section class="cover">
435
+ <p class="eyebrow">WCAG ${B(r.targetVersion)} Conformance Evaluation Report</p>
436
+ <h1>${B(r.siteName)}</h1>
437
+ <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${B(r.siteUrl)}</code></p>
438
+ <div class="conformance-banner ${l.meetsTarget?"met":"not-met"}">
439
+ ${B(d)}
440
+ </div>
441
+ <dl class="meta">
442
+ <dt>Highest level fully satisfied</dt>
443
+ <dd>${l.levelAchieved?`WCAG ${B(r.targetVersion)} Level ${B(l.levelAchieved)}`:"None (target level not met)"}</dd>
444
+ <dt>Target conformance level</dt>
445
+ <dd>WCAG ${B(r.targetVersion)} Level ${B(r.targetLevel)}</dd>
446
+ <dt>Report generated</dt>
447
+ <dd>${B(qe(o))}</dd>
448
+ <dt>Evaluator</dt>
449
+ <dd>
450
+ ${B(r.evaluator.name)}
451
+ ${r.evaluator.organization?`, ${B(r.evaluator.organization)}`:""}
452
+ ${r.evaluator.qualifications?`<br><span style="color: #64748b">${B(r.evaluator.qualifications)}</span>`:""}
453
+ </dd>
454
+ </dl>
455
+ </section>
456
+
457
+ <table class="summary-table">
458
+ <tr><th>Criteria evaluated</th><td>${l.totalCriteria}</td></tr>
459
+ <tr><th>Pass</th><td>${l.pass}</td></tr>
460
+ <tr><th>Fail</th><td>${l.fail}</td></tr>
461
+ <tr><th>Inconclusive</th><td>${l.inconclusive}</td></tr>
462
+ <tr><th>Not applicable</th><td>${l.notApplicable}</td></tr>
463
+ <tr><th>Not evaluated (manual review required)</th><td>${l.notEvaluated}</td></tr>
464
+ </table>
465
+
466
+ <h2>1 — Evaluation scope</h2>
467
+ <dl class="meta">
468
+ <dt>Website / application</dt><dd><strong>${B(r.siteName)}</strong> — <code>${B(r.siteUrl)}</code></dd>
469
+ <dt>Conformance target</dt><dd>WCAG ${B(r.targetVersion)} Level ${B(r.targetLevel)}</dd>
470
+ <dt>Accessibility-support baseline</dt>
471
+ <dd>${B(r.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
472
+ ${r.additionalStandards&&r.additionalStandards.length>0?`
473
+ <dt>Additional standards evaluated against</dt>
474
+ <dd>${r.additionalStandards.map(B).join(", ")}</dd>
475
+ `:""}
476
+ </dl>
477
+
478
+ <h2>2 — Sample of representative pages</h2>
479
+ ${r.pageSample.length===0?"<p><em>No page sample recorded.</em></p>":`
480
+ <table class="sample-table">
481
+ <thead><tr><th>URL</th><th>Page type</th><th>Selection</th><th>Data?</th></tr></thead>
482
+ <tbody>
483
+ ${r.pageSample.map(u=>`
484
+ <tr>
485
+ <td><a href="${B(u.url)}" target="_blank" rel="noopener"><code>${B(u.url)}</code></a></td>
486
+ <td>${B(u.pageType)}</td>
487
+ <td>${B(u.selectionType)}</td>
488
+ <td>${u.hasAuditData?"✓":'<em style="color:#94a3b8">no audit data</em>'}</td>
489
+ </tr>
490
+ `).join("")}
491
+ </tbody>
492
+ </table>
493
+ `}
494
+
495
+ <h2>3 — Detailed per-criterion findings</h2>
496
+ ${c}
497
+
498
+ <section class="methodology">
499
+ <h3>Evaluation methodology</h3>
500
+ <p>This report follows the W3C WCAG-EM 1.0 evaluation methodology (<a href="https://www.w3.org/TR/WCAG-EM/" target="_blank" rel="noopener">https://www.w3.org/TR/WCAG-EM/</a>). Automated checks were executed by the wcagcheckr Chrome extension running axe-core across a multi-state matrix (default, hover, focus, focus-visible, active, disabled, dark theme, forced-colors, LTR / RTL, multiple breakpoints) per Success Criterion. Manual checks were performed using the wcagcheckr Independent Guided Tests workflows, which cover keyboard operation, screen-reader readiness, focus management, forms, page structure, visual indicators, reflow + spacing, hover/focus content, pointer interactions, time-based behaviors, error prevention, and consistency.</p>
501
+ <ul class="methodology-list">
502
+ <li><strong>Pass</strong> — At least one automated rule or guided-test step covered the criterion, and all signals passed.</li>
503
+ <li><strong>Fail</strong> — One or more automated rules or guided-test steps failed against the criterion.</li>
504
+ <li><strong>Inconclusive</strong> — Coverage exists but some guided-test steps remain unanswered or were skipped.</li>
505
+ <li><strong>Not evaluated</strong> — Neither an automated rule nor a guided-test step in the wcagcheckr ruleset maps to this criterion. Manual expert review is required to evaluate.</li>
506
+ <li><strong>Not applicable</strong> — Evaluator-marked: the criterion does not apply to the content under evaluation.</li>
507
+ </ul>
508
+ </section>
509
+
510
+ ${n&&n.total>0?`
511
+ <section class="methodology spot-audit-block">
512
+ <h3>Human spot-audit of AI determinations</h3>
513
+ <p style="font-size: 10pt;">This audit used AI judgment to resolve ambiguous findings (alt-text quality, color-only meaning, axe-incomplete resolution, etc.). The evaluator spot-audited a sample of those AI determinations to verify the AI was correct.</p>
514
+ <table class="anchor-table">
515
+ <tr><th>AI determinations made</th><td><strong>${n.total}</strong></td></tr>
516
+ <tr><th>Reviewed by evaluator</th><td><strong>${n.reviewed}</strong> ${n.total>0?`(${Math.round(n.reviewed/n.total*100)}%)`:""}</td></tr>
517
+ <tr><th>Agreed with AI</th><td><strong style="color: #166534;">${n.agreed}</strong> ${n.reviewed>0?`(${Math.round(n.agreed/n.reviewed*100)}% agreement rate)`:""}</td></tr>
518
+ <tr><th>Disagreed with AI</th><td><strong style="color: #b91c1c;">${n.disagreed}</strong> ${n.reviewed>0?`(${Math.round(n.disagreed/n.reviewed*100)}%)`:""}</td></tr>
519
+ </table>
520
+ ${n.reviewed===0?`
521
+ <p style="font-size: 9.5pt; color: #92400e; background: #fef3c7; border-left: 3px solid #f59e0b; padding: 6pt 10pt; margin-top: 8pt;">No AI determinations were spot-audited by the evaluator. The conformance claim relies entirely on AI judgment without human verification.</p>
522
+ `:n.disagreed>0?`
523
+ <p style="font-size: 9.5pt; color: #475569; margin-top: 8pt;">Disagreements were captured by the evaluator with corrections; see the Trust-but-verify report in the wcagcheckr Compliance tab for the per-determination breakdown.</p>
524
+ `:""}
525
+ </section>
526
+ `:""}
527
+
528
+ <section class="attestation">
529
+ <h3>Conformance claim</h3>
530
+ <p>${l.meetsTarget?`Based on the evidence collected, <strong>${B(r.siteName)}</strong> meets the success criteria required for <strong>WCAG ${B(r.targetVersion)} Level ${B(r.targetLevel)}</strong> conformance, with respect to the accessibility-support baseline declared above and within the page sample evaluated.`:`Based on the evidence collected, <strong>${B(r.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${B(r.targetVersion)} Level ${B(r.targetLevel)} conformance. ${l.fail>0?`${l.fail} criterion failure${l.fail===1?"":"s"}`:"Unresolved manual checks"} prevent the claim. See the detailed findings table above.`}</p>
531
+ <p style="font-size: 9.5pt; color: #475569;">This conformance claim is the responsibility of the named evaluator. The wcagcheckr tooling assembled the per-criterion evidence; the evaluator's signature attests that the methodology was followed and the verdicts reflect the site under evaluation.</p>
532
+ </section>
533
+
534
+ ${s?`
535
+ <section class="anchor-block">
536
+ <h3>Forensic anchor — report integrity proof</h3>
537
+ <p style="font-size: 10pt;">The content of this report was hashed and the hash was anchored to a public RFC 3161 Time Stamping Authority, then counter-signed by the wcagcheckr server's ed25519 key. Any alteration to the conformance-bearing content above invalidates the hash; the receipt below is verifiable offline by anyone with the wcagcheckr-ci CLI.</p>
538
+ <table class="anchor-table">
539
+ <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${B(s.reportHash)}</code></td></tr>
540
+ <tr><th>Anchored at</th><td>${B(qe(s.receipt.anchoredAt))}</td></tr>
541
+ <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${B(s.receipt.tsaName)}</td></tr>
542
+ <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${B(s.receipt.serverKeyFingerprint)}</code></td></tr>
543
+ ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${B(s.receipt.prevAuditHash)}</code></td></tr>`:""}
544
+ </table>
545
+ <p style="font-size: 9pt; color: #64748b; margin-top: 8pt;">
546
+ To verify: download the verification bundle JSON from the wcagcheckr Compliance tab,
547
+ then run <code>wcagcheckr-ci verify &lt;bundle.json&gt;</code>. Verification
548
+ recomputes the SHA-256 over the canonical payload, fetches the server's public
549
+ key by fingerprint, and validates the ed25519 signature offline.
550
+ </p>
551
+ <!-- Machine-readable receipt — verifier can extract from the printed PDF
552
+ if the JSON bundle was lost. Inert in browsers; serves only as
553
+ structured-data preservation. -->
554
+ <script type="application/json" id="wcagcheckr-anchor-receipt">${B(JSON.stringify(s))}<\/script>
555
+ </section>
556
+ `:`
557
+ <section class="anchor-block anchor-missing">
558
+ <h3>Forensic anchor — not yet anchored</h3>
559
+ <p style="font-size: 10pt;">This report has not been anchored. Without an anchor, the report's integrity is not cryptographically verifiable — a reader cannot prove the content shown above is the content you generated. Click <strong>Anchor this report</strong> in the wcagcheckr Compliance tab to attach an RFC 3161 timestamp + server signature.</p>
560
+ </section>
561
+ `}
562
+
563
+ ${a?`
564
+ <section class="declaration declaration-signed">
565
+ <h3>Evaluator declaration — signed and sealed</h3>
566
+ <p>I, <strong>${B(a.signerName)}</strong>${a.signerOrganization?` of <strong>${B(a.signerOrganization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${a.signerQualifications?`My qualifications: ${B(a.signerQualifications)}.`:""}</p>
567
+ <p style="margin-top: 10pt; white-space: pre-wrap;">${B(a.claim)}</p>
568
+ <table class="anchor-table" style="margin-top: 14pt;">
569
+ <tr><th>Signed by</th><td><strong>${B(a.signerName)}</strong>${a.signerOrganization?` &middot; ${B(a.signerOrganization)}`:""} &middot; <code>${B(a.signerEmail)}</code></td></tr>
570
+ ${a.signerQualifications?`<tr><th>Qualifications</th><td>${B(a.signerQualifications)}</td></tr>`:""}
571
+ <tr><th>Signed at</th><td>${B(qe(a.signedAt))}</td></tr>
572
+ <tr><th>Audit captured at</th><td>${B(qe(a.auditCapturedAt))}</td></tr>
573
+ <tr><th>Scope of attestation</th><td>${B(a.scope)}</td></tr>
574
+ ${a.signatureReceipt?`<tr><th>Signature anchor</th><td>${B(a.signatureReceipt.tsaName)} &middot; <code class="hash">${B(a.signatureReceipt.timestampHex.slice(0,24))}…</code></td></tr>`:""}
575
+ </table>
576
+ <p style="font-size: 9pt; color: #475569; margin-top: 8pt;">This is a digitally-recorded attestation captured in the wcagcheckr extension at the time of signing. The signer takes responsibility for the conclusions presented.</p>
577
+ </section>
578
+ `:`
579
+ <section class="declaration">
580
+ <h3>Evaluator declaration — unsigned</h3>
581
+ <p>I, <strong>${B(r.evaluator.name)}</strong>${r.evaluator.organization?` of <strong>${B(r.evaluator.organization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${r.evaluator.qualifications?`My qualifications: ${B(r.evaluator.qualifications)}.`:""} ${r.evaluator.contact?`I may be contacted at <code>${B(r.evaluator.contact)}</code>.`:""}</p>
582
+ <p style="font-size: 9.5pt; color: #92400e; background: #fef3c7; border-left: 3px solid #f59e0b; padding: 6pt 10pt; margin-top: 10pt;">This report has not been signed inside the wcagcheckr extension. Use the <em>Sign and seal</em> step on the Compliance tab to attach a digital attestation, or sign the line below by hand.</p>
583
+ <p style="margin-top: 14pt;">Signature: <span style="display:inline-block; min-width:200pt; border-bottom:1px solid #94a3b8;">&nbsp;</span> &nbsp; Date: <span style="display:inline-block; min-width:90pt; border-bottom:1px solid #94a3b8;">&nbsp;</span></p>
584
+ </section>
585
+ `}
586
+
587
+ <footer class="report-footer">
588
+ <span>Generated ${B(qe(o))} by wcagcheckr</span>
589
+ <span>${l.totalCriteria} criteria · ${l.pass} pass · ${l.fail} fail · ${l.inconclusive} inconclusive</span>
590
+ </footer>
591
+ </body>
592
+ </html>`)}async function nd(t,s,a,n){const r=ad(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),l=URL.createObjectURL(i);await chrome.tabs.create({url:l})}const dt=ka("wcag-em-anchor"),rd="https://api.wcagcheckr.com",id="wcagcheckr",od=15e3;function dn(t){return{scope:{siteName:t.inputs.siteName,siteUrl:t.inputs.siteUrl,targetVersion:t.inputs.targetVersion,targetLevel:t.inputs.targetLevel,accessibilitySupportBaseline:t.inputs.accessibilitySupportBaseline,additionalStandards:t.inputs.additionalStandards??[]},evaluator:{name:t.inputs.evaluator.name,organization:t.inputs.evaluator.organization??null,qualifications:t.inputs.evaluator.qualifications??null,contact:t.inputs.evaluator.contact??null},sample:{pages:t.inputs.pageSample.map(s=>({url:s.url,type:s.pageType,selectionType:s.selectionType,hasAuditData:s.hasAuditData}))},verdicts:t.rows.map(s=>({sc:s.criterion.id,level:s.criterion.level,verdict:s.verdict,overridden:s.overridden,axeFailureCount:s.signals.axeFailures.length,igtFailureCount:s.signals.igtFailures.length})),summary:{totalCriteria:t.summary.totalCriteria,pass:t.summary.pass,fail:t.summary.fail,inconclusive:t.summary.inconclusive,notApplicable:t.summary.notApplicable,notEvaluated:t.summary.notEvaluated,levelAchieved:t.summary.levelAchieved,meetsTarget:t.summary.meetsTarget},generatedAt:t.generatedAt}}async function ld(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function cd(t){return ld(ar(dn(t)))}function dd(t){if(typeof t!="object"||t===null)return!1;const s=t;return s.schemaVersion!==1&&s.schemaVersion!==2||!(typeof s.anchoredAt=="string"&&typeof s.tsaName=="string"&&typeof s.rfc3161TokenBase64=="string"&&s.rfc3161TokenBase64.length>0&&typeof s.serverSignatureBase64=="string"&&s.serverSignatureBase64.length>0&&typeof s.serverKeyFingerprint=="string"&&s.serverKeyFingerprint.length>0)?!1:s.schemaVersion===2?typeof s.prevAuditHash=="string"&&/^[0-9a-f]{64}$/.test(s.prevAuditHash):!0}async function ud(t,s){const a=await Ea();if(!we(a,"wcagEmAnchor"))return dt.debug("wcagEmAnchor not on current tier — skipping anchor request"),null;const n=await cd(t),r={auditHash:n,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},i=`${rd}/v1/products/${id}/forensic/anchor`;try{const l=await fetch(i,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),signal:AbortSignal.timeout(od)});if(!l.ok)return dt.warn(`anchor HTTP ${l.status}`),null;const o=await l.json();return dd(o)?{reportHash:n,capturedAt:t.generatedAt,receipt:o}:(dt.warn("anchor returned malformed receipt",o),null)}catch(l){return dt.warn("anchor request failed",l),null}}function pd(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:dn(t)}}const Yt="auditAttestations",Jt="auditAttestation:defaultSigner";function fs(t,s){return`${t}::${s}`}async function bs(){try{const s=(await chrome.storage.local.get(Yt))[Yt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function un(t){await chrome.storage.local.set({[Yt]:t})}async function hd(t){const s=await bs();s[fs(t.componentId,t.auditCapturedAt)]=t,await un(s)}async function pn(t,s){return(await bs())[fs(t,s)]??null}async function md(t,s){const a=await bs();delete a[fs(t,s)],await un(a)}async function xd(){try{const s=(await chrome.storage.local.get(Jt))[Jt];return s&&typeof s=="object"?s:null}catch{return null}}async function gd(t){await chrome.storage.local.set({[Jt]:t})}function fd(t,s){return t.auditCapturedAt!==s}function bd(t){return`I attest that this audit, dated [DATE], represents a good-faith evaluation of ${t.scope} for WCAG ${t.targetVersion} Level ${t.targetLevel} conformance. The methodology relied on automated analysis + AI-assisted determinations, covering ${t.evaluatedCount} of ${t.totalCount} applicable criteria. I have reviewed the findings + spot-audit verifications and take responsibility for the conclusions presented.`}function vd(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,l]=m.useState(!1),[o,d]=m.useState(""),[p,c]=m.useState(""),[u,h]=m.useState(""),[g,f]=m.useState(""),[v,w]=m.useState("");m.useEffect(()=>{let k=!1;return Promise.all([pn(t.componentId,t.auditCapturedAt),xd()]).then(([x,y])=>{k||(a(x),x?(d(x.signerName),c(x.signerEmail),h(x.signerOrganization??""),f(x.signerQualifications??""),w(x.claim)):y&&(d(y.signerName),c(y.signerEmail),h(y.signerOrganization??""),f(y.signerQualifications??"")),w(R=>R||bd({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{k=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function S(){if(!o.trim()||!p.trim())return;const k={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:o.trim(),signerEmail:p.trim(),signerOrganization:u.trim()||void 0,signerQualifications:g.trim()||void 0,claim:v.trim(),scope:t.scope};await hd(k),await gd({signerName:k.signerName,signerEmail:k.signerEmail,signerOrganization:k.signerOrganization,signerQualifications:k.signerQualifications}),a(k),l(!1)}async function I(){await md(t.componentId,t.auditCapturedAt),a(null),l(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const C=s&&fd(s,t.auditCapturedAt);if(s&&!C&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void I(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&C&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const N=o.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:o,onChange:k=>d(k.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:p,onChange:k=>c(k.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:u,onChange:k=>h(k.target.value),placeholder:"Acme Corp",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Qualifications"}),e.jsx("input",{type:"text",value:g,onChange:k=>f(k.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:v,onChange:k=>w(k.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!N,onClick:()=>void S(),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"🔏 Sign and seal"})]})]})}const Xt="spotAuditReviews";function hn(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function vs(){try{const s=(await chrome.storage.local.get(Xt))[Xt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function mn(t){await chrome.storage.local.set({[Xt]:t})}async function yd(t){const s=await vs();s[t.key]=t,await mn(s)}async function wd(t){const s=await vs();delete s[t],await mn(s)}async function xn(){const t=await vs();return Object.values(t)}function gn(t,s){const a=new Map(s.map(l=>[l.key,l]));let n=0,r=0,i=0;for(const l of t){const o=a.get(l);o&&(n++,o.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function jd(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),i=a[n];a[n]=a[r],a[r]=i}return a.slice(0,Math.min(s,a.length))}function kd(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const l=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,o=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${l}::${i.selector}`):void 0;n.push({key:hn({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:o})}return n}const Nd={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",incomplete:"bg-amber-100 text-amber-800",inapplicable:"bg-slate-100 text-slate-700",ack:"bg-sky-100 text-sky-800",skip:"bg-slate-100 text-slate-700","n/a":"bg-slate-100 text-slate-700"},Sd={pass:"AI: pass",fail:"AI: fail",incomplete:"AI: uncertain",inapplicable:"AI: n/a",ack:"AI flagged · user acked",skip:"AI: skip","n/a":"AI: n/a"};function Ad({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>kd(t,s),[t,s]),[n,r]=m.useState([]),[i,l]=m.useState(!0),[o,d]=m.useState(null),[p,c]=m.useState(5),[u,h]=m.useState(!1);m.useEffect(()=>{let N=!1;return xn().then(k=>{N||(r(k),l(!1))}),()=>{N=!0}},[]);const g=m.useMemo(()=>a.map(N=>N.key),[a]),f=m.useMemo(()=>gn(g,n),[g,n]),w=(u?g:o||n.filter(N=>g.includes(N.key)).map(N=>N.key)).map(N=>a.find(k=>k.key===N)).filter(N=>!!N);async function S(N,k,x){const y={key:N.key,criterionId:N.criterionId,ruleOrStepId:N.ruleOrStepId,pageUrl:N.pageUrl,selector:N.selector,verdict:k,correction:(x==null?void 0:x.trim())||void 0,reviewedAt:new Date().toISOString()};await yd(y),r(R=>[y,...R.filter(A=>A.key!==y.key)])}async function I(N){await wd(N.key),r(k=>k.filter(x=>x.key!==N.key))}function C(){d(jd(g,p)),h(!1)}return a.length===0?e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"mt-2 leading-snug",children:"This audit has no AI determinations yet. Spot-auditing becomes available once AI judgment runs against ambiguous findings (alt-text, color-only meaning, axe-incomplete, etc.)."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI did the determination work. You can audit a sample — pick a random N, review what the AI decided, and mark whether you agree. Your spot-check rate is included in the report."})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-center bg-slate-50 border border-slate-200 rounded p-2",children:[e.jsx(ut,{label:"AI determinations",value:f.total}),e.jsx(ut,{label:"Reviewed",value:f.reviewed,accent:"text-slate-900"}),e.jsx(ut,{label:"Agreed",value:f.agreed,accent:"text-emerald-700"}),e.jsx(ut,{label:"Disagreed",value:f.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:p,onChange:N=>c(Math.max(1,Math.min(a.length,Number(N.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:C,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{h(N=>!N),d(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:u?"Hide list":`Show all (${a.length})`}),o&&e.jsx("button",{type:"button",onClick:()=>d(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):w.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:w.map(N=>e.jsx(Cd,{row:N,review:n.find(k=>k.key===N.key)??null,onAgree:()=>void S(N,"agreed"),onDisagree:k=>void S(N,"disagreed",k),onClear:()=>void I(N)},N.key))})]})}function ut({label:t,value:s,accent:a="text-slate-900"}){return e.jsxs("div",{children:[e.jsx("p",{className:`text-base font-bold ${a}`,children:s}),e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:t})]})}function Cd(t){const{row:s,review:a}=t,[n,r]=m.useState(!1),[i,l]=m.useState((a==null?void 0:a.correction)??""),o=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${o==="agreed"?"border-emerald-300 bg-emerald-50/50":o==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${Nd[s.outcome]}`,children:Sd[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),o&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&o==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:d=>l(d.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),l((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Oe(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,l]=m.useState(!1),[o,d]=m.useState(null),[p,c]=m.useState(null),[u,h]=m.useState(!1),[g,f]=m.useState(""),[v,w]=m.useState(!1),[S,I]=m.useState(null),C=hs();m.useEffect(()=>{let R=!1;return Promise.all([nr(t.componentId,t.criterionId),rr(t.componentId,t.criterionId,t.pageUrl)]).then(([A,$])=>{R||(a(A),c($),r(!1))}),()=>{R=!0}},[t.componentId,t.criterionId,t.pageUrl]);async function N(){l(!0),d(null);try{const A=await Q({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});A.ok?A.result&&a(A.result):d(A.error??"Audit failed.")}catch(R){d(R instanceof Error?R.message:String(R))}finally{l(!1)}}async function k(){await or(t.componentId,t.criterionId),a(null)}async function x(){if(s){w(!0),I(null);try{if(!g||!g.trim()){I("Note is required — explain how you manually verified this."),w(!1);return}if(s.verdict==="pass"){I("This walkthrough already passed — no acknowledgement needed."),w(!1);return}const R={componentId:t.componentId,criterionId:t.criterionId,pageUrl:t.pageUrl,note:g.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:s.verdict};await ss(R),c(R),h(!1),f("")}catch(R){I(R instanceof Error?R.message:String(R))}finally{w(!1)}}}async function y(){w(!0);try{await ir(t.componentId,t.criterionId,t.pageUrl),c(null)}finally{w(!1)}}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!o&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("button",{type:"button",onClick:()=>void N(),disabled:i||!C,title:C?void 0:"AI walkthroughs need an Anthropic API key. Open Settings → AI augmentation to add one.",className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 disabled:cursor-not-allowed font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),!C&&e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Requires an Anthropic API key —"," ",e.jsx("button",{type:"button",onClick:()=>void Q({type:"OPEN_SETTINGS"}),className:"underline hover:no-underline text-brand-600 font-medium",children:"add one in Settings"}),"."]})]}),o&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:o}),e.jsx("button",{type:"button",onClick:()=>void N(),disabled:i,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:i?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${Wt(s.reasoning)?"border-2 border-amber-500 bg-amber-50":s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[Wt(s.reasoning)&&e.jsxs("div",{className:"bg-amber-100 border border-amber-400 rounded p-2 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500 text-white font-bold uppercase tracking-wide",children:"AI cascade flagged this"})}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:["AI's automation paths all flagged this criterion. The verdict is",e.jsx("strong",{children:" fail"}),". The path forward is to fix the underlying issue on the page and re-audit. Read AI's reasoning below to see what it flagged."]}),e.jsxs("details",{className:"text-[11px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-40 overflow-y-auto bg-white/60 p-2 rounded",children:s.reasoning})]}),e.jsx("button",{type:"button",onClick:()=>void N(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",title:"After fixing the page, re-run the walkthrough to confirm the fix.",children:i?"Re-running…":"Re-run walkthrough"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:va(s.reasoning)?`Manual · ${s.verdict}`:Bt(s.reasoning)?`Cascade · ${Bt(s.reasoning)} → ${s.verdict}`:`AI: ${s.verdict}`}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug whitespace-pre-wrap",children:s.reasoning}),(()=>{const R=(s.steps??[]).filter(A=>A.action!=="initial").length;return R===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"Step-replay data not retained for past audits (saves storage). Re-run the walkthrough to see the live step recording."}):e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",R," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(A=>A.action!=="initial").map(A=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",A.focused.role||A.focused.tag,"]"]})," ",A.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:A.focused.selector})]},A.ordinal))})]})})(),s.verdict!=="pass"&&e.jsx("div",{className:"mt-2 pt-2 border-t border-dashed border-slate-300",children:p?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-200 text-emerald-900 font-bold uppercase tracking-wide",children:"✓ Human verified"}),e.jsx("span",{className:"text-[10px] text-emerald-800",children:new Date(p.acknowledgedAt).toLocaleString()})]}),e.jsxs("p",{className:"text-[11px] text-emerald-900 leading-snug",children:[e.jsx("strong",{children:"Verification note:"})," ",p.note]}),e.jsx("button",{type:"button",onClick:()=>void y(),disabled:v,className:"text-[10px] px-2 py-0.5 border border-emerald-300 bg-white text-emerald-800 rounded hover:bg-emerald-50 disabled:opacity-50",children:v?"Removing…":"Un-acknowledge"})]}):u?e.jsxs("div",{className:"bg-slate-50 border border-slate-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-slate-700 block",children:"Manual verification note (required)"}),e.jsxs("p",{className:"text-[10px] text-slate-600 leading-snug",children:["Describe what you did to verify this passes WCAG ",t.criterionId,". This note becomes part of the forensic record on every export — be specific."]}),e.jsx("textarea",{value:g,onChange:R=>f(R.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-slate-300 rounded resize-y min-h-[60px]",autoFocus:!0}),S&&e.jsx("p",{className:"text-[10px] text-rose-700",children:S}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void x(),disabled:v,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:v?"Saving…":"Confirm acknowledgement"}),e.jsx("button",{type:"button",onClick:()=>{h(!1),f(""),I(null)},disabled:v,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{h(!0),I(null)},className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",title:"After verifying manually that this criterion passes, log your verification here. Required note is preserved in the forensic record.",children:"Mark verified manually"})}),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void N(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void k(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function Id(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return me().then(r=>{n||a(r??null)}),()=>{n=!0}},[]),s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI drives a keyboard user through the page to evaluate criteria that require lived-experience judgment. Each walkthrough produces an AI verdict that flows into the conformance report. You can spot-check the AI's reasoning in the panel below."})]}),e.jsx(Oe,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.3",criterionTitle:"Focus Order",description:"AI walks the page Tab-by-Tab, comparing the focus sequence to the visible layout. Verdict: does the order follow a logical reading sequence?"}),e.jsx(Oe,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.1.2",criterionTitle:"No keyboard trap",description:"AI Tab-walks forward then Shift-Tab-walks backward, checking for traps: elements where focus gets stuck, or where Shift-Tab can't reverse out of a region. Verdict: can the user always leave?"}),e.jsx(Oe,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.7",criterionTitle:"Focus visible",description:"AI Tab-walks the page and captures a screenshot at each focused element. Vision then judges whether a visible focus indicator (outline, ring, or compensating treatment) is present on every sampled element."}),e.jsx(Oe,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.3.2",criterionTitle:"Meaningful Sequence (reading order)",description:"AI vision judges whether the heuristic-flagged DOM-vs-visual order divergences are real reading-order breaks or normal multi-column / banked layout patterns. Looks at the page screenshot + the flagged element list."}),e.jsx(Oe,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."}),e.jsx(Oe,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.5.3",criterionTitle:"Label in Name",description:"Programmatic DOM walk + AI fallback. Scans every interactive control for a mismatch between its visible label text and its programmatically-determined accessible name — the failure mode that breaks speech recognition (e.g., visible 'Submit' but accessible 'Continue')."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const ha="igtRuns",Ed={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",inconclusive:"bg-amber-100 text-amber-800","not-evaluated":"bg-slate-100 text-slate-700","not-applicable":"bg-slate-50 text-slate-500"},Rd={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Td(){var K,te,de;const t=b(L=>L.results),s=b(L=>L.acknowledgedKeys),[a,n]=m.useState(""),[r,i]=m.useState(""),l=Cr,o=Ar,[d,p]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,u]=m.useState(""),[h,g]=m.useState(""),[f,v]=m.useState(""),[w,S]=m.useState(""),[I,C]=m.useState(""),[N,k]=m.useState(""),[x,y]=m.useState({}),[R,A]=m.useState(!1),[$,_]=m.useState([]),[H,oe]=m.useState([]),[G,W]=m.useState(null),[E,U]=m.useState(!1),[M,P]=m.useState(null);m.useEffect(()=>{let L=!1;return chrome.storage.local.get(ha).then(z=>{if(L)return;const O=z[ha]??{};y(O),A(!0)}).catch(()=>{L||A(!0)}),()=>{L=!0}},[]),m.useEffect(()=>{var ae;const L=(ae=t[0])==null?void 0:ae.componentId;if(!L)return;let z=!1;const O=()=>{Ae(L).then(F=>{z||oe(F.map(q=>({criterionId:q.criterionId,ruleId:`ai-interactive::${q.criterionId}`,pageUrl:q.pageUrl,verdict:q.verdict,reasoning:q.reasoning})))})};O();const ne=F=>{F.interactiveAuditResults&&O()};return chrome.storage.local.onChanged.addListener(ne),()=>{z=!0,chrome.storage.local.onChanged.removeListener(ne)}},[t]),m.useEffect(()=>{var L;if(!a&&((L=t[0])!=null&&L.pageUrl))try{const z=new URL(t[0].pageUrl);n(z.hostname),i(z.origin)}catch{}},[t,a]),m.useEffect(()=>{const L=new Set;for(const O of t)L.add(O.pageUrl??O.scope);if(L.size===0){_([]);return}let z=!1;return Promise.all(Array.from(L).map(O=>_e(O))).then(O=>{z||_(O.flat())}).catch(()=>{}),()=>{z=!0}},[t]);const T=m.useMemo(()=>{const L=new Map,z=new Map;for(const ne of t){const ae=ne.pageUrl??ne.scope,F=L.get(ae)??[];F.push(ne),L.set(ae,F)}const O=new Map;for(const ne of t){const ae=ne.pageUrl??ne.scope;O.set(ne.componentId,ae)}for(const[ne,ae]of Object.entries(x)){const F=O.get(ne);if(!F)continue;const q=z.get(F)??{};Object.assign(q,ae),z.set(F,q)}return{auditsByUrl:L,igtRunsByUrl:z,workflows:xe,acknowledgedMatchKeys:s,incompleteResolutions:$,interactiveAuditResults:H}},[t,x,s,$,H]),ee=m.useMemo(()=>{const L=[],z=new Set;for(const O of T.auditsByUrl.keys())z.has(O)||(z.add(O),L.push({url:O,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const O of N.split(`
593
+ `).map(ne=>ne.trim()).filter(Boolean))z.has(O)||(z.add(O),L.push({url:O,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return L},[T,N]),X=m.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:l,targetLevel:o,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(L=>L.trim()).filter(Boolean),pageSample:ee,evaluator:{name:h||"(evaluator name pending)",organization:f||void 0,qualifications:w||void 0,contact:I||void 0}}),[a,r,l,o,d,c,ee,h,f,w,I]),D=m.useMemo(()=>R?td(X,T):null,[X,T,R]),Y=m.useMemo(()=>{const L=Array.from(T.auditsByUrl.values()).flat(),z=Object.values(x).flatMap(O=>Object.values(O));return ns({audits:L,igtRuns:z,workflows:xe,acknowledgedMatchKeys:s,incompleteResolutions:$,interactiveAuditResults:H})},[T,x,s,$,H]);async function Z(){if(!D)return;const L=t[0],z=L!=null&&L.componentId&&(L!=null&&L.startedAt)?await pn(L.componentId,L.startedAt):null,O=await xn(),ne=[];for(const F of Y.values())for(const q of F.evidence)q.source==="ai"&&ne.push(hn({criterionId:F.criterionId,ruleOrStepId:q.ruleOrStepId,pageUrl:q.pageUrl,selector:q.selector}));const ae=gn(ne,O);await nd(D,G,z,ae)}async function j(){if(D){U(!0),P(null);try{const L=await ud(D);if(!L){P("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}W(L)}finally{U(!1)}}}function V(){var q,ce,J;if(!D||!G)return;const L=((J=(ce=(q=chrome.runtime).getManifest)==null?void 0:ce.call(q))==null?void 0:J.version)??"0.0.0",z=pd(D,G,L),O=new Blob([JSON.stringify(z,null,2)],{type:"application/json"}),ne=URL.createObjectURL(O),ae=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,F=document.createElement("a");F.href=ne,F.download=ae,F.click(),setTimeout(()=>URL.revokeObjectURL(ne),1e3)}return m.useEffect(()=>{W(null),P(null)},[a,r,d,c,h,f,w,I,N]),R?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),D&&D.summary.totalCriteria>0&&e.jsx($d,{totalCriteria:D.summary.totalCriteria,pass:D.summary.pass,fail:D.summary.fail,inconclusive:D.summary.inconclusive,notEvaluated:D.summary.notEvaluated,notApplicable:D.summary.notApplicable,levelAchieved:D.summary.levelAchieved,meetsTarget:D.summary.meetsTarget,targetVersion:l,targetLevel:o,auditedUrlCount:T.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:L=>n(L.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:L=>i(L.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",l," Level ",o]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:L=>p(L.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:L=>u(L.target.value),placeholder:"Section 508 (Revised 2017), EN 301 549 v3.2.1, ADA Title III",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Page sample"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Audited pages are auto-included.",T.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:T.auditsByUrl.size})," URL",T.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:N,onChange:L=>k(L.target.value),rows:3,placeholder:`https://app.example.com/checkout
594
+ https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:L=>g(L.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:f,onChange:L=>v(L.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:w,onChange:L=>S(L.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:I,onChange:L=>C(L.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),D&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",D.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:D.rows.map(L=>e.jsxs("li",{className:"px-2 py-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-mono text-[10px] text-slate-500",children:[L.criterion.id," · ",L.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:L.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Ed[L.verdict]}`,children:Rd[L.verdict]})]},L.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),G?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[G.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",G.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),M&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:M}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!D||!a||!h||E,onClick:()=>void j(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:E?"Anchoring…":G?"Re-anchor":"Anchor this report"}),G&&e.jsx("button",{type:"button",onClick:V,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),D&&((K=t[0])==null?void 0:K.componentId)&&e.jsx(Id,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),D&&e.jsx(Ad,{verdicts:Y,incompleteResolutions:$}),D&&((te=t[0])==null?void 0:te.componentId)&&((de=t[0])==null?void 0:de.startedAt)&&e.jsx(vd,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:l,targetLevel:o,evaluatedCount:D.summary.pass+D.summary.fail+D.summary.inconclusive+D.summary.notApplicable,totalCount:D.summary.totalCriteria,canClaimConformance:D.summary.meetsTarget}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!D||!a||!h,onClick:()=>void Z(),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:"Generate WCAG-EM report →"})})]}):e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading IGT runs…"})}function $d({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:l,meetsTarget:o,targetVersion:d,targetLevel:p,auditedUrlCount:c}){return e.jsxs("div",{className:`border rounded p-2 ${o?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${o?"text-emerald-900":"text-amber-900"}`,children:o?`Currently meeting WCAG ${d} Level ${p}`:`Does not currently meet WCAG ${d} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:l??"none"})," · ",t," applicable criteria across ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const Ud={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function Ld(t){if(!t)return"never";const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function _d(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+ur[t.cadence]*6e4-Date.now();if(n<0)return"imminent";const r=Math.floor(n/6e4);return r<60?`in ${r} min`:`in ${Math.floor(r/60)}h`}function Dd(){return crypto.randomUUID()}function Od(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,i]=m.useState(""),[l,o]=m.useState("daily"),[d,p]=m.useState(null),[c,u]=m.useState(!1),[h,g]=m.useState(lr),[f,v]=m.useState("idle"),[w,S]=m.useState(!1),[I,C]=m.useState(null);async function N(){n(!0);try{const A=await ja();A.sort(($,_)=>$.enabled!==_.enabled?$.enabled?-1:1:_.createdAt.localeCompare($.createdAt)),s(A)}finally{n(!1)}}m.useEffect(()=>{N(),(async()=>{const A=await cr();g(A)})()},[]);async function k(A){if(C(null),A.webhookEnabled&&A.webhookUrl.trim().length>0)try{if(new URL(A.webhookUrl).protocol!=="https:"){C("Webhook URL must use https://");return}}catch{C("Webhook URL is not a valid https:// URL.");return}v("saving"),await dr(A),g(A),v("saved"),setTimeout(()=>v("idle"),1500)}async function x(){p(null);const A=r.trim();if(!A){p("URL is required.");return}try{new URL(A)}catch{p("Must be a valid URL (e.g. https://example.com/).");return}const $=b.getState().tier,_=Na($).scheduledAuditsMaxCount;if(Number.isFinite(_)&&t.length>=_){p(`Your plan allows up to ${_} scheduled audit${_===1?"":"s"}. Delete one before adding another.`);return}u(!0);try{const H={id:Dd(),url:A,cadence:l,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await Cs(H),await Is(H),i(""),o("daily"),await N(),await Ut()}finally{u(!1)}}async function y(A){const $={...A,enabled:!A.enabled};await Cs($),$.enabled?await Is($):await Es(A.id),await N(),await Ut()}async function R(A){window.confirm(`Remove the scheduled audit for ${A.url}? Run history for this schedule will also be deleted.`)&&(await Es(A.id),await pr(A.id),await hr(A.id),await N(),await Ut())}return e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Scheduled audits"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Re-audit a URL on a cadence. Each scheduled run opens a background tab, runs the audit, compares to the saved baseline, and records the result. New violations vs. baseline trigger alerts when configured below."})]}),e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>S(A=>!A),"aria-expanded":w,className:"w-full flex items-center justify-between px-3 py-2 text-left font-medium hover:bg-slate-50",children:[e.jsxs("span",{children:["Alert preferences",h.emailEnabled||h.webhookEnabled?e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"on"}):e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"off"})]}),e.jsx("span",{className:"text-slate-500","aria-hidden":"true",children:w?"▾":"▸"})]}),w&&e.jsxs("div",{className:"px-3 pb-3 space-y-2.5 border-t border-slate-100 pt-3",children:[e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Alerts fire when a scheduled audit finds NEW violations vs. the saved baseline. Email goes to your license-registered address (server-enforced). Webhook is your own URL."}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-email-enabled",type:"checkbox",checked:h.emailEnabled,onChange:A=>void k({...h,emailEnabled:A.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Email alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"Sends to your team-license email address only."})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-webhook-enabled",type:"checkbox",checked:h.webhookEnabled,onChange:A=>void k({...h,webhookEnabled:A.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Webhook alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"POSTs the alert payload as JSON to your URL."})]})]}),h.webhookEnabled&&e.jsxs("div",{className:"ml-5 space-y-1",children:[e.jsx("label",{htmlFor:"alert-webhook-url",className:"block text-[11px] font-medium",children:"Webhook URL (https:// only)"}),e.jsx("input",{id:"alert-webhook-url",type:"url",value:h.webhookUrl,onChange:A=>g({...h,webhookUrl:A.target.value}),onBlur:()=>void k(h),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),I&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:I})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"alert-min-impact",className:"block text-[11px] font-medium mb-1",children:"Minimum impact to alert on"}),e.jsxs("select",{id:"alert-min-impact",value:h.minImpact,onChange:A=>void k({...h,minImpact:A.target.value}),className:"w-full border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"minor",children:"Minor (alert on everything)"}),e.jsx("option",{value:"moderate",children:"Moderate"}),e.jsx("option",{value:"serious",children:"Serious (recommended)"}),e.jsx("option",{value:"critical",children:"Critical only"})]})]}),f==="saved"&&e.jsx("p",{className:"text-[11px] text-emerald-700",role:"status",children:"✓ Saved"})]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-url",className:"block font-medium mb-1",children:"URL to audit"}),e.jsx("input",{id:"sched-url",type:"url",value:r,onChange:A=>i(A.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:l,onChange:A=>o(A.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),d&&e.jsx("div",{className:"text-rose-700",role:"alert",children:d}),e.jsx("button",{type:"button",onClick:()=>void x(),disabled:c||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:c?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(A=>e.jsx("li",{className:`border rounded p-2.5 ${A.enabled?"border-slate-200 bg-white":"border-slate-200 bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("p",{className:"font-mono text-[11px] text-slate-700 break-all",children:A.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[Ud[A.cadence]," · last run ",Ld(A.lastRunAt)," ·"," ","next ",_d(A)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[A.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",A.lastTotalViolations??0," violation",(A.lastTotalViolations??0)===1?"":"s"]}),A.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:A.lastError??"",children:"✗ failed"}),A.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),A.lastResult==="pending"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700",children:"pending first run"}),(A.lastNewViolationCount??0)>0&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-900",title:"New violations vs. saved baseline",children:["⚠ ",A.lastNewViolationCount," new vs baseline"]}),!A.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void y(A),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:A.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void R(A),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},A.id))})]})}const ma={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function fn(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function Fd(t){let s=0,a=0,n=0,r=0,i=0,l=0,o=0,d=0;for(const p of t){if(!p.enabled){a++;continue}s++;const c=fn(p);c==="clean"?n++:c==="new-violations"?r++:c==="failed"?i++:c==="pending"&&l++,o+=p.lastNewViolationCount??0,d+=p.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:l,totalNewViolations:o,totalViolationsAcrossSchedules:d}}function Md(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,i=n.lastNewViolationCount??0;if(r!==i)return i-r;const l=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-l}).slice(0,s).map(a=>({scheduleId:a.id,url:a.url,cadence:a.cadence,lastRunAt:a.lastRunAt??null,lastTotalViolations:a.lastTotalViolations??0,lastNewViolationCount:a.lastNewViolationCount??0,state:fn(a)}))}function Pd(t,s,a=10){const n=new Map;for(const r of t)n.set(r.id,r.url);return[...s].sort((r,i)=>i.ranAt.localeCompare(r.ranAt)).slice(0,a).map(r=>({scheduleId:r.scheduleId,scheduleUrl:n.get(r.scheduleId)??"(deleted schedule)",ranAt:r.ranAt,totalViolations:r.totalViolations,newVsBaselineViolations:r.newVsBaselineViolations,durationMs:r.durationMs,error:r.error}))}function bn(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),i=[];for(let o=s-1;o>=0;o--){const d=new Date(r.getTime()-o*864e5);i.push({date:d.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const l=new Map(i.map(o=>[o.date,o]));for(const o of t){const d=o.ranAt.slice(0,10),p=l.get(d);p&&(p.runs++,p.totalViolations+=o.totalViolations,p.newViolations+=o.newVsBaselineViolations)}return i}function Gd(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return bn(r,a,n)}function Vd(t,s=new Date){const a=[];for(const n of t){if(!n.enabled)continue;n.lastResult==="failed"&&a.push({kind:"failed-run",scheduleId:n.id,url:n.url,detail:n.lastError??"audit failed"});const r=ma[n.cadence]*6e4;if(n.lastRunAt){const i=s.getTime()-new Date(n.lastRunAt).getTime();if(i>r*2){const l=Math.round(i/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${l}h (expected every ${ma[n.cadence]}min)`})}}(n.lastNewViolationCount??0)>10&&a.push({kind:"large-regression",scheduleId:n.id,url:n.url,detail:`${n.lastNewViolationCount} new violations vs baseline`})}return a}function xa(t){const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function vn(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function ga({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(o=>o.totalViolations)),r=a/Math.max(1,t.length-1),i=t.map((o,d)=>{const p=d*r,c=s-o.totalViolations/n*(s-4)-2;return`${p.toFixed(1)},${c.toFixed(1)}`}),l=t.map((o,d)=>{const p=d*r,c=s-o.newViolations/n*(s-4)-2;return`${p.toFixed(1)},${c.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:l.join(" ")})]})}function pt({state:t,count:s}){const a={clean:"bg-emerald-100 text-emerald-800","new-violations":"bg-rose-100 text-rose-900",failed:"bg-amber-100 text-amber-900",pending:"bg-slate-100 text-slate-700"},n={clean:"clean","new-violations":"new violations",failed:"failed",pending:"pending"};return e.jsxs("div",{className:`px-2 py-1 rounded text-[11px] ${a[t]}`,children:[e.jsx("strong",{children:s})," ",n[t]]})}function Wd({item:t}){const s={"failed-run":"✗ Failed","stale-schedule":"⏳ Stale","large-regression":"⚠ Regression"},a={"failed-run":"text-rose-700","stale-schedule":"text-amber-700","large-regression":"text-rose-700"};return e.jsxs("li",{className:"border-l-2 border-slate-200 pl-2 py-1",children:[e.jsx("div",{className:`text-[11px] font-medium ${a[t.kind]}`,children:s[t.kind]}),e.jsx("div",{className:"text-[11px] font-mono break-all",children:vn(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function Bd(){const[t,s]=m.useState([]),[a,n]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{(async()=>{i(!0);try{const[u,h]=await Promise.all([ja(),mr()]);s(u),n(h)}finally{i(!1)}})()},[]);const l=Fd(t),o=Md(t,5),d=Pd(t,a,10),p=bn(a,30),c=Vd(t);return r?e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading dashboard…"}):t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Nothing to summarize yet. Add a scheduled audit from the Schedules tab to start collecting cross-page compliance posture here."})]}):e.jsxs("div",{className:"p-3 space-y-4 text-xs","data-testid":"risk-view-root",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Aggregate posture across every scheduled audit. Read-only — schedules themselves are managed in the Schedules tab."})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 space-y-2 bg-white",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:["Posture · ",l.enabledSchedules," enabled",l.pausedSchedules>0?` · ${l.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(pt,{state:"clean",count:l.cleanCount}),e.jsx(pt,{state:"new-violations",count:l.newViolationsCount}),e.jsx(pt,{state:"failed",count:l.failedCount}),e.jsx(pt,{state:"pending",count:l.pendingCount})]}),l.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[l.totalNewViolations," new WCAG violation",l.totalNewViolations===1?"":"s"," vs baseline across all schedules."]})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-trend-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"30-day trend"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ga,{buckets:p}),e.jsxs("div",{className:"text-[10px] text-slate-500 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-slate-400 mr-1"})," total violations"]}),e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-rose-600 mr-1"})," new vs baseline"]}),e.jsxs("div",{className:"pt-1 text-slate-400",children:["Sum across ",l.enabledSchedules," schedule",l.enabledSchedules===1?"":"s"]})]})]})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",c.length]}),e.jsx("ul",{className:"space-y-1.5",children:c.map((u,h)=>e.jsx(Wd,{item:u},`${u.kind}-${u.scheduleId}-${h}`))})]}),o.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-top-exposed-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Most exposed pages"}),e.jsx("ul",{className:"space-y-1.5",children:o.map(u=>{const h=Gd(u.scheduleId,a,14),g=h.some(f=>f.runs>0);return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-mono text-[11px] break-all",children:u.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[u.lastTotalViolations," total · ",u.cadence," ·"," ","last run ",u.lastRunAt?xa(u.lastRunAt):"never"]})]}),g&&e.jsx("span",{className:"shrink-0",title:"Last 14 days · new violations vs baseline","data-testid":"risk-top-exposed-sparkline",children:e.jsx(ga,{buckets:h,height:20,width:56})}),u.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",u.lastNewViolationCount," new"]})]},u.scheduleId)})})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:d.map((u,h)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:xa(u.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:vn(u.scheduleUrl)}),u.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:u.error,children:"failed"}):u.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",u.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${u.scheduleId}-${u.ranAt}-${h}`))})]})]})}const ht="aiConfig";function Hd(){var C;const t=b(N=>N.results),s=b(N=>N.componentId),[a,n]=m.useState([]),[r,i]=m.useState(""),[l,o]=m.useState(!1),[d,p]=m.useState(!1),[c,u]=m.useState("claude-sonnet-4-6"),h=m.useRef(""),g=m.useRef(null);m.useEffect(()=>{function N(x){h.current=(x==null?void 0:x.apiKey)??"",p(!!(x!=null&&x.apiKey)),x!=null&&x.model&&u(x.model)}(async()=>{const x=await chrome.storage.local.get(ht);N(x[ht])})();const k=(x,y)=>{var A;if(y!=="local"||!(ht in x))return;const R=(A=x[ht])==null?void 0:A.newValue;N(R)};return chrome.storage.onChanged.addListener(k),()=>chrome.storage.onChanged.removeListener(k)},[]),m.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[a.length]);const f=t.flatMap(N=>N.violations),v=tc({componentId:s??void 0,pageUrl:(C=t[0])==null?void 0:C.pageUrl,violations:f.map(N=>({ruleId:N.ruleId,wcagCriterion:N.wcagCriterion,wcagLevel:N.wcagLevel,impact:N.impact,description:N.description,target:{selector:N.target.selector,outerHTML:N.target.outerHTML}}))}),w=a.reduce((N,k)=>N+(k.costUsd??0),0);async function S(){const N=r.trim();if(!N||l||!h.current)return;i("");const k={role:"user",content:N},x=[...a,k];n(x),o(!0);try{const y=x.map(A=>({role:A.role,content:A.content})),R=await tn({apiKey:h.current,model:c,messages:y,auditContext:v});n([...x,{role:"assistant",content:R.text,costUsd:R.costUsd,inputTokens:R.inputTokens,outputTokens:R.outputTokens}])}catch(y){n([...x,{role:"assistant",content:"",error:y instanceof Error?y.message:String(y)}])}finally{o(!1)}}function I(){n([])}return d?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",w.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:I,className:"text-slate-600 hover:text-slate-900 underline",children:"Clear"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Ask questions about THIS audit (",f.length," violation",f.length===1?"":"s","). The model answers from the structured audit data only — it won't invent findings or check the live page."]}),e.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto space-y-2 border border-slate-200 rounded p-2 bg-white min-h-[200px]","data-testid":"copilot-transcript",children:[a.length===0?e.jsx("p",{className:"text-slate-400 italic text-[11px]",children:`Try: "Which 3 issues are highest priority?" · "Explain finding #1 in plain language" · "What's the cheapest fix on this page?"`}):a.map((N,k)=>e.jsxs("div",{className:N.role==="user"?"border-l-2 border-brand-400 pl-2 py-1":"border-l-2 border-emerald-400 pl-2 py-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-slate-500",children:N.role==="user"?"You":"Co-pilot"}),N.error?e.jsx("p",{className:"text-rose-700 whitespace-pre-wrap",children:N.error}):e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:N.content}),N.role==="assistant"&&N.costUsd!==void 0&&e.jsxs("p",{className:"text-[10px] text-slate-400 mt-1",children:["$",N.costUsd.toFixed(4)," · ",N.inputTokens,"→",N.outputTokens," tok"]})]},k)),l&&e.jsx("div",{className:"border-l-2 border-emerald-200 pl-2 py-1 text-[11px] text-slate-400 italic",children:"Thinking…"})]}),e.jsxs("form",{onSubmit:N=>{N.preventDefault(),S()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:N=>i(N.target.value),placeholder:"Ask about this audit…",disabled:l,"aria-label":"Co-pilot prompt",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50"}),e.jsx("button",{type:"submit",disabled:l||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:l?"Sending…":"Send"})]})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("p",{className:"text-slate-600 leading-snug",children:["The co-pilot uses your own Anthropic API key (BYOK) to answer questions about the current audit. Configure your key in ",e.jsx("strong",{children:"Settings → AI"})," to enable."]})]})}function zd(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[l,o]=m.useState(""),[d,p]=m.useState(new Set);async function c(){i(null),n(!0);try{const g=await me();if(!g){i("No audited tab. Open a page to audit, then return here.");return}const f=await ie({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:g});if(!f.ok||!f.nodes){i(f.error??"Snapshot failed for an unknown reason.");return}s(f.nodes)}finally{n(!1)}}function u(g){p(f=>{const v=new Set(f);return v.has(g)?v.delete(g):v.add(g),v})}const h=t&&l?t.filter(g=>g.role.toLowerCase().includes(l.toLowerCase())||g.name.toLowerCase().includes(l.toLowerCase())):t;return e.jsxs("div",{className:"p-3 text-xs flex flex-col h-full","data-testid":"ax-tree-view",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Accessibility tree"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"Snapshot of the browser's computed AX tree — what screen readers actually consume."})]}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value:l,onChange:g=>o(g.target.value),placeholder:"Filter by role or name…","aria-label":"Filter ax-tree",className:"flex-1 min-w-[140px] border border-slate-300 rounded px-2 py-1"}),e.jsxs("span",{className:"text-slate-500","data-testid":"ax-tree-node-count",children:[(h==null?void 0:h.length)??0," node",((h==null?void 0:h.length)??0)===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto border border-slate-200 rounded bg-white p-2 font-mono text-[11px]",children:[!t&&!a&&e.jsxs("p",{className:"text-slate-400 italic text-center pt-8",children:["Click ",e.jsx("strong",{children:"Snapshot tree"})," above to capture the audited tab's accessibility tree."]}),t&&h&&e.jsx(Kd,{nodes:t,filtered:h,collapsed:d,onToggle:u})]})]})}function Kd({nodes:t,filtered:s,collapsed:a,onToggle:n}){if(s.length!==t.length)return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:s.map(l=>e.jsx("li",{role:"treeitem",children:e.jsx(wn,{node:l,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},l.nodeId))});const r=new Map;for(const l of t){const o=l.parentId,d=r.get(o)??[];d.push(l),r.set(o,d)}const i=r.get(void 0)??t.filter(l=>!l.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:i.map(l=>e.jsx(yn,{node:l,depth:0,byParent:r,collapsed:a,onToggle:n},l.nodeId))})}function yn({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const i=a.get(t.nodeId)??[],l=i.length>0,o=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":l?!o:void 0,children:[e.jsx(wn,{node:t,depth:s,collapsed:o,onToggle:()=>r(t.nodeId),hasChildren:l}),!o&&l&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:i.map(d=>e.jsx(yn,{node:d,depth:s+1,byParent:a,collapsed:n,onToggle:r},d.nodeId))})]})}function wn({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const i=t.properties.filter(l=>l.value!==!1&&l.value!==""&&l.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),i.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:i.map(l=>`${l.name}=${String(l.value)}`).join(" · ")})]})}function qd(){const t=b(p=>p.results),[s,a]=m.useState(!1),[n,r]=m.useState(null),[i,l]=m.useState(null);async function o(){r(null),a(!0);try{const p=await me();if(!p){r("No audited tab. Open a page first.");return}const c=await Re(p,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:p});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const u=new Map;for(const f of t)for(const v of f.violations)u.has(v.target.selector)||u.set(v.target.selector,v.matchKey);const h=c.references.map(f=>({violationMatchKey:u.get(f.selector)??null,referencedTokens:f.referencedTokens})),g=c.tokens;l(Rr(g,h))}finally{a(!1)}}const d=i?Er(i):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void o(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":i?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),d&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(Qe,{label:"Total tokens",value:d.totalTokens}),e.jsx(Qe,{label:"Color tokens",value:d.colorTokens}),e.jsx(Qe,{label:"Used",value:d.usedTokens}),e.jsx(Qe,{label:"Unused",value:d.unusedTokens,tint:d.unusedTokens>0?"amber":"slate"}),e.jsx(Qe,{label:"In violations",value:d.violatingTokens,tint:d.violatingTokens>0?"rose":"slate"})]}),i&&i.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:i.map(p=>e.jsxs("li",{className:"px-3 py-2 space-y-1","data-testid":"ds-token-row",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:p.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:p.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",p.token.value]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["declared on ",e.jsx("code",{children:p.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[p.usageCount," usage",p.usageCount===1?"":"s"]}),p.violationMatchKeys.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"text-rose-700 font-semibold",children:[p.violationMatchKeys.length," violation",p.violationMatchKeys.length===1?"":"s"]})]})]})]},p.token.name))})]}):i?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function Qe({label:t,value:s,tint:a}){const n={slate:"bg-slate-50 text-slate-700",amber:"bg-amber-50 text-amber-800",rose:"bg-rose-50 text-rose-900"};return e.jsxs("div",{className:`px-2 py-1.5 rounded ${n[a??"slate"]}`,children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide",children:t}),e.jsx("div",{className:"text-base font-semibold leading-tight",children:s})]})}const Gt="onboarding:dismissed",Vt="onboarding:exportTried",mt="onboarding:collapsed";function Qd(){const t=b(y=>y.tier),s=b(y=>y.results),a=b(y=>y.baselineList),[n,r]=m.useState(!1),[i,l]=m.useState(!1),[o,d]=m.useState(!1),[p,c]=m.useState(!1),[u,h]=m.useState(null);m.useEffect(()=>{(async()=>{const y=await chrome.storage.local.get([Gt,Vt,mt]);r(y[Gt]===!0),d(y[Vt]===!0),typeof y[mt]=="boolean"&&h(y[mt]);const R=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],A=await Promise.all(R.map($=>ie({type:"SETTINGS_GET",key:$})));c(A.some($=>typeof $.data=="string"&&$.data.length>0)),l(!0)})()},[]);const g=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:o?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:p?"done":"pending",optional:!0}],f=g.filter(y=>!y.optional),v=g.filter(y=>y.state==="done").length,w=f.filter(y=>y.state==="done").length,S=v===g.length,I=w===f.length;if(!i||n||I)return null;async function C(){r(!0),await chrome.storage.local.set({[Gt]:!0})}async function N(){const y=!o;d(y),await chrome.storage.local.set({[Vt]:y})}const k=u??v>0;async function x(){const y=!k;h(y),await chrome.storage.local.set({[mt]:y})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void x(),"aria-expanded":!k,"aria-controls":"onboarding-checklist-body",className:"flex-1 text-left flex items-center gap-1.5 hover:text-amber-950",children:[e.jsx("span",{className:"text-amber-800 text-[10px]","aria-hidden":"true",children:k?"▸":"▾"}),e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",v," of ",g.length," done"]})]}),e.jsx("button",{type:"button",onClick:()=>void C(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none",children:"✕"})]}),!k&&e.jsxs("div",{id:"onboarding-checklist-body",className:"mt-1.5",children:[e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug mb-1.5",children:["Quick checklist to get you started. ",S?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:g.map(y=>e.jsx("li",{className:"flex items-start gap-1.5",children:y.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:y.state==="done",onChange:()=>void N(),className:"mt-0.5","aria-label":y.label}),e.jsx("span",{className:y.state==="done"?"line-through text-amber-700":"text-amber-900",children:y.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:y.state==="done"?"✓":"○"}),e.jsxs("span",{className:y.state==="done"?"line-through text-amber-700":"text-amber-900",children:[y.label,y.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},y.id))})]})]})}function ru(){const t=b(r=>r.view),s=b(r=>r.userMode);b(r=>r.tier);const[a,n]=m.useState(!1);return m.useEffect(()=>{const r=setTimeout(()=>n(!0),600);return()=>clearTimeout(r)},[]),m.useEffect(()=>{const r=Vr(),l=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),o=_r();Ra({forceRefresh:!0}).catch(()=>{}),yt().catch(()=>{}),Gr().catch(()=>{}),Pr().catch(()=>{}),Wr().catch(()=>{}),Fr().catch(()=>{}),xr().then(c=>{b.getState().setAcknowledgedKeys(new Set(c.map(u=>u.matchKey)))}).catch(()=>{});const d=b.subscribe((c,u)=>{var f,v;const h=(f=c.results[0])==null?void 0:f.pageUrl,g=(v=u.results[0])==null?void 0:v.pageUrl;!h||h===g||cs(h).then(w=>{b.getState().setDismissedKeys(new Set(Object.keys(w)))}).catch(()=>{})});gr().then(c=>{c&&b.setState(u=>{const h={siteCrawlReport:c};return u.siteCrawlStatus!=="running"&&(h.siteCrawlStatus="complete"),u.view==="matrix"&&u.results.length===0&&(h.view="crawl"),h})}).catch(()=>{});const p=c=>{if(c.key!=="Escape")return;const{pinnedMatchKey:u,setPinned:h,results:g}=b.getState();u&&(h(null),me().then(f=>{var v;f&&be(f,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:f},(v=g[0])==null?void 0:v.frameId).catch(()=>{})}))};return window.addEventListener("keydown",p),()=>{o(),r.disconnect(),l==null||l.disconnect(),window.removeEventListener("keydown",p),d()}},[]),s==="owner"||s===null?e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(da,{}),e.jsx(js,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx(ln,{}),e.jsx(Da,{}),e.jsx(ii,{}),e.jsx(Qd,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[t==="matrix"&&e.jsxs(e.Fragment,{children:[e.jsx(di,{}),e.jsx(gi,{}),e.jsx(Ec,{}),e.jsx(Ic,{})]}),e.jsx(bi,{}),e.jsx(Sc,{}),e.jsx(Ac,{}),e.jsx(rn,{}),e.jsx(vi,{viewingRun:t==="crawl"||t==="report",onView:()=>b.getState().setView(b.getState().siteCrawlReport?"crawl":"report")}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Ni,{}),t==="report"&&e.jsx(ol,{}),t==="delta"&&e.jsx(Ka,{}),t==="activity"&&e.jsx(Ba,{}),t==="guided"&&e.jsx(Ne,{feature:"igtWorkflows",label:"Intelligent Guided Tests",children:e.jsx(Il,{})}),t==="flows"&&e.jsx(Ne,{feature:"flowRecorder",label:"Flow recorder",children:e.jsx($l,{})}),t==="scorecard"&&e.jsx(_l,{}),t==="crawl"&&e.jsx(Ne,{feature:"siteCrawl",label:"Site crawl",children:e.jsx(an,{})}),t==="forensic"&&e.jsx(Ne,{feature:"forensicLog",label:"Forensic log",children:e.jsx(on,{})}),t==="compliance"&&e.jsx(Ne,{feature:"wcagEmReport",label:"WCAG-EM conformance report",children:e.jsx(Td,{})}),t==="schedules"&&e.jsx(Ne,{feature:"scheduledAudits",label:"Scheduled audits",children:e.jsx(Od,{})}),t==="risk"&&e.jsx(Ne,{feature:"riskDashboard",label:"Risk dashboard",children:e.jsx(Bd,{})}),t==="copilot"&&e.jsx(Ne,{feature:"aiCopilot",label:"AI Copilot",children:e.jsx(Hd,{})}),t==="ax-tree"&&e.jsx(Ne,{feature:"axTreeViewer",label:"AX-tree viewer",children:e.jsx(zd,{})}),t==="wcag3"&&e.jsx(Ne,{feature:"wcag3Preview",label:"WCAG 3 preview",children:e.jsx(Qa,{})}),t==="tokens"&&e.jsx(Ne,{feature:"designSystemAudit",label:"Design-system audit",children:e.jsx(qd,{})})]})]}),e.jsx($c,{}),e.jsx(Rc,{}),e.jsx(Nc,{}),e.jsx(da,{}),e.jsx(js,{})]})}class iu extends Ye.Component{constructor(){super(...arguments);ws(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{Ac as A,lc as C,iu as E,Wl as M,Oa as P,Za as a,Br as b,It as c,hs as d,en as e,_a as f,yt as g,Gr as h,Le as i,Pr as j,Fr as k,je as l,rn as m,ru as n,nu as o,Wr as p,Ra as r,Vr as s,b as u,_r as w};