@wcag-checkr/ci 1.0.18 → 1.0.19

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-d21LPHZR.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-DAZnNefT.js","assets/diff-CECbooHD.js","assets/ai-usage-log-HdIilbbf.js","assets/copy-ai-fixer-prompt-JItHLeHQ.js","assets/site-report-renderer-B5INfVSh.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-d21LPHZR.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-DAZnNefT.js","assets/diff-CECbooHD.js","assets/ai-usage-log-HdIilbbf.js","assets/copy-ai-fixer-prompt-1eFKA9Wr.js","assets/site-report-renderer-B5INfVSh.js"])))=>i.map(i=>d[i]);
2
2
  var Nn=Object.defineProperty;var kn=(t,s,a)=>s in t?Nn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Ns=(t,s,a)=>kn(t,typeof s!="symbol"?s+"":s,a);import{R as Xe,k as me,r as m,j as e,M as We,C as Ge,A as ks}from"./styles-clWOl0K-.js";import{k as ts,l as Ve,m as Sn,n as An,o as Ss,p as ba,q as xe,r as ss,t as Ee,S as Fe,u as As,b as _e,v as Ae,w as Te,x as as,y as va,z as Cn,A as In,B as En,D as Rn,E as Tn,f as $n,F as Un,g as Ln,s as ns,G as _n,H as Dn,N as On,I as rs,J as Fn,K as Ht,L as ya,M as zt,O as wa,P as Mn,Q as Pn,R as Gn,T as Vn,h as Wn,U as Bn,V as Hn,W as zn,X as Kn,Y as qn,Z as Qn,_ as Yn,$ as Jn,a0 as ja,a1 as Xn,a2 as Zn,a3 as Ze,a4 as vt,a5 as er,a6 as tr,a7 as Cs,a8 as sr,a9 as Is,aa as ar,ab as nr,ac as rr,ad as ir,ae as or,af as lr,ag as cr,ah as dr,ai as ur,aj as Na,ak as pr,al as Es,am as Rs,an as Lt,ao as hr,ap as Ts,aq as mr,ar as xr,as as gr,i as fr,j as br}from"./scheduled-audit-runner-d21LPHZR.js";import{o as fe,r as ce,e as we,s as X,c as ka,f as be,h as Re,j as Sa,T as vr}from"./crash-reporter-DAZnNefT.js";import{_ as ve}from"./preload-helper-D7HrI6pR.js";import{g as Aa,f as Ct,t as rt,r as yr,B as Me,h as wr,i as is,j as ge,e as os,k as jr,o as De,m as Ca,u as Nr,n as It,p as kr,q as Sr,W as Ia,v as Ar,w as Cr,T as Ir,x as Er}from"./ai-usage-log-HdIilbbf.js";import{g as Ea,a as Rr,b as Ra}from"./diff-CECbooHD.js";import{s as Tr,t as $r}from"./design-system-audit-DpxJrxnb.js";const $s=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,i={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,i);return i},Ur=t=>t?$s(t):$s,Lr=t=>t;function _r(t,s=Lr){const a=Xe.useSyncExternalStore(t.subscribe,Xe.useCallback(()=>s(t.getState()),[t,s]),Xe.useCallback(()=>s(t.getInitialState()),[t,s]));return Xe.useDebugValue(a),a}const Us=t=>{const s=Ur(t),a=n=>_r(s,n);return Object.assign(a,s),a},Dr=t=>t?Us(t):Us,f=Dr(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 o=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:o,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}),ts(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(i=>i.id!==s?i:a==="seen"?{...i,seen:!0}:a==="dismissed"?{...i,dismissed:!0}:a==="acknowledged"?{...i,acknowledged:!0}:a==="clicked"?{...i,clicked:!0}:i).filter(i=>i.severity==="critical"?!i.acknowledged:!i.dismissed),o=r.filter(i=>!i.seen).length,l=r.some(i=>i.severity==="critical"&&!i.acknowledged);return{messages:r,unreadMessageCount:o,criticalUnacked:l}})}));async function ls(t,s={}){try{const a=await Ve(),n=a==null?void 0:a.find(r=>r.url===t);if(!n||n.results.length===0||!n.componentId)return console.warn("[crawl-page-loader] no cached crawl results for",t),!1;try{const{getResolutionsForPage:r}=await ve(async()=>{const{getResolutionsForPage:l}=await import("./scheduled-audit-runner-d21LPHZR.js").then(i=>i.b7);return{getResolutionsForPage:l}},__vite__mapDeps([0,1,2,3,4])),o=await r(t);f.getState().setResolutionsForUrl(t,o)}catch{}f.getState().setResults(n.results,n.delta,n.componentId),f.getState().setCrawlNavContext({mode:"page",url:t});try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:n.results.map(({screenshotDataUrl:r,...o})=>o),delta:n.delta,componentId:n.componentId,crawlNavContext:{mode:"page",url:t}}})}catch{}return s.switchToReport&&(f.getState().setView("report"),f.getState().setFindingsLens("overview")),!0}catch(a){return console.warn("[crawl-page-loader] loadCrawlPageIntoStore failed",a),!1}}const yt="sidePanel:lastAudit";function Or(){const t=[];return t.push(fe("AUDIT_PROGRESS_EVENT",s=>{const a=f.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||me.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`))})),t.push(fe("AUDIT_COMPLETE_EVENT",s=>{var i;f.getState().setResults(s.results,s.delta,s.componentId),f.getState().setCrawlNavContext(null);const a=s.results.reduce((d,p)=>d+p.violations.length,0),n=((i=s.delta)==null?void 0:i.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"}.`;me.polite(r);const o=f.getState().view;["compliance","guided","crawl"].includes(o)||(f.getState().setView("report"),f.getState().setFindingsLens("overview")),Mr({results:s.results,delta:s.delta,componentId:s.componentId}),Fr(s.results,s.delta,s.componentId)})),t.push(fe("AUDIT_FAILED_EVENT",s=>{f.getState().setError(s.error.message)})),t.push(fe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=f.getState().aiProgress;f.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||me.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(fe("AI_AUGMENTATION_FAILED_EVENT",s=>{f.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(fe("SCORECARD_UPDATED_EVENT",()=>{wt()})),t.push(fe("LICENSE_CHANGED_EVENT",()=>{Ta()})),t.push(fe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&me.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(fe("SITE_CRAWL_COMPLETE_EVENT",s=>{var l,i,d,p;const a=f.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null);const n=(i=(l=s.report.pages)==null?void 0:l[0])==null?void 0:i.url,r=((d=a.crawlNavContext)==null?void 0:d.mode)==="page"?a.crawlNavContext.url:null,o=!!r&&(s.report.pages??[]).some(c=>c.url===r);n&&!o&&ls(n,{switchToReport:!1}),me.polite(s.report.siteGrade==="pending"?`Site crawl complete. Grade pending — answer the ${((p=s.report.spotCheckGate)==null?void 0:p.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:c}=await ve(async()=>{const{loadSiteCrawlPerUrlResults:x}=await import("./scheduled-audit-runner-d21LPHZR.js").then(v=>v.b5);return{loadSiteCrawlPerUrlResults:x}},__vite__mapDeps([0,1,2,3,4])),{getResolutionsForPage:u}=await ve(async()=>{const{getResolutionsForPage:x}=await import("./scheduled-audit-runner-d21LPHZR.js").then(v=>v.b7);return{getResolutionsForPage:x}},__vite__mapDeps([0,1,2,3,4])),h=await c();if(!h||h.length===0)return;const g=f.getState().setResolutionsForUrl;await Promise.all(h.map(async x=>{try{const v=await u(x.url);g(x.url,v)}catch{}}))}catch(c){console.warn("[site-crawl] failed to pre-warm resolutions cache",c)}})()})),t.push(fe("SITE_CRAWL_FAILED_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),me.assertive(`Site crawl failed: ${s.error.message}`)})),t.push(fe("CRAWL_DISCOVERY_PROGRESS_EVENT",s=>{const a=f.getState();a.crawlDiscoveryStatus!=="discovering"&&a.setCrawlDiscoveryStatus("discovering"),a.setCrawlDiscoveryProgress(s.found,s.url),s.found===1&&me.polite("Discovering pages to review.")})),t.push(fe("CRAWL_DISCOVERY_COMPLETE_EVENT",s=>{const a=f.getState();a.setCrawlDiscoveryUrls(s.urls),a.setCrawlDiscoveryStatus("reviewing"),me.polite(`Discovery complete. ${s.urls.length} page${s.urls.length===1?"":"s"} found — review and choose which to audit.`)})),t.push(fe("CRAWL_DISCOVERY_FAILED_EVENT",s=>{const a=f.getState();a.resetCrawlDiscovery(),a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),me.assertive(`Page discovery failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Fr(t,s,a){var n,r;if(t.length!==0)try{const o=await Aa();if(!o.enabled)return;const l=f.getState().tier;if(ba(l)||!we(l,"autoExportAuditReports"))return;const i=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",d=[],p=f.getState().lastAuditWallClockMs??void 0;for(const c of o.formats)try{const u=await ce({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=Ct(c,a??null);rt(u.content,h),i&&await yr({url:i,exportedAt:new Date().toISOString(),format:c,filename:h}),d.push(h)}catch(u){console.warn(`[auto-export] format ${c} failed:`,u)}d.length>0&&me.polite(`Audit auto-exported ${d.length} file${d.length===1?"":"s"}.`)}catch(o){console.warn("[auto-export] failed:",o)}}async function Mr(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[yt]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Pr(){const s=(await chrome.storage.local.get(yt))[yt];s&&f.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete",crawlNavContext:s.crawlNavContext??null})}async function Gr(){await chrome.storage.local.remove(yt)}async function Et(){const t=f.getState();t.clearResults(),t.setSiteCrawlReport(null),t.setSiteCrawlError(null),t.setSiteCrawlStatus("idle"),await Gr();const{saveSiteCrawlReport:s}=await ve(async()=>{const{saveSiteCrawlReport:o}=await import("./scheduled-audit-runner-d21LPHZR.js").then(l=>l.b5);return{saveSiteCrawlReport:o}},__vite__mapDeps([0,1,2,3,4]));await s(null);const{clearAllCachedAudits:a}=await ve(async()=>{const{clearAllCachedAudits:o}=await import("./ai-usage-log-HdIilbbf.js").then(l=>l.R);return{clearAllCachedAudits:o}},__vite__mapDeps([4,2]));await a();const{clearAllResolutions:n}=await ve(async()=>{const{clearAllResolutions:o}=await import("./scheduled-audit-runner-d21LPHZR.js").then(l=>l.b7);return{clearAllResolutions:o}},__vite__mapDeps([0,1,2,3,4])),{clearAllInteractiveAuditResults:r}=await ve(async()=>{const{clearAllInteractiveAuditResults:o}=await import("./scheduled-audit-runner-d21LPHZR.js").then(l=>l.b8);return{clearAllInteractiveAuditResults:o}},__vite__mapDeps([0,1,2,3,4]));await Promise.all([n(),r()])}async function wt(){const t=await ce({type:"BASELINE_LIST"});f.getState().setBaselineList(t.items)}async function Ta(t){const s=await ce({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});f.getState().setTier(s.tier,{seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),$a()}async function $a(){const{fetchMessages:t}=await ve(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Xr);return{fetchMessages:n}},void 0),s=f.getState().userMode,a=await t(s);a&&f.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Vr(){async function t(){const s=await Sn();if(!s||An(s)==="expired"){Ss(null);return}Ss(s.config)}await t(),chrome.storage.onChanged.addListener((s,a)=>{a!=="local"||!("rubricConfigCache"in s)||t()})}async function Wr(){const s=(await ce({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="power"||s==="dev"?s:null;f.getState().setUserMode(a)}function Br(){return chrome.runtime.connect({name:"audit-keepalive"})}let jt=null;async function Hr(){if(jt===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(jt=t.id)}catch{}}function cs(){if(jt===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:jt}).catch(()=>{})}function Ne(t){cs(),f.getState().setSiteCrawlReport(null),ts(null).catch(()=>{}),X(t)}function zr(t){cs(),f.getState().setSiteCrawlReport(null),ts(null).catch(()=>{}),X(t)}const Kt="dismissedFindings";function Rt(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function tt(t){return`reading-order::${t}`}function st(t){return`tab-order::${t}`}function ds(t){return`violation::${t}`}async function Tt(){try{const t=await chrome.storage.local.get(Kt),s=t==null?void 0:t[Kt];if(s&&typeof s=="object")return s}catch{}return{}}async function us(t){await chrome.storage.local.set({[Kt]:t})}async function ps(t){return(await Tt())[Rt(t)]??{}}async function hs(t,s,a,n){const r=await Tt(),o=Rt(t),l=r[o]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[o]=l,await us(r)}async function at(t,s){if(s.length===0)return;const a=await Tt(),n=Rt(t),r=a[n]??{},o=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:o,snippet:l.snippet};a[n]=r,await us(a)}async function ms(t,s){const a=await Tt(),n=Rt(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await us(a))}const uu=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:hs,addDismissals:at,dismissalKeyForReadingOrder:tt,dismissalKeyForTabOrder:st,dismissalKeyForViolation:ds,getDismissalsForUrl:ps,removeDismissal:ms},Symbol.toStringTag,{value:"Module"}));function Kr({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[o,l]=m.useState(!0),[i,d]=m.useState(""),[p,c]=m.useState(!1),[u,h]=m.useState(null);async function g(x){var v;if(x.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const j=await ce({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:o,replyEmail:i.trim()||void 0});j.success?(h({ok:!0,msg:`Sent (ref: ${j.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((v=j.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:x=>a(x.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:x=>r(x.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:i,onChange:x=>d(x.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:o,onChange:x=>l(x.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 Ls({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 Nt=ka("messages-client"),qr="https://api.wcagcheckr.com",Ua="wcagcheckr",Qr=1e4;function Yr(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function La(t,s){const a=await Ea();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Yr()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${qr}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Qr)})}async function Jr(t){if(!await Ea())return null;try{const s=await La(`/v1/products/${Ua}/messages`,{userMode:t??null});return s.ok?await s.json():(Nt.warn("fetchMessages http",s.status),null)}catch(s){return Nt.warn("fetchMessages failed",s),null}}async function Pe(t,s){try{const a=await La(`/v1/products/${Ua}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Nt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Nt.warn("ackMessage failed",a),!1}}const Xr=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Pe,fetchMessages:Jr},Symbol.toStringTag,{value:"Module"})),Zr=["http:","https:"];function ei(t){try{const s=new URL(t);return Zr.includes(s.protocol)}catch{return!1}}function _s(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const o=t.indexOf("]",a+1);if(o!==-1&&t[o+1]==="("){const l=t.indexOf(")",o+2);if(l!==-1){const i=t.slice(a+1,o),d=t.slice(o+2,l);ei(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:i},`l-${n++}`)):s.push(e.jsx(m.Fragment,{children:i},`l-${n++}`)),a=l+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const o=t.indexOf("**",a+2);if(o!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,o)},`b-${n++}`)),a=o+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const o=t.indexOf("*",a+1);if(o!==-1&&t[o+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,o)},`i-${n++}`)),a=o+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 _a({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],o=0;function l(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:_s(d)},`p-${o++}`)),r=[]}function i(){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:_s(d)},p))},`u-${o++}`)),n=[])}for(const d of s){const p=d.trimEnd();if(p===""){l(),i();continue}const c=/^[-*]\s+(.*)$/.exec(p);if(c){l(),n.push(c[1]);continue}i(),r.push(p)}return l(),i(),e.jsx("div",{className:"space-y-1.5",children:a})}const ti={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},si={critical:"bg-rose-50 border-rose-200"};function Da(){const t=f(h=>h.unreadMessageCount),s=f(h=>h.messages),a=f(h=>h.applyMessageAck),[n,r]=m.useState(!1),o=m.useRef(-1),[l,i]=m.useState(!1);m.useEffect(()=>{const h=s.filter(x=>!x.seen);if(h.length===0)return;const g=Math.max(...h.map(x=>x.id));if(g>o.current){o.current=g,i(!0);const x=setTimeout(()=>i(!1),1500);return()=>clearTimeout(x)}},[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(ai,{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(ni,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function ai({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 ni({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=m.useRef(null);return m.useEffect(()=>{const o=i=>{r.current&&(r.current.contains(i.target)||s())},l=i=>{i.key==="Escape"&&s()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",o),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:()=>{$a()},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(o=>e.jsx("li",{className:`p-3 ${o.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${ti[o.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:o.title}),o.dismissible&&o.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(o),"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(_a,{source:o.bodyMd})}),o.ctaLabel&&o.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(o),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:o.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(o.createdAt).toLocaleString()})]})]})},o.id))})]})}function Oa(){const t=f(o=>o.messages),s=f(o=>o.applyMessageAck),a=t.find(o=>o.severity==="critical"&&!o.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 ${si.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(_a,{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 ri=[{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 Fa(){const t=f(n=>n.userMode)??"owner",s=f(n=>n.setUserMode);function a(n){n!==t&&(s(n),chrome.storage.local.set({userMode:n,v2UiEnabled:n==="power"}),X({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:ri.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 ii=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function oi(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function li(){var p,c;const t=f(u=>u.view),s=f(u=>u.setView);f(u=>u.setUserMode);const a=f(u=>u.results),n=f(u=>u.status),[r,o]=m.useState(!1),l=((p=a[0])==null?void 0:p.pageUrl)??((c=a[0])==null?void 0:c.scope),i=oi(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(Fa,{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Da,{}),e.jsx(Ls,{onClick:()=>void X({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Ls,{onClick:()=>o(!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&&i&&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 ${i}`,children:i}),e.jsx("button",{type:"button",onClick:()=>void Et(),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(ci,{view:t,setView:s}),e.jsx(We,{open:r,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Kr,{onClose:()=>o(!1)})})]})}function ci({view:t,setView:s}){const a=m.useRef([]),n=f(i=>i.results),r=ii.filter(i=>!i.hideWhenIdle||n.length>0);function o(i){var c;const d=(i+r.length)%r.length,p=r[d];p&&(s(p.slug),(c=a.current[d])==null||c.focus())}function l(i,d){switch(i.key){case"ArrowRight":i.preventDefault(),o(d+1);break;case"ArrowLeft":i.preventDefault(),o(d-1);break;case"Home":i.preventDefault(),o(0);break;case"End":i.preventDefault(),o(r.length-1);break}}return e.jsx("nav",{className:"flex gap-1","aria-label":"Primary navigation",role:"tablist",children:r.map((i,d)=>{const p=t===i.slug;return e.jsx("button",{ref:c=>{a.current[d]=c},role:"tab","aria-selected":p,tabIndex:p?0:-1,onClick:()=>s(i.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:i.label},i.slug)})})}function di({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 ui="https://wcagcheckr.com/upgrade";function pi(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(null),[d,p]=m.useState(Me),[c,u]=m.useState(Me[0].id),[h,g]=m.useState("none"),[x,v]=m.useState(null),j=f(L=>L.status),I=f(L=>L.tier),E=f(L=>L.results.length>0),A=j==="running";m.useEffect(()=>{Promise.all([ce({type:"SETTINGS_GET",key:"matrixPresets"}),ce({type:"SETTINGS_GET",key:"activePresetId"})]).then(([L,F])=>{const O=Array.isArray(L.data)?L.data:null;p(O&&O.length>0?O:Me),typeof F.data=="string"&&u(F.data)})},[]);function S(L){const F=d.find(O=>O.id===L);F&&(u(L),X({type:"SETTINGS_SET",key:"activePresetId",value:L}),X({type:"SETTINGS_SET",key:"stateMatrix",value:F.matrix}))}const N=we(I,"storybookAutoIterate");m.useEffect(()=>{const L=fe("ELEMENT_PICKED_EVENT",(O,$)=>{n(!1);const Z=$.frameId;G(Z),o({selector:O.selector,frameId:Z,speech:O.speech})}),F=fe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{L(),F()}},[]);async function b(){const L=await xe();L&&(n(!0),await be(L,{type:"PICKER_ACTIVATE_REQUEST",tabId:L}))}function k(){r&&(G(r.frameId),Ne({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),f.getState().startNewScan())}function C(){if(!N){i("storybook:auto-iterate");return}G(),Ne({type:"START_AUDIT",mode:"storybook-all"}),f.getState().startNewScan()}function y(){G(),Ne({type:"START_AUDIT",mode:"all-frames"}),f.getState().startNewScan()}function R(){G(),Ne({type:"START_AUDIT",mode:"full-page"}),f.getState().startNewScan()}function U(){G(),Ne({type:"START_AUDIT",mode:"full-page",verifyFixesOnly:!0}),f.getState().startNewScan()}function M(){G(),Ne({type:"START_AUDIT",mode:"quick-scan"}),f.getState().startNewScan()}function te(){G(),Ne({type:"START_AUDIT",mode:"parallel-scan"}),f.getState().startNewScan()}function P(){X({type:"CANCEL_AUDIT"})}async function G(L){f.getState().setPinned(null);const F=await xe();if(F)try{await be(F,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:F},L)}catch{}}async function T(L){v(null);const F=await xe();if(!F){v("No audited tab; open a page first.");return}if(L==="none"){const $=await ce({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:F});$.ok||v($.error??"Failed to clear throttle."),g("none");return}const O=await ce({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:F,profile:L});if(!O.ok){v(O.error??"Failed to apply throttle.");return}g(L)}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:L=>s(L.target.value),disabled:A||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)",N?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:L=>S(L.target.value),disabled:A||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(L=>e.jsx("option",{value:L.id,children:L.name},L.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:L=>void T(L.target.value),disabled:A||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(mi,{picking:a,picked:r,isRunning:A,onPick:b,onRun:k,onClearPick:()=>o(null)}):t==="full-page"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,disabled:A,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:A?"Auditing…":"Scan page"}),e.jsx("button",{onClick:U,disabled:A||!E,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:E?"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:A?"Auditing…":"Verify fixes (skip passed)"})]}):t==="quick-scan"?e.jsx("button",{onClick:M,disabled:A,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:A?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:te,disabled:A,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:A?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:y,disabled:A,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:A?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:C,disabled:A,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:A?"Auditing…":"Audit all stories"}),A&&e.jsx("button",{onClick:P,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!A&&E&&e.jsx("button",{type:"button",onClick:()=>void Et(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),x&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",x]}),t==="single-element"&&r&&!a&&!A&&e.jsx(xi,{selector:r.selector,onRepick:b,onClear:()=>o(null)})]}),e.jsx(We,{open:l!==null,onClose:()=>i(null),title:"Upgrade to continue",children:e.jsx(di,{feature:l??"",upgradeUrl:ui})})]})}function hi({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 mi({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:o}){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(hi,{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 xi({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 gi={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},fi={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function bi(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState("off"),d=f(x=>x.results),p=f(x=>x.tier),c=d.flatMap(x=>x.violations);if(!we(p,"visualizers"))return null;async function u(x){const v=await xe();v&&(i(x),x==="off"?await be(v,{type:"VISION_SIMULATOR_CLEAR",tabId:v}).catch(()=>{}):await be(v,{type:"VISION_SIMULATOR_APPLY",tabId:v,mode:x}).catch(()=>{}))}async function h(x){const v=await xe();if(v){if(t&&await be(v,{type:gi[t],tabId:v}).catch(()=>{}),t===x){s(null);return}await be(v,{type:fi[x],tabId:v}).catch(()=>{}),s(x)}}async function g(){const x=await xe();if(x){if(a){await be(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),o(null);return}if(c.length===0){o("Run an audit first.");return}try{const v=await Re(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:c});n(!0),o(`Previewing ${v.visualFixCount} visual fix${v.visualFixCount===1?"":"es"} + ${v.annotationCount} annotation${v.annotationCount===1?"":"s"}.`)}catch{o("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(ze,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>h("outline")}),e.jsx(ze,{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(ze,{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(ze,{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(ze,{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:x=>void u(x.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 ze({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 ke({feature:t,label:s,children:a}){const n=f(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 vi(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 yi(){const t=f(d=>d.status),s=f(d=>d.progress),a=f(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}`,o=n?"reading order · tab order · typography · CSS vars · AI candidates":vi(s.currentState),l=n?100:s.current/s.total*100,i=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(Ds,{label:r,detail:o,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"}),i&&e.jsx(Ds,{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 Ds({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:o,barClass:l,fillClass:i}){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":o,children:e.jsx("div",{className:`h-full transition-all ${i}`,style:{width:`${a}%`}})})]})}function Os(t){if(!t)return"";try{return new URL(t).host}catch{return t}}function wi({onView:t,viewingRun:s,crawlOnly:a}){var d,p;const n=f(c=>c.siteCrawlReport),r=f(c=>c.results),o=f(c=>c.siteCrawlStatus)==="running",l=f(c=>c.status)==="running";if(s||o||l)return null;let i=null;if(n)i=`Last crawl · ${Os(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);i=`Last audit · ${Os(c)} · ${u} finding${u===1?"":"s"}`}return i?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:i,children:i}),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 ji(){const t=new Set;for(const s of Fe)for(const a of s.axeRules)t.add(a);return t}function Ma(t,s,a={}){const n=a.excludeAckedMatchKeys?t.filter(i=>!a.excludeAckedMatchKeys.has(i.matchKey)):t,r=ss(n),o=new Set(r.map(i=>Ee(i.ruleId,i.target.selector)));let l=0;for(const i of s){if(i.verdict!=="fail")continue;const d=Ee(i.ruleId,i.selector);o.has(d)||(o.add(d),l++)}return r.length+l}function Pa(t,s,a,n){const r=new Set;for(const o of t)a.has(o.matchKey)||n.has(`violation::${o.matchKey}`)||r.add(`${o.ruleId}::${o.target.selector}`);for(const o of s)o.verdict==="fail"&&r.add(`${o.ruleId}::${o.selector}`);return r.size}function Ni(t,s,a,n){const r=new Set;for(const o of t)a.has(o.matchKey)||n.has(`violation::${o.matchKey}`)||o.wcagCriterion&&r.add(o.wcagCriterion);for(const o of s)o.verdict==="fail"&&o.wcagCriterion&&r.add(o.wcagCriterion);return Array.from(r).sort()}function ki(t,s,a={}){const n=ji(),o=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),l=ss(o),i={critical:0,serious:0,moderate:0,minor:0};for(const c of l)i[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),i.serious++)}return{total:i.critical+i.serious+i.moderate+i.minor,counts:i,representatives:l}}function xs(t){var o,l;const s=((o=t[0])==null?void 0:o.pageUrl)??((l=t[0])==null?void 0:l.scope)??"",a=f(i=>i.setResolutionsForUrl),[n,r]=m.useState(()=>{if(!s)return[];const i=f.getState().resolutionsByUrl[s];return i?As(i,t):[]});return m.useEffect(()=>{if(!s){r([]);return}let i=!1;return _e(s).then(d=>{i||(a(s,d),r(As(d,t)))}),()=>{i=!0}},[s,t,a]),n}const Si=[{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 Ai(){const t=f(n=>n.results),s=f(n=>n.status),a=f(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(Ci,{results:t,status:s,setView:a}),e.jsx(Ii,{setView:a})]})}function Ci({results:t,status:s,setView:a}){var v,j;const n=xs(t),r=f(I=>I.acknowledgedKeys),o=f(I=>I.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(I=>I.violations),i=ss(l),d=((v=t[0])==null?void 0:v.pageUrl)??((j=t[0])==null?void 0:j.scope)??"audited page",p=t.length,c=Pa(l,n,r,o),u=l.filter(I=>!r.has(I.matchKey)&&!o.has(`violation::${I.matchKey}`)),h=Ma(u,n),g=3,x=c>0&&c<=g?i.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 →"})]}),x.length>0&&e.jsx("ul",{className:"border-t border-slate-200 divide-y divide-slate-100","aria-label":"Violations inline list",children:x.map(I=>{var S;const E=((S=I.target)==null?void 0:S.selector)??"(no selector)",A=E.length>50?E.slice(0,47)+"…":E;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:`${I.description??I.ruleId} — ${E}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${I.impact==="critical"?"bg-rose-200 text-rose-900":I.impact==="serious"?"bg-orange-200 text-orange-900":I.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:I.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:I.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:A})]})},`${I.ruleId}::${E}`)})})]})}function Ii({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:Si.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 it="aiConfig";function gs(){const[t,s]=m.useState(!1);return m.useEffect(()=>{function a(r){s(!!(r&&r.enabled&&r.apiKey))}chrome.storage.local.get(it).then(r=>a(r[it])).catch(()=>s(!1));const n=(r,o)=>{var l;o!=="local"||!(it in r)||a((l=r[it])==null?void 0:l.newValue)};return chrome.storage.onChanged.addListener(n),()=>chrome.storage.onChanged.removeListener(n)},[]),t}const Ei={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 Ri({violations:t,componentId:s}){var Y,ne,K,le,ie,q,je,he;const[a,n]=m.useState([]),[r,o]=m.useState({}),[l,i]=m.useState([]),[d,p]=m.useState([]),[c,u]=m.useState(new Set),[h,g]=m.useState(null),[x,v]=m.useState({}),[j,I]=m.useState(new Set),[E,A]=m.useState(null),S=f(H=>H.status),N=f(H=>H.progress),b=f(H=>H.freshThisSession),k=f(H=>H.results),C=f(H=>H.acknowledgedKeys),y=(Y=k[0])==null?void 0:Y.startedAt,R=((ne=k[0])==null?void 0:ne.pageUrl)??((K=k[0])==null?void 0:K.scope)??null;m.useEffect(()=>{if(!s){n([]),o({});return}let H=!1;return chrome.storage.local.get("igtRuns").then(oe=>{if(H)return;const B=((oe==null?void 0:oe.igtRuns)??{})[s]??{};n(Object.values(B))}),Promise.all([Ae(s),Te([s])]).then(([oe,_])=>{if(H)return;const B=new Set(_.map(Q=>Q.criterionId)),V={},re=[];for(const Q of oe){const J=B.has(Q.criterionId)?"pass":Q.verdict;Q.criterionId==="2.4.3"?V.focusOrder=J:Q.criterionId==="2.1.2"?V.keyboardTrap=J:Q.criterionId==="2.4.7"?V.focusVisible=J:Q.criterionId==="1.3.2"?V.readingOrder=J:Q.criterionId==="1.4.11"&&(V.nonTextContrast=J),re.push({criterionId:Q.criterionId,ruleId:`ai-walkthrough-${Q.criterionId}`,pageUrl:Q.pageUrl,verdict:J,reasoning:B.has(Q.criterionId)?`Human verified: ${Q.reasoning}`:Q.reasoning})}o(V),i(re)}),()=>{H=!0}},[s]),m.useEffect(()=>{if(!R){p([]);return}let H=!1;return _e(R).then(oe=>{H||p(oe)}),()=>{H=!0}},[R,k]);const U=xs(k),M=as({violations:t,auditRan:k.length>0,manualRuns:a,workflows:ge,heuristicCounts:{tabOrder:((ie=(le=k[0])==null?void 0:le.tabOrderIssues)==null?void 0:ie.length)??0,readingOrder:((je=(q=k[0])==null?void 0:q.readingOrderIssues)==null?void 0:je.length)??0},interactiveAuditVerdicts:r,aiResolvedFails:U.map(H=>({ruleId:H.ruleId,impact:"serious",selector:H.selector}))}),P=new Set(k.map(H=>H.pageUrl??H.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",G=k.length>0?va(k,{runs:a,workflows:ge},"2.1","AA",C,d,l,P):void 0,T=k.length>0?wr(is({audits:k,igtRuns:a,workflows:ge,acknowledgedMatchKeys:C,incompleteResolutions:d,interactiveAuditResults:l,auditScope:P}),ge):void 0,F=(G?G.failingCriteria.length+G.inconclusiveCriteria.length+G.untestedCriteria.length:0)===0&&!!G;async function O(H){var re;if(!R||!((re=G==null?void 0:G.inconclusiveReasons)!=null&&re[H]))return;const _=G.inconclusiveReasons[H].filter(Q=>Q.source==="axe-incomplete"&&Q.elements&&Q.elements.length>0);if(_.length===0)return;u(Q=>new Set(Q).add(H)),g(null);const B=[];let V=0;try{for(const J of _){const pe=await X({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:J.ruleOrStepId,pageUrl:J.pageUrl??R,wcagCriterion:H,elements:J.elements??[],targetLevel:"AA"});if(pe!=null&&pe.unavailableReason){g(pe.unavailableReason);break}pe!=null&&pe.resolutions&&(B.push(...pe.resolutions),V+=pe.totalCostUsd??0)}if(R){const J=await _e(R);p(J)}const Q={total:B.length,pass:B.filter(J=>J.verdict==="pass").length,fail:B.filter(J=>J.verdict==="fail").length,uncertain:B.filter(J=>J.verdict==="uncertain").length,costUsd:V,resolutions:B};v(J=>({...J,[H]:Q}))}finally{u(Q=>{const J=new Set(Q);return J.delete(H),J})}}function $(H){I(oe=>{const _=new Set(oe);return _.has(H)?_.delete(H):_.add(H),_})}const Z=((he=k[0])==null?void 0:he.startedAt)??null,ae=s&&Z?`${s}::${Z}`:null;if(m.useEffect(()=>{if(!ae||!G||E===ae||S!=="complete")return;const H=G.inconclusiveCriteria.filter(oe=>{var B;return(((B=G.inconclusiveReasons)==null?void 0:B[oe])??[]).some(V=>V.source==="axe-incomplete"&&V.elements&&V.elements.length>0)});if(H.length===0){A(ae);return}A(ae),(async()=>{for(const oe of H)try{await O(oe)}catch{}})()},[ae,G,S]),S==="running")return e.jsx(Oi,{current:N==null?void 0:N.current,total:N==null?void 0:N.total});async function z(H){var pe,Be;if(!R)return;const oe=((pe=G==null?void 0:G.inconclusiveReasons)==null?void 0:pe[H])??[],_=((Be=G==null?void 0:G.failingReasons)==null?void 0:Be[H])??[],B=[],V=new Set;for(const ue of oe){if(ue.source!=="axe-incomplete"||!ue.elements)continue;const Ce=ue.pageUrl??R;for(const Ie of ue.elements){const He=`${Ce}::${ue.ruleOrStepId}::${Ie.selector}`;V.has(He)||(V.add(He),B.push({ruleId:ue.ruleOrStepId,pageUrl:Ce,selector:Ie.selector}))}}for(const ue of _){if(ue.source!=="ai"||!ue.selector)continue;const Ce=ue.ruleOrStepId.startsWith("ai-resolved::")?ue.ruleOrStepId.slice(13):ue.ruleOrStepId,Ie=ue.pageUrl??R,He=`${Ie}::${Ce}::${ue.selector}`;V.has(He)||(V.add(He),B.push({ruleId:Ce,pageUrl:Ie,selector:ue.selector}))}if(B.length===0)return;const re=new Date().toISOString(),Q=[];for(const ue of B){const Ce=d.find(Ie=>Ie.pageUrl===ue.pageUrl&&Ie.ruleId===ue.ruleId&&Ie.selector===ue.selector);Ce&&Ce.verdict==="pass"&&Ce.reasoning.startsWith("Marked as visually verified")||Q.push({pageUrl:ue.pageUrl,ruleId:ue.ruleId,selector:ue.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${re.slice(0,10)}.`,resolvedAt:re,costUsd:0,wcagCriterion:H})}if(Q.length===0)return;await Cn(Q);const J=await _e(R);p(J),v(ue=>({...ue,[H]:{total:Q.length,pass:Q.length,fail:0,uncertain:0,costUsd:0,resolutions:Q}}))}const ee=(()=>{if(!G)return null;if(F)return{kind:"conformant",text:`WCAG ${G.targetLevel} Status: Conformant`,detail:"All applicable criteria pass automated + AI checks."};const H=G.inconclusiveCriteria.length,oe=G.failingCriteria.length,_=G.untestedCriteria.length,B=[];if(oe>0){const re=G.failingCriteria.slice(0,4).join(", ")+(oe>4?`, +${oe-4}`:"");B.push(`${oe} ${oe===1?"criterion":"criteria"} failing (${re})`)}if(H>0){const re=G.inconclusiveCriteria.slice(0,4).join(", ")+(H>4?`, +${H-4}`:"");B.push(`${H} inconclusive (${re})`)}if(_>0){const re=G.untestedCriteria.slice(0,4).join(", ")+(_>4?`, +${_-4}`:"");B.push(`${_} untested (${re})`)}const V=oe>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":_>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 ${G.targetLevel} Status: Not conformant`,detail:`${B.join(" · ")}. ${V}`}})();let se=0;for(const H of ge){const oe=a.find(B=>B.workflowId===H.id);if(!oe)continue;H.steps.every(B=>{const V=oe.steps[B.id];return(V==null?void 0:V.status)==="pass"||(V==null?void 0:V.status)==="fail"||(V==null?void 0:V.status)==="skip"||(V==null?void 0:V.status)==="not-applicable"})&&se++}const w=new Set;for(const H of t)C.has(H.matchKey)||w.add(`${H.ruleId}::${H.target.selector}`);for(const H of U)H.verdict==="fail"&&w.add(`${H.ruleId}::${H.selector}`);const D=w.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!b&&y&&e.jsx(Fi,{scannedAt:y}),ee&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${ee.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:[ee.kind==="conformant"?"✓ ":"✗ ",ee.text]}),e.jsx("p",{className:"mt-0.5",children:ee.detail})]}),M.isLawsuitRisk&&e.jsx(Ui,{areas:M.warningAreas}),e.jsx(Li,{grades:M.subGrades,uncategorized:ki(t,d,{excludeAckedMatchKeys:C})}),G&&e.jsx(Ti,{coverage:G,onResolveWithAi:O,onMarkVisuallyVerified:z,resolving:c,resolveError:h,lastResolveResult:x,expandedResultFor:j,onToggleResultDetail:$,violations:t}),T&&e.jsx($i,{layers:T}),e.jsx(Di,{violationsRemaining:D,manualCompleted:se,manualTotal:ge.length}),se>0||k.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:se})," of ",e.jsx("strong",{children:ge.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:`${se/ge.length*100}%`}})})]}):null]})}function Ti({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:o,expandedResultFor:l,onToggleResultDetail:i,violations:d}){const p=f(A=>A.setView),c=f(A=>A.setFindingsLens),u=f(A=>A.setPendingAreaExpand);function h(A){const S=In(A,d);p("report"),S?(c("per-area"),u(S)):c("violations")}const g=t.untestedCriteria.length+t.inconclusiveCriteria.length,[x,v]=m.useState(g>0&&g<=3),j=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),I=t.canClaimConformance,E=[];return t.failingCriteria.length>0&&E.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&E.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&E.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${I?"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 ${I?"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 (",j,"%)"]}),I&&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)."]}),!I&&(()=>{const A=[];t.failingCriteria.length>0&&A.push("failing"),t.inconclusiveCriteria.length>0&&A.push("inconclusive"),t.untestedCriteria.length>0&&A.push("untested");const S=A.length===0?"unresolved":A.length===1?A[0]:A.length===2?`${A[0]} or ${A[1]}`:`${A.slice(0,-1).join(", ")}, or ${A[A.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",S,"."]})})(),!I&&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."]}),!I&&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."]})]}),!I&&E.length>0&&e.jsx("button",{type:"button",onClick:()=>v(A=>!A),className:"text-[11px] underline shrink-0 self-start",children:x?"hide":"show list"})]}),x&&!I&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[E.map(A=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${A.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[A.kind==="untested"?"Untested":A.kind==="inconclusive"?"Inconclusive":"Failing"," (",A.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:A.ids.map(S=>{var M,te;const N=A.kind==="inconclusive"?(M=t.inconclusiveReasons)==null?void 0:M[S]:void 0,b=A.kind==="failing"?(te=t.failingReasons)==null?void 0:te[S]:void 0,k=N==null?void 0:N.some(P=>P.source==="axe-incomplete"&&P.elements&&P.elements.length>0),C=b==null?void 0:b.some(P=>P.source==="ai"),y=(n==null?void 0:n.has(S))??!1,R=o==null?void 0:o[S],U=(l==null?void 0:l.has(S))??!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(S),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 ${S}`,children:["· ",S]}),(A.kind==="inconclusive"&&k||A.kind==="failing"&&C)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[A.kind==="inconclusive"&&s&&S!=="1.4.3"&&S!=="1.4.6"&&e.jsx("button",{type:"button",disabled:y,onClick:()=>s(S),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:y?"Resolving…":R?"✨ Resolve again →":"✨ Resolve with AI →"}),A.kind==="inconclusive"&&(S==="1.4.3"||S==="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:y,onClick:()=>a(S),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:A.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"})]})]}),R&&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 ",R.total," ",R.total===1?"verdict":"verdicts",":",R.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",R.pass," pass"]}),R.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",R.fail," fail"]}),R.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",R.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",R.costUsd.toFixed(4)]}),i&&e.jsx("button",{type:"button",onClick:()=>i(S),className:"ml-auto text-[10px] underline text-brand-700",children:U?"hide reasoning":"show reasoning"})]}),R.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",R.uncertain," ",R.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),R.pass===R.total&&R.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."]}),U&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:R.resolutions.map((P,G)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:P.verdict==="pass"?"text-emerald-700 font-semibold":P.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:P.verdict==="pass"?"✓":P.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:P.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:P.reasoning})]},G))})]}),b&&b.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:b.map((P,G)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[P.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:P.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),P.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:P.ruleOrStepId})," fail — "]}),P.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:P.ruleOrStepId})," fail — "]}),P.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:P.selector}),P.notes&&e.jsx("span",{className:"text-rose-700",children:P.notes})]},G))}),N&&N.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:N.map((P,G)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[P.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:P.ruleOrStepId})," — "]}),P.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:P.ruleOrStepId})," skipped — "]}),P.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:P.ruleOrStepId})," — "]}),P.resolutionHint,P.elements&&P.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",P.elements.length===1?"element":`${P.elements.length} elements`,":"," ",P.elements.slice(0,3).map((T,L,F)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:T.selector}),L<F.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},L)),P.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",P.elements.length-3," more"]})]})]},G))}):A.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.)"})]},S)})})]},A.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 Fs={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 $i({layers:t}){const s=f(o=>o.setView),a=f(o=>o.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(o=>{const l=t[o],i=l.coveredCriteria.length,d=l.failing.length,p=l.inconclusive.length,c=l.unevaluated.length,u=l.cleared,h=d>0||p>0,g=i>0&&!h&&c===0,x=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:Fs[o].label}),e.jsx("span",{className:`font-mono text-[10px] ${x}`,children:i===0?"no coverage yet":`${u}/${i}`}),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:Fs[o].hint}),o==="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 →"})]})]},o)})})]})}function Ui({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 Li({grades:t,uncategorized:s}){const a=f(i=>i.setView),n=f(i=>i.setFindingsLens),r=f(i=>i.setPendingAreaExpand);function o(i){a("report"),n("per-area"),r(i)}function l(i){const d=i.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(i=>{const d=l(i),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 ${Ei[i.letter]}`,"aria-label":`Grade ${i.letter}`,children:i.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:i.label}),e.jsx(_i,{grade:i,onOpenGuided:()=>a("guided")})]});return e.jsx("li",{children:d?e.jsx("button",{type:"button",onClick:()=>o(i.id),className:`${p} ${c}`,"aria-label":`Open ${i.label} violations`,children:u}):e.jsx("div",{className:p,children:u})},i.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(i=>i.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 i=[];return s.counts.critical>0&&i.push(`${s.counts.critical} critical`),s.counts.serious>0&&i.push(`${s.counts.serious} serious`),s.counts.moderate>0&&i.push(`${s.counts.moderate} moderate`),s.counts.minor>0&&i.push(`${s.counts.minor} minor`),i.join(" · ")})()})]})]})]})}function _i({grade:t,onOpenGuided:s}){const a=i=>{if(!i)return"";const d=ge.find(p=>p.id===i);return(d==null?void 0:d.name)??i};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 i=t.verifiedAt?Ga(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",i?` ${i} ago`:""]})}const{critical:n,serious:r,moderate:o,minor:l}=t.counts;if(n>0||r>0||o>0||l>0){const i=[];return n>0&&i.push({label:"critical",n,cls:"text-rose-700"}),r>0&&i.push({label:"serious",n:r,cls:"text-orange-700"}),o>0&&i.push({label:"moderate",n:o,cls:"text-amber-700"}),l>0&&i.push({label:"minor",n:l,cls:"text-slate-600"}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:i.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 Di({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=f(l=>l.setView),r=f(l=>l.setFindingsLens),o=[{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:o.map((l,i)=>{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:[i+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:"✓"})]},i)})})]})}function Oi({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 Fi({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 (",Ga(s)," old). Re-scan to grade the current page state."]})]})}function Ga(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 Mi(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 Pi({coverage:t}){const s=Mi(t);if(!s)return null;const{untested:a,inconclusive:n,remaining:r,failing:o,target:l}=s;if(s.kind==="incomplete"){const i=[];return a>0&&i.push(`${a} not yet checked`),n>0&&i.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 (",i.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 — ",o," 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 Va(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Ms(t){if(!Va())return!1;const s=chrome.devtools;return await new Promise(a=>{const r=`(function(){
3
3
  try {
4
4
  var el = document.querySelector(${JSON.stringify(t)});
@@ -15,7 +15,7 @@ var Nn=Object.defineProperty;var kn=(t,s,a)=>s in t?Nn(t,s,{enumerable:!0,config
15
15
  `),p=new URLSearchParams({"[Title]":l,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${p.toString()}`;return c.length>Zs&&(c=c.slice(0,Zs)),{url:c,title:l,description:d}}const ea=7800;function Wo(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(x=>`${x.ruleId}::${x.target.selector}`===u);if(g){g._states.includes(h)||g._states.push(h);continue}r.push({...c,_states:[h]})}const o=`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 i=l.join(`
16
16
  `),d=new URLSearchParams({"issue[title]":o,"issue[description]":i});let p=`${n}/-/issues/new?${d.toString()}`;return p.length>ea&&(p=p.slice(0,ea)),{url:p,title:o,description:i}}const ta=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Bo=["wcag-component-auditor","wcag-forensic-log"];async function Ho(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(ta);s=Object.keys(n).length,await chrome.storage.local.remove(ta)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Bo)try{await zo(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 zo(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 qt="accessibilityStatementInputs:v1";async function Ko(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(qt))[qt];return s&&typeof s=="object"?s:null}async function qo(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[qt]:t})}function Ka({open:t,onClose:s,results:a,siteCrawlSource:n}){const[r,o]=m.useState("eaa"),[l,i]=m.useState(""),[d,p]=m.useState(""),[c,u]=m.useState("partial"),[h,g]=m.useState(""),[x,v]=m.useState(""),[j,I]=m.useState(""),[E,A]=m.useState(""),[S,N]=m.useState("English"),[b,k]=m.useState("wcagcheckr (self-evaluation)"),[C,y]=m.useState("2.1"),[R,U]=m.useState("AA"),[M,te]=m.useState(!1),[P,G]=m.useState(null),T=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var Z,ae,z,ee;const $=await Ko();if($&&($.framing&&o($.framing),$.organizationName&&i($.organizationName),$.siteUrl&&p($.siteUrl),$.conformanceStatus&&u($.conformanceStatus),(Z=$.contact)!=null&&Z.email&&g($.contact.email),(ae=$.contact)!=null&&ae.phone&&v($.contact.phone),(z=$.contact)!=null&&z.formUrl&&I($.contact.formUrl),$.countryCode&&A($.countryCode),$.language&&N($.language),$.auditedBy&&k($.auditedBy),$.wcagVersion&&y($.wcagVersion),$.wcagLevel&&U($.wcagLevel)),!($!=null&&$.siteUrl)&&((ee=a[0])!=null&&ee.pageUrl))try{const se=new URL(a[0].pageUrl);p(`${se.protocol}//${se.host}/`)}catch{}$!=null&&$.conformanceStatus||u(Dn(a)),setTimeout(()=>{var se;return(se=T.current)==null?void 0:se.focus()},50)})()},[t,a]),!t)return null;function L(){var z;const $=new Date().toISOString().slice(0,10),Z=(z=a[0])!=null&&z.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):$,ae={};return h.trim()&&(ae.email=h.trim()),x.trim()&&(ae.phone=x.trim()),j.trim()&&(ae.formUrl=j.trim()),{framing:r,organizationName:l.trim(),siteUrl:d.trim(),conformanceStatus:c,preparedAt:$,evaluatedAt:Z,contact:ae,countryCode:E||null,language:S.trim()||"English",auditedBy:b.trim()||"wcagcheckr (self-evaluation)",wcagVersion:C,wcagLevel:R}}function F($){if(!$.organizationName)return"Organization name is required.";if(!$.siteUrl)return"Site URL is required.";try{new URL($.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!$.contact.email&&!$.contact.phone&&!$.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 O($){var z;G(null);const Z=L(),ae=F(Z);if(ae){G(ae);return}te(!0);try{await qo(Z);const ee=await ce({type:"EXPORT_REQUEST",format:$==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:n?[]:a,siteCrawlSource:n||void 0,statementInputs:Z}),se=(ee==null?void 0:ee.content)??"";if(!se||se.startsWith("# Accessibility statement — error")){G(se||"Export failed — no response.");return}try{await navigator.clipboard.writeText(se)}catch{}const w=new Blob([se],{type:$==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),D=URL.createObjectURL(w);typeof chrome<"u"&&((z=chrome.tabs)!=null&&z.create)?await chrome.tabs.create({url:D,active:!0}).catch(()=>{window.open(D,"_blank","noopener,noreferrer")}):window.open(D,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(D),6e4),s()}catch(ee){G(ee instanceof Error?ee.message:String(ee))}finally{te(!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:$=>$.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:()=>o("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:()=>o("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:T,type:"text",value:l,onChange:$=>i($.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:$=>p($.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:$=>u($.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:C,onChange:$=>y($.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:R,onChange:$=>U($.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:$=>g($.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:x,onChange:$=>v($.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:j,onChange:$=>I($.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:E,onChange:$=>A($.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(On).map(([$,Z])=>e.jsxs("option",{value:$,children:[$," — ",Z.name.replace(/^[A-Z]+\s*—\s*/,"")]},$))]}),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:S,onChange:$=>N($.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:b,onChange:$=>k($.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),P&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:P})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void O("markdown"),disabled:M,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:M?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void O("html"),disabled:M,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:M?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:M,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 qa(){const t=f(w=>w.delta),s=f(w=>w.componentId),a=f(w=>w.results),n=f(w=>w.tier),r=f(w=>w.baselineList),o=f(w=>w.siteCrawlReport),[l,i]=m.useState(""),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,g]=m.useState(""),[x,v]=m.useState(!1),[j,I]=m.useState(!1),[E,A]=m.useState(null),[S,N]=m.useState(null),[b,k]=m.useState(!1),[C,y]=m.useState(!1),[R,U]=m.useState(!1),[M,te]=m.useState(null),[P,G]=m.useState(!1);m.useEffect(()=>{Promise.all([ce({type:"SETTINGS_GET",key:"githubRepoUrl"}),ce({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),ce({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),ce({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([w,D,Y,ne])=>{i(typeof w.data=="string"?w.data:""),p(typeof D.data=="string"?D.data:""),u(typeof Y.data=="string"?Y.data:""),g(typeof ne.data=="string"?ne.data:"")})},[]),m.useEffect(()=>fe("BADGE_CLICKED_EVENT",D=>{const Y=`viol-row-${D.violationId}`,ne=document.getElementById(Y);ne&&(ne.scrollIntoView({behavior:"smooth",block:"center"}),ne.classList.add("ring-2","ring-rose-500"),setTimeout(()=>ne.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const w=await xe();w&&(R&&await be(w,{type:"BADGES_HIDE_REQUEST",tabId:w}).catch(()=>{}),P&&await be(w,{type:"HEATMAP_HIDE_REQUEST",tabId:w}).catch(()=>{}))})()},[]);async function T(){const w=await xe();if(!w){me.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(R){await be(w,{type:"BADGES_HIDE_REQUEST",tabId:w}).catch(()=>{}),U(!1),te(null);return}const D={critical:4,serious:3,moderate:2,minor:1},Y=new Map;for(const ie of a)for(const q of ie.violations)Y.has(q.matchKey)||Y.set(q.matchKey,q);const K=Array.from(Y.values()).sort((ie,q)=>D[q.impact]-D[ie.impact]).map((ie,q)=>({id:ie.matchKey,index:q+1,selector:ie.target.selector,impact:ie.impact,ruleId:ie.ruleId,wcagCriterion:ie.wcagCriterion}));if(K.length===0){me.polite("No violations to badge.");return}const le=await Re(w,{type:"BADGES_SHOW_REQUEST",tabId:w,violations:K}).catch(()=>null);le&&(U(!0),te({rendered:le.rendered,requested:le.requested,clustered:le.clustered}),me.polite(`${le.rendered} violation badges shown on the page.`))}async function L(){const w=await xe();if(!w){me.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(P){await be(w,{type:"HEATMAP_HIDE_REQUEST",tabId:w}).catch(()=>{}),G(!1);return}const D=new Map;for(const K of a)for(const le of K.violations)D.has(le.matchKey)||D.set(le.matchKey,le);const Y=Array.from(D.values()).map(K=>({selector:K.target.selector,impact:K.impact}));if(Y.length===0){me.polite("No violations to heatmap.");return}const ne=await Re(w,{type:"HEATMAP_SHOW_REQUEST",tabId:w,violations:Y}).catch(()=>null);ne&&(G(!0),me.polite(`Heatmap shown with ${ne.rendered} violation blobs.`))}const F=we(n,"exportJson"),O=we(n,"issueTrackers"),$=Sa(n).maxBaselines,Z=r.some(w=>w.componentId===s),ae=Z||r.length<$;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 z(){if(!s||a.length===0)return;const w=a.flatMap(q=>q.violations),D=a.flatMap(q=>q.announcements??[]),Y=a.flatMap(q=>q.focusEvents??[]),ne=a[0],le=(await ce({type:"SETTINGS_GET",key:"stateMatrix"})).data??os;await X({type:"BASELINE_SET",componentId:s,violations:w,announcements:D,focusEvents:Y,snapshotMeta:{url:window.location.href,axeVersion:ne.axeVersion,matrixConfig:le,capturedAt:new Date().toISOString()}});const ie=await ce({type:"BASELINE_COMPARE",componentId:s,currentViolations:w,announcements:D,focusEvents:Y,currentMatrix:le});f.getState().setDelta(ie.delta),me.polite(`Baseline saved for ${s}.`)}async function ee(){if(!s||!Z||!window.confirm(`Remove the saved baseline for "${s}"?
17
17
 
18
- Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await X({type:"BASELINE_DELETE",componentId:s});const D=a.flatMap(ie=>ie.violations),Y=a.flatMap(ie=>ie.announcements??[]),ne=a.flatMap(ie=>ie.focusEvents??[]),K=await ce({type:"BASELINE_COMPARE",componentId:s,currentViolations:D,announcements:Y,focusEvents:ne});f.getState().setDelta(K.delta);const le=await ce({type:"BASELINE_LIST"});f.getState().setBaselineList(le.items),me.polite(`Baseline cleared for ${s}.`)}async function se(w,D=!1){if(a.length===0)return;if(w==="ai-prompt"){const{copyAiFixerPrompt:B}=await ve(async()=>{const{copyAiFixerPrompt:V}=await import("./copy-ai-fixer-prompt-JItHLeHQ.js");return{copyAiFixerPrompt:V}},__vite__mapDeps([5,1,2]));await B({results:a,componentId:s,delta:D?void 0:t,siteCrawlReport:o});return}let Y;if((w==="defense-bundle"||w==="evidence-bundle"||w==="deposition-packet")&&s){const B=await chrome.storage.local.get("igtRuns"),re=((B==null?void 0:B.igtRuns)??{})[s]??{};Y=Object.values(re)}const le=await ce({type:"EXPORT_REQUEST",format:w,results:a,delta:D?void 0:t??void 0,manualRuns:Y,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:f.getState().lastAuditWallClockMs??void 0});if(w==="defense-bundle"||w==="evidence-bundle"||w==="deposition-packet"){const B=Ct(w,s);await Ca()?rt(le.content,B):N({open:!0,format:w,content:le.content,filename:B});return}if(w==="html-print"||w==="vpat"||w==="methodology-doc"||w==="conformance-crosswalk"||w==="executive-report"){De(le.content);return}const ie=w==="json"?"application/json":w==="sarif"?"application/sarif+json":w==="ticket-bundle"?"text/markdown":"application/xml",q=w==="junit"?"xml":w==="ticket-bundle"?"md":w,{body:je,type:he}=Nr(le.content,ie),H=new Blob([je],{type:he}),oe=URL.createObjectURL(H),_=document.createElement("a");_.href=oe,_.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${q}`,_.click(),URL.revokeObjectURL(oe)}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:z,disabled:!ae,title:ae?void 0:`Free tier limits you to ${$} 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"}),Z&&e.jsx("button",{onClick:ee,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 T(),"aria-pressed":R,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:R?"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:R?"Hide badges":"Show badges 🎯"}),R&&M&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[M.rendered," of ",M.requested," rendered",M.clustered>0?` · ${M.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void L(),"aria-pressed":P,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:P?"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:P?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(el,{disabled:!F,onExport:se,onAccessibilityStatement:()=>k(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta),canExport:w=>Le(n,w),onUpgrade:()=>y(!0)}),!ae&&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 w=Dt(t.new),D=Dt(t.persistent),Y=Dt(t.fixed),ne=[...w.review,...D.review];return e.jsxs(e.Fragment,{children:[e.jsx(qe,{title:"New",violations:w.findings,count:w.findings.length,accent:"red",actions:[...O&&l&&w.findings.length>0?[{label:"File GitHub issue",onClick:()=>Yo(l,s,w.findings)}]:[],...O&&d&&w.findings.length>0?[{label:"File Jira issue",onClick:()=>Jo(d,s,w.findings)}]:[],...O&&c&&w.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Xo(c,s,w.findings)}]:[],...O&&h&&w.findings.length>0?[{label:"File GitLab issue",onClick:()=>Zo(h,s,w.findings)}]:[]]}),e.jsx(qe,{title:"Persistent",violations:D.findings,count:D.findings.length,accent:"slate"}),e.jsx(qe,{title:"Fixed",violations:Y.findings,count:t.fixedCount,accent:"green"}),ne.length>0&&e.jsx(qe,{title:"Needs review (does not affect grade)",violations:ne,count:ne.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(qe,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),S&&e.jsx(za,{open:S.open,onClose:()=>N(null),format:S.format,content:S.content,filename:S.filename}),e.jsx(Ka,{open:b,onClose:()=>k(!1),results:a}),e.jsx(Ge,{open:C,onClose:()=>y(!1)}),x&&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"})]})]}),E&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",E.chromeStorageKeysCleared," chrome.storage key",E.chromeStorageKeysCleared===1?"":"s"," + ",E.indexedDbsCleared.length," database",E.indexedDbsCleared.length===1?"":"s",".",E.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",E.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:E?e.jsx("button",{type:"button",onClick:()=>{v(!1),A(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:j,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()=>{I(!0);try{const w=await Ho();A(w),await Et(),me.polite("Audit data reset. Ready for a fresh scan.")}catch(w){A({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[w instanceof Error?w.message:String(w)]})}finally{I(!1)}},disabled:j,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:j?"Resetting…":"Reset everything"})]})})]})})]})}const Qo={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Dt(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 qe({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:o}){const[l,i]=m.useState(!o);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 ${Qo[n]} ${o?"cursor-pointer select-none":""}`,onClick:o?()=>i(d=>!d):void 0,children:[o&&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:o?s.map((d,p)=>e.jsx(nt,{violation:d,alreadyAcknowledged:!0},p)):Oo(s).map(d=>e.jsx(Do,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Yo(t,s,a){if(a.length===0)return;const{url:n}=Po(t,s,a);It(n)}function Jo(t,s,a){if(a.length===0)return;const{url:n}=Go(t,s,a);It(n)}function Xo(t,s,a){if(a.length===0)return;const{url:n}=Vo(t,s,a);It(n)}function Zo(t,s,a){if(a.length===0)return;const{url:n}=Wo(t,s,a);It(n)}function el({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n,canExport:r,onUpgrade:o}){const[l,i]=m.useState(!1),[d,p]=m.useState(!1);function c(u){if(i(!1),!r(u)){o();return}s(u,d)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(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:()=>i(!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(i(!1),!r("accessibility-statement-html")){o();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 tl="2024-07-25",sl="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 al(t,s){return Qa.map(a=>{const n=a.wcag2Criteria.filter(l=>t.has(l)),r=a.wcag2Criteria.some(l=>s.has(l));let o;return n.length>0?o="has-violations":r?o="clean":o="not-evaluated",{outcome:a,violatedCriteria:n,status:o}})}const nl={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Ya(){const t=f(c=>c.results),s=f(c=>c.acknowledgedKeys),a=f(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 o=al(n,r),l=new Map;for(const c of o){const u=l.get(c.outcome.category)??[];u.push(c),l.set(c.outcome.category,u)}const i=o.filter(c=>c.status==="clean").length,d=o.filter(c=>c.status==="has-violations").length,p=o.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:tl}),"."," ",sl]})]}),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:[i," 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:[nl[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(rl,{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 rl({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 il(t,s,a){var i,d;const n=f(p=>p.acknowledgedKeys),[r,o]=m.useState(null),l=((i=s[0])==null?void 0:i.pageUrl)??((d=s[0])==null?void 0:d.scope)??"";return m.useEffect(()=>{if(s.length===0){o(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(N=>N.componentId).filter(Boolean),[x,v,j,I]=await Promise.all([t?Ae(t):Promise.resolve([]),Te(g),rs(g),l?_e(l):Promise.resolve([])]);if(p)return;const A=new Set(s.map(N=>N.pageUrl??N.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",S=x.map(N=>({criterionId:N.criterionId,ruleId:`ai-walkthrough-${N.criterionId}`,pageUrl:N.pageUrl,verdict:N.verdict,reasoning:N.reasoning}));o(Fn(a,{runs:h,workflows:ge},s,n,S,v,j,A,I))})(),()=>{p=!0}},[t,l,s,a,n]),r}const ol=[{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"}],ll={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 cl(){const t=f(u=>u.results),s=f(u=>u.componentId),a=f(u=>u.findingsLens),n=f(u=>u.setFindingsLens),r=f(u=>u.setView),o=f(u=>u.status),[l,i]=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 x=new Set(g.map(j=>j.criterionId)),v={};for(const j of h){const I=x.has(j.criterionId)?"pass":j.verdict;j.criterionId==="2.4.3"?v.focusOrder=I:j.criterionId==="2.1.2"?v.keyboardTrap=I:j.criterionId==="2.4.7"?v.focusVisible=I:j.criterionId==="1.3.2"?v.readingOrder=I:j.criterionId==="1.4.11"&&(v.nonTextContrast=I)}i(v)})(),()=>{u=!0}},[s]);const d=xs(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 x=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(x))}),()=>{u=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(sa,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:o==="running"?"Audit in progress. Findings appear here when the matrix completes.":o==="failed"||o==="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(sa,{setView:r}),e.jsx(ul,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:d}),e.jsx(dl,{results:t}),e.jsx(pl,{lens:a,setLens:n}),e.jsx(hl,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:d})]})}function sa({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 dl({results:t}){const s=f(p=>p.crawlNavContext),a=f(p=>p.setCrawlNavContext),n=f(p=>p.setView);if(t.length===0)return null;const r=new Set(t.map(p=>p.pageUrl??p.scope??"").filter(Boolean)),o=r.size>1,l=o?null:Array.from(r)[0]??"(unknown)",i=(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 ${o?"border-blue-200 bg-blue-50 text-blue-900":i?"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:[i&&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"}),o?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."]}):i?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 ul({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var I,E,A,S,N,b;const r=t.flatMap(k=>k.violations),o=f(k=>k.lastAuditWallClockMs),l=f(k=>k.acknowledgedKeys),i=f(k=>k.dismissedKeys),d=il(((I=t[0])==null?void 0:I.componentId)??null,t,r),p=as({violations:r,auditRan:!0,manualRuns:a,workflows:ge,heuristicCounts:{tabOrder:((A=(E=t[0])==null?void 0:E.tabOrderIssues)==null?void 0:A.length)??0,readingOrder:((N=(S=t[0])==null?void 0:S.readingOrderIssues)==null?void 0:N.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(k=>({ruleId:k.ruleId,impact:"serious",selector:k.selector}))}),c=(d==null?void 0:d.combined)??p.overallLetter,u=Pa(r,n,l,i),h=r.filter(k=>!l.has(k.matchKey)&&!i.has(`violation::${k.matchKey}`)),g=Ma(h,n),x=Ni(r,n,l,i),v=t.length,j=o??t.reduce((k,C)=>k+C.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 ${ll[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&&x.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",x.length," WCAG criteri",x.length===1?"on":"a"," (",x.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[v," state",v===1?"":"s"," tested · ",(j/1e3).toFixed(1),"s"]})]})]}),e.jsx(Pi,{coverage:(b=d==null?void 0:d.score)==null?void 0:b.coverage})]})}function pl({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:ol.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 hl({lens:t,results:s,componentId:a,interactiveVerdicts:n,aiResolvedFails:r}){var o,l;return t==="overview"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(ml,{componentId:a,results:s}),e.jsx(bl,{componentId:a}),e.jsx(Ri,{violations:s.flatMap(i=>i.violations),componentId:a}),e.jsx(Nl,{pageUrl:((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(vl,{})]}):t==="per-area"?e.jsx(yo,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(wl,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ha,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(qa,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ya,{})}):null}const kt={critical:0,serious:1,moderate:2,minor:3};function Qt(t){return`${Ee(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function ml({componentId:t,results:s}){var x,v;const a=f(j=>j.setFindingsLens),[n,r]=m.useState({}),[o,l]=m.useState({}),[i,d]=m.useState(0);m.useEffect(()=>{let j=!1;return(async()=>{if(!t){r({}),l({});return}const I=await Ae(t);if(j)return;const E={};for(const N of I)E[N.criterionId]=N;r(E);const A=await Te([t]);if(j)return;const S={};for(const N of A)S[`${N.criterionId}::${N.pageUrl}`]=N;l(S)})(),()=>{j=!0}},[t,i]);const p=((x=s[0])==null?void 0:x.pageUrl)??((v=s[0])==null?void 0:v.scope)??"",c=gt.map(j=>({crit:j,record:n[j.id]??null})).filter(({record:j})=>j&&(j.verdict==="fail"||j.verdict==="uncertain")).filter(({crit:j})=>!o[`${j.id}::${p}`]),u=new Set,h=[];for(const j of s)for(const I of j.violations){if(I.needsReview)continue;const E=Ee(I.ruleId,I.target.selector);u.has(E)||(u.add(E),h.push(I))}h.sort((j,I)=>(kt[j.impact]??99)-(kt[I.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:j,record:I})=>e.jsx(xl,{componentId:t??"",pageUrl:p,criterionId:j.id,label:j.label,blurb:j.blurb,record:I,onChanged:()=>d(E=>E+1)},`wt::${j.id}`)),h.map(j=>e.jsx(gl,{violation:j,onOpen:()=>a("violations")},`axe::${Qt(j)}`))]})]})}function xl({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l}){const[i,d]=m.useState(!1),[p,c]=m.useState(""),[u,h]=m.useState(!1),[g,x]=m.useState(null),[v,j]=m.useState(!1),[I,E]=m.useState(!1),A=gs(),S=o.verdict,N=S==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function b(){h(!0),x(null);try{if(!p.trim()){x("Note is required — explain how you manually verified this."),h(!1);return}await ns({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:S}),l()}catch(C){x(C instanceof Error?C.message:String(C))}finally{h(!1)}}async function k(){var C;E(!0),x(null);try{const R=(C=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:C.id;if(!R){x("No active tab — open the audited page first."),E(!1);return}const M=await X({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:R,componentId:t,pageUrl:s});M.ok||x(M.error??"Re-run failed."),l()}catch(y){x(y instanceof Error?y.message:String(y))}finally{E(!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 ${N}`,children:S}),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:S==="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:()=>j(C=>!C),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 k(),disabled:I||!A,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:A?"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:I?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{d(C=>!C),x(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:o.reasoning})]}),i&&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:C=>c(C.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 b(),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(""),x(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&&!i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:g})]})}function gl({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 gt=[{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)."}],fl={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function bl({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 x={};for(const j of h)x[j.criterionId]=j;a(x);const v={};for(const j of g)v[j.criterionId]=j;r(v)})(),()=>{u=!0}},[t]);const o={};for(const[u,h]of Object.entries(s))o[u]=n[u]?"pass":h.verdict;const l=Object.values(o).length,i=Object.values(o).filter(u=>u==="pass").length,d=Object.values(o).filter(u=>u==="fail").length,p=Object.values(o).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 ${gt.length} criteria pending human verification`:`${l}/${gt.length} · ${i} 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:gt.map(u=>{const h=s[u.id],g=n[u.id],x=h==null?void 0:h.verdict,v=g?"pass":x,j=h?Ht(h.reasoning):!1,I=h?ya(h.reasoning):!1,E=h?zt(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?fl[v]:"bg-slate-200 text-slate-500"}`,title:g?`Human verified at ${new Date(g.acknowledgedAt).toLocaleString()} — note: "${g.note}". (AI verdict was: ${x})`:v?`AI verdict: ${v}${E?` (cascade ${E})`:""}`:"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,I&&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}),j&&!I&&!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: ",x,"."]})]})]})]},u.id)})})]})}function vl(){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 yl({componentId:t,records:s,stateCount:a}){const[n,r]=m.useState(0),[o,l]=m.useState({});return m.useEffect(()=>{if(!t){l({});return}let i=!1;return Te([t]).then(d=>{if(i)return;const p={};for(const c of d)p[c.criterionId]=c;l(p)}),()=>{i=!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(i=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(fs,{componentId:t??"",pageUrl:i.pageUrl,criterionId:i.criterionId,record:i,onChanged:()=>r(d=>d+1),ack:o[i.criterionId]??null})},i.criterionId))]})}function wl({results:t}){const s=f(i=>i.dismissedKeys),a=f(i=>i.componentId),n=new Set,r=[];for(const i of t)for(const d of i.violations){if(s.has(`violation::${d.matchKey}`))continue;const p=Qt(d);n.has(p)||(n.add(p),r.push(d))}r.sort((i,d)=>{const p=kt[i.impact]??99,c=kt[d.impact]??99;return p-c});const[o,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let i=!1;return Ae(a).then(d=>{i||l(d.filter(p=>p.verdict!=="pass"))}),()=>{i=!0}},[a]),r.length===0&&o.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&&o.length>0?e.jsx(yl,{componentId:a,records:o,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(i=>e.jsx(nt,{violation:i},Qt(i)))]})}const jl={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function Nl({pageUrl:t}){const s=f(p=>p.tier),a=ba(),n=we(s,"autoExportAuditReports"),[r,o]=m.useState(null),[l,i]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await Aa();if(p||o(c),t){const u=await kr(t);p||i(u)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?jl[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 Yt="igtRuns";async function kl(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const o=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const l=n.tabOrderIssues??[];if(l.length===0)return;await at(r,l.map(i=>({key:st(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await at(r,l.map(i=>({key:tt(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}}const Sl={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"}},Al={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"}},Cl={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function aa(t,s){const a=await xe();if(!a)return;const n=s?Sl[t]:Al[t];try{await be(a,n)}catch{}}async function Il(){const s=(await chrome.storage.local.get(Yt))[Yt];return s&&typeof s=="object"?s:{}}async function na(t){await chrome.storage.local.set({[Yt]:t})}function El(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 Rl(){const t=f(c=>c.componentId),s=f(c=>c.results),[a,n]=m.useState({}),[r,o]=m.useState(null);if(m.useEffect(()=>{Il().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 i(c,u,h){var x;const g={...a,[t]:{...l,[c]:{...l[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((x=l[c])==null?void 0:x.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(g),na(g),h.status==="pass"){const v=ge.find(I=>I.id===c),j=v==null?void 0:v.steps.find(I=>I.id===u);j!=null&&j.autoDismissActivity&&kl(j.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),na(h)}const p=ge.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(Tl,{workflow:p,run:c,results:s,onAnswer:(u,h)=>i(p.id,u,h),onBack:()=>o(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."}),ge.map(c=>{const u=l[c.id],h=u?Sr(u,c):null,g=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",x={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:()=>o(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${x}`,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 Tl({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const o=m.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=El(p,a);return d},[t,a]);function l(){for(const d of t.steps){const p=o[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 i=t.steps.filter(d=>{var p;return((p=o[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}),i>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:[i," step",i===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 ",i," →"]})]})]}),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=o[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 aa(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Cl[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void aa(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(ot,{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(ot,{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(ot,{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(ot,{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 $l={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 ot({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?$l[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const ft="savedFlows";async function Ul(){const t=await chrome.storage.local.get(ft);return Array.isArray(t[ft])?t[ft]:[]}async function ra(t){await chrome.storage.local.set({[ft]:t})}function Ll(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,o]=m.useState(null);m.useEffect(()=>{Ul().then(s)},[]);async function l(){const c=await xe();if(!c){o("No audit-target tab found.");return}try{await be(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),o("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{o("Failed to start recording.")}}async function i(){const c=await xe();if(c)try{const u=await Re(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){o("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()){o("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()},x=[g,...t];s(x),await ra(x),o(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(u){o(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await xe();if(u){o(`Replaying "${c.name}"…`);try{const h=await Re(u,{type:"FLOW_PLAY_REQUEST",steps:c.steps});o(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){o(`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 ra(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:i,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 _l(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 o=n.slice(0,r),l=n.slice(r+1);return o==="story"?{primary:l.split("--").map(d=>d.split("-").map(Dl).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||o}}function Dl(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Ol(){const t=f(i=>i.baselineList),s=f(i=>i.tier),a=vr[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,o]=m.useState(!1);if(m.useEffect(()=>{wt().finally(()=>o(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(i=>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"})]},i))});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(i){await X({type:"BASELINE_DELETE",componentId:i}),await wt()}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(i=>{const d=_l(i.componentId),p=i.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:i.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:[i.violationCount," ",i.violationCount===1?"violation":"violations"," ·"," ",new Date(i.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[i.seenOnUrlsCount&&i.seenOnUrlsCount>1&&e.jsxs(Ue,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",i.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(i.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},i.componentId)})]})}const Fl={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 ${Fl[t]}`,children:a})}const Ja={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Ml={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ja]},Pl={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ja]};function Ut(t){return t==="thorough"?Pl:Ml}function Jt(t){const s=Ut(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Xa({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(ia,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Jt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(ia,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Jt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function ia({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:o}){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:o})]})}const bs={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"};function Za(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return(async()=>{const r=await Ve(),o=(r??[]).flatMap(i=>i.results),l=await wa(o);n||a(Mn(r??[],l.acknowledgedMatchKeys))})(),()=>{n=!0}},[t.startUrl,t.finishedAt]),s}function Gl(t){var s;return((s=Za(t))==null?void 0:s.site)??null}function en(){const t=f(d=>d.siteCrawlReport),s=f(d=>d.results),a=f(d=>d.delta),n=f(d=>d.componentId),r=f(d=>d.status),o=f(d=>d.siteCrawlStatus),[l,i]=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(x=>_e(x)))).flat().map(Gn).map(Vn).filter(x=>x.verdict==="fail")}if(o==="running"||r==="running"){i({report:null,resolvedFails:[]});return}if(t)return(async()=>{const h=t.pages.map(x=>x.url),g=await p(h);d||i({report:t,resolvedFails:g})})(),()=>{d=!0};if(s.length===0||!n){i({report:null,resolvedFails:[]});return}const c=(u=s[0])==null?void 0:u.pageUrl;if(!c){i({report:null,resolvedFails:[]});return}return(async()=>{try{const[h,g]=await Promise.all([wa(s,[c]),p([c])]),x=new Date().toISOString(),v=Pn(c,[{url:c,results:s,delta:a,componentId:n,durationMs:0}],x,x,0,h.walkthroughsByComponent,h.walkthroughAcksByComponent,h.ackedKeysByComponent,h.humanVerdictsByComponent,h.incompleteResolutionsByComponent,h.attestations);d||i({report:v,resolvedFails:g})}catch(h){console.warn("[view-model] synthesize single-page report failed",h),d||i({report:null,resolvedFails:[]})}})(),()=>{d=!0}},[t,s,a,n,r,o]),l}function tn(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 Vl(t){var s;return((s=Ia.find(a=>a.id===t))==null?void 0:s.title)??t}const Wl={"attested-conforms":"Conforms (attested)","attested-na":"N/A (attested)","not-addressed":"Not addressed"},Bl={"attested-conforms":"#34d399","attested-na":"#94a3b8","not-addressed":"#fbbf24"};function Hl(){var C;const{report:t}=en(),s=f(y=>y.componentId),a=f(y=>y.siteCrawlReport),[n,r]=m.useState({}),[o,l]=m.useState(!1),[i,d]=m.useState(null),[p,c]=m.useState(""),[u,h]=m.useState("operator"),[g,x]=m.useState(new Set),v=y=>x(R=>{const U=new Set(R);return U.has(y)?U.delete(y):U.add(y),U}),j=(t==null?void 0:t.startUrl)??tn({storeComponentId:s,storeCrawlReport:a,pageUrls:(t==null?void 0:t.pages.map(y=>y.url))??[]});m.useEffect(()=>{(async()=>{var U;const y=await Rr().catch(()=>null),R=(U=y==null?void 0:y.response)==null?void 0:U.email;R&&h(R)})()},[]),m.useEffect(()=>{let y=!1;return(async()=>{if(!j){y||r({});return}const R=await Wn([j]).catch(()=>[]);if(y)return;const U={};for(const M of R)U[M.criterionId]=M;r(U)})(),()=>{y=!0}},[j]);const I=((C=t==null?void 0:t.spotCheckGate)==null?void 0:C.status)==="pending";if(m.useEffect(()=>{I&&l(!0)},[I]),!t||!j)return null;const E=t.spotCheckGate;if(!E||E.status==="none")return null;const A=E.status==="pending",S=()=>{X({type:"REGRADE_SITE_CRAWL"}).catch(()=>{})},N=async(y,R,U)=>{const M={componentId:j,criterionId:y,kind:R,note:U.trim(),operator:u,timestamp:new Date().toISOString(),toolVersion:chrome.runtime.getManifest().version};await Qn(M),r(te=>({...te,[y]:M})),d(null),c(""),S()},b=async y=>{await qn(j,y),r(R=>{const U={...R};return delete U[y],U}),S()},k=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(y=>!y),style:{width:"100%",textAlign:"left",background:"#0f172a",color:"#e2e8f0",border:"none",padding:"12px 14px",cursor:"pointer",fontSize:13,fontWeight:600},children:[o?"▾":"▸"," ",A?"Required to finalize your grade — spot checks":"Spot checks (content-meaning criteria)",e.jsxs("span",{style:{color:A?"#fbbf24":"#94a3b8",fontWeight:A?600:400},children:[" — ",k," of ",E.total," answered",A?" · grade is PENDING until all are answered":E.displayGrade==="A"?" · grade A":" · grade B"]})]}),o&&e.jsxs("div",{style:{padding:"12px 14px",background:"#0b1220"},children:[A&&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 ",E.total,". ",e.jsxs("strong",{children:[E.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:Bn}),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."]}),Hn.map(y=>{const R=n[y.id],U=Vl(y.id),M=zn[y.id],te=g.has(y.id);return e.jsxs("div",{style:{borderTop:"1px solid #1e293b",padding:"10px 0"},children:[e.jsxs("button",{onClick:()=>v(y.id),"aria-expanded":te,style:{background:"none",border:"none",padding:0,cursor:"pointer",textAlign:"left",width:"100%",fontSize:12,color:"#93c5fd",fontWeight:600,textDecoration:"underline"},children:[te?"▾":"▸"," WCAG ",y.id," — ",U]}),e.jsx("div",{style:{fontSize:11,color:"#cbd5e1",margin:"4px 0 0",lineHeight:1.5},children:(M==null?void 0:M.what)??y.reason}),te&&M&&e.jsxs("div",{style:{margin:"8px 0",padding:"8px 10px",background:"#0f172a",border:"1px solid #334155",borderRadius:6},children:[e.jsxs("div",{style:{fontSize:11,color:"#cbd5e1",lineHeight:1.55,marginBottom:6},children:[e.jsx("span",{style:{color:"#fbbf24",fontWeight:700},children:"Does this apply to you?"})," ",M.applies]}),e.jsxs("div",{style:{fontSize:11,color:"#cbd5e1",lineHeight:1.55},children:[e.jsx("span",{style:{color:"#34d399",fontWeight:700},children:"How to confirm:"})," ",M.confirm]})]}),!te&&e.jsx("div",{style:{fontSize:10,color:"#64748b",margin:"3px 0 8px"},children:e.jsx("button",{onClick:()=>v(y.id),style:{...Ft,color:"#64748b"},children:"does this apply to me? · how do I check this?"})}),te&&e.jsx("div",{style:{height:4}}),R?e.jsxs("div",{style:{fontSize:11,color:"#cbd5e1"},children:[e.jsxs("span",{style:{color:Bl[R.kind],fontWeight:700},children:["● ",Wl[R.kind]]}),R.note?e.jsxs("span",{style:{color:"#94a3b8"},children:[' — "',R.note,'"']}):null,e.jsxs("div",{style:{color:"#64748b",marginTop:2},children:[R.operator," · ",R.timestamp.slice(0,10)," · self-attested, not tool-verified"]}),e.jsx("button",{onClick:()=>void b(y.id),style:Ft,children:"un-attest"})]}):(i==null?void 0:i.id)===y.id?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic",margin:"0 0 6px",lineHeight:1.5},children:['"',Kn(U,new Date().toISOString(),i.kind),'"']}),e.jsx("textarea",{value:p,onChange:P=>c(P.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 N(y.id,i.kind,p),style:{...zl,opacity:p.trim()?1:.5},children:"Record attestation"}),e.jsx("button",{onClick:()=>{d(null),c("")},style:Ft,children:"cancel"})]})]}):e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>{d({id:y.id,kind:"attested-conforms"}),c("")},style:Ot,children:"Conforms…"}),e.jsx("button",{onClick:()=>{d({id:y.id,kind:"attested-na"}),c("")},style:Ot,children:"N/A…"}),e.jsx("button",{onClick:()=>void N(y.id,"not-addressed",""),style:Ot,children:"Not addressed"})]})]},y.id)})]})]})}const Ot={background:"#1e293b",color:"#cbd5e1",border:"1px solid #334155",borderRadius:4,fontSize:11,padding:"4px 8px",cursor:"pointer"},zl={background:"#2563eb",color:"#fff",border:"none",borderRadius:4,fontSize:11,padding:"5px 10px",cursor:"pointer"},Ft={background:"none",color:"#64748b",border:"none",fontSize:11,padding:"2px 0",cursor:"pointer",textDecoration:"underline"},Kl={"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 ql(t){return Kl[t]??null}const Ql={"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 lt(t){return Ql[t]??null}const Yl="https://api.anthropic.com/v1/messages",Jl="2023-06-01",Xl="claude-sonnet-4-6",Zl={input:3/1e6,output:15/1e6},ec={input:1/1e6,output:5/1e6},tc=`You are wcagcheckr's accessibility-audit co-pilot.
18
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await X({type:"BASELINE_DELETE",componentId:s});const D=a.flatMap(ie=>ie.violations),Y=a.flatMap(ie=>ie.announcements??[]),ne=a.flatMap(ie=>ie.focusEvents??[]),K=await ce({type:"BASELINE_COMPARE",componentId:s,currentViolations:D,announcements:Y,focusEvents:ne});f.getState().setDelta(K.delta);const le=await ce({type:"BASELINE_LIST"});f.getState().setBaselineList(le.items),me.polite(`Baseline cleared for ${s}.`)}async function se(w,D=!1){if(a.length===0)return;if(w==="ai-prompt"){const{copyAiFixerPrompt:B}=await ve(async()=>{const{copyAiFixerPrompt:V}=await import("./copy-ai-fixer-prompt-1eFKA9Wr.js");return{copyAiFixerPrompt:V}},__vite__mapDeps([5,1,2]));await B({results:a,componentId:s,delta:D?void 0:t,siteCrawlReport:o});return}let Y;if((w==="defense-bundle"||w==="evidence-bundle"||w==="deposition-packet")&&s){const B=await chrome.storage.local.get("igtRuns"),re=((B==null?void 0:B.igtRuns)??{})[s]??{};Y=Object.values(re)}const le=await ce({type:"EXPORT_REQUEST",format:w,results:a,delta:D?void 0:t??void 0,manualRuns:Y,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:f.getState().lastAuditWallClockMs??void 0});if(w==="defense-bundle"||w==="evidence-bundle"||w==="deposition-packet"){const B=Ct(w,s);await Ca()?rt(le.content,B):N({open:!0,format:w,content:le.content,filename:B});return}if(w==="html-print"||w==="vpat"||w==="methodology-doc"||w==="conformance-crosswalk"||w==="executive-report"){De(le.content);return}const ie=w==="json"?"application/json":w==="sarif"?"application/sarif+json":w==="ticket-bundle"?"text/markdown":"application/xml",q=w==="junit"?"xml":w==="ticket-bundle"?"md":w,{body:je,type:he}=Nr(le.content,ie),H=new Blob([je],{type:he}),oe=URL.createObjectURL(H),_=document.createElement("a");_.href=oe,_.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${q}`,_.click(),URL.revokeObjectURL(oe)}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:z,disabled:!ae,title:ae?void 0:`Free tier limits you to ${$} 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"}),Z&&e.jsx("button",{onClick:ee,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 T(),"aria-pressed":R,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:R?"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:R?"Hide badges":"Show badges 🎯"}),R&&M&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[M.rendered," of ",M.requested," rendered",M.clustered>0?` · ${M.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void L(),"aria-pressed":P,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:P?"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:P?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(el,{disabled:!F,onExport:se,onAccessibilityStatement:()=>k(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta),canExport:w=>Le(n,w),onUpgrade:()=>y(!0)}),!ae&&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 w=Dt(t.new),D=Dt(t.persistent),Y=Dt(t.fixed),ne=[...w.review,...D.review];return e.jsxs(e.Fragment,{children:[e.jsx(qe,{title:"New",violations:w.findings,count:w.findings.length,accent:"red",actions:[...O&&l&&w.findings.length>0?[{label:"File GitHub issue",onClick:()=>Yo(l,s,w.findings)}]:[],...O&&d&&w.findings.length>0?[{label:"File Jira issue",onClick:()=>Jo(d,s,w.findings)}]:[],...O&&c&&w.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Xo(c,s,w.findings)}]:[],...O&&h&&w.findings.length>0?[{label:"File GitLab issue",onClick:()=>Zo(h,s,w.findings)}]:[]]}),e.jsx(qe,{title:"Persistent",violations:D.findings,count:D.findings.length,accent:"slate"}),e.jsx(qe,{title:"Fixed",violations:Y.findings,count:t.fixedCount,accent:"green"}),ne.length>0&&e.jsx(qe,{title:"Needs review (does not affect grade)",violations:ne,count:ne.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(qe,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),S&&e.jsx(za,{open:S.open,onClose:()=>N(null),format:S.format,content:S.content,filename:S.filename}),e.jsx(Ka,{open:b,onClose:()=>k(!1),results:a}),e.jsx(Ge,{open:C,onClose:()=>y(!1)}),x&&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"})]})]}),E&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",E.chromeStorageKeysCleared," chrome.storage key",E.chromeStorageKeysCleared===1?"":"s"," + ",E.indexedDbsCleared.length," database",E.indexedDbsCleared.length===1?"":"s",".",E.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",E.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:E?e.jsx("button",{type:"button",onClick:()=>{v(!1),A(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:j,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()=>{I(!0);try{const w=await Ho();A(w),await Et(),me.polite("Audit data reset. Ready for a fresh scan.")}catch(w){A({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[w instanceof Error?w.message:String(w)]})}finally{I(!1)}},disabled:j,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:j?"Resetting…":"Reset everything"})]})})]})})]})}const Qo={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Dt(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 qe({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:o}){const[l,i]=m.useState(!o);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 ${Qo[n]} ${o?"cursor-pointer select-none":""}`,onClick:o?()=>i(d=>!d):void 0,children:[o&&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:o?s.map((d,p)=>e.jsx(nt,{violation:d,alreadyAcknowledged:!0},p)):Oo(s).map(d=>e.jsx(Do,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Yo(t,s,a){if(a.length===0)return;const{url:n}=Po(t,s,a);It(n)}function Jo(t,s,a){if(a.length===0)return;const{url:n}=Go(t,s,a);It(n)}function Xo(t,s,a){if(a.length===0)return;const{url:n}=Vo(t,s,a);It(n)}function Zo(t,s,a){if(a.length===0)return;const{url:n}=Wo(t,s,a);It(n)}function el({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n,canExport:r,onUpgrade:o}){const[l,i]=m.useState(!1),[d,p]=m.useState(!1);function c(u){if(i(!1),!r(u)){o();return}s(u,d)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(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:()=>i(!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(i(!1),!r("accessibility-statement-html")){o();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 tl="2024-07-25",sl="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 al(t,s){return Qa.map(a=>{const n=a.wcag2Criteria.filter(l=>t.has(l)),r=a.wcag2Criteria.some(l=>s.has(l));let o;return n.length>0?o="has-violations":r?o="clean":o="not-evaluated",{outcome:a,violatedCriteria:n,status:o}})}const nl={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Ya(){const t=f(c=>c.results),s=f(c=>c.acknowledgedKeys),a=f(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 o=al(n,r),l=new Map;for(const c of o){const u=l.get(c.outcome.category)??[];u.push(c),l.set(c.outcome.category,u)}const i=o.filter(c=>c.status==="clean").length,d=o.filter(c=>c.status==="has-violations").length,p=o.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:tl}),"."," ",sl]})]}),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:[i," 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:[nl[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(rl,{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 rl({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 il(t,s,a){var i,d;const n=f(p=>p.acknowledgedKeys),[r,o]=m.useState(null),l=((i=s[0])==null?void 0:i.pageUrl)??((d=s[0])==null?void 0:d.scope)??"";return m.useEffect(()=>{if(s.length===0){o(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(N=>N.componentId).filter(Boolean),[x,v,j,I]=await Promise.all([t?Ae(t):Promise.resolve([]),Te(g),rs(g),l?_e(l):Promise.resolve([])]);if(p)return;const A=new Set(s.map(N=>N.pageUrl??N.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",S=x.map(N=>({criterionId:N.criterionId,ruleId:`ai-walkthrough-${N.criterionId}`,pageUrl:N.pageUrl,verdict:N.verdict,reasoning:N.reasoning}));o(Fn(a,{runs:h,workflows:ge},s,n,S,v,j,A,I))})(),()=>{p=!0}},[t,l,s,a,n]),r}const ol=[{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"}],ll={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 cl(){const t=f(u=>u.results),s=f(u=>u.componentId),a=f(u=>u.findingsLens),n=f(u=>u.setFindingsLens),r=f(u=>u.setView),o=f(u=>u.status),[l,i]=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 x=new Set(g.map(j=>j.criterionId)),v={};for(const j of h){const I=x.has(j.criterionId)?"pass":j.verdict;j.criterionId==="2.4.3"?v.focusOrder=I:j.criterionId==="2.1.2"?v.keyboardTrap=I:j.criterionId==="2.4.7"?v.focusVisible=I:j.criterionId==="1.3.2"?v.readingOrder=I:j.criterionId==="1.4.11"&&(v.nonTextContrast=I)}i(v)})(),()=>{u=!0}},[s]);const d=xs(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 x=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(x))}),()=>{u=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(sa,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:o==="running"?"Audit in progress. Findings appear here when the matrix completes.":o==="failed"||o==="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(sa,{setView:r}),e.jsx(ul,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:d}),e.jsx(dl,{results:t}),e.jsx(pl,{lens:a,setLens:n}),e.jsx(hl,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:d})]})}function sa({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 dl({results:t}){const s=f(p=>p.crawlNavContext),a=f(p=>p.setCrawlNavContext),n=f(p=>p.setView);if(t.length===0)return null;const r=new Set(t.map(p=>p.pageUrl??p.scope??"").filter(Boolean)),o=r.size>1,l=o?null:Array.from(r)[0]??"(unknown)",i=(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 ${o?"border-blue-200 bg-blue-50 text-blue-900":i?"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:[i&&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"}),o?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."]}):i?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 ul({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var I,E,A,S,N,b;const r=t.flatMap(k=>k.violations),o=f(k=>k.lastAuditWallClockMs),l=f(k=>k.acknowledgedKeys),i=f(k=>k.dismissedKeys),d=il(((I=t[0])==null?void 0:I.componentId)??null,t,r),p=as({violations:r,auditRan:!0,manualRuns:a,workflows:ge,heuristicCounts:{tabOrder:((A=(E=t[0])==null?void 0:E.tabOrderIssues)==null?void 0:A.length)??0,readingOrder:((N=(S=t[0])==null?void 0:S.readingOrderIssues)==null?void 0:N.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(k=>({ruleId:k.ruleId,impact:"serious",selector:k.selector}))}),c=(d==null?void 0:d.combined)??p.overallLetter,u=Pa(r,n,l,i),h=r.filter(k=>!l.has(k.matchKey)&&!i.has(`violation::${k.matchKey}`)),g=Ma(h,n),x=Ni(r,n,l,i),v=t.length,j=o??t.reduce((k,C)=>k+C.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 ${ll[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&&x.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",x.length," WCAG criteri",x.length===1?"on":"a"," (",x.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[v," state",v===1?"":"s"," tested · ",(j/1e3).toFixed(1),"s"]})]})]}),e.jsx(Pi,{coverage:(b=d==null?void 0:d.score)==null?void 0:b.coverage})]})}function pl({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:ol.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 hl({lens:t,results:s,componentId:a,interactiveVerdicts:n,aiResolvedFails:r}){var o,l;return t==="overview"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(ml,{componentId:a,results:s}),e.jsx(bl,{componentId:a}),e.jsx(Ri,{violations:s.flatMap(i=>i.violations),componentId:a}),e.jsx(Nl,{pageUrl:((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(vl,{})]}):t==="per-area"?e.jsx(yo,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(wl,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ha,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(qa,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ya,{})}):null}const kt={critical:0,serious:1,moderate:2,minor:3};function Qt(t){return`${Ee(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function ml({componentId:t,results:s}){var x,v;const a=f(j=>j.setFindingsLens),[n,r]=m.useState({}),[o,l]=m.useState({}),[i,d]=m.useState(0);m.useEffect(()=>{let j=!1;return(async()=>{if(!t){r({}),l({});return}const I=await Ae(t);if(j)return;const E={};for(const N of I)E[N.criterionId]=N;r(E);const A=await Te([t]);if(j)return;const S={};for(const N of A)S[`${N.criterionId}::${N.pageUrl}`]=N;l(S)})(),()=>{j=!0}},[t,i]);const p=((x=s[0])==null?void 0:x.pageUrl)??((v=s[0])==null?void 0:v.scope)??"",c=gt.map(j=>({crit:j,record:n[j.id]??null})).filter(({record:j})=>j&&(j.verdict==="fail"||j.verdict==="uncertain")).filter(({crit:j})=>!o[`${j.id}::${p}`]),u=new Set,h=[];for(const j of s)for(const I of j.violations){if(I.needsReview)continue;const E=Ee(I.ruleId,I.target.selector);u.has(E)||(u.add(E),h.push(I))}h.sort((j,I)=>(kt[j.impact]??99)-(kt[I.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:j,record:I})=>e.jsx(xl,{componentId:t??"",pageUrl:p,criterionId:j.id,label:j.label,blurb:j.blurb,record:I,onChanged:()=>d(E=>E+1)},`wt::${j.id}`)),h.map(j=>e.jsx(gl,{violation:j,onOpen:()=>a("violations")},`axe::${Qt(j)}`))]})]})}function xl({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l}){const[i,d]=m.useState(!1),[p,c]=m.useState(""),[u,h]=m.useState(!1),[g,x]=m.useState(null),[v,j]=m.useState(!1),[I,E]=m.useState(!1),A=gs(),S=o.verdict,N=S==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function b(){h(!0),x(null);try{if(!p.trim()){x("Note is required — explain how you manually verified this."),h(!1);return}await ns({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:S}),l()}catch(C){x(C instanceof Error?C.message:String(C))}finally{h(!1)}}async function k(){var C;E(!0),x(null);try{const R=(C=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:C.id;if(!R){x("No active tab — open the audited page first."),E(!1);return}const M=await X({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:R,componentId:t,pageUrl:s});M.ok||x(M.error??"Re-run failed."),l()}catch(y){x(y instanceof Error?y.message:String(y))}finally{E(!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 ${N}`,children:S}),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:S==="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:()=>j(C=>!C),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 k(),disabled:I||!A,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:A?"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:I?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{d(C=>!C),x(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:o.reasoning})]}),i&&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:C=>c(C.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 b(),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(""),x(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&&!i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:g})]})}function gl({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 gt=[{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)."}],fl={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function bl({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 x={};for(const j of h)x[j.criterionId]=j;a(x);const v={};for(const j of g)v[j.criterionId]=j;r(v)})(),()=>{u=!0}},[t]);const o={};for(const[u,h]of Object.entries(s))o[u]=n[u]?"pass":h.verdict;const l=Object.values(o).length,i=Object.values(o).filter(u=>u==="pass").length,d=Object.values(o).filter(u=>u==="fail").length,p=Object.values(o).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 ${gt.length} criteria pending human verification`:`${l}/${gt.length} · ${i} 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:gt.map(u=>{const h=s[u.id],g=n[u.id],x=h==null?void 0:h.verdict,v=g?"pass":x,j=h?Ht(h.reasoning):!1,I=h?ya(h.reasoning):!1,E=h?zt(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?fl[v]:"bg-slate-200 text-slate-500"}`,title:g?`Human verified at ${new Date(g.acknowledgedAt).toLocaleString()} — note: "${g.note}". (AI verdict was: ${x})`:v?`AI verdict: ${v}${E?` (cascade ${E})`:""}`:"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,I&&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}),j&&!I&&!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: ",x,"."]})]})]})]},u.id)})})]})}function vl(){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 yl({componentId:t,records:s,stateCount:a}){const[n,r]=m.useState(0),[o,l]=m.useState({});return m.useEffect(()=>{if(!t){l({});return}let i=!1;return Te([t]).then(d=>{if(i)return;const p={};for(const c of d)p[c.criterionId]=c;l(p)}),()=>{i=!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(i=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(fs,{componentId:t??"",pageUrl:i.pageUrl,criterionId:i.criterionId,record:i,onChanged:()=>r(d=>d+1),ack:o[i.criterionId]??null})},i.criterionId))]})}function wl({results:t}){const s=f(i=>i.dismissedKeys),a=f(i=>i.componentId),n=new Set,r=[];for(const i of t)for(const d of i.violations){if(s.has(`violation::${d.matchKey}`))continue;const p=Qt(d);n.has(p)||(n.add(p),r.push(d))}r.sort((i,d)=>{const p=kt[i.impact]??99,c=kt[d.impact]??99;return p-c});const[o,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let i=!1;return Ae(a).then(d=>{i||l(d.filter(p=>p.verdict!=="pass"))}),()=>{i=!0}},[a]),r.length===0&&o.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&&o.length>0?e.jsx(yl,{componentId:a,records:o,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(i=>e.jsx(nt,{violation:i},Qt(i)))]})}const jl={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function Nl({pageUrl:t}){const s=f(p=>p.tier),a=ba(),n=we(s,"autoExportAuditReports"),[r,o]=m.useState(null),[l,i]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await Aa();if(p||o(c),t){const u=await kr(t);p||i(u)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?jl[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 Yt="igtRuns";async function kl(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const o=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const l=n.tabOrderIssues??[];if(l.length===0)return;await at(r,l.map(i=>({key:st(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await at(r,l.map(i=>({key:tt(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}}const Sl={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"}},Al={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"}},Cl={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function aa(t,s){const a=await xe();if(!a)return;const n=s?Sl[t]:Al[t];try{await be(a,n)}catch{}}async function Il(){const s=(await chrome.storage.local.get(Yt))[Yt];return s&&typeof s=="object"?s:{}}async function na(t){await chrome.storage.local.set({[Yt]:t})}function El(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 Rl(){const t=f(c=>c.componentId),s=f(c=>c.results),[a,n]=m.useState({}),[r,o]=m.useState(null);if(m.useEffect(()=>{Il().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 i(c,u,h){var x;const g={...a,[t]:{...l,[c]:{...l[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((x=l[c])==null?void 0:x.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(g),na(g),h.status==="pass"){const v=ge.find(I=>I.id===c),j=v==null?void 0:v.steps.find(I=>I.id===u);j!=null&&j.autoDismissActivity&&kl(j.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),na(h)}const p=ge.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(Tl,{workflow:p,run:c,results:s,onAnswer:(u,h)=>i(p.id,u,h),onBack:()=>o(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."}),ge.map(c=>{const u=l[c.id],h=u?Sr(u,c):null,g=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",x={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:()=>o(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${x}`,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 Tl({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const o=m.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=El(p,a);return d},[t,a]);function l(){for(const d of t.steps){const p=o[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 i=t.steps.filter(d=>{var p;return((p=o[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}),i>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:[i," step",i===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 ",i," →"]})]})]}),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=o[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 aa(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Cl[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void aa(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(ot,{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(ot,{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(ot,{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(ot,{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 $l={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 ot({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?$l[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const ft="savedFlows";async function Ul(){const t=await chrome.storage.local.get(ft);return Array.isArray(t[ft])?t[ft]:[]}async function ra(t){await chrome.storage.local.set({[ft]:t})}function Ll(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,o]=m.useState(null);m.useEffect(()=>{Ul().then(s)},[]);async function l(){const c=await xe();if(!c){o("No audit-target tab found.");return}try{await be(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),o("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{o("Failed to start recording.")}}async function i(){const c=await xe();if(c)try{const u=await Re(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){o("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()){o("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()},x=[g,...t];s(x),await ra(x),o(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(u){o(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await xe();if(u){o(`Replaying "${c.name}"…`);try{const h=await Re(u,{type:"FLOW_PLAY_REQUEST",steps:c.steps});o(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){o(`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 ra(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:i,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 _l(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 o=n.slice(0,r),l=n.slice(r+1);return o==="story"?{primary:l.split("--").map(d=>d.split("-").map(Dl).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||o}}function Dl(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Ol(){const t=f(i=>i.baselineList),s=f(i=>i.tier),a=vr[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,o]=m.useState(!1);if(m.useEffect(()=>{wt().finally(()=>o(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(i=>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"})]},i))});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(i){await X({type:"BASELINE_DELETE",componentId:i}),await wt()}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(i=>{const d=_l(i.componentId),p=i.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:i.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:[i.violationCount," ",i.violationCount===1?"violation":"violations"," ·"," ",new Date(i.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[i.seenOnUrlsCount&&i.seenOnUrlsCount>1&&e.jsxs(Ue,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",i.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(i.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},i.componentId)})]})}const Fl={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 ${Fl[t]}`,children:a})}const Ja={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Ml={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ja]},Pl={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ja]};function Ut(t){return t==="thorough"?Pl:Ml}function Jt(t){const s=Ut(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Xa({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(ia,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Jt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(ia,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Jt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function ia({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:o}){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:o})]})}const bs={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"};function Za(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return(async()=>{const r=await Ve(),o=(r??[]).flatMap(i=>i.results),l=await wa(o);n||a(Mn(r??[],l.acknowledgedMatchKeys))})(),()=>{n=!0}},[t.startUrl,t.finishedAt]),s}function Gl(t){var s;return((s=Za(t))==null?void 0:s.site)??null}function en(){const t=f(d=>d.siteCrawlReport),s=f(d=>d.results),a=f(d=>d.delta),n=f(d=>d.componentId),r=f(d=>d.status),o=f(d=>d.siteCrawlStatus),[l,i]=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(x=>_e(x)))).flat().map(Gn).map(Vn).filter(x=>x.verdict==="fail")}if(o==="running"||r==="running"){i({report:null,resolvedFails:[]});return}if(t)return(async()=>{const h=t.pages.map(x=>x.url),g=await p(h);d||i({report:t,resolvedFails:g})})(),()=>{d=!0};if(s.length===0||!n){i({report:null,resolvedFails:[]});return}const c=(u=s[0])==null?void 0:u.pageUrl;if(!c){i({report:null,resolvedFails:[]});return}return(async()=>{try{const[h,g]=await Promise.all([wa(s,[c]),p([c])]),x=new Date().toISOString(),v=Pn(c,[{url:c,results:s,delta:a,componentId:n,durationMs:0}],x,x,0,h.walkthroughsByComponent,h.walkthroughAcksByComponent,h.ackedKeysByComponent,h.humanVerdictsByComponent,h.incompleteResolutionsByComponent,h.attestations);d||i({report:v,resolvedFails:g})}catch(h){console.warn("[view-model] synthesize single-page report failed",h),d||i({report:null,resolvedFails:[]})}})(),()=>{d=!0}},[t,s,a,n,r,o]),l}function tn(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 Vl(t){var s;return((s=Ia.find(a=>a.id===t))==null?void 0:s.title)??t}const Wl={"attested-conforms":"Conforms (attested)","attested-na":"N/A (attested)","not-addressed":"Not addressed"},Bl={"attested-conforms":"#34d399","attested-na":"#94a3b8","not-addressed":"#fbbf24"};function Hl(){var C;const{report:t}=en(),s=f(y=>y.componentId),a=f(y=>y.siteCrawlReport),[n,r]=m.useState({}),[o,l]=m.useState(!1),[i,d]=m.useState(null),[p,c]=m.useState(""),[u,h]=m.useState("operator"),[g,x]=m.useState(new Set),v=y=>x(R=>{const U=new Set(R);return U.has(y)?U.delete(y):U.add(y),U}),j=(t==null?void 0:t.startUrl)??tn({storeComponentId:s,storeCrawlReport:a,pageUrls:(t==null?void 0:t.pages.map(y=>y.url))??[]});m.useEffect(()=>{(async()=>{var U;const y=await Rr().catch(()=>null),R=(U=y==null?void 0:y.response)==null?void 0:U.email;R&&h(R)})()},[]),m.useEffect(()=>{let y=!1;return(async()=>{if(!j){y||r({});return}const R=await Wn([j]).catch(()=>[]);if(y)return;const U={};for(const M of R)U[M.criterionId]=M;r(U)})(),()=>{y=!0}},[j]);const I=((C=t==null?void 0:t.spotCheckGate)==null?void 0:C.status)==="pending";if(m.useEffect(()=>{I&&l(!0)},[I]),!t||!j)return null;const E=t.spotCheckGate;if(!E||E.status==="none")return null;const A=E.status==="pending",S=()=>{X({type:"REGRADE_SITE_CRAWL"}).catch(()=>{})},N=async(y,R,U)=>{const M={componentId:j,criterionId:y,kind:R,note:U.trim(),operator:u,timestamp:new Date().toISOString(),toolVersion:chrome.runtime.getManifest().version};await Qn(M),r(te=>({...te,[y]:M})),d(null),c(""),S()},b=async y=>{await qn(j,y),r(R=>{const U={...R};return delete U[y],U}),S()},k=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(y=>!y),style:{width:"100%",textAlign:"left",background:"#0f172a",color:"#e2e8f0",border:"none",padding:"12px 14px",cursor:"pointer",fontSize:13,fontWeight:600},children:[o?"▾":"▸"," ",A?"Required to finalize your grade — spot checks":"Spot checks (content-meaning criteria)",e.jsxs("span",{style:{color:A?"#fbbf24":"#94a3b8",fontWeight:A?600:400},children:[" — ",k," of ",E.total," answered",A?" · grade is PENDING until all are answered":E.displayGrade==="A"?" · grade A":" · grade B"]})]}),o&&e.jsxs("div",{style:{padding:"12px 14px",background:"#0b1220"},children:[A&&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 ",E.total,". ",e.jsxs("strong",{children:[E.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:Bn}),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."]}),Hn.map(y=>{const R=n[y.id],U=Vl(y.id),M=zn[y.id],te=g.has(y.id);return e.jsxs("div",{style:{borderTop:"1px solid #1e293b",padding:"10px 0"},children:[e.jsxs("button",{onClick:()=>v(y.id),"aria-expanded":te,style:{background:"none",border:"none",padding:0,cursor:"pointer",textAlign:"left",width:"100%",fontSize:12,color:"#93c5fd",fontWeight:600,textDecoration:"underline"},children:[te?"▾":"▸"," WCAG ",y.id," — ",U]}),e.jsx("div",{style:{fontSize:11,color:"#cbd5e1",margin:"4px 0 0",lineHeight:1.5},children:(M==null?void 0:M.what)??y.reason}),te&&M&&e.jsxs("div",{style:{margin:"8px 0",padding:"8px 10px",background:"#0f172a",border:"1px solid #334155",borderRadius:6},children:[e.jsxs("div",{style:{fontSize:11,color:"#cbd5e1",lineHeight:1.55,marginBottom:6},children:[e.jsx("span",{style:{color:"#fbbf24",fontWeight:700},children:"Does this apply to you?"})," ",M.applies]}),e.jsxs("div",{style:{fontSize:11,color:"#cbd5e1",lineHeight:1.55},children:[e.jsx("span",{style:{color:"#34d399",fontWeight:700},children:"How to confirm:"})," ",M.confirm]})]}),!te&&e.jsx("div",{style:{fontSize:10,color:"#64748b",margin:"3px 0 8px"},children:e.jsx("button",{onClick:()=>v(y.id),style:{...Ft,color:"#64748b"},children:"does this apply to me? · how do I check this?"})}),te&&e.jsx("div",{style:{height:4}}),R?e.jsxs("div",{style:{fontSize:11,color:"#cbd5e1"},children:[e.jsxs("span",{style:{color:Bl[R.kind],fontWeight:700},children:["● ",Wl[R.kind]]}),R.note?e.jsxs("span",{style:{color:"#94a3b8"},children:[' — "',R.note,'"']}):null,e.jsxs("div",{style:{color:"#64748b",marginTop:2},children:[R.operator," · ",R.timestamp.slice(0,10)," · self-attested, not tool-verified"]}),e.jsx("button",{onClick:()=>void b(y.id),style:Ft,children:"un-attest"})]}):(i==null?void 0:i.id)===y.id?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic",margin:"0 0 6px",lineHeight:1.5},children:['"',Kn(U,new Date().toISOString(),i.kind),'"']}),e.jsx("textarea",{value:p,onChange:P=>c(P.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 N(y.id,i.kind,p),style:{...zl,opacity:p.trim()?1:.5},children:"Record attestation"}),e.jsx("button",{onClick:()=>{d(null),c("")},style:Ft,children:"cancel"})]})]}):e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>{d({id:y.id,kind:"attested-conforms"}),c("")},style:Ot,children:"Conforms…"}),e.jsx("button",{onClick:()=>{d({id:y.id,kind:"attested-na"}),c("")},style:Ot,children:"N/A…"}),e.jsx("button",{onClick:()=>void N(y.id,"not-addressed",""),style:Ot,children:"Not addressed"})]})]},y.id)})]})]})}const Ot={background:"#1e293b",color:"#cbd5e1",border:"1px solid #334155",borderRadius:4,fontSize:11,padding:"4px 8px",cursor:"pointer"},zl={background:"#2563eb",color:"#fff",border:"none",borderRadius:4,fontSize:11,padding:"5px 10px",cursor:"pointer"},Ft={background:"none",color:"#64748b",border:"none",fontSize:11,padding:"2px 0",cursor:"pointer",textDecoration:"underline"},Kl={"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 ql(t){return Kl[t]??null}const Ql={"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 lt(t){return Ql[t]??null}const Yl="https://api.anthropic.com/v1/messages",Jl="2023-06-01",Xl="claude-sonnet-4-6",Zl={input:3/1e6,output:15/1e6},ec={input:1/1e6,output:5/1e6},tc=`You are wcagcheckr's accessibility-audit co-pilot.
19
19
 
20
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
21
 
@@ -32,7 +32,7 @@ Rules:
32
32
  ${t.auditContext}
33
33
  </audit-context>`);const r=await fetch(Yl,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":Jl,"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 o=await r.json(),l=o.content.filter(c=>c.type==="text").map(c=>c.text).join(`
34
34
  `).trim(),i=o.usage.input_tokens,d=o.usage.output_tokens,p=sc(i,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:i,outputTokens:d,costUsd:p,model:o.model}}function ac(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 o=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: ${o}`),s.push(` axe says: ${n.description}`),s.push("")}return s.join(`
35
- `)}const oa="aiConfig";function nc(t){return`https://www.w3.org/WAI/WCAG22/Understanding/${t}`}const rc=new Map(Ia.map(t=>[t.id,t]));async function ic(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=St(t.pageUrl),o=St(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 oc(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 i=[120,250,500,800,1200,800];let d="";for(let p=0;p<=i.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=i[p];if(g===void 0)break;await new Promise(x=>setTimeout(x,g))}return{ok:!1,error:r!==o?`Navigated to ${t.pageUrl} — but the in-page highlighter couldn't attach (${d}).`:d}}function St(t){try{return new URL(t).origin}catch{return""}}function oc(t,s,a){return new Promise(n=>{let r=!1;const o=setTimeout(()=>{r||(r=!0,chrome.tabs.onUpdated.removeListener(l),n(!1))},a);function l(i,d,p){if(i!==t||d.status!=="complete")return;const c=St(p.url??""),u=St(s);u&&c&&c!==u||r||(r=!0,clearTimeout(o),chrome.tabs.onUpdated.removeListener(l),n(!0))}chrome.tabs.onUpdated.addListener(l)})}function la(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 lc(t){return t.length>70?t.slice(0,67)+"...":t}function cc(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 o=s.toDateString()===r.toDateString(),l=s.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return n?`today, ${l}`:o?`yesterday, ${l}`:`${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${l}`}catch{return t}}function dc(){const{report:t}=en(),s=f(j=>j.componentId),a=f(j=>j.siteCrawlReport),[n,r]=m.useState(!1),[o,l]=m.useState(new Set),[i,d]=m.useState(0),p=m.useRef(""),[c,u]=m.useState(!1),[h,g]=m.useState("claude-sonnet-4-6");m.useEffect(()=>{(async()=>{const I=(await chrome.storage.local.get(oa))[oa];p.current=(I==null?void 0:I.apiKey)??"",u(!!(I!=null&&I.apiKey)),I!=null&&I.model&&g(I.model)})()},[]);const x=tn({storeComponentId:s,storeCrawlReport:a,pageUrls:(t==null?void 0:t.pages.map(j=>j.url))??[]});if(m.useEffect(()=>{let j=!1;return(async()=>{if(!x){j||l(new Set);return}try{const I=await rs([x]);if(j)return;l(new Set(I.map(E=>E.criterionId)))}catch{j||l(new Set)}})(),()=>{j=!0}},[x,i]),!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(j=>!j),"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 j=v.length,I=v.filter(A=>o.has(A.criterionId)).length,E=j-I;return I===0?`${j} criteri${j===1?"on":"a"} need${j===1?"s":""} your judgment`:E===0?`${j} criteri${j===1?"on":"a"} verified — re-crawl to lift the grade`:`${I} of ${j} verified · ${E} 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(j=>e.jsx(uc,{criterionId:j.criterionId,title:j.title,state:j.state,evidence:j.evidence,targetComponentId:x,apiKeyRef:p,apiKeyPresent:c,model:h,onVerdictChange:()=>d(I=>I+1)},j.criterionId))]})]})}function uc({criterionId:t,title:s,state:a,evidence:n,targetComponentId:r,apiKeyRef:o,apiKeyPresent:l,model:i,onVerdictChange:d}){var Z,ae;const[p,c]=m.useState(null),[u,h]=m.useState(""),[g,x]=m.useState(!1),[v,j]=m.useState(null),[I,E]=m.useState(null),[A,S]=m.useState(!0),[N,b]=m.useState(!1),[k,C]=m.useState(null),[y,R]=m.useState(null),[U,M]=m.useState(null),te={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 z=!1;return(async()=>{if(!r){z||S(!1);return}try{const se=(await rs([r])).find(w=>w.criterionId===t);if(z)return;E(se?{verdict:se.verdict,note:se.note,verifiedAt:se.verifiedAt}:null)}catch{z||E(null)}finally{z||S(!1)}})(),()=>{z=!0}},[t,r]);async function P(){if(r){x(!0),j(null);try{await Yn(r,t),E(null),d()}catch(z){j(z instanceof Error?z.message:String(z))}finally{x(!1)}}}const G=rc.get(t),T=G==null?void 0:G.shortDescription,L=G==null?void 0:G.understandingSlug,F=ql(t);async function O(){if(!o.current){R("Set an Anthropic API key in extension Options first.");return}b(!0),R(null);try{const ee=`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.`,se=await sn({apiKey:o.current,model:i,messages:[{role:"user",content:ee}],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});C(se.text),M(se.costUsd)}catch(z){R(z instanceof Error?z.message:String(z))}finally{b(!1)}}async function $(z){if(!r){j("No componentId available — re-run an audit first.");return}if(!u.trim()){j("Note is required — describe what you checked and why this verdict applies.");return}x(!0),j(null);const ee=new Date().toISOString(),se=u.trim();try{await Jn({componentId:r,criterionId:t,verdict:z,note:se,verifiedAt:ee}),E({verdict:z,note:se,verifiedAt:ee}),c(null),h(""),d()}catch(w){j(w instanceof Error?w.message:String(w))}finally{x(!1)}}if(I){const ee={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"}}[I.verdict];return e.jsxs("div",{role:"status",style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:ee.bg,border:`1px solid ${ee.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:ee.ink},children:["✓ ",ee.label]})]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.5,whiteSpace:"pre-wrap"},children:I.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 ",cc(I.verifiedAt)]}),e.jsx("button",{type:"button",onClick:P,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 A?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&&lt(t)&&e.jsx("span",{title:`AI would add: ${(Z=lt(t))==null?void 0:Z.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"})]}),T&&e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.5},children:T}),!l&&lt(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: ",(ae=lt(t))==null?void 0:ae.whatAiAdds]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:te[a]}),F&&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:F.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((z,ee)=>e.jsx(pc,{ev:z},`${z.pageUrl}::${z.selector??""}::${ee}`))})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-3)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap",alignItems:"center"},children:[L&&e.jsx("a",{href:nc(L),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:O,disabled:N,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:N?"wait":"pointer",fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:N?"Explaining…":k?"Re-explain with AI":"Explain with AI ↗"})]}),(k||y)&&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:[k&&e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.55,whiteSpace:"pre-wrap"},children:k}),y&&e.jsx("p",{role:"alert",style:{margin:0,fontSize:11,color:"var(--v2-critical)"},children:y}),U!==null&&e.jsxs("p",{className:"v2-mono",style:{margin:"4px 0 0",fontSize:10,color:"var(--v2-ink-tertiary)"},children:["$",U.toFixed(4)," · ",i]})]}),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"),j(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"),j(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"),j(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:z=>h(z.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:()=>$(p),disabled:g||!u.trim(),children:g?"Saving…":`Confirm ${p.toUpperCase()}`})})]})]})}function pc({ev:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(null);async function o(){a(!0),r(null);try{const l=await ic({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 ${la(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:la(t.pageUrl)}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:o,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:lc(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 bt="wcagcheckr";function de(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function et(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 hc(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function mc(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 xc(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 gc(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 fc(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 (${de(t.receipt.tsaName)}) — anchored ${de(et(t.receipt.anchoredAt))}</td></tr>
35
+ `)}const oa="aiConfig";function nc(t){return`https://www.w3.org/WAI/WCAG22/Understanding/${t}`}const rc=new Map(Ia.map(t=>[t.id,t]));async function ic(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=St(t.pageUrl),o=St(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 oc(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 i=[120,250,500,800,1200,800];let d="";for(let p=0;p<=i.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=i[p];if(g===void 0)break;await new Promise(x=>setTimeout(x,g))}return{ok:!1,error:r!==o?`Navigated to ${t.pageUrl} — but the in-page highlighter couldn't attach (${d}).`:d}}function St(t){try{return new URL(t).origin}catch{return""}}function oc(t,s,a){return new Promise(n=>{let r=!1;const o=setTimeout(()=>{r||(r=!0,chrome.tabs.onUpdated.removeListener(l),n(!1))},a);function l(i,d,p){if(i!==t||d.status!=="complete")return;const c=St(p.url??""),u=St(s);u&&c&&c!==u||r||(r=!0,clearTimeout(o),chrome.tabs.onUpdated.removeListener(l),n(!0))}chrome.tabs.onUpdated.addListener(l)})}function la(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 lc(t){return t.length>70?t.slice(0,67)+"...":t}function cc(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 o=s.toDateString()===r.toDateString(),l=s.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return n?`today, ${l}`:o?`yesterday, ${l}`:`${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${l}`}catch{return t}}function dc(){const{report:t}=en(),s=f(j=>j.componentId),a=f(j=>j.siteCrawlReport),[n,r]=m.useState(!1),[o,l]=m.useState(new Set),[i,d]=m.useState(0),p=m.useRef(""),[c,u]=m.useState(!1),[h,g]=m.useState("claude-sonnet-4-6");m.useEffect(()=>{(async()=>{const I=(await chrome.storage.local.get(oa))[oa];p.current=(I==null?void 0:I.apiKey)??"",u(!!(I!=null&&I.apiKey)),I!=null&&I.model&&g(I.model)})()},[]);const x=(a==null?void 0:a.startUrl)??tn({storeComponentId:s,storeCrawlReport:a,pageUrls:(t==null?void 0:t.pages.map(j=>j.url))??[]});if(m.useEffect(()=>{let j=!1;return(async()=>{if(!x){j||l(new Set);return}try{const I=await rs([x]);if(j)return;l(new Set(I.map(E=>E.criterionId)))}catch{j||l(new Set)}})(),()=>{j=!0}},[x,i]),!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(j=>!j),"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 j=v.length,I=v.filter(A=>o.has(A.criterionId)).length,E=j-I;return I===0?`${j} criteri${j===1?"on":"a"} need${j===1?"s":""} your judgment`:E===0?`${j} criteri${j===1?"on":"a"} verified — re-crawl to lift the grade`:`${I} of ${j} verified · ${E} 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(j=>e.jsx(uc,{criterionId:j.criterionId,title:j.title,state:j.state,evidence:j.evidence,targetComponentId:x,apiKeyRef:p,apiKeyPresent:c,model:h,onVerdictChange:()=>d(I=>I+1)},j.criterionId))]})]})}function uc({criterionId:t,title:s,state:a,evidence:n,targetComponentId:r,apiKeyRef:o,apiKeyPresent:l,model:i,onVerdictChange:d}){var Z,ae;const[p,c]=m.useState(null),[u,h]=m.useState(""),[g,x]=m.useState(!1),[v,j]=m.useState(null),[I,E]=m.useState(null),[A,S]=m.useState(!0),[N,b]=m.useState(!1),[k,C]=m.useState(null),[y,R]=m.useState(null),[U,M]=m.useState(null),te={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 z=!1;return(async()=>{if(!r){z||S(!1);return}try{const se=(await rs([r])).find(w=>w.criterionId===t);if(z)return;E(se?{verdict:se.verdict,note:se.note,verifiedAt:se.verifiedAt}:null)}catch{z||E(null)}finally{z||S(!1)}})(),()=>{z=!0}},[t,r]);async function P(){if(r){x(!0),j(null);try{await Yn(r,t),E(null),d()}catch(z){j(z instanceof Error?z.message:String(z))}finally{x(!1)}}}const G=rc.get(t),T=G==null?void 0:G.shortDescription,L=G==null?void 0:G.understandingSlug,F=ql(t);async function O(){if(!o.current){R("Set an Anthropic API key in extension Options first.");return}b(!0),R(null);try{const ee=`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.`,se=await sn({apiKey:o.current,model:i,messages:[{role:"user",content:ee}],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});C(se.text),M(se.costUsd)}catch(z){R(z instanceof Error?z.message:String(z))}finally{b(!1)}}async function $(z){if(!r){j("No componentId available — re-run an audit first.");return}if(!u.trim()){j("Note is required — describe what you checked and why this verdict applies.");return}x(!0),j(null);const ee=new Date().toISOString(),se=u.trim();try{await Jn({componentId:r,criterionId:t,verdict:z,note:se,verifiedAt:ee}),E({verdict:z,note:se,verifiedAt:ee}),c(null),h(""),d()}catch(w){j(w instanceof Error?w.message:String(w))}finally{x(!1)}}if(I){const ee={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"}}[I.verdict];return e.jsxs("div",{role:"status",style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:ee.bg,border:`1px solid ${ee.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:ee.ink},children:["✓ ",ee.label]})]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.5,whiteSpace:"pre-wrap"},children:I.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 ",cc(I.verifiedAt)]}),e.jsx("button",{type:"button",onClick:P,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 A?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&&lt(t)&&e.jsx("span",{title:`AI would add: ${(Z=lt(t))==null?void 0:Z.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"})]}),T&&e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.5},children:T}),!l&&lt(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: ",(ae=lt(t))==null?void 0:ae.whatAiAdds]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:te[a]}),F&&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:F.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((z,ee)=>e.jsx(pc,{ev:z},`${z.pageUrl}::${z.selector??""}::${ee}`))})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-3)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap",alignItems:"center"},children:[L&&e.jsx("a",{href:nc(L),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:O,disabled:N,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:N?"wait":"pointer",fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:N?"Explaining…":k?"Re-explain with AI":"Explain with AI ↗"})]}),(k||y)&&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:[k&&e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.55,whiteSpace:"pre-wrap"},children:k}),y&&e.jsx("p",{role:"alert",style:{margin:0,fontSize:11,color:"var(--v2-critical)"},children:y}),U!==null&&e.jsxs("p",{className:"v2-mono",style:{margin:"4px 0 0",fontSize:10,color:"var(--v2-ink-tertiary)"},children:["$",U.toFixed(4)," · ",i]})]}),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"),j(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"),j(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"),j(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:z=>h(z.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:()=>$(p),disabled:g||!u.trim(),children:g?"Saving…":`Confirm ${p.toUpperCase()}`})})]})]})}function pc({ev:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(null);async function o(){a(!0),r(null);try{const l=await ic({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 ${la(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:la(t.pageUrl)}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:o,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:lc(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 bt="wcagcheckr";function de(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function et(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 hc(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function mc(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 xc(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 gc(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 fc(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 (${de(t.receipt.tsaName)}) — anchored ${de(et(t.receipt.anchoredAt))}</td></tr>
36
36
  <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${de(t.receipt.serverKeyFingerprint)}</code></td></tr>
37
37
  ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${de(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${de(bt)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
38
38
  <article class="entry">