@wcag-checkr/ci 1.0.0-rc.331 → 1.0.0-rc.333

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,26 +1,26 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-QcMYcqgA.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-Bu2p8K-p.js","assets/ai-usage-log-D5enikfX.js","assets/diff-DIBMr3fQ.js","assets/copy-ai-fixer-prompt-D22iP0cq.js","assets/site-report-renderer-DA-9wVvE.js"])))=>i.map(i=>d[i]);
2
- var Ba=Object.defineProperty;var Ha=(t,s,a)=>s in t?Ba(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var ls=(t,s,a)=>Ha(t,typeof s!="symbol"?s+"":s,a);import{R as ze,i as ge,r as m,j as e,M as Me,C as Lt,A as tt}from"./styles-Kyv31scG.js";import{e as Xs,o as Bt,p as Ka,q as ue,t as Zs,u as Ue,S as De,g as qe,v as Ie,w as Le,x as Ht,y as ea,z as za,A as Kt,B as fe,C as qa,D as Qa,E as Ya,F as Ja,k as Xa,G as Za,h as en,i as zt,H as tn,I as sn,N as an,J as _t,K as ta,L as Dt,M as nn,O as rn,f as dt,P as ut,Q as on,R as ln,T as cs,U as cn,V as dn,X as un,Y as pn,Z as hn,_ as mn,$ as xn,a0 as gn,a1 as fn,a2 as bn,a3 as vn,a4 as yn,a5 as wn,a6 as sa,a7 as jn,a8 as ds,a9 as us,aa as kt,ab as Nn,ac as ps,ad as kn,ae as Sn,af as An,m as Cn,n as In}from"./scheduled-audit-runner-QcMYcqgA.js";import{_ as ke}from"./preload-helper-D7HrI6pR.js";import{o as we,a as Z,s as ae,c as aa,d as be,r as Ee}from"./crash-reporter-Bu2p8K-p.js";import{g as na,j as ft,k as bt,t as et,m as En,B as Oe,i as qt,n as Rn,o as $e,T as ra,p as ia,q as vt,u as Tn}from"./ai-usage-log-D5enikfX.js";import{s as $n,t as Un}from"./design-system-audit-DpxJrxnb.js";const hs=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(x=>x(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},Ln=t=>t?hs(t):hs,_n=t=>t;function Dn(t,s=_n){const a=ze.useSyncExternalStore(t.subscribe,ze.useCallback(()=>s(t.getState()),[t,s]),ze.useCallback(()=>s(t.getInitialState()),[t,s]));return ze.useDebugValue(a),a}const ms=t=>{const s=Ln(t),a=n=>Dn(s,n);return Object.assign(a,s),a},On=t=>t?ms(t):ms,y=On(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,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,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,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,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}),Xs(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),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}})})),pt="sidePanel:lastAudit";function Fn(){const t=[];return t.push(we("AUDIT_PROGRESS_EVENT",s=>{const a=y.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||ge.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`))})),t.push(we("AUDIT_COMPLETE_EVENT",s=>{var i;y.getState().setResults(s.results,s.delta,s.componentId);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"}.`;ge.polite(r);const o=y.getState().view;["compliance","guided","crawl"].includes(o)||(y.getState().setView("report"),y.getState().setFindingsLens("overview")),Pn({results:s.results,delta:s.delta,componentId:s.componentId}),Mn(s.results,s.delta,s.componentId)})),t.push(we("AUDIT_FAILED_EVENT",s=>{y.getState().setError(s.error.message)})),t.push(we("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=y.getState().aiProgress;y.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ge.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(we("AI_AUGMENTATION_FAILED_EVENT",s=>{y.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(we("SCORECARD_UPDATED_EVENT",()=>{ht()})),t.push(we("LICENSE_CHANGED_EVENT",()=>{oa()})),t.push(we("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=y.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ge.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(we("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=y.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ge.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`),(async()=>{try{const{loadSiteCrawlPerUrlResults:n}=await ke(async()=>{const{loadSiteCrawlPerUrlResults:i}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(d=>d.aR);return{loadSiteCrawlPerUrlResults:i}},__vite__mapDeps([0,1,2,3,4])),{getResolutionsForPage:r}=await ke(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(d=>d.aT);return{getResolutionsForPage:i}},__vite__mapDeps([0,1,2,3,4])),o=await n();if(!o||o.length===0)return;const l=y.getState().setResolutionsForUrl;await Promise.all(o.map(async i=>{try{const d=await r(i.url);l(i.url,d)}catch{}}))}catch(n){console.warn("[site-crawl] failed to pre-warm resolutions cache",n)}})()})),t.push(we("SITE_CRAWL_FAILED_EVENT",s=>{const a=y.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ge.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Mn(t,s,a){var n,r;if(t.length!==0)try{const o=await na();if(!o.enabled)return;const l=y.getState().tier;if(Bt(l)||!ft(l,"autoExportAuditReports"))return;const i=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",d=[],p=y.getState().lastAuditWallClockMs??void 0;for(const c of o.formats)try{const u=await Z({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=bt(c,a??null);et(u.content,h),i&&await En({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&&ge.polite(`Audit auto-exported ${d.length} file${d.length===1?"":"s"}.`)}catch(o){console.warn("[auto-export] failed:",o)}}async function Pn(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[pt]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Gn(){const s=(await chrome.storage.local.get(pt))[pt];s&&y.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Vn(){await chrome.storage.local.remove(pt)}async function yt(){y.getState().clearResults(),await Vn()}async function ht(){const t=await Z({type:"BASELINE_LIST"});y.getState().setBaselineList(t.items)}async function oa(t){const s=await Z({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});y.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),la()}async function la(){const{fetchMessages:t}=await ke(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Jn);return{fetchMessages:n}},void 0),s=y.getState().userMode,a=await t(s);a&&y.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Wn(){const s=(await Z({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;y.getState().setUserMode(a)}function Bn(){return chrome.runtime.connect({name:"audit-keepalive"})}let mt=null;async function Hn(){if(mt===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(mt=t.id)}catch{}}function ca(){if(mt===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:mt}).catch(()=>{})}function Ne(t){ca(),y.getState().setSiteCrawlReport(null),Xs(null).catch(()=>{}),ae(t)}const Ot="dismissedFindings";function wt(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function Ye(t){return`reading-order::${t}`}function Je(t){return`tab-order::${t}`}function Qt(t){return`violation::${t}`}async function jt(){try{const t=await chrome.storage.local.get(Ot),s=t==null?void 0:t[Ot];if(s&&typeof s=="object")return s}catch{}return{}}async function Yt(t){await chrome.storage.local.set({[Ot]:t})}async function Jt(t){return(await jt())[wt(t)]??{}}async function Xt(t,s,a,n){const r=await jt(),o=wt(t),l=r[o]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[o]=l,await Yt(r)}async function Xe(t,s){if(s.length===0)return;const a=await jt(),n=wt(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 Yt(a)}async function Zt(t,s){const a=await jt(),n=wt(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await Yt(a))}const Vc=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Xt,addDismissals:Xe,dismissalKeyForReadingOrder:Ye,dismissalKeyForTabOrder:Je,dismissalKeyForViolation:Qt,getDismissalsForUrl:Jt,removeDismissal:Zt},Symbol.toStringTag,{value:"Module"}));function Kn({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 x(b){var w;if(b.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const N=await Z({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:o,replyEmail:i.trim()||void 0});N.success?(h({ok:!0,msg:`Sent (ref: ${N.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((w=N.error)==null?void 0:w.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:x,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:b=>a(b.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:b=>r(b.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:b=>d(b.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:b=>l(b.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 xs({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 xt=aa("messages-client"),zn="https://api.wcagcheckr.com",da="wcagcheckr",qn=1e4;function Qn(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ua(t,s){const a=await Ka();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Qn()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${zn}${t}`,{...s,headers:n,signal:AbortSignal.timeout(qn)})}async function Yn(t){try{const s=await ua(`/v1/products/${da}/messages`,{userMode:t??null});return s.ok?await s.json():(xt.warn("fetchMessages http",s.status),null)}catch(s){return xt.warn("fetchMessages failed",s),null}}async function Fe(t,s){try{const a=await ua(`/v1/products/${da}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(xt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return xt.warn("ackMessage failed",a),!1}}const Jn=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Fe,fetchMessages:Yn},Symbol.toStringTag,{value:"Module"})),Xn=["http:","https:"];function Zn(t){try{const s=new URL(t);return Xn.includes(s.protocol)}catch{return!1}}function gs(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);Zn(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 pa({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:gs(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:gs(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 er={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},tr={critical:"bg-rose-50 border-rose-200"};function ha(){const t=y(h=>h.unreadMessageCount),s=y(h=>h.messages),a=y(h=>h.applyMessageAck),[n,r]=m.useState(!1),o=m.useRef(-1),[l,i]=m.useState(!1);m.useEffect(()=>{const h=s.filter(b=>!b.seen);if(h.length===0)return;const x=Math.max(...h.map(b=>b.id));if(x>o.current){o.current=x,i(!0);const b=setTimeout(()=>i(!1),1500);return()=>clearTimeout(b)}},[s]);async function d(){const h=s.filter(x=>!x.seen);if(h.length!==0)for(const x of h)a(x.id,"seen"),Fe(x.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function c(h){a(h.id,"dismissed"),await Fe(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),Fe(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(sr,{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(ar,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function sr({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 ar({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:()=>{la()},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 ${er[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(pa,{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 ma(){const t=y(o=>o.messages),s=y(o=>o.applyMessageAck),a=t.find(o=>o.severity==="critical"&&!o.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await Fe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),Fe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${tr.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(pa,{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 nr=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function rr(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function ir(){var u,h;const t=y(x=>x.view),s=y(x=>x.setView),a=y(x=>x.setUserMode),n=y(x=>x.results),r=y(x=>x.status),[o,l]=m.useState(!1),i=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),d=rr(i),p=n.length>0&&r!=="running";function c(){a("owner"),ae({type:"SETTINGS_SET",key:"userMode",value:"owner"})}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.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]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{chrome.storage.local.set({v2UiEnabled:!0})},title:"Switch to the new v2 UI preview (rc.276+). Toggle off via the same button in v2's settings.",className:"text-[11px] px-2 py-1 border border-emerald-400 rounded text-emerald-700 bg-white hover:bg-emerald-50 font-medium",children:"Try v2 UI"}),e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(ha,{}),e.jsx(xs,{onClick:()=>void ae({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(xs,{onClick:()=>l(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&d&&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:i??"",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 ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void yt(),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(or,{view:t,setView:s}),e.jsx(Me,{open:o,onClose:()=>l(!1),title:"Send support message",children:e.jsx(Kn,{onClose:()=>l(!1)})})]})}function or({view:t,setView:s}){const a=m.useRef([]),n=y(i=>i.results),r=nr.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 lr({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(Lt,{open:a,onClose:()=>n(!1)})]})}const cr="https://wcagcheckr.com/upgrade";function dr(){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(Oe),[c,u]=m.useState(Oe[0].id),[h,x]=m.useState("none"),[b,w]=m.useState(null),N=y(_=>_.status),E=y(_=>_.tier),I=y(_=>_.results.length>0),C=N==="running";m.useEffect(()=>{Promise.all([Z({type:"SETTINGS_GET",key:"matrixPresets"}),Z({type:"SETTINGS_GET",key:"activePresetId"})]).then(([_,F])=>{const H=Array.isArray(_.data)?_.data:null;p(H&&H.length>0?H:Oe),typeof F.data=="string"&&u(F.data)})},[]);function f(_){const F=d.find(H=>H.id===_);F&&(u(_),ae({type:"SETTINGS_SET",key:"activePresetId",value:_}),ae({type:"SETTINGS_SET",key:"stateMatrix",value:F.matrix}))}const j=ft(E,"storybookAutoIterate");m.useEffect(()=>{const _=we("ELEMENT_PICKED_EVENT",(H,R)=>{n(!1);const M=R.frameId;q(M),o({selector:H.selector,frameId:M,speech:H.speech})}),F=we("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{_(),F()}},[]);async function g(){const _=await ue();_&&(n(!0),await be(_,{type:"PICKER_ACTIVATE_REQUEST",tabId:_}))}function v(){r&&(q(r.frameId),Ne({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),y.getState().startNewScan())}function S(){if(!j){i("storybook:auto-iterate");return}q(),Ne({type:"START_AUDIT",mode:"storybook-all"}),y.getState().startNewScan()}function k(){q(),Ne({type:"START_AUDIT",mode:"all-frames"}),y.getState().startNewScan()}function T(){q(),Ne({type:"START_AUDIT",mode:"full-page"}),y.getState().startNewScan()}function V(){q(),Ne({type:"START_AUDIT",mode:"full-page",verifyFixesOnly:!0}),y.getState().startNewScan()}function P(){q(),Ne({type:"START_AUDIT",mode:"quick-scan"}),y.getState().startNewScan()}function B(){q(),Ne({type:"START_AUDIT",mode:"parallel-scan"}),y.getState().startNewScan()}function U(){ae({type:"CANCEL_AUDIT"})}async function q(_){y.getState().setPinned(null);const F=await ue();if(F)try{await be(F,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:F},_)}catch{}}async function $(_){w(null);const F=await ue();if(!F){w("No audited tab; open a page first.");return}if(_==="none"){const R=await Z({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:F});R.ok||w(R.error??"Failed to clear throttle."),x("none");return}const H=await Z({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:F,profile:_});if(!H.ok){w(H.error??"Failed to apply throttle.");return}x(_)}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:_=>s(_.target.value),disabled:C||a,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",j?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:_=>f(_.target.value),disabled:C||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:_=>void $(_.target.value),disabled:C||a,title:"Apply CDP network + CPU throttling to the audited tab. Catch contrast / focus / loading-state issues that only manifest under realistic conditions.",className:`text-xs border rounded px-2 py-1 ${h==="none"?"border-slate-300":"border-amber-400 bg-amber-50"}`,children:[e.jsx("option",{value:"none",children:"⚡ Throttle: off"}),e.jsx("option",{value:"3g-slow",children:"⚡ Slow 3G + 6× CPU"}),e.jsx("option",{value:"3g-fast",children:"⚡ Fast 3G + 4× CPU"}),e.jsx("option",{value:"4g",children:"⚡ 4G LTE + 2× CPU"}),e.jsx("option",{value:"cpu-2x",children:"⚡ CPU 2× only"}),e.jsx("option",{value:"cpu-4x",children:"⚡ CPU 4× only"})]}),t==="single-element"?e.jsx(pr,{picking:a,picked:r,isRunning:C,onPick:g,onRun:v,onClearPick:()=>o(null)}):t==="full-page"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:T,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Scan page"}),e.jsx("button",{onClick:V,disabled:C||!I,className:"text-xs px-3 py-1 border border-emerald-400 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed",title:I?"Re-runs the audit but skips walkthroughs that already passed or are human-acked. Faster + cheaper after a fix/ack pass.":"Run a full Scan page first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.",children:C?"Auditing…":"Verify fixes (skip passed)"})]}):t==="quick-scan"?e.jsx("button",{onClick:P,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:C?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:B,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:C?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:k,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:S,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all stories"}),C&&e.jsx("button",{onClick:U,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!C&&I&&e.jsx("button",{type:"button",onClick:()=>void yt(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),b&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",b]}),t==="single-element"&&r&&!a&&!C&&e.jsx(hr,{selector:r.selector,onRepick:g,onClear:()=>o(null)})]}),e.jsx(Me,{open:l!==null,onClose:()=>i(null),title:"Upgrade to continue",children:e.jsx(lr,{feature:l??"",upgradeUrl:cr})})]})}function ur({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 pr({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(ur,{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 hr({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 mr={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},xr={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function gr(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState("off"),p=y(x=>x.results).flatMap(x=>x.violations);async function c(x){const b=await ue();b&&(i(x),x==="off"?await be(b,{type:"VISION_SIMULATOR_CLEAR",tabId:b}).catch(()=>{}):await be(b,{type:"VISION_SIMULATOR_APPLY",tabId:b,mode:x}).catch(()=>{}))}async function u(x){const b=await ue();if(b){if(t&&await be(b,{type:mr[t],tabId:b}).catch(()=>{}),t===x){s(null);return}await be(b,{type:xr[x],tabId:b}).catch(()=>{}),s(x)}}async function h(){const x=await ue();if(x){if(a){await be(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),o(null);return}if(p.length===0){o("Run an audit first.");return}try{const b=await Ee(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:p});n(!0),o(`Previewing ${b.visualFixCount} visual fix${b.visualFixCount===1?"":"es"} + ${b.annotationCount} annotation${b.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(Ge,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(Ge,{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:()=>u("tab-order")}),e.jsx(Ge,{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:()=>u("reading-order")}),e.jsx(Ge,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(Ge,{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:h}),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 c(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 Ge({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 fr(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 br(){const t=y(d=>d.status),s=y(d=>d.progress),a=y(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":fr(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(fs,{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(fs,{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 fs({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 vr(){const t=new Set;for(const s of De)for(const a of s.axeRules)t.add(a);return t}function xa(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 yr(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 wr(t,s,a={}){const n=vr(),o=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),l=Zs(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=>Ue(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const u=Ue(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 bs(t,s){var n;const a=new Set;for(const r of s)for(const o of((n=r.axeRulesEvaluated)==null?void 0:n.incomplete)??[])for(const l of o.elements??[])a.add(`${o.ruleId}::${l.selector}`);return t.filter(r=>r.verdict==="fail"&&a.has(`${r.ruleId}::${r.selector}`))}function es(t){var o,l;const s=((o=t[0])==null?void 0:o.pageUrl)??((l=t[0])==null?void 0:l.scope)??"",a=y(i=>i.setResolutionsForUrl),[n,r]=m.useState(()=>{if(!s)return[];const i=y.getState().resolutionsByUrl[s];return i?bs(i,t):[]});return m.useEffect(()=>{if(!s){r([]);return}let i=!1;return qe(s).then(d=>{i||(a(s,d),r(bs(d,t)))}),()=>{i=!0}},[s,t,a]),n}const jr=[{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 Nr(){const t=y(n=>n.results),s=y(n=>n.status),a=y(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(kr,{results:t,status:s,setView:a}),e.jsx(Sr,{setView:a})]})}function kr({results:t,status:s,setView:a}){var x,b;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 n=t.flatMap(w=>w.violations),r=Zs(n),o=((x=t[0])==null?void 0:x.pageUrl)??((b=t[0])==null?void 0:b.scope)??"audited page",l=t.length,i=es(t),d=y(w=>w.acknowledgedKeys),p=y(w=>w.dismissedKeys),c=xa(n,i,d,p),u=3,h=c>0&&c<=u?r.slice(0,u):[];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 · ",l," state",l===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate mt-0.5",title:o,children:c===0?"No issues found by automation":`Fix ${c} element${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 →"})]}),h.length>0&&e.jsx("ul",{className:"border-t border-slate-200 divide-y divide-slate-100","aria-label":"Violations inline list",children:h.map(w=>{var I;const N=((I=w.target)==null?void 0:I.selector)??"(no selector)",E=N.length>50?N.slice(0,47)+"…":N;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:`${w.description??w.ruleId} — ${N}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${w.impact==="critical"?"bg-rose-200 text-rose-900":w.impact==="serious"?"bg-orange-200 text-orange-900":w.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:w.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:w.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:E})]})},`${w.ruleId}::${N}`)})})]})}function Sr({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:jr.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-400",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 Ar={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Cr={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 Ir({violations:t,componentId:s,hideOverallHeader:a=!1}){var pe,L,X,z,Y,he,de,xe;const[n,r]=m.useState([]),[o,l]=m.useState({}),[i,d]=m.useState([]),[p,c]=m.useState([]),[u,h]=m.useState(new Set),[x,b]=m.useState(null),[w,N]=m.useState({}),[E,I]=m.useState(new Set),[C,f]=m.useState(null),j=y(O=>O.status),g=y(O=>O.progress),v=y(O=>O.freshThisSession),S=y(O=>O.results),k=(pe=S[0])==null?void 0:pe.startedAt,T=((L=S[0])==null?void 0:L.pageUrl)??((X=S[0])==null?void 0:X.scope)??null;m.useEffect(()=>{if(!s){r([]),l({});return}let O=!1;return chrome.storage.local.get("igtRuns").then(ee=>{if(O)return;const se=((ee==null?void 0:ee.igtRuns)??{})[s]??{};r(Object.values(se))}),Promise.all([Ie(s),Le([s])]).then(([ee,me])=>{if(O)return;const se=new Set(me.map(J=>J.criterionId)),Q={},ve=[];for(const J of ee){const re=se.has(J.criterionId)?"pass":J.verdict;J.criterionId==="2.4.3"?Q.focusOrder=re:J.criterionId==="2.1.2"?Q.keyboardTrap=re:J.criterionId==="2.4.7"?Q.focusVisible=re:J.criterionId==="1.3.2"?Q.readingOrder=re:J.criterionId==="1.4.11"&&(Q.nonTextContrast=re),ve.push({criterionId:J.criterionId,ruleId:`ai-walkthrough-${J.criterionId}`,pageUrl:J.pageUrl,verdict:re,reasoning:se.has(J.criterionId)?`Human verified: ${J.reasoning}`:J.reasoning})}l(Q),d(ve)}),()=>{O=!0}},[s]),m.useEffect(()=>{if(!T){c([]);return}let O=!1;return qe(T).then(ee=>{O||c(ee)}),()=>{O=!0}},[T,S]);const V=es(S);if(j==="running")return e.jsx(_r,{current:g==null?void 0:g.current,total:g==null?void 0:g.total});const P=Ht({violations:t,auditRan:S.length>0,manualRuns:n,workflows:fe,heuristicCounts:{tabOrder:((Y=(z=S[0])==null?void 0:z.tabOrderIssues)==null?void 0:Y.length)??0,readingOrder:((de=(he=S[0])==null?void 0:he.readingOrderIssues)==null?void 0:de.length)??0},interactiveAuditVerdicts:o,aiResolvedFails:V.map(O=>({ruleId:O.ruleId,impact:"serious",selector:O.selector}))}),B=y(O=>O.acknowledgedKeys),q=new Set(S.map(O=>O.pageUrl??O.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",$=S.length>0?ea(S,{runs:n,workflows:fe},"2.1","AA",B,p,i,q):void 0,_=S.length>0?za(Kt({audits:S,igtRuns:n,workflows:fe,acknowledgedMatchKeys:B,incompleteResolutions:p,interactiveAuditResults:i,auditScope:q}),fe):void 0,F=P.overallLetter,R=($?$.failingCriteria.length+$.inconclusiveCriteria.length+$.untestedCriteria.length:0)===0&&!!$;async function M(O){var ve;if(!T||!((ve=$==null?void 0:$.inconclusiveReasons)!=null&&ve[O]))return;const me=$.inconclusiveReasons[O].filter(J=>J.source==="axe-incomplete"&&J.elements&&J.elements.length>0);if(me.length===0)return;h(J=>new Set(J).add(O)),b(null);const se=[];let Q=0;try{for(const re of me){const je=await ae({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:re.ruleOrStepId,pageUrl:re.pageUrl??T,wcagCriterion:O,elements:re.elements??[],targetLevel:"AA"});if(je!=null&&je.unavailableReason){b(je.unavailableReason);break}je!=null&&je.resolutions&&(se.push(...je.resolutions),Q+=je.totalCostUsd??0)}if(T){const re=await qe(T);c(re)}const J={total:se.length,pass:se.filter(re=>re.verdict==="pass").length,fail:se.filter(re=>re.verdict==="fail").length,uncertain:se.filter(re=>re.verdict==="uncertain").length,costUsd:Q,resolutions:se};N(re=>({...re,[O]:J}))}finally{h(J=>{const re=new Set(J);return re.delete(O),re})}}function ie(O){I(ee=>{const me=new Set(ee);return me.has(O)?me.delete(O):me.add(O),me})}const A=((xe=S[0])==null?void 0:xe.startedAt)??null,G=s&&A?`${s}::${A}`:null;m.useEffect(()=>{if(!G||!$||C===G||j!=="complete")return;const O=$.inconclusiveCriteria.filter(ee=>{var se;return(((se=$.inconclusiveReasons)==null?void 0:se[ee])??[]).some(Q=>Q.source==="axe-incomplete"&&Q.elements&&Q.elements.length>0)});if(O.length===0){f(G);return}f(G),(async()=>{for(const ee of O)try{await M(ee)}catch{}})()},[G,$,j]);async function W(O){var je,os;if(!T)return;const ee=((je=$==null?void 0:$.inconclusiveReasons)==null?void 0:je[O])??[],me=((os=$==null?void 0:$.failingReasons)==null?void 0:os[O])??[],se=[],Q=new Set;for(const ce of ee){if(ce.source!=="axe-incomplete"||!ce.elements)continue;const Se=ce.pageUrl??T;for(const Ae of ce.elements){const Pe=`${Se}::${ce.ruleOrStepId}::${Ae.selector}`;Q.has(Pe)||(Q.add(Pe),se.push({ruleId:ce.ruleOrStepId,pageUrl:Se,selector:Ae.selector}))}}for(const ce of me){if(ce.source!=="ai"||!ce.selector)continue;const Se=ce.ruleOrStepId.startsWith("ai-resolved::")?ce.ruleOrStepId.slice(13):ce.ruleOrStepId,Ae=ce.pageUrl??T,Pe=`${Ae}::${Se}::${ce.selector}`;Q.has(Pe)||(Q.add(Pe),se.push({ruleId:Se,pageUrl:Ae,selector:ce.selector}))}if(se.length===0)return;const ve=new Date().toISOString(),J=[];for(const ce of se){const Se=p.find(Ae=>Ae.pageUrl===ce.pageUrl&&Ae.ruleId===ce.ruleId&&Ae.selector===ce.selector);Se&&Se.verdict==="pass"&&Se.reasoning.startsWith("Marked as visually verified")||J.push({pageUrl:ce.pageUrl,ruleId:ce.ruleId,selector:ce.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${ve.slice(0,10)}.`,resolvedAt:ve,costUsd:0,wcagCriterion:O})}if(J.length===0)return;await qa(J);const re=await qe(T);c(re),N(ce=>({...ce,[O]:{total:J.length,pass:J.length,fail:0,uncertain:0,costUsd:0,resolutions:J}}))}const K=(()=>{if(!$)return null;if(R)return{kind:"conformant",text:`WCAG ${$.targetLevel} Status: Conformant`,detail:"All applicable criteria pass automated + AI checks."};const O=$.inconclusiveCriteria.length,ee=$.failingCriteria.length,me=$.untestedCriteria.length,se=[];if(ee>0){const ve=$.failingCriteria.slice(0,4).join(", ")+(ee>4?`, +${ee-4}`:"");se.push(`${ee} ${ee===1?"criterion":"criteria"} failing (${ve})`)}if(O>0){const ve=$.inconclusiveCriteria.slice(0,4).join(", ")+(O>4?`, +${O-4}`:"");se.push(`${O} inconclusive (${ve})`)}if(me>0){const ve=$.untestedCriteria.slice(0,4).join(", ")+(me>4?`, +${me-4}`:"");se.push(`${me} untested (${ve})`)}const Q=ee>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":me>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 ${$.targetLevel} Status: Not conformant`,detail:`${se.join(" · ")}. ${Q}`}})();let oe=0;for(const O of fe){const ee=n.find(se=>se.workflowId===O.id);if(!ee)continue;O.steps.every(se=>{const Q=ee.steps[se.id];return(Q==null?void 0:Q.status)==="pass"||(Q==null?void 0:Q.status)==="fail"||(Q==null?void 0:Q.status)==="skip"||(Q==null?void 0:Q.status)==="not-applicable"})&&oe++}const ne=new Set;for(const O of t)B.has(O.matchKey)||ne.add(`${O.ruleId}::${O.target.selector}`);for(const O of V)O.verdict==="fail"&&ne.add(`${O.ruleId}::${O.selector}`);const le=ne.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!v&&k&&e.jsx(Dr,{scannedAt:k}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Ar[F]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:F})}),e.jsxs("div",{className:"flex-1 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:"Overall grade"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Mean of ",P.subGrades.length," verification areas below. Untested areas count as F until verified."]}),K&&e.jsxs("div",{className:`text-[11px] leading-snug mt-1 rounded px-2 py-1 border ${K.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:[K.kind==="conformant"?"✓ ":"✗ ",K.text]}),e.jsx("p",{className:"mt-0.5",children:K.detail})]})]})]}),a&&K&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${K.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:[K.kind==="conformant"?"✓ ":"✗ ",K.text]}),e.jsx("p",{className:"mt-0.5",children:K.detail})]}),P.isLawsuitRisk&&e.jsx(Tr,{areas:P.warningAreas}),e.jsx($r,{grades:P.subGrades,uncategorized:wr(t,p,{excludeAckedMatchKeys:B})}),$&&e.jsx(Er,{coverage:$,onResolveWithAi:M,onMarkVisuallyVerified:W,resolving:u,resolveError:x,lastResolveResult:w,expandedResultFor:E,onToggleResultDetail:ie,violations:t}),_&&e.jsx(Rr,{layers:_}),e.jsx(Lr,{violationsRemaining:le,manualCompleted:oe,manualTotal:fe.length}),oe>0||S.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:oe})," of ",e.jsx("strong",{children:fe.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:`${oe/fe.length*100}%`}})})]}):null]})}function Er({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:o,expandedResultFor:l,onToggleResultDetail:i,violations:d}){const p=y(C=>C.setView),c=y(C=>C.setFindingsLens),u=y(C=>C.setPendingAreaExpand);function h(C){const f=Qa(C,d);p("report"),f?(c("per-area"),u(f)):c("violations")}const x=t.untestedCriteria.length+t.inconclusiveCriteria.length,[b,w]=m.useState(x>0&&x<=3),N=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),E=t.canClaimConformance,I=[];return t.failingCriteria.length>0&&I.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&I.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&I.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${E?"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 ${E?"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 (",N,"%)"]}),E&&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)."]}),!E&&(()=>{const C=[];t.failingCriteria.length>0&&C.push("failing"),t.inconclusiveCriteria.length>0&&C.push("inconclusive"),t.untestedCriteria.length>0&&C.push("untested");const f=C.length===0?"unresolved":C.length===1?C[0]:C.length===2?`${C[0]} or ${C[1]}`:`${C.slice(0,-1).join(", ")}, or ${C[C.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",f,"."]})})(),!E&&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."]}),!E&&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."]})]}),!E&&I.length>0&&e.jsx("button",{type:"button",onClick:()=>w(C=>!C),className:"text-[11px] underline shrink-0 self-start",children:b?"hide":"show list"})]}),b&&!E&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[I.map(C=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${C.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[C.kind==="untested"?"Untested":C.kind==="inconclusive"?"Inconclusive":"Failing"," (",C.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:C.ids.map(f=>{var P,B;const j=C.kind==="inconclusive"?(P=t.inconclusiveReasons)==null?void 0:P[f]:void 0,g=C.kind==="failing"?(B=t.failingReasons)==null?void 0:B[f]:void 0,v=j==null?void 0:j.some(U=>U.source==="axe-incomplete"&&U.elements&&U.elements.length>0),S=g==null?void 0:g.some(U=>U.source==="ai"),k=(n==null?void 0:n.has(f))??!1,T=o==null?void 0:o[f],V=(l==null?void 0:l.has(f))??!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(f),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 ${f}`,children:["· ",f]}),(C.kind==="inconclusive"&&v||C.kind==="failing"&&S)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[C.kind==="inconclusive"&&s&&f!=="1.4.3"&&f!=="1.4.6"&&e.jsx("button",{type:"button",disabled:k,onClick:()=>s(f),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:k?"Resolving…":T?"✨ Resolve again →":"✨ Resolve with AI →"}),C.kind==="inconclusive"&&(f==="1.4.3"||f==="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:k,onClick:()=>a(f),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:C.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),T&&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 ",T.total," ",T.total===1?"verdict":"verdicts",":",T.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",T.pass," pass"]}),T.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",T.fail," fail"]}),T.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",T.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",T.costUsd.toFixed(4)]}),i&&e.jsx("button",{type:"button",onClick:()=>i(f),className:"ml-auto text-[10px] underline text-brand-700",children:V?"hide reasoning":"show reasoning"})]}),T.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",T.uncertain," ",T.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),T.pass===T.total&&T.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."]}),V&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:T.resolutions.map((U,q)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:U.verdict==="pass"?"text-emerald-700 font-semibold":U.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:U.verdict==="pass"?"✓":U.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:U.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:U.reasoning})]},q))})]}),g&&g.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:g.map((U,q)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[U.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:U.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),U.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:U.ruleOrStepId})," fail — "]}),U.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:U.ruleOrStepId})," fail — "]}),U.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:U.selector}),U.notes&&e.jsx("span",{className:"text-rose-700",children:U.notes})]},q))}),j&&j.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:j.map((U,q)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[U.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:U.ruleOrStepId})," — "]}),U.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:U.ruleOrStepId})," skipped — "]}),U.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:U.ruleOrStepId})," — "]}),U.resolutionHint,U.elements&&U.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",U.elements.length===1?"element":`${U.elements.length} elements`,":"," ",U.elements.slice(0,3).map(($,_,F)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:$.selector}),_<F.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},_)),U.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",U.elements.length-3," more"]})]})]},q))}):C.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},f)})})]},C.kind)),r&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:r})]})]})}const vs={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 Rr({layers:t}){const s=y(o=>o.setView),a=y(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,x=i>0&&!h&&c===0,b=x?"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 ${x?"bg-emerald-500 text-white":d>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:x?"✓":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:vs[o].label}),e.jsx("span",{className:`font-mono text-[10px] ${b}`,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:vs[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 Tr({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 $r({grades:t,uncategorized:s}){const a=y(i=>i.setView),n=y(i=>i.setFindingsLens),r=y(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 ${Cr[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(Ur,{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 Ur({grade:t,onOpenGuided:s}){const a=i=>{if(!i)return"";const d=fe.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 Lr({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=y(l=>l.setView),r=y(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 _r({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 Dr({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 fa(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function ys(t){if(!fa())return!1;const s=chrome.devtools;return await new Promise(a=>{const r=`(function(){
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-QcMYcqgA.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-Bu2p8K-p.js","assets/ai-usage-log-D5enikfX.js","assets/diff-DIBMr3fQ.js","assets/copy-ai-fixer-prompt-NJgLyjks.js","assets/site-report-renderer-DA-9wVvE.js"])))=>i.map(i=>d[i]);
2
+ var Ha=Object.defineProperty;var Ka=(t,s,a)=>s in t?Ha(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var ls=(t,s,a)=>Ka(t,typeof s!="symbol"?s+"":s,a);import{R as ze,i as ge,r as m,j as e,M as Me,C as Ut,A as Nt}from"./styles-QDrJ67q_.js";import{e as Xs,o as Bt,p as za,q as ue,t as Zs,u as Le,S as De,g as qe,v as Ie,w as Ue,x as Ht,y as ea,z as qa,A as Kt,B as fe,C as Qa,D as Ya,E as Ja,F as Xa,k as Za,G as en,h as tn,i as zt,H as sn,I as an,N as nn,J as _t,K as ta,L as Dt,M as rn,O as on,f as ct,P as dt,Q as ln,R as cn,T as cs,U as dn,V as un,X as pn,Y as hn,Z as mn,_ as xn,$ as gn,a0 as fn,a1 as bn,a2 as vn,a3 as yn,a4 as wn,a5 as jn,a6 as sa,a7 as Nn,a8 as ds,a9 as us,aa as kt,ab as kn,ac as ps,ad as Sn,ae as An,af as Cn,m as In,n as En}from"./scheduled-audit-runner-QcMYcqgA.js";import{_ as ke}from"./preload-helper-D7HrI6pR.js";import{o as we,a as Z,s as ne,c as aa,d as be,r as Ee}from"./crash-reporter-Bu2p8K-p.js";import{g as na,j as gt,k as ft,t as et,m as Rn,B as Oe,i as qt,n as Tn,o as $e,T as ra,p as ia,q as bt,u as $n}from"./ai-usage-log-D5enikfX.js";import{s as Ln,t as Un}from"./design-system-audit-DpxJrxnb.js";const hs=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},_n=t=>t?hs(t):hs,Dn=t=>t;function On(t,s=Dn){const a=ze.useSyncExternalStore(t.subscribe,ze.useCallback(()=>s(t.getState()),[t,s]),ze.useCallback(()=>s(t.getInitialState()),[t,s]));return ze.useDebugValue(a),a}const ms=t=>{const s=_n(t),a=n=>On(s,n);return Object.assign(a,s),a},Fn=t=>t?ms(t):ms,y=Fn(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,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,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,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,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}),Xs(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),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}})})),ut="sidePanel:lastAudit";function Mn(){const t=[];return t.push(we("AUDIT_PROGRESS_EVENT",s=>{const a=y.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||ge.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`))})),t.push(we("AUDIT_COMPLETE_EVENT",s=>{var i;y.getState().setResults(s.results,s.delta,s.componentId);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"}.`;ge.polite(r);const o=y.getState().view;["compliance","guided","crawl"].includes(o)||(y.getState().setView("report"),y.getState().setFindingsLens("overview")),Gn({results:s.results,delta:s.delta,componentId:s.componentId}),Pn(s.results,s.delta,s.componentId)})),t.push(we("AUDIT_FAILED_EVENT",s=>{y.getState().setError(s.error.message)})),t.push(we("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=y.getState().aiProgress;y.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ge.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(we("AI_AUGMENTATION_FAILED_EVENT",s=>{y.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(we("SCORECARD_UPDATED_EVENT",()=>{pt()})),t.push(we("LICENSE_CHANGED_EVENT",()=>{oa()})),t.push(we("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=y.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ge.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(we("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=y.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ge.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`),(async()=>{try{const{loadSiteCrawlPerUrlResults:n}=await ke(async()=>{const{loadSiteCrawlPerUrlResults:i}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(d=>d.aR);return{loadSiteCrawlPerUrlResults:i}},__vite__mapDeps([0,1,2,3,4])),{getResolutionsForPage:r}=await ke(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(d=>d.aT);return{getResolutionsForPage:i}},__vite__mapDeps([0,1,2,3,4])),o=await n();if(!o||o.length===0)return;const l=y.getState().setResolutionsForUrl;await Promise.all(o.map(async i=>{try{const d=await r(i.url);l(i.url,d)}catch{}}))}catch(n){console.warn("[site-crawl] failed to pre-warm resolutions cache",n)}})()})),t.push(we("SITE_CRAWL_FAILED_EVENT",s=>{const a=y.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ge.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Pn(t,s,a){var n,r;if(t.length!==0)try{const o=await na();if(!o.enabled)return;const l=y.getState().tier;if(Bt(l)||!gt(l,"autoExportAuditReports"))return;const i=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",d=[],p=y.getState().lastAuditWallClockMs??void 0;for(const c of o.formats)try{const u=await Z({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=ft(c,a??null);et(u.content,h),i&&await Rn({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&&ge.polite(`Audit auto-exported ${d.length} file${d.length===1?"":"s"}.`)}catch(o){console.warn("[auto-export] failed:",o)}}async function Gn(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[ut]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Vn(){const s=(await chrome.storage.local.get(ut))[ut];s&&y.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Wn(){await chrome.storage.local.remove(ut)}async function vt(){y.getState().clearResults(),await Wn()}async function pt(){const t=await Z({type:"BASELINE_LIST"});y.getState().setBaselineList(t.items)}async function oa(t){const s=await Z({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});y.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),la()}async function la(){const{fetchMessages:t}=await ke(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Xn);return{fetchMessages:n}},void 0),s=y.getState().userMode,a=await t(s);a&&y.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Bn(){const s=(await Z({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="power"||s==="dev"?s:null;y.getState().setUserMode(a)}function Hn(){return chrome.runtime.connect({name:"audit-keepalive"})}let ht=null;async function Kn(){if(ht===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(ht=t.id)}catch{}}function ca(){if(ht===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:ht}).catch(()=>{})}function Ne(t){ca(),y.getState().setSiteCrawlReport(null),Xs(null).catch(()=>{}),ne(t)}const Ot="dismissedFindings";function yt(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function Ye(t){return`reading-order::${t}`}function Je(t){return`tab-order::${t}`}function Qt(t){return`violation::${t}`}async function wt(){try{const t=await chrome.storage.local.get(Ot),s=t==null?void 0:t[Ot];if(s&&typeof s=="object")return s}catch{}return{}}async function Yt(t){await chrome.storage.local.set({[Ot]:t})}async function Jt(t){return(await wt())[yt(t)]??{}}async function Xt(t,s,a,n){const r=await wt(),o=yt(t),l=r[o]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[o]=l,await Yt(r)}async function Xe(t,s){if(s.length===0)return;const a=await wt(),n=yt(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 Yt(a)}async function Zt(t,s){const a=await wt(),n=yt(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await Yt(a))}const Wc=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Xt,addDismissals:Xe,dismissalKeyForReadingOrder:Ye,dismissalKeyForTabOrder:Je,dismissalKeyForViolation:Qt,getDismissalsForUrl:Jt,removeDismissal:Zt},Symbol.toStringTag,{value:"Module"}));function zn({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(b){var w;if(b.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const N=await Z({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:o,replyEmail:i.trim()||void 0});N.success?(h({ok:!0,msg:`Sent (ref: ${N.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((w=N.error)==null?void 0:w.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:b=>a(b.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:b=>r(b.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:b=>d(b.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:b=>l(b.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 xs({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 mt=aa("messages-client"),qn="https://api.wcagcheckr.com",da="wcagcheckr",Qn=1e4;function Yn(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ua(t,s){const a=await za();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Yn()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${qn}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Qn)})}async function Jn(t){try{const s=await ua(`/v1/products/${da}/messages`,{userMode:t??null});return s.ok?await s.json():(mt.warn("fetchMessages http",s.status),null)}catch(s){return mt.warn("fetchMessages failed",s),null}}async function Fe(t,s){try{const a=await ua(`/v1/products/${da}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(mt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return mt.warn("ackMessage failed",a),!1}}const Xn=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Fe,fetchMessages:Jn},Symbol.toStringTag,{value:"Module"})),Zn=["http:","https:"];function er(t){try{const s=new URL(t);return Zn.includes(s.protocol)}catch{return!1}}function gs(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);er(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 pa({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:gs(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:gs(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 tr={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},sr={critical:"bg-rose-50 border-rose-200"};function ha(){const t=y(h=>h.unreadMessageCount),s=y(h=>h.messages),a=y(h=>h.applyMessageAck),[n,r]=m.useState(!1),o=m.useRef(-1),[l,i]=m.useState(!1);m.useEffect(()=>{const h=s.filter(b=>!b.seen);if(h.length===0)return;const g=Math.max(...h.map(b=>b.id));if(g>o.current){o.current=g,i(!0);const b=setTimeout(()=>i(!1),1500);return()=>clearTimeout(b)}},[s]);async function d(){const h=s.filter(g=>!g.seen);if(h.length!==0)for(const g of h)a(g.id,"seen"),Fe(g.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function c(h){a(h.id,"dismissed"),await Fe(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),Fe(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(ar,{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(nr,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function ar({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 nr({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:()=>{la()},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 ${tr[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(pa,{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 ma(){const t=y(o=>o.messages),s=y(o=>o.applyMessageAck),a=t.find(o=>o.severity==="critical"&&!o.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await Fe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),Fe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${sr.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(pa,{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 rr=[{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 xa(){const t=y(n=>n.userMode)??"owner",s=y(n=>n.setUserMode);function a(n){n!==t&&(s(n),chrome.storage.local.set({userMode:n,v2UiEnabled:n==="power"}),ne({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:rr.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 ir=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function or(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function lr(){var p,c;const t=y(u=>u.view),s=y(u=>u.setView);y(u=>u.setUserMode);const a=y(u=>u.results),n=y(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=or(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(xa,{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ha,{}),e.jsx(xs,{onClick:()=>void ne({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(xs,{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 vt(),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(cr,{view:t,setView:s}),e.jsx(Me,{open:r,onClose:()=>o(!1),title:"Send support message",children:e.jsx(zn,{onClose:()=>o(!1)})})]})}function cr({view:t,setView:s}){const a=m.useRef([]),n=y(i=>i.results),r=ir.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 dr({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(Ut,{open:a,onClose:()=>n(!1)})]})}const ur="https://wcagcheckr.com/upgrade";function pr(){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(Oe),[c,u]=m.useState(Oe[0].id),[h,g]=m.useState("none"),[b,w]=m.useState(null),N=y(_=>_.status),E=y(_=>_.tier),I=y(_=>_.results.length>0),C=N==="running";m.useEffect(()=>{Promise.all([Z({type:"SETTINGS_GET",key:"matrixPresets"}),Z({type:"SETTINGS_GET",key:"activePresetId"})]).then(([_,F])=>{const H=Array.isArray(_.data)?_.data:null;p(H&&H.length>0?H:Oe),typeof F.data=="string"&&u(F.data)})},[]);function f(_){const F=d.find(H=>H.id===_);F&&(u(_),ne({type:"SETTINGS_SET",key:"activePresetId",value:_}),ne({type:"SETTINGS_SET",key:"stateMatrix",value:F.matrix}))}const j=gt(E,"storybookAutoIterate");m.useEffect(()=>{const _=we("ELEMENT_PICKED_EVENT",(H,R)=>{n(!1);const M=R.frameId;q(M),o({selector:H.selector,frameId:M,speech:H.speech})}),F=we("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{_(),F()}},[]);async function x(){const _=await ue();_&&(n(!0),await be(_,{type:"PICKER_ACTIVATE_REQUEST",tabId:_}))}function v(){r&&(q(r.frameId),Ne({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),y.getState().startNewScan())}function S(){if(!j){i("storybook:auto-iterate");return}q(),Ne({type:"START_AUDIT",mode:"storybook-all"}),y.getState().startNewScan()}function k(){q(),Ne({type:"START_AUDIT",mode:"all-frames"}),y.getState().startNewScan()}function T(){q(),Ne({type:"START_AUDIT",mode:"full-page"}),y.getState().startNewScan()}function V(){q(),Ne({type:"START_AUDIT",mode:"full-page",verifyFixesOnly:!0}),y.getState().startNewScan()}function P(){q(),Ne({type:"START_AUDIT",mode:"quick-scan"}),y.getState().startNewScan()}function B(){q(),Ne({type:"START_AUDIT",mode:"parallel-scan"}),y.getState().startNewScan()}function L(){ne({type:"CANCEL_AUDIT"})}async function q(_){y.getState().setPinned(null);const F=await ue();if(F)try{await be(F,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:F},_)}catch{}}async function $(_){w(null);const F=await ue();if(!F){w("No audited tab; open a page first.");return}if(_==="none"){const R=await Z({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:F});R.ok||w(R.error??"Failed to clear throttle."),g("none");return}const H=await Z({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:F,profile:_});if(!H.ok){w(H.error??"Failed to apply throttle.");return}g(_)}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:_=>s(_.target.value),disabled:C||a,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",j?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:_=>f(_.target.value),disabled:C||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:_=>void $(_.target.value),disabled:C||a,title:"Apply CDP network + CPU throttling to the audited tab. Catch contrast / focus / loading-state issues that only manifest under realistic conditions.",className:`text-xs border rounded px-2 py-1 ${h==="none"?"border-slate-300":"border-amber-400 bg-amber-50"}`,children:[e.jsx("option",{value:"none",children:"⚡ Throttle: off"}),e.jsx("option",{value:"3g-slow",children:"⚡ Slow 3G + 6× CPU"}),e.jsx("option",{value:"3g-fast",children:"⚡ Fast 3G + 4× CPU"}),e.jsx("option",{value:"4g",children:"⚡ 4G LTE + 2× CPU"}),e.jsx("option",{value:"cpu-2x",children:"⚡ CPU 2× only"}),e.jsx("option",{value:"cpu-4x",children:"⚡ CPU 4× only"})]}),t==="single-element"?e.jsx(mr,{picking:a,picked:r,isRunning:C,onPick:x,onRun:v,onClearPick:()=>o(null)}):t==="full-page"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:T,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Scan page"}),e.jsx("button",{onClick:V,disabled:C||!I,className:"text-xs px-3 py-1 border border-emerald-400 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed",title:I?"Re-runs the audit but skips walkthroughs that already passed or are human-acked. Faster + cheaper after a fix/ack pass.":"Run a full Scan page first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.",children:C?"Auditing…":"Verify fixes (skip passed)"})]}):t==="quick-scan"?e.jsx("button",{onClick:P,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:C?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:B,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:C?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:k,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:S,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all stories"}),C&&e.jsx("button",{onClick:L,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!C&&I&&e.jsx("button",{type:"button",onClick:()=>void vt(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),b&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",b]}),t==="single-element"&&r&&!a&&!C&&e.jsx(xr,{selector:r.selector,onRepick:x,onClear:()=>o(null)})]}),e.jsx(Me,{open:l!==null,onClose:()=>i(null),title:"Upgrade to continue",children:e.jsx(dr,{feature:l??"",upgradeUrl:ur})})]})}function hr({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 mr({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(hr,{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 xr({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 gr={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},fr={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function br(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState("off"),p=y(g=>g.results).flatMap(g=>g.violations);async function c(g){const b=await ue();b&&(i(g),g==="off"?await be(b,{type:"VISION_SIMULATOR_CLEAR",tabId:b}).catch(()=>{}):await be(b,{type:"VISION_SIMULATOR_APPLY",tabId:b,mode:g}).catch(()=>{}))}async function u(g){const b=await ue();if(b){if(t&&await be(b,{type:gr[t],tabId:b}).catch(()=>{}),t===g){s(null);return}await be(b,{type:fr[g],tabId:b}).catch(()=>{}),s(g)}}async function h(){const g=await ue();if(g){if(a){await be(g,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:g}).catch(()=>{}),n(!1),o(null);return}if(p.length===0){o("Run an audit first.");return}try{const b=await Ee(g,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:g,violations:p});n(!0),o(`Previewing ${b.visualFixCount} visual fix${b.visualFixCount===1?"":"es"} + ${b.annotationCount} annotation${b.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(Ge,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(Ge,{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:()=>u("tab-order")}),e.jsx(Ge,{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:()=>u("reading-order")}),e.jsx(Ge,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(Ge,{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:h}),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:g=>void c(g.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 Ge({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 vr(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 yr(){const t=y(d=>d.status),s=y(d=>d.progress),a=y(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":vr(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(fs,{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(fs,{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 fs({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 wr(){const t=new Set;for(const s of De)for(const a of s.axeRules)t.add(a);return t}function ga(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 jr(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 Nr(t,s,a={}){const n=wr(),o=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),l=Zs(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=>Le(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const u=Le(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 bs(t,s){var n;const a=new Set;for(const r of s)for(const o of((n=r.axeRulesEvaluated)==null?void 0:n.incomplete)??[])for(const l of o.elements??[])a.add(`${o.ruleId}::${l.selector}`);return t.filter(r=>r.verdict==="fail"&&a.has(`${r.ruleId}::${r.selector}`))}function es(t){var o,l;const s=((o=t[0])==null?void 0:o.pageUrl)??((l=t[0])==null?void 0:l.scope)??"",a=y(i=>i.setResolutionsForUrl),[n,r]=m.useState(()=>{if(!s)return[];const i=y.getState().resolutionsByUrl[s];return i?bs(i,t):[]});return m.useEffect(()=>{if(!s){r([]);return}let i=!1;return qe(s).then(d=>{i||(a(s,d),r(bs(d,t)))}),()=>{i=!0}},[s,t,a]),n}const kr=[{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 Sr(){const t=y(n=>n.results),s=y(n=>n.status),a=y(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(Ar,{results:t,status:s,setView:a}),e.jsx(Cr,{setView:a})]})}function Ar({results:t,status:s,setView:a}){var g,b;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 n=t.flatMap(w=>w.violations),r=Zs(n),o=((g=t[0])==null?void 0:g.pageUrl)??((b=t[0])==null?void 0:b.scope)??"audited page",l=t.length,i=es(t),d=y(w=>w.acknowledgedKeys),p=y(w=>w.dismissedKeys),c=ga(n,i,d,p),u=3,h=c>0&&c<=u?r.slice(0,u):[];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 · ",l," state",l===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate mt-0.5",title:o,children:c===0?"No issues found by automation":`Fix ${c} element${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 →"})]}),h.length>0&&e.jsx("ul",{className:"border-t border-slate-200 divide-y divide-slate-100","aria-label":"Violations inline list",children:h.map(w=>{var I;const N=((I=w.target)==null?void 0:I.selector)??"(no selector)",E=N.length>50?N.slice(0,47)+"…":N;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:`${w.description??w.ruleId} — ${N}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${w.impact==="critical"?"bg-rose-200 text-rose-900":w.impact==="serious"?"bg-orange-200 text-orange-900":w.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:w.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:w.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:E})]})},`${w.ruleId}::${N}`)})})]})}function Cr({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:kr.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-400",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 Ir={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Er={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 Rr({violations:t,componentId:s,hideOverallHeader:a=!1}){var pe,U,X,z,Y,he,de,xe;const[n,r]=m.useState([]),[o,l]=m.useState({}),[i,d]=m.useState([]),[p,c]=m.useState([]),[u,h]=m.useState(new Set),[g,b]=m.useState(null),[w,N]=m.useState({}),[E,I]=m.useState(new Set),[C,f]=m.useState(null),j=y(O=>O.status),x=y(O=>O.progress),v=y(O=>O.freshThisSession),S=y(O=>O.results),k=(pe=S[0])==null?void 0:pe.startedAt,T=((U=S[0])==null?void 0:U.pageUrl)??((X=S[0])==null?void 0:X.scope)??null;m.useEffect(()=>{if(!s){r([]),l({});return}let O=!1;return chrome.storage.local.get("igtRuns").then(ee=>{if(O)return;const se=((ee==null?void 0:ee.igtRuns)??{})[s]??{};r(Object.values(se))}),Promise.all([Ie(s),Ue([s])]).then(([ee,me])=>{if(O)return;const se=new Set(me.map(J=>J.criterionId)),Q={},ve=[];for(const J of ee){const re=se.has(J.criterionId)?"pass":J.verdict;J.criterionId==="2.4.3"?Q.focusOrder=re:J.criterionId==="2.1.2"?Q.keyboardTrap=re:J.criterionId==="2.4.7"?Q.focusVisible=re:J.criterionId==="1.3.2"?Q.readingOrder=re:J.criterionId==="1.4.11"&&(Q.nonTextContrast=re),ve.push({criterionId:J.criterionId,ruleId:`ai-walkthrough-${J.criterionId}`,pageUrl:J.pageUrl,verdict:re,reasoning:se.has(J.criterionId)?`Human verified: ${J.reasoning}`:J.reasoning})}l(Q),d(ve)}),()=>{O=!0}},[s]),m.useEffect(()=>{if(!T){c([]);return}let O=!1;return qe(T).then(ee=>{O||c(ee)}),()=>{O=!0}},[T,S]);const V=es(S);if(j==="running")return e.jsx(Or,{current:x==null?void 0:x.current,total:x==null?void 0:x.total});const P=Ht({violations:t,auditRan:S.length>0,manualRuns:n,workflows:fe,heuristicCounts:{tabOrder:((Y=(z=S[0])==null?void 0:z.tabOrderIssues)==null?void 0:Y.length)??0,readingOrder:((de=(he=S[0])==null?void 0:he.readingOrderIssues)==null?void 0:de.length)??0},interactiveAuditVerdicts:o,aiResolvedFails:V.map(O=>({ruleId:O.ruleId,impact:"serious",selector:O.selector}))}),B=y(O=>O.acknowledgedKeys),q=new Set(S.map(O=>O.pageUrl??O.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",$=S.length>0?ea(S,{runs:n,workflows:fe},"2.1","AA",B,p,i,q):void 0,_=S.length>0?qa(Kt({audits:S,igtRuns:n,workflows:fe,acknowledgedMatchKeys:B,incompleteResolutions:p,interactiveAuditResults:i,auditScope:q}),fe):void 0,F=P.overallLetter,R=($?$.failingCriteria.length+$.inconclusiveCriteria.length+$.untestedCriteria.length:0)===0&&!!$;async function M(O){var ve;if(!T||!((ve=$==null?void 0:$.inconclusiveReasons)!=null&&ve[O]))return;const me=$.inconclusiveReasons[O].filter(J=>J.source==="axe-incomplete"&&J.elements&&J.elements.length>0);if(me.length===0)return;h(J=>new Set(J).add(O)),b(null);const se=[];let Q=0;try{for(const re of me){const je=await ne({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:re.ruleOrStepId,pageUrl:re.pageUrl??T,wcagCriterion:O,elements:re.elements??[],targetLevel:"AA"});if(je!=null&&je.unavailableReason){b(je.unavailableReason);break}je!=null&&je.resolutions&&(se.push(...je.resolutions),Q+=je.totalCostUsd??0)}if(T){const re=await qe(T);c(re)}const J={total:se.length,pass:se.filter(re=>re.verdict==="pass").length,fail:se.filter(re=>re.verdict==="fail").length,uncertain:se.filter(re=>re.verdict==="uncertain").length,costUsd:Q,resolutions:se};N(re=>({...re,[O]:J}))}finally{h(J=>{const re=new Set(J);return re.delete(O),re})}}function ie(O){I(ee=>{const me=new Set(ee);return me.has(O)?me.delete(O):me.add(O),me})}const A=((xe=S[0])==null?void 0:xe.startedAt)??null,G=s&&A?`${s}::${A}`:null;m.useEffect(()=>{if(!G||!$||C===G||j!=="complete")return;const O=$.inconclusiveCriteria.filter(ee=>{var se;return(((se=$.inconclusiveReasons)==null?void 0:se[ee])??[]).some(Q=>Q.source==="axe-incomplete"&&Q.elements&&Q.elements.length>0)});if(O.length===0){f(G);return}f(G),(async()=>{for(const ee of O)try{await M(ee)}catch{}})()},[G,$,j]);async function W(O){var je,os;if(!T)return;const ee=((je=$==null?void 0:$.inconclusiveReasons)==null?void 0:je[O])??[],me=((os=$==null?void 0:$.failingReasons)==null?void 0:os[O])??[],se=[],Q=new Set;for(const ce of ee){if(ce.source!=="axe-incomplete"||!ce.elements)continue;const Se=ce.pageUrl??T;for(const Ae of ce.elements){const Pe=`${Se}::${ce.ruleOrStepId}::${Ae.selector}`;Q.has(Pe)||(Q.add(Pe),se.push({ruleId:ce.ruleOrStepId,pageUrl:Se,selector:Ae.selector}))}}for(const ce of me){if(ce.source!=="ai"||!ce.selector)continue;const Se=ce.ruleOrStepId.startsWith("ai-resolved::")?ce.ruleOrStepId.slice(13):ce.ruleOrStepId,Ae=ce.pageUrl??T,Pe=`${Ae}::${Se}::${ce.selector}`;Q.has(Pe)||(Q.add(Pe),se.push({ruleId:Se,pageUrl:Ae,selector:ce.selector}))}if(se.length===0)return;const ve=new Date().toISOString(),J=[];for(const ce of se){const Se=p.find(Ae=>Ae.pageUrl===ce.pageUrl&&Ae.ruleId===ce.ruleId&&Ae.selector===ce.selector);Se&&Se.verdict==="pass"&&Se.reasoning.startsWith("Marked as visually verified")||J.push({pageUrl:ce.pageUrl,ruleId:ce.ruleId,selector:ce.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${ve.slice(0,10)}.`,resolvedAt:ve,costUsd:0,wcagCriterion:O})}if(J.length===0)return;await Qa(J);const re=await qe(T);c(re),N(ce=>({...ce,[O]:{total:J.length,pass:J.length,fail:0,uncertain:0,costUsd:0,resolutions:J}}))}const K=(()=>{if(!$)return null;if(R)return{kind:"conformant",text:`WCAG ${$.targetLevel} Status: Conformant`,detail:"All applicable criteria pass automated + AI checks."};const O=$.inconclusiveCriteria.length,ee=$.failingCriteria.length,me=$.untestedCriteria.length,se=[];if(ee>0){const ve=$.failingCriteria.slice(0,4).join(", ")+(ee>4?`, +${ee-4}`:"");se.push(`${ee} ${ee===1?"criterion":"criteria"} failing (${ve})`)}if(O>0){const ve=$.inconclusiveCriteria.slice(0,4).join(", ")+(O>4?`, +${O-4}`:"");se.push(`${O} inconclusive (${ve})`)}if(me>0){const ve=$.untestedCriteria.slice(0,4).join(", ")+(me>4?`, +${me-4}`:"");se.push(`${me} untested (${ve})`)}const Q=ee>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":me>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 ${$.targetLevel} Status: Not conformant`,detail:`${se.join(" · ")}. ${Q}`}})();let oe=0;for(const O of fe){const ee=n.find(se=>se.workflowId===O.id);if(!ee)continue;O.steps.every(se=>{const Q=ee.steps[se.id];return(Q==null?void 0:Q.status)==="pass"||(Q==null?void 0:Q.status)==="fail"||(Q==null?void 0:Q.status)==="skip"||(Q==null?void 0:Q.status)==="not-applicable"})&&oe++}const ae=new Set;for(const O of t)B.has(O.matchKey)||ae.add(`${O.ruleId}::${O.target.selector}`);for(const O of V)O.verdict==="fail"&&ae.add(`${O.ruleId}::${O.selector}`);const le=ae.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!v&&k&&e.jsx(Fr,{scannedAt:k}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Ir[F]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:F})}),e.jsxs("div",{className:"flex-1 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:"Overall grade"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Mean of ",P.subGrades.length," verification areas below. Untested areas count as F until verified."]}),K&&e.jsxs("div",{className:`text-[11px] leading-snug mt-1 rounded px-2 py-1 border ${K.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:[K.kind==="conformant"?"✓ ":"✗ ",K.text]}),e.jsx("p",{className:"mt-0.5",children:K.detail})]})]})]}),a&&K&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${K.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:[K.kind==="conformant"?"✓ ":"✗ ",K.text]}),e.jsx("p",{className:"mt-0.5",children:K.detail})]}),P.isLawsuitRisk&&e.jsx(Lr,{areas:P.warningAreas}),e.jsx(Ur,{grades:P.subGrades,uncategorized:Nr(t,p,{excludeAckedMatchKeys:B})}),$&&e.jsx(Tr,{coverage:$,onResolveWithAi:M,onMarkVisuallyVerified:W,resolving:u,resolveError:g,lastResolveResult:w,expandedResultFor:E,onToggleResultDetail:ie,violations:t}),_&&e.jsx($r,{layers:_}),e.jsx(Dr,{violationsRemaining:le,manualCompleted:oe,manualTotal:fe.length}),oe>0||S.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:oe})," of ",e.jsx("strong",{children:fe.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:`${oe/fe.length*100}%`}})})]}):null]})}function Tr({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:o,expandedResultFor:l,onToggleResultDetail:i,violations:d}){const p=y(C=>C.setView),c=y(C=>C.setFindingsLens),u=y(C=>C.setPendingAreaExpand);function h(C){const f=Ya(C,d);p("report"),f?(c("per-area"),u(f)):c("violations")}const g=t.untestedCriteria.length+t.inconclusiveCriteria.length,[b,w]=m.useState(g>0&&g<=3),N=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),E=t.canClaimConformance,I=[];return t.failingCriteria.length>0&&I.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&I.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&I.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${E?"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 ${E?"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 (",N,"%)"]}),E&&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)."]}),!E&&(()=>{const C=[];t.failingCriteria.length>0&&C.push("failing"),t.inconclusiveCriteria.length>0&&C.push("inconclusive"),t.untestedCriteria.length>0&&C.push("untested");const f=C.length===0?"unresolved":C.length===1?C[0]:C.length===2?`${C[0]} or ${C[1]}`:`${C.slice(0,-1).join(", ")}, or ${C[C.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",f,"."]})})(),!E&&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."]}),!E&&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."]})]}),!E&&I.length>0&&e.jsx("button",{type:"button",onClick:()=>w(C=>!C),className:"text-[11px] underline shrink-0 self-start",children:b?"hide":"show list"})]}),b&&!E&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[I.map(C=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${C.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[C.kind==="untested"?"Untested":C.kind==="inconclusive"?"Inconclusive":"Failing"," (",C.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:C.ids.map(f=>{var P,B;const j=C.kind==="inconclusive"?(P=t.inconclusiveReasons)==null?void 0:P[f]:void 0,x=C.kind==="failing"?(B=t.failingReasons)==null?void 0:B[f]:void 0,v=j==null?void 0:j.some(L=>L.source==="axe-incomplete"&&L.elements&&L.elements.length>0),S=x==null?void 0:x.some(L=>L.source==="ai"),k=(n==null?void 0:n.has(f))??!1,T=o==null?void 0:o[f],V=(l==null?void 0:l.has(f))??!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(f),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 ${f}`,children:["· ",f]}),(C.kind==="inconclusive"&&v||C.kind==="failing"&&S)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[C.kind==="inconclusive"&&s&&f!=="1.4.3"&&f!=="1.4.6"&&e.jsx("button",{type:"button",disabled:k,onClick:()=>s(f),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:k?"Resolving…":T?"✨ Resolve again →":"✨ Resolve with AI →"}),C.kind==="inconclusive"&&(f==="1.4.3"||f==="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:k,onClick:()=>a(f),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:C.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),T&&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 ",T.total," ",T.total===1?"verdict":"verdicts",":",T.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",T.pass," pass"]}),T.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",T.fail," fail"]}),T.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",T.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",T.costUsd.toFixed(4)]}),i&&e.jsx("button",{type:"button",onClick:()=>i(f),className:"ml-auto text-[10px] underline text-brand-700",children:V?"hide reasoning":"show reasoning"})]}),T.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",T.uncertain," ",T.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),T.pass===T.total&&T.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."]}),V&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:T.resolutions.map((L,q)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:L.verdict==="pass"?"text-emerald-700 font-semibold":L.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:L.verdict==="pass"?"✓":L.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:L.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:L.reasoning})]},q))})]}),x&&x.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:x.map((L,q)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[L.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),L.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," fail — "]}),L.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," fail — "]}),L.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:L.selector}),L.notes&&e.jsx("span",{className:"text-rose-700",children:L.notes})]},q))}),j&&j.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:j.map((L,q)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[L.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," — "]}),L.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," skipped — "]}),L.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," — "]}),L.resolutionHint,L.elements&&L.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",L.elements.length===1?"element":`${L.elements.length} elements`,":"," ",L.elements.slice(0,3).map(($,_,F)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:$.selector}),_<F.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},_)),L.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",L.elements.length-3," more"]})]})]},q))}):C.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},f)})})]},C.kind)),r&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:r})]})]})}const vs={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 $r({layers:t}){const s=y(o=>o.setView),a=y(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,b=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:vs[o].label}),e.jsx("span",{className:`font-mono text-[10px] ${b}`,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:vs[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 Lr({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 Ur({grades:t,uncategorized:s}){const a=y(i=>i.setView),n=y(i=>i.setFindingsLens),r=y(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 ${Er[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(_r,{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 _r({grade:t,onOpenGuided:s}){const a=i=>{if(!i)return"";const d=fe.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?fa(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 Dr({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=y(l=>l.setView),r=y(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 Or({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 Fr({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 (",fa(s)," old). Re-scan to grade the current page state."]})]})}function fa(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 ba(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function ys(t){if(!ba())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)});
5
5
  if (el) { inspect(el); return true; }
6
6
  return false;
7
7
  } catch (err) { return false; }
8
- })()`;s.inspectedWindow.eval(r,(o,l)=>{a(l?!1:o===!0)})})}const ws=.022,Or=1.414,St=2.4,Fr=.2126729,Mr=.7151522,Pr=.072175,Gr=.56,Vr=.57,Wr=.62,Br=.65,js=1.14,Ns=.1,Hr=.027,Kr=.027,zr=5e-4;function ks(t,s,a){const n=t/255,r=s/255,o=a/255;return Fr*Math.pow(n,St)+Mr*Math.pow(r,St)+Pr*Math.pow(o,St)}function Ss(t){return t<0?0:t<ws?t+Math.pow(ws-t,Or):t}function qr(t,s){const a=Ss(ks(t[0],t[1],t[2])),n=Ss(ks(s[0],s[1],s[2]));if(Math.abs(n-a)<zr)return 0;let r=0;return n>a?(r=(Math.pow(n,Gr)-Math.pow(a,Vr))*js,r<Ns?0:(r-Hr)*100):(r=(Math.pow(n,Br)-Math.pow(a,Wr))*js,r>-Ns?0:(r+Kr)*100)}function As(t){const s=t.trim().replace(/^#/,"");if(s.length===3){const a=parseInt(s[0]+s[0],16),n=parseInt(s[1]+s[1],16),r=parseInt(s[2]+s[2],16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}if(s.length===6){const a=parseInt(s.slice(0,2),16),n=parseInt(s.slice(2,4),16),r=parseInt(s.slice(4,6),16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}return null}function Qr(t,s,a=75){const n=As(t),r=As(s);if(!n||!r)return null;const o=qr(n,r);return{lc:o,passes:Math.abs(o)>=a,threshold:a}}const Ve={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Yr(t){return/^wcag\d/.test(t.wcagCriterion)?[Ve["ada-iii"],Ve[508],Ve.eaa,Ve["en-301-549"],Ve.aoda]:[]}const Jr={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Ze({violation:t,alreadyAcknowledged:s}){const a=y(g=>g.pinnedMatchKey),n=y(g=>g.pinnedFound),r=y(g=>g.setPinned),o=y(g=>{var v;return(v=g.results[0])==null?void 0:v.frameId}),l=y(g=>{var v;return(v=g.results[0])==null?void 0:v.scope}),i=y(g=>g.results),d=y(g=>g.acknowledgedKeys.has(t.matchKey)),p=y(g=>g.markAcknowledged),c=y(g=>g.markUnacknowledged),u=s||d,h=Qt(t.matchKey),x=y(g=>g.dismissedKeys.has(h)),b=y(g=>g.markDismissed),w=y(g=>g.markUndismissed),N=a===t.matchKey,E=N&&!n;async function I(g){try{return(await Ee(g,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:g,selector:t.target.selector},o)).found}catch{return!0}}async function C(){const g=await ue();if(!g)return;if(N){r(null);try{await be(g,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:g},o)}catch{}return}const v=await I(g);r(t.matchKey,v)}function f(g){g.stopPropagation(),t.currentState.breakpoint.width<=640&&ca(),(async()=>{const v=await ue();if(!v)return;try{await Z({type:"STATE_DRIVE_REQUEST",tabId:v,state:t.currentState,scope:l,frameId:o})}catch{}const S=await I(v);r(t.matchKey,S)})()}async function j(g){g.stopPropagation();const v=await ue();if(!v)return;try{await Z({type:"STATE_DRIVE_REQUEST",tabId:v,state:ai(),scope:l,frameId:o})}catch{ae({type:"STATE_RESET_REQUEST",tabId:v})}const S=await I(v);r(t.matchKey,S)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:C,"aria-pressed":N,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
9
- ${N?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Jr[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(ni,{violation:t}),e.jsx(oi,{violation:t}),e.jsx(ii,{violation:t}),e.jsx(ri,{text:t.target.failureSummary}),e.jsx(li,{ruleId:t.ruleId}),N&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",Xr(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:f,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),f(g))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:j,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),j(g))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),fa()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:g=>{g.preventDefault(),g.stopPropagation(),ys(t.target.selector)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),ys(t.target.selector))},title:"Focus this element in the DevTools Elements tab",className:"text-brand-600 hover:underline cursor-pointer","data-testid":"reveal-in-elements",children:"Reveal in Elements"})]}),E&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap text-xs",children:[t.needsReview&&(u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Verified OK"}),e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),c(t.matchKey),ei(t,i)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),p(t.matchKey),Zr(t,i)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},title:"The rule was right to flag this — I verified the content is fine. Surfaces in the AI fix prompt's 'Previously verified by human' section.",className:"px-2 py-0.5 border border-emerald-300 bg-emerald-50 text-emerald-800 rounded hover:bg-emerald-100 cursor-pointer",children:"✓ Verified OK"})),x?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700 font-semibold",children:"✗ Dismissed"}),e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),w(h),si(t,i)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),b(h),ti(t,i,h)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},title:"The rule itself is wrong about this page — false positive. Suppresses this finding from future audits on this URL + filters it from the AI fix prompt.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"✗ Not a real issue"})]}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:g=>g.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Xr(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function Zr(t,s){await Xa({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Nt(t.componentId,s)}async function ei(t,s){await Ja(t.componentId,t.matchKey),await Nt(t.componentId,s)}async function ti(t,s,a){var l,i;const n=((l=s[0])==null?void 0:l.pageUrl)??((i=s[0])==null?void 0:i.scope)??"";if(!n)return;const r=(t.target.outerHTML??t.target.selector).slice(0,200),o=`Marked "not a real issue" via Findings UI (${t.ruleId} on ${t.target.selector})`;await Xt(n,a,o,r),await Nt(t.componentId,s)}async function si(t,s){var n,r;const a=((n=s[0])==null?void 0:n.pageUrl)??((r=s[0])==null?void 0:r.scope)??"";a&&(await Zt(a,Qt(t.matchKey)),await Nt(t.componentId,s))}async function Nt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await Z({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});y.getState().setDelta(n.delta)}catch{}}function ai(){const t=qt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function ba(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),o=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(o==null?void 0:o[1])??"#ffffff"}}function ni({violation:t}){const s=ba(t);if(!s)return null;const a=s.ratio>=s.required,n=Qr(s.fg,s.bg,75),r=(n==null?void 0:n.passes)??!1;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] flex-wrap",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]}),n&&e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${r?"border-emerald-300 bg-emerald-50 text-emerald-800":"border-amber-300 bg-amber-50 text-amber-800"}`,title:"APCA Lc — the contrast algorithm WCAG 3 is built around. Signed: positive = dark text on light, negative = light on dark. |Lc| ≥ 75 typically required for body text.","data-testid":"apca-lc",children:["APCA Lc ",n.lc.toFixed(1)]})]})}function ri({text:t}){return t?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-slate-500 cursor-pointer hover:text-slate-700",children:"Show failure detail"}),e.jsx("pre",{className:"text-[11px] text-slate-600 whitespace-pre-wrap mt-1 bg-slate-50 p-1.5 rounded",children:t})]}):null}function ii({violation:t}){const s=Yr(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function oi({violation:t}){const s=ba(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let o=!1;return Ya(t.matchKey).then(l=>{l&&!o&&n({kind:"ready",suggestion:l})}),()=>{o=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const o=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await Z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:o}]}),i=l.results.find(d=>d.matchKey===t.matchKey);i?(await Za(i),n({kind:"ready",suggestion:i})):n({kind:"empty",reason:l.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(o){n({kind:"empty",reason:o instanceof Error?o.message:String(o)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((o,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:o.background,color:o.foreground},title:`fg ${o.foreground} on bg ${o.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:o.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:o.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[o.contrast.toFixed(2)," : 1"]})]}),o.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:o.rationale})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function li({ruleId:t}){const s=en(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}function ts({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l,ack:i}){const[d,p]=m.useState(!1),[c,u]=m.useState(""),[h,x]=m.useState(!1),[b,w]=m.useState(null),[N,E]=m.useState(!1),[I,C]=m.useState(!1),f=o.verdict,j=f==="pass"?"bg-emerald-200 text-emerald-900":f==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function g(){x(!0),w(null);try{if(!c.trim()){w("Note is required — explain how you manually verified this."),x(!1);return}if(f==="pass"){w("This walkthrough already passed — no acknowledgement needed."),x(!1);return}await zt({componentId:t,criterionId:a,pageUrl:s,note:c.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:f}),l()}catch(S){w(S instanceof Error?S.message:String(S))}finally{x(!1)}}async function v(){var S;C(!0),w(null);try{const T=(S=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:S.id;if(!T){w("No active tab — open the audited page first."),C(!1);return}const P=await ae({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:T,componentId:t,pageUrl:s});P.ok||w(P.error??"Re-run failed."),l()}catch(k){w(k instanceof Error?k.message:String(k))}finally{C(!1)}}return i?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"shrink-0 font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase bg-emerald-500 text-white",children:"✓ verified"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-emerald-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-emerald-700 mr-1.5",children:a}),n??"Walkthrough"," — human verified"]}),e.jsxs("p",{className:"text-[11px] text-emerald-800 mt-0.5 leading-snug",children:[e.jsx("strong",{children:"Note:"})," ",i.note]}),e.jsxs("p",{className:"text-[10px] text-emerald-700 mt-0.5",children:["Recorded ",new Date(i.acknowledgedAt).toLocaleString(),". Original AI verdict: ",f,"."]})]})]})}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${j}`,children:f}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:a}),n??`Walkthrough verdict: ${f}`]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:f==="fail"?"AI walkthrough flagged a failure here. Fix the page and re-run, or verify manually and acknowledge.":f==="uncertain"?"AI walkthrough couldn't decide. Fix the underlying ambiguity, or verify manually and acknowledge.":"AI walkthrough passed — no action needed."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>E(S=>!S),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:N?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void v(),disabled:I,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",title:"Re-run AI walkthrough after fixing the page (uses the active tab)",children:I?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{p(S=>!S),w(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"})]}),N&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"What the walkthrough does"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:r})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"AI reasoning"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap font-mono",children:o.reasoning})]}),d&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"How did you verify? (required, goes into the forensic record)"}),e.jsx("textarea",{value:c,onChange:S=>u(S.target.value),placeholder:"e.g., Verified live page via curl + screenshot — 2px white borders visible on both inputs against dark card.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),b&&e.jsx("p",{className:"text-[10px] text-rose-700",children:b}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void g(),disabled:h,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:h?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{p(!1),u(""),w(null)},disabled:h,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}),b&&!d&&e.jsx("p",{className:"text-[10px] text-rose-700",children:b})]})}function ci(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function va(t){return`${Ue(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function di(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=va(n),o=s.get(r);o?o.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const Cs={critical:0,serious:1,moderate:2,minor:3},ui={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 pi({results:t,interactiveVerdicts:s,aiResolvedFails:a}){var f;const n=t.length,r=t.flatMap(j=>j.violations),o=di(t);o.sort((j,g)=>{const v=Cs[j.representative.impact]??99,S=Cs[g.representative.impact]??99;return v!==S?v-S:g.states.length-j.states.length});const l=Ht({violations:r,auditRan:!0,manualRuns:[],workflows:fe,heuristicCounts:{},interactiveAuditVerdicts:s}),i=new Map;for(const j of De)i.set(j.id,[]);const d=[];for(const j of o){let g=!1;for(const v of De)if(v.axeRules.includes(j.representative.ruleId)){i.get(v.id).push(j),g=!0;break}g||d.push(j)}const p=new Map;for(const j of De)p.set(j.id,[]);const c=[];for(const j of a??[]){let g=!1;for(const v of De)if(v.axeRules.includes(j.ruleId)){p.get(v.id).push(j),g=!0;break}g||c.push(j)}const u=((f=t[0])==null?void 0:f.componentId)??null,[h,x]=m.useState([]),[b,w]=m.useState({}),[N,E]=m.useState(0);m.useEffect(()=>{let j=!1;return(async()=>{if(!u){x([]),w({});return}const[g,v]=await Promise.all([Ie(u),Le([u])]);if(j)return;x(g);const S={};for(const k of v)S[k.criterionId]=k;w(S)})(),()=>{j=!0}},[u,N]);const I=new Map;for(const j of De)I.set(j.id,[]);const C={"2.4.3":"tab-order","2.1.2":"keyboard","2.4.7":"keyboard","1.3.2":"reading-order","1.4.11":"contrast","2.5.3":"aria"};for(const j of h){if(j.verdict==="pass")continue;const g=C[j.criterionId];if(!g)continue;const v=I.get(g);v&&v.push({record:j,ack:b[j.criterionId]??null})}return e.jsxs("div",{className:"space-y-1.5",children:[l.subGrades.map(j=>e.jsx(Is,{subGrade:j,groups:i.get(j.id)??[],totalStates:n,aiFails:p.get(j.id)??[],walkthroughIssues:I.get(j.id)??[],componentId:u,onWalkthroughChanged:()=>E(g=>g+1)},j.id)),(d.length>0||c.length>0)&&e.jsx(Is,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:d,totalStates:n,aiFails:c,walkthroughIssues:[],componentId:u,onWalkthroughChanged:()=>E(j=>j+1)})]})}function Is({subGrade:t,groups:s,totalStates:a,aiFails:n,walkthroughIssues:r,componentId:o,onWalkthroughChanged:l}){const[i,d]=m.useState(!1),p=y(g=>g.pendingAreaExpand),c=y(g=>g.setPendingAreaExpand);m.useEffect(()=>{p===t.id&&(d(!0),c(null),requestAnimationFrame(()=>{const g=document.querySelector(`[data-area-card="${t.id}"]`);g==null||g.scrollIntoView({behavior:"smooth",block:"start"})}))},[p,t.id,c]);const[u,h]=m.useState("idle"),[x,b]=m.useState(null),[w,N]=m.useState(0),E=s.length>0||n.length>0||r.length>0,I=ui[t.letter],C=s.filter(g=>g.representative.ruleId==="color-contrast"||g.representative.ruleId==="color-contrast-enhanced"),f=C.length>=2;async function j(g){g.stopPropagation(),h("loading"),b(null);try{const v=C.map(k=>{const T=k.representative.target.outerHTML,V=k.representative.target.failureSummary,P=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(V),B=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(V);if(!P||!B)return null;const U=k.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:k.representative.matchKey,foreground:P[1],background:B[1],fontSize:16,fontWeight:400,targetLevel:U,_html:T}}).filter(k=>k!==null);if(v.length===0){h("error"),b("Could not parse fg/bg colors from the violation failure summaries.");return}const S=await Z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:v.map(({_html:k,...T})=>T)});if(S.unavailableReason&&S.results.length===0){h("error"),b(S.unavailableReason);return}await tn(S.results),h("done"),N(k=>k+1),i||d(!0)}catch(v){h("error"),b(v instanceof Error?v.message:String(v))}}return e.jsxs("div",{"data-area-card":t.id,className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>d(g=>!g),"aria-expanded":i,disabled:!E,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold font-display ${I}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:E?(()=>{const g=s.length+n.length+r.length,v=[];return s.length>0&&v.push(`${s.length} axe`),n.length>0&&v.push(`${n.length} AI-resolved`),r.length>0&&v.push(`${r.length} walkthrough`),`${g} ${g===1?"issue":"issues"} to fix (${v.join(" + ")})`})():"No issues found"})]}),f&&e.jsx("span",{role:"button",tabIndex:0,onClick:g=>void j(g),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),j(g))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${C.length} contrast issues at once`,children:u==="loading"?"Asking AI…":u==="done"?`✓ Suggested for all ${C.length}`:`✨ Suggest for all ${C.length}`}),E&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0 font-mono","aria-hidden":"true",children:i?"−":"+"})]}),u==="error"&&x&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:x}),i&&E&&e.jsxs("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:[s.map(g=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ze,{violation:g.representative}),e.jsx(hi,{states:g.states,totalStates:a})]},`${va(g.representative)}::${w}`)),n.length>0&&e.jsxs(e.Fragment,{children:[s.length>0&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI-resolved fails (",n.length,")"]}),n.map(g=>e.jsx(mi,{fail:g},`${g.ruleId}::${g.selector}`))]}),r.length>0&&e.jsxs(e.Fragment,{children:[(s.length>0||n.length>0)&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI walkthrough findings (",r.length,")"]}),r.map(g=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(ts,{componentId:o??"",pageUrl:g.record.pageUrl,criterionId:g.record.criterionId,record:g.record,ack:g.ack,onChanged:l})},g.record.criterionId))]})]})]})}function hi({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(ci))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",o=a.join(`
10
- `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:o,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}function mi({fail:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(!1);async function o(){a(!0);try{const{saveResolutions:l}=await ke(async()=>{const{saveResolutions:i}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(d=>d.aT);return{saveResolutions:i}},__vite__mapDeps([0,1,2,3,4]));await l([{...t,verdict:"pass",reasoning:`[Human override — visually verified by user] ${t.reasoning}`,resolvedAt:new Date().toISOString()}]),r(!0)}finally{a(!1)}}return e.jsxs("div",{className:`border rounded-md bg-white p-2 text-[11px] ${n?"border-emerald-200 bg-emerald-50":"border-rose-200"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[10px] text-rose-700",children:t.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold ${n?"bg-emerald-100 text-emerald-800":"bg-rose-100 text-rose-900"}`,children:n?"✓ Resolved":"AI verdict: FAIL"})]}),e.jsx("p",{className:"font-mono text-[10px] text-slate-700 mb-1 break-all",children:t.selector}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:t.reasoning}),!n&&e.jsx("button",{type:"button",onClick:()=>void o(),disabled:s,className:"px-2 py-1 text-[11px] font-medium bg-white border border-emerald-300 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50",title:"Override the AI's fail determination — your human visual judgment is the highest authority per WCAG-EM. Use when you've verified the contrast / labeling is actually fine.",children:"✓ Mark as resolved (override AI)"})]})}const Es="igtRuns";async function xi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Es))[Es];return s&&typeof s=="object"?s:{}}async function gi(t,s){var l,i;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,o=(await xi())[t];if(o)for(const d of fe){const p=o[d.id];if(p)for(const c of d.steps){if(!c.autoDismissActivity||((i=(l=p.steps)==null?void 0:l[c.id])==null?void 0:i.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Xe(n,x.map(b=>({key:Je(b.selector),reason:h,snippet:`${b.selector} — ${b.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Xe(n,x.map(b=>({key:Ye(b.selector),reason:h,snippet:`${b.selector} — ${b.textSnippet||"(no text)"}`})))}}}}const fi=new Set(["heading-order","page-has-heading-one","empty-heading","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","landmark-banner-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-complementary-is-top-level","landmark-unique","region","bypass","duplicate-id","duplicate-id-aria","duplicate-id-active"]),bi=new Set(["label","label-content-name-mismatch","label-title-only","form-field-multiple-labels","input-button-name","input-image-alt","autocomplete-valid","aria-required-attr","aria-required-children","aria-required-parent","aria-input-field-name","aria-toggle-field-name","select-name","button-name"]);function vi(t){return fi.has(t.ruleId)}function yi(t){return bi.has(t.ruleId)}function wi(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function ya(){var P,B,U,q;const t=y($=>$.results),s=y($=>$.delta),a=y($=>$.componentId),n=((P=t[0])==null?void 0:P.pageUrl)??((B=t[0])==null?void 0:B.scope)??"",[r,o]=m.useState({}),[l,i]=m.useState(!1),[d,p]=m.useState(!1);m.useEffect(()=>{if(!a){i(!1),p(!1);return}let $=!1;return(async()=>{const _=await Ie(a);if($)return;const F=_.some(R=>R.criterionId==="2.1.2"&&R.verdict==="pass"),H=_.some(R=>R.criterionId==="1.3.2");i(F),p(H)})(),()=>{$=!0}},[a]);const[c,u]=m.useState(0);m.useEffect(()=>{if(!n)return;let $=!1;return(async()=>{if(a&&t.length>0)try{await gi(a,t)}catch{}if($)return;const _=await Jt(n);$||o(_)})(),()=>{$=!0}},[n,c,a,t]);async function h($,_){if(!n)return;const F=window.prompt(`Why is this finding a false positive?
8
+ })()`;s.inspectedWindow.eval(r,(o,l)=>{a(l?!1:o===!0)})})}const ws=.022,Mr=1.414,St=2.4,Pr=.2126729,Gr=.7151522,Vr=.072175,Wr=.56,Br=.57,Hr=.62,Kr=.65,js=1.14,Ns=.1,zr=.027,qr=.027,Qr=5e-4;function ks(t,s,a){const n=t/255,r=s/255,o=a/255;return Pr*Math.pow(n,St)+Gr*Math.pow(r,St)+Vr*Math.pow(o,St)}function Ss(t){return t<0?0:t<ws?t+Math.pow(ws-t,Mr):t}function Yr(t,s){const a=Ss(ks(t[0],t[1],t[2])),n=Ss(ks(s[0],s[1],s[2]));if(Math.abs(n-a)<Qr)return 0;let r=0;return n>a?(r=(Math.pow(n,Wr)-Math.pow(a,Br))*js,r<Ns?0:(r-zr)*100):(r=(Math.pow(n,Kr)-Math.pow(a,Hr))*js,r>-Ns?0:(r+qr)*100)}function As(t){const s=t.trim().replace(/^#/,"");if(s.length===3){const a=parseInt(s[0]+s[0],16),n=parseInt(s[1]+s[1],16),r=parseInt(s[2]+s[2],16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}if(s.length===6){const a=parseInt(s.slice(0,2),16),n=parseInt(s.slice(2,4),16),r=parseInt(s.slice(4,6),16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}return null}function Jr(t,s,a=75){const n=As(t),r=As(s);if(!n||!r)return null;const o=Yr(n,r);return{lc:o,passes:Math.abs(o)>=a,threshold:a}}const Ve={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Xr(t){return/^wcag\d/.test(t.wcagCriterion)?[Ve["ada-iii"],Ve[508],Ve.eaa,Ve["en-301-549"],Ve.aoda]:[]}const Zr={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Ze({violation:t,alreadyAcknowledged:s}){const a=y(x=>x.pinnedMatchKey),n=y(x=>x.pinnedFound),r=y(x=>x.setPinned),o=y(x=>{var v;return(v=x.results[0])==null?void 0:v.frameId}),l=y(x=>{var v;return(v=x.results[0])==null?void 0:v.scope}),i=y(x=>x.results),d=y(x=>x.acknowledgedKeys.has(t.matchKey)),p=y(x=>x.markAcknowledged),c=y(x=>x.markUnacknowledged),u=s||d,h=Qt(t.matchKey),g=y(x=>x.dismissedKeys.has(h)),b=y(x=>x.markDismissed),w=y(x=>x.markUndismissed),N=a===t.matchKey,E=N&&!n;async function I(x){try{return(await Ee(x,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:x,selector:t.target.selector},o)).found}catch{return!0}}async function C(){const x=await ue();if(!x)return;if(N){r(null);try{await be(x,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:x},o)}catch{}return}const v=await I(x);r(t.matchKey,v)}function f(x){x.stopPropagation(),t.currentState.breakpoint.width<=640&&ca(),(async()=>{const v=await ue();if(!v)return;try{await Z({type:"STATE_DRIVE_REQUEST",tabId:v,state:t.currentState,scope:l,frameId:o})}catch{}const S=await I(v);r(t.matchKey,S)})()}async function j(x){x.stopPropagation();const v=await ue();if(!v)return;try{await Z({type:"STATE_DRIVE_REQUEST",tabId:v,state:ri(),scope:l,frameId:o})}catch{ne({type:"STATE_RESET_REQUEST",tabId:v})}const S=await I(v);r(t.matchKey,S)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:C,"aria-pressed":N,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
9
+ ${N?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Zr[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(ii,{violation:t}),e.jsx(ci,{violation:t}),e.jsx(li,{violation:t}),e.jsx(oi,{text:t.target.failureSummary}),e.jsx(di,{ruleId:t.ruleId}),N&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",ei(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:f,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),f(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:j,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),j(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),ba()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:x=>{x.preventDefault(),x.stopPropagation(),ys(t.target.selector)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),ys(t.target.selector))},title:"Focus this element in the DevTools Elements tab",className:"text-brand-600 hover:underline cursor-pointer","data-testid":"reveal-in-elements",children:"Reveal in Elements"})]}),E&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap text-xs",children:[t.needsReview&&(u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Verified OK"}),e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),c(t.matchKey),si(t,i)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),p(t.matchKey),ti(t,i)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},title:"The rule was right to flag this — I verified the content is fine. Surfaces in the AI fix prompt's 'Previously verified by human' section.",className:"px-2 py-0.5 border border-emerald-300 bg-emerald-50 text-emerald-800 rounded hover:bg-emerald-100 cursor-pointer",children:"✓ Verified OK"})),g?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700 font-semibold",children:"✗ Dismissed"}),e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),w(h),ni(t,i)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),b(h),ai(t,i,h)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},title:"The rule itself is wrong about this page — false positive. Suppresses this finding from future audits on this URL + filters it from the AI fix prompt.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"✗ Not a real issue"})]}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function ei(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function ti(t,s){await Za({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await jt(t.componentId,s)}async function si(t,s){await Xa(t.componentId,t.matchKey),await jt(t.componentId,s)}async function ai(t,s,a){var l,i;const n=((l=s[0])==null?void 0:l.pageUrl)??((i=s[0])==null?void 0:i.scope)??"";if(!n)return;const r=(t.target.outerHTML??t.target.selector).slice(0,200),o=`Marked "not a real issue" via Findings UI (${t.ruleId} on ${t.target.selector})`;await Xt(n,a,o,r),await jt(t.componentId,s)}async function ni(t,s){var n,r;const a=((n=s[0])==null?void 0:n.pageUrl)??((r=s[0])==null?void 0:r.scope)??"";a&&(await Zt(a,Qt(t.matchKey)),await jt(t.componentId,s))}async function jt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await Z({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});y.getState().setDelta(n.delta)}catch{}}function ri(){const t=qt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function va(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),o=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(o==null?void 0:o[1])??"#ffffff"}}function ii({violation:t}){const s=va(t);if(!s)return null;const a=s.ratio>=s.required,n=Jr(s.fg,s.bg,75),r=(n==null?void 0:n.passes)??!1;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] flex-wrap",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]}),n&&e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${r?"border-emerald-300 bg-emerald-50 text-emerald-800":"border-amber-300 bg-amber-50 text-amber-800"}`,title:"APCA Lc — the contrast algorithm WCAG 3 is built around. Signed: positive = dark text on light, negative = light on dark. |Lc| ≥ 75 typically required for body text.","data-testid":"apca-lc",children:["APCA Lc ",n.lc.toFixed(1)]})]})}function oi({text:t}){return t?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-slate-500 cursor-pointer hover:text-slate-700",children:"Show failure detail"}),e.jsx("pre",{className:"text-[11px] text-slate-600 whitespace-pre-wrap mt-1 bg-slate-50 p-1.5 rounded",children:t})]}):null}function li({violation:t}){const s=Xr(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function ci({violation:t}){const s=va(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let o=!1;return Ja(t.matchKey).then(l=>{l&&!o&&n({kind:"ready",suggestion:l})}),()=>{o=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const o=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await Z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:o}]}),i=l.results.find(d=>d.matchKey===t.matchKey);i?(await en(i),n({kind:"ready",suggestion:i})):n({kind:"empty",reason:l.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(o){n({kind:"empty",reason:o instanceof Error?o.message:String(o)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((o,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:o.background,color:o.foreground},title:`fg ${o.foreground} on bg ${o.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:o.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:o.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[o.contrast.toFixed(2)," : 1"]})]}),o.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:o.rationale})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function di({ruleId:t}){const s=tn(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}function ts({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l,ack:i}){const[d,p]=m.useState(!1),[c,u]=m.useState(""),[h,g]=m.useState(!1),[b,w]=m.useState(null),[N,E]=m.useState(!1),[I,C]=m.useState(!1),f=o.verdict,j=f==="pass"?"bg-emerald-200 text-emerald-900":f==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function x(){g(!0),w(null);try{if(!c.trim()){w("Note is required — explain how you manually verified this."),g(!1);return}if(f==="pass"){w("This walkthrough already passed — no acknowledgement needed."),g(!1);return}await zt({componentId:t,criterionId:a,pageUrl:s,note:c.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:f}),l()}catch(S){w(S instanceof Error?S.message:String(S))}finally{g(!1)}}async function v(){var S;C(!0),w(null);try{const T=(S=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:S.id;if(!T){w("No active tab — open the audited page first."),C(!1);return}const P=await ne({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:T,componentId:t,pageUrl:s});P.ok||w(P.error??"Re-run failed."),l()}catch(k){w(k instanceof Error?k.message:String(k))}finally{C(!1)}}return i?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"shrink-0 font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase bg-emerald-500 text-white",children:"✓ verified"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-emerald-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-emerald-700 mr-1.5",children:a}),n??"Walkthrough"," — human verified"]}),e.jsxs("p",{className:"text-[11px] text-emerald-800 mt-0.5 leading-snug",children:[e.jsx("strong",{children:"Note:"})," ",i.note]}),e.jsxs("p",{className:"text-[10px] text-emerald-700 mt-0.5",children:["Recorded ",new Date(i.acknowledgedAt).toLocaleString(),". Original AI verdict: ",f,"."]})]})]})}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${j}`,children:f}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:a}),n??`Walkthrough verdict: ${f}`]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:f==="fail"?"AI walkthrough flagged a failure here. Fix the page and re-run, or verify manually and acknowledge.":f==="uncertain"?"AI walkthrough couldn't decide. Fix the underlying ambiguity, or verify manually and acknowledge.":"AI walkthrough passed — no action needed."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>E(S=>!S),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:N?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void v(),disabled:I,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",title:"Re-run AI walkthrough after fixing the page (uses the active tab)",children:I?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{p(S=>!S),w(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"})]}),N&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"What the walkthrough does"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:r})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"AI reasoning"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap font-mono",children:o.reasoning})]}),d&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"How did you verify? (required, goes into the forensic record)"}),e.jsx("textarea",{value:c,onChange:S=>u(S.target.value),placeholder:"e.g., Verified live page via curl + screenshot — 2px white borders visible on both inputs against dark card.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),b&&e.jsx("p",{className:"text-[10px] text-rose-700",children:b}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void x(),disabled:h,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:h?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{p(!1),u(""),w(null)},disabled:h,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}),b&&!d&&e.jsx("p",{className:"text-[10px] text-rose-700",children:b})]})}function ui(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function ya(t){return`${Le(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function pi(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=ya(n),o=s.get(r);o?o.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const Cs={critical:0,serious:1,moderate:2,minor:3},hi={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 mi({results:t,interactiveVerdicts:s,aiResolvedFails:a}){var f;const n=t.length,r=t.flatMap(j=>j.violations),o=pi(t);o.sort((j,x)=>{const v=Cs[j.representative.impact]??99,S=Cs[x.representative.impact]??99;return v!==S?v-S:x.states.length-j.states.length});const l=Ht({violations:r,auditRan:!0,manualRuns:[],workflows:fe,heuristicCounts:{},interactiveAuditVerdicts:s}),i=new Map;for(const j of De)i.set(j.id,[]);const d=[];for(const j of o){let x=!1;for(const v of De)if(v.axeRules.includes(j.representative.ruleId)){i.get(v.id).push(j),x=!0;break}x||d.push(j)}const p=new Map;for(const j of De)p.set(j.id,[]);const c=[];for(const j of a??[]){let x=!1;for(const v of De)if(v.axeRules.includes(j.ruleId)){p.get(v.id).push(j),x=!0;break}x||c.push(j)}const u=((f=t[0])==null?void 0:f.componentId)??null,[h,g]=m.useState([]),[b,w]=m.useState({}),[N,E]=m.useState(0);m.useEffect(()=>{let j=!1;return(async()=>{if(!u){g([]),w({});return}const[x,v]=await Promise.all([Ie(u),Ue([u])]);if(j)return;g(x);const S={};for(const k of v)S[k.criterionId]=k;w(S)})(),()=>{j=!0}},[u,N]);const I=new Map;for(const j of De)I.set(j.id,[]);const C={"2.4.3":"tab-order","2.1.2":"keyboard","2.4.7":"keyboard","1.3.2":"reading-order","1.4.11":"contrast","2.5.3":"aria"};for(const j of h){if(j.verdict==="pass")continue;const x=C[j.criterionId];if(!x)continue;const v=I.get(x);v&&v.push({record:j,ack:b[j.criterionId]??null})}return e.jsxs("div",{className:"space-y-1.5",children:[l.subGrades.map(j=>e.jsx(Is,{subGrade:j,groups:i.get(j.id)??[],totalStates:n,aiFails:p.get(j.id)??[],walkthroughIssues:I.get(j.id)??[],componentId:u,onWalkthroughChanged:()=>E(x=>x+1)},j.id)),(d.length>0||c.length>0)&&e.jsx(Is,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:d,totalStates:n,aiFails:c,walkthroughIssues:[],componentId:u,onWalkthroughChanged:()=>E(j=>j+1)})]})}function Is({subGrade:t,groups:s,totalStates:a,aiFails:n,walkthroughIssues:r,componentId:o,onWalkthroughChanged:l}){const[i,d]=m.useState(!1),p=y(x=>x.pendingAreaExpand),c=y(x=>x.setPendingAreaExpand);m.useEffect(()=>{p===t.id&&(d(!0),c(null),requestAnimationFrame(()=>{const x=document.querySelector(`[data-area-card="${t.id}"]`);x==null||x.scrollIntoView({behavior:"smooth",block:"start"})}))},[p,t.id,c]);const[u,h]=m.useState("idle"),[g,b]=m.useState(null),[w,N]=m.useState(0),E=s.length>0||n.length>0||r.length>0,I=hi[t.letter],C=s.filter(x=>x.representative.ruleId==="color-contrast"||x.representative.ruleId==="color-contrast-enhanced"),f=C.length>=2;async function j(x){x.stopPropagation(),h("loading"),b(null);try{const v=C.map(k=>{const T=k.representative.target.outerHTML,V=k.representative.target.failureSummary,P=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(V),B=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(V);if(!P||!B)return null;const L=k.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:k.representative.matchKey,foreground:P[1],background:B[1],fontSize:16,fontWeight:400,targetLevel:L,_html:T}}).filter(k=>k!==null);if(v.length===0){h("error"),b("Could not parse fg/bg colors from the violation failure summaries.");return}const S=await Z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:v.map(({_html:k,...T})=>T)});if(S.unavailableReason&&S.results.length===0){h("error"),b(S.unavailableReason);return}await sn(S.results),h("done"),N(k=>k+1),i||d(!0)}catch(v){h("error"),b(v instanceof Error?v.message:String(v))}}return e.jsxs("div",{"data-area-card":t.id,className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>d(x=>!x),"aria-expanded":i,disabled:!E,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold font-display ${I}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:E?(()=>{const x=s.length+n.length+r.length,v=[];return s.length>0&&v.push(`${s.length} axe`),n.length>0&&v.push(`${n.length} AI-resolved`),r.length>0&&v.push(`${r.length} walkthrough`),`${x} ${x===1?"issue":"issues"} to fix (${v.join(" + ")})`})():"No issues found"})]}),f&&e.jsx("span",{role:"button",tabIndex:0,onClick:x=>void j(x),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),j(x))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${C.length} contrast issues at once`,children:u==="loading"?"Asking AI…":u==="done"?`✓ Suggested for all ${C.length}`:`✨ Suggest for all ${C.length}`}),E&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0 font-mono","aria-hidden":"true",children:i?"−":"+"})]}),u==="error"&&g&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:g}),i&&E&&e.jsxs("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:[s.map(x=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ze,{violation:x.representative}),e.jsx(xi,{states:x.states,totalStates:a})]},`${ya(x.representative)}::${w}`)),n.length>0&&e.jsxs(e.Fragment,{children:[s.length>0&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI-resolved fails (",n.length,")"]}),n.map(x=>e.jsx(gi,{fail:x},`${x.ruleId}::${x.selector}`))]}),r.length>0&&e.jsxs(e.Fragment,{children:[(s.length>0||n.length>0)&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI walkthrough findings (",r.length,")"]}),r.map(x=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(ts,{componentId:o??"",pageUrl:x.record.pageUrl,criterionId:x.record.criterionId,record:x.record,ack:x.ack,onChanged:l})},x.record.criterionId))]})]})]})}function xi({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(ui))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",o=a.join(`
10
+ `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:o,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}function gi({fail:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(!1);async function o(){a(!0);try{const{saveResolutions:l}=await ke(async()=>{const{saveResolutions:i}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(d=>d.aT);return{saveResolutions:i}},__vite__mapDeps([0,1,2,3,4]));await l([{...t,verdict:"pass",reasoning:`[Human override — visually verified by user] ${t.reasoning}`,resolvedAt:new Date().toISOString()}]),r(!0)}finally{a(!1)}}return e.jsxs("div",{className:`border rounded-md bg-white p-2 text-[11px] ${n?"border-emerald-200 bg-emerald-50":"border-rose-200"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[10px] text-rose-700",children:t.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold ${n?"bg-emerald-100 text-emerald-800":"bg-rose-100 text-rose-900"}`,children:n?"✓ Resolved":"AI verdict: FAIL"})]}),e.jsx("p",{className:"font-mono text-[10px] text-slate-700 mb-1 break-all",children:t.selector}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:t.reasoning}),!n&&e.jsx("button",{type:"button",onClick:()=>void o(),disabled:s,className:"px-2 py-1 text-[11px] font-medium bg-white border border-emerald-300 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50",title:"Override the AI's fail determination — your human visual judgment is the highest authority per WCAG-EM. Use when you've verified the contrast / labeling is actually fine.",children:"✓ Mark as resolved (override AI)"})]})}const Es="igtRuns";async function fi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Es))[Es];return s&&typeof s=="object"?s:{}}async function bi(t,s){var l,i;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,o=(await fi())[t];if(o)for(const d of fe){const p=o[d.id];if(p)for(const c of d.steps){if(!c.autoDismissActivity||((i=(l=p.steps)==null?void 0:l[c.id])==null?void 0:i.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const g=a.tabOrderIssues??[];if(g.length===0)continue;await Xe(n,g.map(b=>({key:Je(b.selector),reason:h,snippet:`${b.selector} — ${b.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const g=a.readingOrderIssues??[];if(g.length===0)continue;await Xe(n,g.map(b=>({key:Ye(b.selector),reason:h,snippet:`${b.selector} — ${b.textSnippet||"(no text)"}`})))}}}}const vi=new Set(["heading-order","page-has-heading-one","empty-heading","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","landmark-banner-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-complementary-is-top-level","landmark-unique","region","bypass","duplicate-id","duplicate-id-aria","duplicate-id-active"]),yi=new Set(["label","label-content-name-mismatch","label-title-only","form-field-multiple-labels","input-button-name","input-image-alt","autocomplete-valid","aria-required-attr","aria-required-children","aria-required-parent","aria-input-field-name","aria-toggle-field-name","select-name","button-name"]);function wi(t){return vi.has(t.ruleId)}function ji(t){return yi.has(t.ruleId)}function Ni(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function wa(){var P,B,L,q;const t=y($=>$.results),s=y($=>$.delta),a=y($=>$.componentId),n=((P=t[0])==null?void 0:P.pageUrl)??((B=t[0])==null?void 0:B.scope)??"",[r,o]=m.useState({}),[l,i]=m.useState(!1),[d,p]=m.useState(!1);m.useEffect(()=>{if(!a){i(!1),p(!1);return}let $=!1;return(async()=>{const _=await Ie(a);if($)return;const F=_.some(R=>R.criterionId==="2.1.2"&&R.verdict==="pass"),H=_.some(R=>R.criterionId==="1.3.2");i(F),p(H)})(),()=>{$=!0}},[a]);const[c,u]=m.useState(0);m.useEffect(()=>{if(!n)return;let $=!1;return(async()=>{if(a&&t.length>0)try{await bi(a,t)}catch{}if($)return;const _=await Jt(n);$||o(_)})(),()=>{$=!0}},[n,c,a,t]);async function h($,_){if(!n)return;const F=window.prompt(`Why is this finding a false positive?
11
11
 
12
- (Recorded with the dismissal so future you remembers the reasoning.)`,"");F!==null&&(await Xt(n,$,F||"(no reason given)",_),u(H=>H+1))}async function x($){n&&(await Zt(n,$),u(_=>_+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const b=t.reduce(($,_)=>{var F;return $+(((F=_.announcements)==null?void 0:F.length)??0)},0),w=t.reduce(($,_)=>{var F;return $+(((F=_.focusEvents)==null?void 0:F.length)??0)},0),N=t.reduce(($,_)=>{var F;return $+(((F=_.focusEvents)==null?void 0:F.filter(H=>H.isFocusReset).length)??0)},0),E=Rs(t,vi),I=Rs(t,yi),C=E.length,f=I.length,j=d?[]:((U=t[0])==null?void 0:U.readingOrderIssues)??[],g=l?[]:((q=t[0])==null?void 0:q.tabOrderIssues)??[],v=j.filter($=>!(Ye($.selector)in r)),S=j.filter($=>Ye($.selector)in r),k=g.filter($=>!(Je($.selector)in r)),T=g.filter($=>Je($.selector)in r);if(b===0&&w===0&&C===0&&f===0&&v.length===0&&k.length===0&&S.length===0&&T.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const V=S.length+T.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[C," structural · ",f," form ·"," ",k.length," tab-order ·"," ",v.length," reading-order ·"," ",b," ",b===1?"announcement":"announcements"," ·"," ",w," focus ",w===1?"event":"events",N>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",N," focus reset",N===1?"":"s"]}),V>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",V," dismissed"]})]}),k.length>0&&e.jsx(ki,{issues:k,onDismiss:h}),v.length>0&&e.jsx(Si,{issues:v,onDismiss:h}),V>0&&e.jsx(Ai,{dismissedReadingOrder:S,dismissedTabOrder:T,dismissals:r,onRestore:x}),C>0&&e.jsx(Ts,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:E}),f>0&&e.jsx(Ts,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:I}),e.jsx(ji,{delta:s}),t.map(($,_)=>{const F=$.announcements??[],H=$.focusEvents??[];return F.length===0&&H.length===0?null:e.jsx(Ni,{state:$.state,announcements:F,focusEvents:H},_)})]})}function ji({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,o)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},o))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,o)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},o))})]})]})}function Rs(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const o=Ue(r.ruleId,r.target.selector),l=a.get(o);l?l.states.push(r.currentState):a.set(o,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const o={critical:0,serious:1,moderate:2,minor:3};return(o[n.violation.impact]??99)-(o[r.violation.impact]??99)})}function Ts({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function Ni({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:wi(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function ki({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,o)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},o)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Si({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Ai({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,o]=m.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>o(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(i=>{const d=`tab-order::${i.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:i.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:i.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(i=>{const d=`reading-order::${i.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:i.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:i.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Ci={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Ii({ruleId:t,violations:s}){const[a,n]=m.useState(s.length===1),r=s[0];if(!r)return null;const o=r.impact,l=r.description,i=s.length;return i===1?e.jsx(Ze,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Ci[o]}`,children:o}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",i]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(Ze,{violation:d},p))})]})}function Ei(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const Ri={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function wa({open:t,onClose:s,format:a,content:n,filename:r}){const o=Rn(new Blob([n]).size);function l(){et(n,r),s()}function i(){$e(n),s()}return e.jsxs(Me,{open:t,onClose:s,title:Ri[a],description:`Generated bundle — ${o}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:i,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const $s=7800;function Ti(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}`,x=r.find(b=>`${b.ruleId}::${b.target.selector}`===u);if(x){x._states.includes(h)||x._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(`
13
- `),d=new URLSearchParams({title:o,body:i});let p=`${n}/issues/new?${d.toString()}`;return p.length>$s&&(p=p.slice(0,$s)),{url:p,title:o,body:i}}const Us=7800;function $i(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}`,x=r.find(b=>`${b.ruleId}::${b.target.selector}`===u);if(x){x._states.includes(h)||x._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(`Rule: ${c.ruleId} (${c.impact})`),l.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),l.push(`Description: ${c.description}`),l.push(`Selector: ${c.target.selector}`),l.push(`Found in state(s): ${c._states.join(", ")}`),c.helpUrl&&l.push(`More info: ${c.helpUrl}`),l.push(""),l.push(`HTML: ${c.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const i=l.join(`
14
- `),d=new URLSearchParams({summary:o,description:i});let p=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return p.length>Us&&(p=p.slice(0,Us)),{url:p,summary:o,description:i}}const Ls=7800;function Ui(t,s,a,n="Bug"){const r=t.replace(/\/$/,""),o=[];for(const u of a){const h=`${u.ruleId}::${u.target.selector}`,x=`:${u.currentState.pseudoState} · ${u.currentState.theme} · ${u.currentState.direction}`,b=o.find(w=>`${w.ruleId}::${w.target.selector}`===h);if(b){b._states.includes(x)||b._states.push(x);continue}o.push({...u,_states:[x]})}const l=`a11y: ${o.length} new violation${o.length===1?"":"s"} in ${s??"audited component"}`,i=[];i.push(`**Component:** \`${s??"unknown"}\``),i.push(""),i.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),i.push(""),i.push("---"),i.push("");for(const u of o)i.push(`### \`${u.ruleId}\` — ${u.impact}`),i.push(""),i.push(u.description),i.push(""),i.push(`- **WCAG:** ${u.wcagCriterion} (${u.wcagLevel})`),i.push(`- **Selector:** \`${u.target.selector}\``),i.push(`- **Found in state(s):** ${u._states.join(", ")}`),u.helpUrl&&i.push(`- **More info:** ${u.helpUrl}`),i.push(""),i.push("```html"),i.push(u.target.outerHTML),i.push("```"),i.push("");i.push("---"),i.push(""),i.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const d=i.join(`
15
- `),p=new URLSearchParams({"[Title]":l,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${p.toString()}`;return c.length>Ls&&(c=c.slice(0,Ls)),{url:c,title:l,description:d}}const _s=7800;function Li(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}`,x=r.find(b=>`${b.ruleId}::${b.target.selector}`===u);if(x){x._states.includes(h)||x._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
- `),d=new URLSearchParams({"issue[title]":o,"issue[description]":i});let p=`${n}/-/issues/new?${d.toString()}`;return p.length>_s&&(p=p.slice(0,_s)),{url:p,title:o,description:i}}const Ds=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],_i=["wcag-component-auditor","wcag-forensic-log"];async function Di(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Ds);s=Object.keys(n).length,await chrome.storage.local.remove(Ds)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of _i)try{await Oi(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 Oi(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 Ft="accessibilityStatementInputs:v1";async function Fi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(Ft))[Ft];return s&&typeof s=="object"?s:null}async function Mi(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[Ft]:t})}function ja({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,x]=m.useState(""),[b,w]=m.useState(""),[N,E]=m.useState(""),[I,C]=m.useState(""),[f,j]=m.useState("English"),[g,v]=m.useState("wcagcheckr (self-evaluation)"),[S,k]=m.useState("2.1"),[T,V]=m.useState("AA"),[P,B]=m.useState(!1),[U,q]=m.useState(null),$=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var M,ie,A,G;const R=await Fi();if(R&&(R.framing&&o(R.framing),R.organizationName&&i(R.organizationName),R.siteUrl&&p(R.siteUrl),R.conformanceStatus&&u(R.conformanceStatus),(M=R.contact)!=null&&M.email&&x(R.contact.email),(ie=R.contact)!=null&&ie.phone&&w(R.contact.phone),(A=R.contact)!=null&&A.formUrl&&E(R.contact.formUrl),R.countryCode&&C(R.countryCode),R.language&&j(R.language),R.auditedBy&&v(R.auditedBy),R.wcagVersion&&k(R.wcagVersion),R.wcagLevel&&V(R.wcagLevel)),!(R!=null&&R.siteUrl)&&((G=a[0])!=null&&G.pageUrl))try{const W=new URL(a[0].pageUrl);p(`${W.protocol}//${W.host}/`)}catch{}R!=null&&R.conformanceStatus||u(sn(a)),setTimeout(()=>{var W;return(W=$.current)==null?void 0:W.focus()},50)})()},[t,a]),!t)return null;function _(){var A;const R=new Date().toISOString().slice(0,10),M=(A=a[0])!=null&&A.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):R,ie={};return h.trim()&&(ie.email=h.trim()),b.trim()&&(ie.phone=b.trim()),N.trim()&&(ie.formUrl=N.trim()),{framing:r,organizationName:l.trim(),siteUrl:d.trim(),conformanceStatus:c,preparedAt:R,evaluatedAt:M,contact:ie,countryCode:I||null,language:f.trim()||"English",auditedBy:g.trim()||"wcagcheckr (self-evaluation)",wcagVersion:S,wcagLevel:T}}function F(R){if(!R.organizationName)return"Organization name is required.";if(!R.siteUrl)return"Site URL is required.";try{new URL(R.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!R.contact.email&&!R.contact.phone&&!R.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 H(R){var A;q(null);const M=_(),ie=F(M);if(ie){q(ie);return}B(!0);try{await Mi(M);const G=await Z({type:"EXPORT_REQUEST",format:R==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:n?[]:a,siteCrawlSource:n||void 0,statementInputs:M}),W=(G==null?void 0:G.content)??"";if(!W||W.startsWith("# Accessibility statement — error")){q(W||"Export failed — no response.");return}try{await navigator.clipboard.writeText(W)}catch{}const K=new Blob([W],{type:R==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),oe=URL.createObjectURL(K);typeof chrome<"u"&&((A=chrome.tabs)!=null&&A.create)?await chrome.tabs.create({url:oe,active:!0}).catch(()=>{window.open(oe,"_blank","noopener,noreferrer")}):window.open(oe,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(oe),6e4),s()}catch(G){q(G instanceof Error?G.message:String(G))}finally{B(!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:R=>R.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:$,type:"text",value:l,onChange:R=>i(R.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:R=>p(R.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:R=>u(R.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:S,onChange:R=>k(R.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:T,onChange:R=>V(R.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:R=>x(R.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:b,onChange:R=>w(R.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:N,onChange:R=>E(R.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:I,onChange:R=>C(R.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(an).map(([R,M])=>e.jsxs("option",{value:R,children:[R," — ",M.name.replace(/^[A-Z]+\s*—\s*/,"")]},R))]}),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:f,onChange:R=>j(R.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:g,onChange:R=>v(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),U&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:U})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void H("markdown"),disabled:P,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:P?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void H("html"),disabled:P,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:P?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:P,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 Na(){const t=y(A=>A.delta),s=y(A=>A.componentId),a=y(A=>A.results),n=y(A=>A.tier),r=y(A=>A.baselineList),o=y(A=>A.siteCrawlReport),[l,i]=m.useState(""),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,x]=m.useState(""),[b,w]=m.useState(!1),[N,E]=m.useState(!1),[I,C]=m.useState(null),[f,j]=m.useState(null),[g,v]=m.useState(!1),[S,k]=m.useState(!1),[T,V]=m.useState(null),[P,B]=m.useState(!1);m.useEffect(()=>{Promise.all([Z({type:"SETTINGS_GET",key:"githubRepoUrl"}),Z({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),Z({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),Z({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([A,G,W,K])=>{i(typeof A.data=="string"?A.data:""),p(typeof G.data=="string"?G.data:""),u(typeof W.data=="string"?W.data:""),x(typeof K.data=="string"?K.data:"")})},[]),m.useEffect(()=>we("BADGE_CLICKED_EVENT",G=>{const W=`viol-row-${G.violationId}`,K=document.getElementById(W);K&&(K.scrollIntoView({behavior:"smooth",block:"center"}),K.classList.add("ring-2","ring-rose-500"),setTimeout(()=>K.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const A=await ue();A&&(S&&await be(A,{type:"BADGES_HIDE_REQUEST",tabId:A}).catch(()=>{}),P&&await be(A,{type:"HEATMAP_HIDE_REQUEST",tabId:A}).catch(()=>{}))})()},[]);async function U(){const A=await ue();if(!A){ge.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(S){await be(A,{type:"BADGES_HIDE_REQUEST",tabId:A}).catch(()=>{}),k(!1),V(null);return}const G={critical:4,serious:3,moderate:2,minor:1},W=new Map;for(const le of a)for(const pe of le.violations)W.has(pe.matchKey)||W.set(pe.matchKey,pe);const oe=Array.from(W.values()).sort((le,pe)=>G[pe.impact]-G[le.impact]).map((le,pe)=>({id:le.matchKey,index:pe+1,selector:le.target.selector,impact:le.impact,ruleId:le.ruleId,wcagCriterion:le.wcagCriterion}));if(oe.length===0){ge.polite("No violations to badge.");return}const ne=await Ee(A,{type:"BADGES_SHOW_REQUEST",tabId:A,violations:oe}).catch(()=>null);ne&&(k(!0),V({rendered:ne.rendered,requested:ne.requested,clustered:ne.clustered}),ge.polite(`${ne.rendered} violation badges shown on the page.`))}async function q(){const A=await ue();if(!A){ge.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(P){await be(A,{type:"HEATMAP_HIDE_REQUEST",tabId:A}).catch(()=>{}),B(!1);return}const G=new Map;for(const oe of a)for(const ne of oe.violations)G.has(ne.matchKey)||G.set(ne.matchKey,ne);const W=Array.from(G.values()).map(oe=>({selector:oe.target.selector,impact:oe.impact}));if(W.length===0){ge.polite("No violations to heatmap.");return}const K=await Ee(A,{type:"HEATMAP_SHOW_REQUEST",tabId:A,violations:W}).catch(()=>null);K&&(B(!0),ge.polite(`Heatmap shown with ${K.rendered} violation blobs.`))}const $=ft(n,"exportJson"),_=ra[n].maxBaselines,F=r.some(A=>A.componentId===s),H=F||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 R(){if(!s||a.length===0)return;const A=a.flatMap(pe=>pe.violations),G=a.flatMap(pe=>pe.announcements??[]),W=a.flatMap(pe=>pe.focusEvents??[]),K=a[0],ne=(await Z({type:"SETTINGS_GET",key:"stateMatrix"})).data??qt;await ae({type:"BASELINE_SET",componentId:s,violations:A,announcements:G,focusEvents:W,snapshotMeta:{url:window.location.href,axeVersion:K.axeVersion,matrixConfig:ne,capturedAt:new Date().toISOString()}});const le=await Z({type:"BASELINE_COMPARE",componentId:s,currentViolations:A,announcements:G,focusEvents:W,currentMatrix:ne});y.getState().setDelta(le.delta),ge.polite(`Baseline saved for ${s}.`)}async function M(){if(!s||!F||!window.confirm(`Remove the saved baseline for "${s}"?
12
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");F!==null&&(await Xt(n,$,F||"(no reason given)",_),u(H=>H+1))}async function g($){n&&(await Zt(n,$),u(_=>_+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const b=t.reduce(($,_)=>{var F;return $+(((F=_.announcements)==null?void 0:F.length)??0)},0),w=t.reduce(($,_)=>{var F;return $+(((F=_.focusEvents)==null?void 0:F.length)??0)},0),N=t.reduce(($,_)=>{var F;return $+(((F=_.focusEvents)==null?void 0:F.filter(H=>H.isFocusReset).length)??0)},0),E=Rs(t,wi),I=Rs(t,ji),C=E.length,f=I.length,j=d?[]:((L=t[0])==null?void 0:L.readingOrderIssues)??[],x=l?[]:((q=t[0])==null?void 0:q.tabOrderIssues)??[],v=j.filter($=>!(Ye($.selector)in r)),S=j.filter($=>Ye($.selector)in r),k=x.filter($=>!(Je($.selector)in r)),T=x.filter($=>Je($.selector)in r);if(b===0&&w===0&&C===0&&f===0&&v.length===0&&k.length===0&&S.length===0&&T.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const V=S.length+T.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[C," structural · ",f," form ·"," ",k.length," tab-order ·"," ",v.length," reading-order ·"," ",b," ",b===1?"announcement":"announcements"," ·"," ",w," focus ",w===1?"event":"events",N>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",N," focus reset",N===1?"":"s"]}),V>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",V," dismissed"]})]}),k.length>0&&e.jsx(Ai,{issues:k,onDismiss:h}),v.length>0&&e.jsx(Ci,{issues:v,onDismiss:h}),V>0&&e.jsx(Ii,{dismissedReadingOrder:S,dismissedTabOrder:T,dismissals:r,onRestore:g}),C>0&&e.jsx(Ts,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:E}),f>0&&e.jsx(Ts,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:I}),e.jsx(ki,{delta:s}),t.map(($,_)=>{const F=$.announcements??[],H=$.focusEvents??[];return F.length===0&&H.length===0?null:e.jsx(Si,{state:$.state,announcements:F,focusEvents:H},_)})]})}function ki({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,o)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},o))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,o)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},o))})]})]})}function Rs(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const o=Le(r.ruleId,r.target.selector),l=a.get(o);l?l.states.push(r.currentState):a.set(o,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const o={critical:0,serious:1,moderate:2,minor:3};return(o[n.violation.impact]??99)-(o[r.violation.impact]??99)})}function Ts({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function Si({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Ni(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Ai({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,o)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},o)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Ci({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Ii({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,o]=m.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>o(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(i=>{const d=`tab-order::${i.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:i.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:i.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(i=>{const d=`reading-order::${i.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:i.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:i.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Ei={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Ri({ruleId:t,violations:s}){const[a,n]=m.useState(s.length===1),r=s[0];if(!r)return null;const o=r.impact,l=r.description,i=s.length;return i===1?e.jsx(Ze,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Ei[o]}`,children:o}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",i]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(Ze,{violation:d},p))})]})}function Ti(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const $i={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function ja({open:t,onClose:s,format:a,content:n,filename:r}){const o=Tn(new Blob([n]).size);function l(){et(n,r),s()}function i(){$e(n),s()}return e.jsxs(Me,{open:t,onClose:s,title:$i[a],description:`Generated bundle — ${o}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:i,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const $s=7800;function Li(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(b=>`${b.ruleId}::${b.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(`
13
+ `),d=new URLSearchParams({title:o,body:i});let p=`${n}/issues/new?${d.toString()}`;return p.length>$s&&(p=p.slice(0,$s)),{url:p,title:o,body:i}}const Ls=7800;function Ui(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(b=>`${b.ruleId}::${b.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(`Rule: ${c.ruleId} (${c.impact})`),l.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),l.push(`Description: ${c.description}`),l.push(`Selector: ${c.target.selector}`),l.push(`Found in state(s): ${c._states.join(", ")}`),c.helpUrl&&l.push(`More info: ${c.helpUrl}`),l.push(""),l.push(`HTML: ${c.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const i=l.join(`
14
+ `),d=new URLSearchParams({summary:o,description:i});let p=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return p.length>Ls&&(p=p.slice(0,Ls)),{url:p,summary:o,description:i}}const Us=7800;function _i(t,s,a,n="Bug"){const r=t.replace(/\/$/,""),o=[];for(const u of a){const h=`${u.ruleId}::${u.target.selector}`,g=`:${u.currentState.pseudoState} · ${u.currentState.theme} · ${u.currentState.direction}`,b=o.find(w=>`${w.ruleId}::${w.target.selector}`===h);if(b){b._states.includes(g)||b._states.push(g);continue}o.push({...u,_states:[g]})}const l=`a11y: ${o.length} new violation${o.length===1?"":"s"} in ${s??"audited component"}`,i=[];i.push(`**Component:** \`${s??"unknown"}\``),i.push(""),i.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),i.push(""),i.push("---"),i.push("");for(const u of o)i.push(`### \`${u.ruleId}\` — ${u.impact}`),i.push(""),i.push(u.description),i.push(""),i.push(`- **WCAG:** ${u.wcagCriterion} (${u.wcagLevel})`),i.push(`- **Selector:** \`${u.target.selector}\``),i.push(`- **Found in state(s):** ${u._states.join(", ")}`),u.helpUrl&&i.push(`- **More info:** ${u.helpUrl}`),i.push(""),i.push("```html"),i.push(u.target.outerHTML),i.push("```"),i.push("");i.push("---"),i.push(""),i.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const d=i.join(`
15
+ `),p=new URLSearchParams({"[Title]":l,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${p.toString()}`;return c.length>Us&&(c=c.slice(0,Us)),{url:c,title:l,description:d}}const _s=7800;function Di(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(b=>`${b.ruleId}::${b.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
+ `),d=new URLSearchParams({"issue[title]":o,"issue[description]":i});let p=`${n}/-/issues/new?${d.toString()}`;return p.length>_s&&(p=p.slice(0,_s)),{url:p,title:o,description:i}}const Ds=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Oi=["wcag-component-auditor","wcag-forensic-log"];async function Fi(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Ds);s=Object.keys(n).length,await chrome.storage.local.remove(Ds)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Oi)try{await Mi(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 Mi(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 Ft="accessibilityStatementInputs:v1";async function Pi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(Ft))[Ft];return s&&typeof s=="object"?s:null}async function Gi(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[Ft]:t})}function Na({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(""),[b,w]=m.useState(""),[N,E]=m.useState(""),[I,C]=m.useState(""),[f,j]=m.useState("English"),[x,v]=m.useState("wcagcheckr (self-evaluation)"),[S,k]=m.useState("2.1"),[T,V]=m.useState("AA"),[P,B]=m.useState(!1),[L,q]=m.useState(null),$=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var M,ie,A,G;const R=await Pi();if(R&&(R.framing&&o(R.framing),R.organizationName&&i(R.organizationName),R.siteUrl&&p(R.siteUrl),R.conformanceStatus&&u(R.conformanceStatus),(M=R.contact)!=null&&M.email&&g(R.contact.email),(ie=R.contact)!=null&&ie.phone&&w(R.contact.phone),(A=R.contact)!=null&&A.formUrl&&E(R.contact.formUrl),R.countryCode&&C(R.countryCode),R.language&&j(R.language),R.auditedBy&&v(R.auditedBy),R.wcagVersion&&k(R.wcagVersion),R.wcagLevel&&V(R.wcagLevel)),!(R!=null&&R.siteUrl)&&((G=a[0])!=null&&G.pageUrl))try{const W=new URL(a[0].pageUrl);p(`${W.protocol}//${W.host}/`)}catch{}R!=null&&R.conformanceStatus||u(an(a)),setTimeout(()=>{var W;return(W=$.current)==null?void 0:W.focus()},50)})()},[t,a]),!t)return null;function _(){var A;const R=new Date().toISOString().slice(0,10),M=(A=a[0])!=null&&A.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):R,ie={};return h.trim()&&(ie.email=h.trim()),b.trim()&&(ie.phone=b.trim()),N.trim()&&(ie.formUrl=N.trim()),{framing:r,organizationName:l.trim(),siteUrl:d.trim(),conformanceStatus:c,preparedAt:R,evaluatedAt:M,contact:ie,countryCode:I||null,language:f.trim()||"English",auditedBy:x.trim()||"wcagcheckr (self-evaluation)",wcagVersion:S,wcagLevel:T}}function F(R){if(!R.organizationName)return"Organization name is required.";if(!R.siteUrl)return"Site URL is required.";try{new URL(R.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!R.contact.email&&!R.contact.phone&&!R.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 H(R){var A;q(null);const M=_(),ie=F(M);if(ie){q(ie);return}B(!0);try{await Gi(M);const G=await Z({type:"EXPORT_REQUEST",format:R==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:n?[]:a,siteCrawlSource:n||void 0,statementInputs:M}),W=(G==null?void 0:G.content)??"";if(!W||W.startsWith("# Accessibility statement — error")){q(W||"Export failed — no response.");return}try{await navigator.clipboard.writeText(W)}catch{}const K=new Blob([W],{type:R==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),oe=URL.createObjectURL(K);typeof chrome<"u"&&((A=chrome.tabs)!=null&&A.create)?await chrome.tabs.create({url:oe,active:!0}).catch(()=>{window.open(oe,"_blank","noopener,noreferrer")}):window.open(oe,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(oe),6e4),s()}catch(G){q(G instanceof Error?G.message:String(G))}finally{B(!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:R=>R.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:$,type:"text",value:l,onChange:R=>i(R.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:R=>p(R.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:R=>u(R.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:S,onChange:R=>k(R.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:T,onChange:R=>V(R.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:R=>g(R.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:b,onChange:R=>w(R.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:N,onChange:R=>E(R.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:I,onChange:R=>C(R.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(nn).map(([R,M])=>e.jsxs("option",{value:R,children:[R," — ",M.name.replace(/^[A-Z]+\s*—\s*/,"")]},R))]}),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:f,onChange:R=>j(R.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:x,onChange:R=>v(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),L&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:L})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void H("markdown"),disabled:P,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:P?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void H("html"),disabled:P,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:P?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:P,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function ka(){const t=y(A=>A.delta),s=y(A=>A.componentId),a=y(A=>A.results),n=y(A=>A.tier),r=y(A=>A.baselineList),o=y(A=>A.siteCrawlReport),[l,i]=m.useState(""),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,g]=m.useState(""),[b,w]=m.useState(!1),[N,E]=m.useState(!1),[I,C]=m.useState(null),[f,j]=m.useState(null),[x,v]=m.useState(!1),[S,k]=m.useState(!1),[T,V]=m.useState(null),[P,B]=m.useState(!1);m.useEffect(()=>{Promise.all([Z({type:"SETTINGS_GET",key:"githubRepoUrl"}),Z({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),Z({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),Z({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([A,G,W,K])=>{i(typeof A.data=="string"?A.data:""),p(typeof G.data=="string"?G.data:""),u(typeof W.data=="string"?W.data:""),g(typeof K.data=="string"?K.data:"")})},[]),m.useEffect(()=>we("BADGE_CLICKED_EVENT",G=>{const W=`viol-row-${G.violationId}`,K=document.getElementById(W);K&&(K.scrollIntoView({behavior:"smooth",block:"center"}),K.classList.add("ring-2","ring-rose-500"),setTimeout(()=>K.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const A=await ue();A&&(S&&await be(A,{type:"BADGES_HIDE_REQUEST",tabId:A}).catch(()=>{}),P&&await be(A,{type:"HEATMAP_HIDE_REQUEST",tabId:A}).catch(()=>{}))})()},[]);async function L(){const A=await ue();if(!A){ge.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(S){await be(A,{type:"BADGES_HIDE_REQUEST",tabId:A}).catch(()=>{}),k(!1),V(null);return}const G={critical:4,serious:3,moderate:2,minor:1},W=new Map;for(const le of a)for(const pe of le.violations)W.has(pe.matchKey)||W.set(pe.matchKey,pe);const oe=Array.from(W.values()).sort((le,pe)=>G[pe.impact]-G[le.impact]).map((le,pe)=>({id:le.matchKey,index:pe+1,selector:le.target.selector,impact:le.impact,ruleId:le.ruleId,wcagCriterion:le.wcagCriterion}));if(oe.length===0){ge.polite("No violations to badge.");return}const ae=await Ee(A,{type:"BADGES_SHOW_REQUEST",tabId:A,violations:oe}).catch(()=>null);ae&&(k(!0),V({rendered:ae.rendered,requested:ae.requested,clustered:ae.clustered}),ge.polite(`${ae.rendered} violation badges shown on the page.`))}async function q(){const A=await ue();if(!A){ge.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(P){await be(A,{type:"HEATMAP_HIDE_REQUEST",tabId:A}).catch(()=>{}),B(!1);return}const G=new Map;for(const oe of a)for(const ae of oe.violations)G.has(ae.matchKey)||G.set(ae.matchKey,ae);const W=Array.from(G.values()).map(oe=>({selector:oe.target.selector,impact:oe.impact}));if(W.length===0){ge.polite("No violations to heatmap.");return}const K=await Ee(A,{type:"HEATMAP_SHOW_REQUEST",tabId:A,violations:W}).catch(()=>null);K&&(B(!0),ge.polite(`Heatmap shown with ${K.rendered} violation blobs.`))}const $=gt(n,"exportJson"),_=ra[n].maxBaselines,F=r.some(A=>A.componentId===s),H=F||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 R(){if(!s||a.length===0)return;const A=a.flatMap(pe=>pe.violations),G=a.flatMap(pe=>pe.announcements??[]),W=a.flatMap(pe=>pe.focusEvents??[]),K=a[0],ae=(await Z({type:"SETTINGS_GET",key:"stateMatrix"})).data??qt;await ne({type:"BASELINE_SET",componentId:s,violations:A,announcements:G,focusEvents:W,snapshotMeta:{url:window.location.href,axeVersion:K.axeVersion,matrixConfig:ae,capturedAt:new Date().toISOString()}});const le=await Z({type:"BASELINE_COMPARE",componentId:s,currentViolations:A,announcements:G,focusEvents:W,currentMatrix:ae});y.getState().setDelta(le.delta),ge.polite(`Baseline saved for ${s}.`)}async function M(){if(!s||!F||!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 ae({type:"BASELINE_DELETE",componentId:s});const G=a.flatMap(le=>le.violations),W=a.flatMap(le=>le.announcements??[]),K=a.flatMap(le=>le.focusEvents??[]),oe=await Z({type:"BASELINE_COMPARE",componentId:s,currentViolations:G,announcements:W,focusEvents:K});y.getState().setDelta(oe.delta);const ne=await Z({type:"BASELINE_LIST"});y.getState().setBaselineList(ne.items),ge.polite(`Baseline cleared for ${s}.`)}async function ie(A,G=!1){if(a.length===0)return;if(A==="ai-prompt"){const{copyAiFixerPrompt:Y}=await ke(async()=>{const{copyAiFixerPrompt:he}=await import("./copy-ai-fixer-prompt-D22iP0cq.js");return{copyAiFixerPrompt:he}},__vite__mapDeps([5,1,2]));await Y({results:a,componentId:s,delta:G?void 0:t,siteCrawlReport:o});return}let W;if((A==="defense-bundle"||A==="evidence-bundle"||A==="deposition-packet")&&s){const Y=await chrome.storage.local.get("igtRuns"),de=((Y==null?void 0:Y.igtRuns)??{})[s]??{};W=Object.values(de)}const ne=await Z({type:"EXPORT_REQUEST",format:A,results:a,delta:G?void 0:t??void 0,manualRuns:W,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:y.getState().lastAuditWallClockMs??void 0});if(A==="defense-bundle"||A==="evidence-bundle"||A==="deposition-packet"){const Y=bt(A,s);await ia()?et(ne.content,Y):j({open:!0,format:A,content:ne.content,filename:Y});return}if(A==="html-print"||A==="vpat"||A==="methodology-doc"||A==="conformance-crosswalk"||A==="executive-report"){$e(ne.content);return}const le=A==="json"?"application/json":A==="sarif"?"application/sarif+json":A==="ticket-bundle"?"text/markdown":"application/xml",pe=A==="junit"?"xml":A==="ticket-bundle"?"md":A,L=new Blob([ne.content],{type:le}),X=URL.createObjectURL(L),z=document.createElement("a");z.href=X,z.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${pe}`,z.click(),URL.revokeObjectURL(X)}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:R,disabled:!H,title:H?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"}),F&&e.jsx("button",{onClick:M,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:()=>w(!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 U(),"aria-pressed":S,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:S?"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:S?"Hide badges":"Show badges 🎯"}),S&&T&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[T.rendered," of ",T.requested," rendered",T.clustered>0?` · ${T.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void q(),"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(Hi,{disabled:!$,onExport:ie,onAccessibilityStatement:()=>v(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!H&&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 A=At(t.new),G=At(t.persistent),W=At(t.fixed),K=[...A.review,...G.review];return e.jsxs(e.Fragment,{children:[e.jsx(We,{title:"New",violations:A.findings,count:A.findings.length,accent:"red",actions:[...l&&A.findings.length>0?[{label:"File GitHub issue",onClick:()=>Gi(l,s,A.findings)}]:[],...d&&A.findings.length>0?[{label:"File Jira issue",onClick:()=>Vi(d,s,A.findings)}]:[],...c&&A.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Wi(c,s,A.findings)}]:[],...h&&A.findings.length>0?[{label:"File GitLab issue",onClick:()=>Bi(h,s,A.findings)}]:[]]}),e.jsx(We,{title:"Persistent",violations:G.findings,count:G.findings.length,accent:"slate"}),e.jsx(We,{title:"Fixed",violations:W.findings,count:t.fixedCount,accent:"green"}),K.length>0&&e.jsx(We,{title:"Needs review (does not affect grade)",violations:K,count:K.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(We,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),f&&e.jsx(wa,{open:f.open,onClose:()=>j(null),format:f.format,content:f.content,filename:f.filename}),e.jsx(ja,{open:g,onClose:()=>v(!1),results:a}),b&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),I&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",I.chromeStorageKeysCleared," chrome.storage key",I.chromeStorageKeysCleared===1?"":"s"," + ",I.indexedDbsCleared.length," database",I.indexedDbsCleared.length===1?"":"s",".",I.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",I.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:I?e.jsx("button",{type:"button",onClick:()=>{w(!1),C(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>w(!1),disabled:N,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()=>{E(!0);try{const A=await Di();C(A),await yt(),ge.polite("Audit data reset. Ready for a fresh scan.")}catch(A){C({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[A instanceof Error?A.message:String(A)]})}finally{E(!1)}},disabled:N,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:N?"Resetting…":"Reset everything"})]})})]})})]})}const Pi={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function At(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 We({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 ${Pi[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(Ze,{violation:d,alreadyAcknowledged:!0},p)):Ei(s).map(d=>e.jsx(Ii,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Gi(t,s,a){if(a.length===0)return;const{url:n}=Ti(t,s,a);vt(n)}function Vi(t,s,a){if(a.length===0)return;const{url:n}=$i(t,s,a);vt(n)}function Wi(t,s,a){if(a.length===0)return;const{url:n}=Ui(t,s,a);vt(n)}function Bi(t,s,a){if(a.length===0)return;const{url:n}=Li(t,s,a);vt(n)}function Hi({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,o]=m.useState(!1),[l,i]=m.useState(!1);function d(p){o(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>o(p=>!p),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 ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>o(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 w-[260px] max-w-[calc(100vw-1rem)] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:p=>i(p.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:()=>d("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ye,{onClick:()=>d("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ye,{onClick:()=>d("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:()=>d("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:()=>d("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ye,{onClick:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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,{onClick:()=>{o(!1),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}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const Ki="2024-07-25",zi="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.",ka=[{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(ka.flatMap(t=>t.wcag2Criteria));function qi(t,s){return ka.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 Qi={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Sa(){const t=y(c=>c.results),s=y(c=>c.acknowledgedKeys),a=y(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=qi(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:Ki}),"."," ",zi]})]}),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:[Qi[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(Yi,{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 Yi({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"})}const Ji=[{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"}],Xi={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 Zi(){const t=y(u=>u.results),s=y(u=>u.componentId),a=y(u=>u.findingsLens),n=y(u=>u.setFindingsLens),r=y(u=>u.setView),o=y(u=>u.status),[l,i]=m.useState({});m.useEffect(()=>{if(!s)return;let u=!1;return(async()=>{const h=await Ie(s),x=await Le([s]);if(u)return;const b=new Set(x.map(N=>N.criterionId)),w={};for(const N of h){const E=b.has(N.criterionId)?"pass":N.verdict;N.criterionId==="2.4.3"?w.focusOrder=E:N.criterionId==="2.1.2"?w.keyboardTrap=E:N.criterionId==="2.4.7"?w.focusVisible=E:N.criterionId==="1.3.2"?w.readingOrder=E:N.criterionId==="1.4.11"&&(w.nonTextContrast=E)}i(w)})(),()=>{u=!0}},[s]);const d=es(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 b=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(b))}),()=>{u=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(Os,{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(Os,{setView:r}),e.jsx(to,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:d}),e.jsx(eo,{results:t}),e.jsx(so,{lens:a,setLens:n}),e.jsx(ao,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:d})]})}function Os({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 eo({results:t}){const s=y(p=>p.crawlNavContext),a=y(p=>p.setCrawlNavContext),n=y(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 to({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var b,w,N,E;const r=t.flatMap(I=>I.violations),o=y(I=>I.lastAuditWallClockMs),l=y(I=>I.acknowledgedKeys),i=y(I=>I.dismissedKeys),p=Ht({violations:r,auditRan:!0,manualRuns:a,workflows:fe,heuristicCounts:{tabOrder:((w=(b=t[0])==null?void 0:b.tabOrderIssues)==null?void 0:w.length)??0,readingOrder:((E=(N=t[0])==null?void 0:N.readingOrderIssues)==null?void 0:E.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(I=>({ruleId:I.ruleId,impact:"serious",selector:I.selector}))}).overallLetter,c=xa(r,n,l,i),u=yr(r,n,l,i),h=t.length,x=o??t.reduce((I,C)=>I+C.durationMs,0);return e.jsx("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 ${Xi[p]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:p})}),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 · 9 verification areas"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`}),c>0&&u.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",u.length," WCAG criterion",u.length===1?"":"a"," (",u.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[h," state",h===1?"":"s"," tested · ",(x/1e3).toFixed(1),"s"]})]})]})})}function so({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:Ji.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 ao({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(no,{componentId:a,results:s}),e.jsx(lo,{componentId:a}),e.jsx(Ir,{violations:s.flatMap(i=>i.violations),componentId:a,hideOverallHeader:!0}),e.jsx(mo,{pageUrl:((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(co,{})]}):t==="per-area"?e.jsx(pi,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(po,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(ya,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(Na,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Sa,{})}):null}const gt={critical:0,serious:1,moderate:2,minor:3};function Mt(t){return`${Ue(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function no({componentId:t,results:s}){var b,w;const a=y(N=>N.setFindingsLens),[n,r]=m.useState({}),[o,l]=m.useState({}),[i,d]=m.useState(0);m.useEffect(()=>{let N=!1;return(async()=>{if(!t){r({}),l({});return}const E=await Ie(t);if(N)return;const I={};for(const j of E)I[j.criterionId]=j;r(I);const C=await Le([t]);if(N)return;const f={};for(const j of C)f[`${j.criterionId}::${j.pageUrl}`]=j;l(f)})(),()=>{N=!0}},[t,i]);const p=((b=s[0])==null?void 0:b.pageUrl)??((w=s[0])==null?void 0:w.scope)??"",c=ot.map(N=>({crit:N,record:n[N.id]??null})).filter(({record:N})=>N&&(N.verdict==="fail"||N.verdict==="uncertain")).filter(({crit:N})=>!o[`${N.id}::${p}`]),u=new Set,h=[];for(const N of s)for(const E of N.violations){if(E.needsReview)continue;const I=Ue(E.ruleId,E.target.selector);u.has(I)||(u.add(I),h.push(E))}h.sort((N,E)=>(gt[N.impact]??99)-(gt[E.impact]??99));const x=c.length+h.length;return x===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:[x," item",x===1?"":"s"," need",x===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:N,record:E})=>e.jsx(ro,{componentId:t??"",pageUrl:p,criterionId:N.id,label:N.label,blurb:N.blurb,record:E,onChanged:()=>d(I=>I+1)},`wt::${N.id}`)),h.map(N=>e.jsx(io,{violation:N,onOpen:()=>a("violations")},`axe::${Mt(N)}`))]})]})}function ro({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),[x,b]=m.useState(null),[w,N]=m.useState(!1),[E,I]=m.useState(!1),C=o.verdict,f=C==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function j(){h(!0),b(null);try{if(!p.trim()){b("Note is required — explain how you manually verified this."),h(!1);return}await zt({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:C}),l()}catch(v){b(v instanceof Error?v.message:String(v))}finally{h(!1)}}async function g(){var v;I(!0),b(null);try{const k=(v=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:v.id;if(!k){b("No active tab — open the audited page first."),I(!1);return}const V=await ae({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:k,componentId:t,pageUrl:s});V.ok||b(V.error??"Re-run failed."),l()}catch(S){b(S instanceof Error?S.message:String(S))}finally{I(!1)}}return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${f}`,children:C}),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:C==="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:()=>N(v=>!v),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:w?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:E,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",title:"Re-run AI walkthrough after fixing the page (will switch to the active tab)",children:E?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{d(v=>!v),b(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",children:"Mark verified manually"})]}),w&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2 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:v=>c(v.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}),x&&e.jsx("p",{className:"text-[10px] text-rose-700",children:x}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void j(),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(""),b(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"})]})]}),x&&!i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:x})]})}function io({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 ot=[{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)."}],oo={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function lo({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,x]=await Promise.all([Ie(t),Le([t])]);if(u)return;const b={};for(const N of h)b[N.criterionId]=N;a(b);const w={};for(const N of x)w[N.criterionId]=N;r(w)})(),()=>{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 ${ot.length} criteria pending human verification`:`${l}/${ot.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:ot.map(u=>{const h=s[u.id],x=n[u.id],b=h==null?void 0:h.verdict,w=x?"pass":b,N=h?_t(h.reasoning):!1,E=h?ta(h.reasoning):!1,I=h?Dt(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 ${x?"bg-emerald-500 text-white":w?oo[w]:"bg-slate-200 text-slate-500"}`,title:x?`Human verified at ${new Date(x.acknowledgedAt).toLocaleString()} — note: "${x.note}". (AI verdict was: ${b})`:w?`AI verdict: ${w}${I?` (cascade ${I})`:""}`:"AI did not produce a verdict on this criterion",children:x?"✓ verified":w||"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,E&&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}),N&&!E&&!x&&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})]})]}),x&&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:"})," ",x.note]}),e.jsxs("p",{className:"text-[10px] text-emerald-700 mt-0.5",children:["Recorded ",new Date(x.acknowledgedAt).toLocaleString(),". Original AI verdict: ",b,"."]})]})]})]},u.id)})})]})}function co(){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(Re,{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(Re,{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(Re,{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(Re,{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(Re,{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(Re,{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(Re,{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 Re({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 uo({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 Le([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(ts,{componentId:t??"",pageUrl:i.pageUrl,criterionId:i.criterionId,record:i,onChanged:()=>r(d=>d+1),ack:o[i.criterionId]??null})},i.criterionId))]})}function po({results:t}){const s=y(i=>i.dismissedKeys),a=y(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=Mt(d);n.has(p)||(n.add(p),r.push(d))}r.sort((i,d)=>{const p=gt[i.impact]??99,c=gt[d.impact]??99;return p-c});const[o,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let i=!1;return Ie(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(uo,{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(Ze,{violation:i},Mt(i)))]})}const ho={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function mo({pageUrl:t}){const s=y(p=>p.tier),a=Bt(s),n=ft(s,"autoExportAuditReports"),[r,o]=m.useState(null),[l,i]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await na();if(p||o(c),t){const u=await Tn(t);p||i(u)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?ho[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 Pt="igtRuns";async function xo(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 Xe(r,l.map(i=>({key:Je(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 Xe(r,l.map(i=>({key:Ye(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}}const go={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"}},fo={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"}},bo={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Fs(t,s){const a=await ue();if(!a)return;const n=s?go[t]:fo[t];try{await be(a,n)}catch{}}async function vo(){const s=(await chrome.storage.local.get(Pt))[Pt];return s&&typeof s=="object"?s:{}}async function Ms(t){await chrome.storage.local.set({[Pt]:t})}function yo(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 wo(){const t=y(c=>c.componentId),s=y(c=>c.results),[a,n]=m.useState({}),[r,o]=m.useState(null);if(m.useEffect(()=>{vo().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 b;const x={...a,[t]:{...l,[c]:{...l[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((b=l[c])==null?void 0:b.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(x),Ms(x),h.status==="pass"){const w=fe.find(E=>E.id===c),N=w==null?void 0:w.steps.find(E=>E.id===u);N!=null&&N.autoDismissActivity&&xo(N.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),Ms(h)}const p=fe.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(jo,{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."}),fe.map(c=>{const u=l[c.id],h=u?nn(u,c):null,x=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",b={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"}[x];return e.jsxs("button",{type:"button",onClick:()=>o(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${b}`,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}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="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:w=>{w.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function jo({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]=yo(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 Fs(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",bo[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Fs(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(st,{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(st,{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(st,{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(st,{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 No={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 st({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?No[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const lt="savedFlows";async function ko(){const t=await chrome.storage.local.get(lt);return Array.isArray(t[lt])?t[lt]:[]}async function Ps(t){await chrome.storage.local.set({[lt]:t})}function So(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,o]=m.useState(null);m.useEffect(()=>{ko().then(s)},[]);async function l(){const c=await ue();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 ue();if(c)try{const u=await Ee(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 x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},b=[x,...t];s(b),await Ps(b),o(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(u){o(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await ue();if(u){o(`Replaying "${c.name}"…`);try{const h=await Ee(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 Ps(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 Ao(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(Co).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||o}}function Co(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Io(){const t=y(i=>i.baselineList),s=y(i=>i.tier),a=ra[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,o]=m.useState(!1);if(m.useEffect(()=>{ht().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 ae({type:"BASELINE_DELETE",componentId:i}),await ht()}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=Ao(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(Te,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",i.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(Te,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(Te,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(Te,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(Te,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(Te,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(Te,{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 Eo={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 Te({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Eo[t]}`,children:a})}const ct="wcagcheckr";function te(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Qe(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 Ro(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function To(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 $o(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 Uo(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 Lo(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 (${te(t.receipt.tsaName)}) — anchored ${te(Qe(t.receipt.anchoredAt))}</td></tr>
18
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await ne({type:"BASELINE_DELETE",componentId:s});const G=a.flatMap(le=>le.violations),W=a.flatMap(le=>le.announcements??[]),K=a.flatMap(le=>le.focusEvents??[]),oe=await Z({type:"BASELINE_COMPARE",componentId:s,currentViolations:G,announcements:W,focusEvents:K});y.getState().setDelta(oe.delta);const ae=await Z({type:"BASELINE_LIST"});y.getState().setBaselineList(ae.items),ge.polite(`Baseline cleared for ${s}.`)}async function ie(A,G=!1){if(a.length===0)return;if(A==="ai-prompt"){const{copyAiFixerPrompt:Y}=await ke(async()=>{const{copyAiFixerPrompt:he}=await import("./copy-ai-fixer-prompt-NJgLyjks.js");return{copyAiFixerPrompt:he}},__vite__mapDeps([5,1,2]));await Y({results:a,componentId:s,delta:G?void 0:t,siteCrawlReport:o});return}let W;if((A==="defense-bundle"||A==="evidence-bundle"||A==="deposition-packet")&&s){const Y=await chrome.storage.local.get("igtRuns"),de=((Y==null?void 0:Y.igtRuns)??{})[s]??{};W=Object.values(de)}const ae=await Z({type:"EXPORT_REQUEST",format:A,results:a,delta:G?void 0:t??void 0,manualRuns:W,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:y.getState().lastAuditWallClockMs??void 0});if(A==="defense-bundle"||A==="evidence-bundle"||A==="deposition-packet"){const Y=ft(A,s);await ia()?et(ae.content,Y):j({open:!0,format:A,content:ae.content,filename:Y});return}if(A==="html-print"||A==="vpat"||A==="methodology-doc"||A==="conformance-crosswalk"||A==="executive-report"){$e(ae.content);return}const le=A==="json"?"application/json":A==="sarif"?"application/sarif+json":A==="ticket-bundle"?"text/markdown":"application/xml",pe=A==="junit"?"xml":A==="ticket-bundle"?"md":A,U=new Blob([ae.content],{type:le}),X=URL.createObjectURL(U),z=document.createElement("a");z.href=X,z.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${pe}`,z.click(),URL.revokeObjectURL(X)}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:R,disabled:!H,title:H?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"}),F&&e.jsx("button",{onClick:M,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:()=>w(!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 L(),"aria-pressed":S,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:S?"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:S?"Hide badges":"Show badges 🎯"}),S&&T&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[T.rendered," of ",T.requested," rendered",T.clustered>0?` · ${T.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void q(),"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(zi,{disabled:!$,onExport:ie,onAccessibilityStatement:()=>v(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!H&&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 A=At(t.new),G=At(t.persistent),W=At(t.fixed),K=[...A.review,...G.review];return e.jsxs(e.Fragment,{children:[e.jsx(We,{title:"New",violations:A.findings,count:A.findings.length,accent:"red",actions:[...l&&A.findings.length>0?[{label:"File GitHub issue",onClick:()=>Wi(l,s,A.findings)}]:[],...d&&A.findings.length>0?[{label:"File Jira issue",onClick:()=>Bi(d,s,A.findings)}]:[],...c&&A.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Hi(c,s,A.findings)}]:[],...h&&A.findings.length>0?[{label:"File GitLab issue",onClick:()=>Ki(h,s,A.findings)}]:[]]}),e.jsx(We,{title:"Persistent",violations:G.findings,count:G.findings.length,accent:"slate"}),e.jsx(We,{title:"Fixed",violations:W.findings,count:t.fixedCount,accent:"green"}),K.length>0&&e.jsx(We,{title:"Needs review (does not affect grade)",violations:K,count:K.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(We,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),f&&e.jsx(ja,{open:f.open,onClose:()=>j(null),format:f.format,content:f.content,filename:f.filename}),e.jsx(Na,{open:x,onClose:()=>v(!1),results:a}),b&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),I&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",I.chromeStorageKeysCleared," chrome.storage key",I.chromeStorageKeysCleared===1?"":"s"," + ",I.indexedDbsCleared.length," database",I.indexedDbsCleared.length===1?"":"s",".",I.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",I.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:I?e.jsx("button",{type:"button",onClick:()=>{w(!1),C(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>w(!1),disabled:N,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()=>{E(!0);try{const A=await Fi();C(A),await vt(),ge.polite("Audit data reset. Ready for a fresh scan.")}catch(A){C({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[A instanceof Error?A.message:String(A)]})}finally{E(!1)}},disabled:N,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:N?"Resetting…":"Reset everything"})]})})]})})]})}const Vi={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function At(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 We({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 ${Vi[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(Ze,{violation:d,alreadyAcknowledged:!0},p)):Ti(s).map(d=>e.jsx(Ri,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Wi(t,s,a){if(a.length===0)return;const{url:n}=Li(t,s,a);bt(n)}function Bi(t,s,a){if(a.length===0)return;const{url:n}=Ui(t,s,a);bt(n)}function Hi(t,s,a){if(a.length===0)return;const{url:n}=_i(t,s,a);bt(n)}function Ki(t,s,a){if(a.length===0)return;const{url:n}=Di(t,s,a);bt(n)}function zi({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,o]=m.useState(!1),[l,i]=m.useState(!1);function d(p){o(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>o(p=>!p),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 ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>o(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 w-[260px] max-w-[calc(100vw-1rem)] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:p=>i(p.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:()=>d("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ye,{onClick:()=>d("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ye,{onClick:()=>d("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:()=>d("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:()=>d("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ye,{onClick:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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,{onClick:()=>{o(!1),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}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const qi="2024-07-25",Qi="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.",Sa=[{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(Sa.flatMap(t=>t.wcag2Criteria));function Yi(t,s){return Sa.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 Ji={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Aa(){const t=y(c=>c.results),s=y(c=>c.acknowledgedKeys),a=y(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=Yi(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:qi}),"."," ",Qi]})]}),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:[Ji[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(Xi,{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 Xi({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"})}const Zi=[{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"}],eo={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 to(){const t=y(u=>u.results),s=y(u=>u.componentId),a=y(u=>u.findingsLens),n=y(u=>u.setFindingsLens),r=y(u=>u.setView),o=y(u=>u.status),[l,i]=m.useState({});m.useEffect(()=>{if(!s)return;let u=!1;return(async()=>{const h=await Ie(s),g=await Ue([s]);if(u)return;const b=new Set(g.map(N=>N.criterionId)),w={};for(const N of h){const E=b.has(N.criterionId)?"pass":N.verdict;N.criterionId==="2.4.3"?w.focusOrder=E:N.criterionId==="2.1.2"?w.keyboardTrap=E:N.criterionId==="2.4.7"?w.focusVisible=E:N.criterionId==="1.3.2"?w.readingOrder=E:N.criterionId==="1.4.11"&&(w.nonTextContrast=E)}i(w)})(),()=>{u=!0}},[s]);const d=es(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 b=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(b))}),()=>{u=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(Os,{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(Os,{setView:r}),e.jsx(ao,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:d}),e.jsx(so,{results:t}),e.jsx(no,{lens:a,setLens:n}),e.jsx(ro,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:d})]})}function Os({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 so({results:t}){const s=y(p=>p.crawlNavContext),a=y(p=>p.setCrawlNavContext),n=y(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 ao({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var b,w,N,E;const r=t.flatMap(I=>I.violations),o=y(I=>I.lastAuditWallClockMs),l=y(I=>I.acknowledgedKeys),i=y(I=>I.dismissedKeys),p=Ht({violations:r,auditRan:!0,manualRuns:a,workflows:fe,heuristicCounts:{tabOrder:((w=(b=t[0])==null?void 0:b.tabOrderIssues)==null?void 0:w.length)??0,readingOrder:((E=(N=t[0])==null?void 0:N.readingOrderIssues)==null?void 0:E.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(I=>({ruleId:I.ruleId,impact:"serious",selector:I.selector}))}).overallLetter,c=ga(r,n,l,i),u=jr(r,n,l,i),h=t.length,g=o??t.reduce((I,C)=>I+C.durationMs,0);return e.jsx("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 ${eo[p]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:p})}),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 · 9 verification areas"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`}),c>0&&u.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",u.length," WCAG criterion",u.length===1?"":"a"," (",u.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[h," state",h===1?"":"s"," tested · ",(g/1e3).toFixed(1),"s"]})]})]})})}function no({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:Zi.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 ro({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(io,{componentId:a,results:s}),e.jsx(uo,{componentId:a}),e.jsx(Rr,{violations:s.flatMap(i=>i.violations),componentId:a,hideOverallHeader:!0}),e.jsx(go,{pageUrl:((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(po,{})]}):t==="per-area"?e.jsx(mi,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(mo,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(wa,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(ka,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Aa,{})}):null}const xt={critical:0,serious:1,moderate:2,minor:3};function Mt(t){return`${Le(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function io({componentId:t,results:s}){var b,w;const a=y(N=>N.setFindingsLens),[n,r]=m.useState({}),[o,l]=m.useState({}),[i,d]=m.useState(0);m.useEffect(()=>{let N=!1;return(async()=>{if(!t){r({}),l({});return}const E=await Ie(t);if(N)return;const I={};for(const j of E)I[j.criterionId]=j;r(I);const C=await Ue([t]);if(N)return;const f={};for(const j of C)f[`${j.criterionId}::${j.pageUrl}`]=j;l(f)})(),()=>{N=!0}},[t,i]);const p=((b=s[0])==null?void 0:b.pageUrl)??((w=s[0])==null?void 0:w.scope)??"",c=it.map(N=>({crit:N,record:n[N.id]??null})).filter(({record:N})=>N&&(N.verdict==="fail"||N.verdict==="uncertain")).filter(({crit:N})=>!o[`${N.id}::${p}`]),u=new Set,h=[];for(const N of s)for(const E of N.violations){if(E.needsReview)continue;const I=Le(E.ruleId,E.target.selector);u.has(I)||(u.add(I),h.push(E))}h.sort((N,E)=>(xt[N.impact]??99)-(xt[E.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:N,record:E})=>e.jsx(oo,{componentId:t??"",pageUrl:p,criterionId:N.id,label:N.label,blurb:N.blurb,record:E,onChanged:()=>d(I=>I+1)},`wt::${N.id}`)),h.map(N=>e.jsx(lo,{violation:N,onOpen:()=>a("violations")},`axe::${Mt(N)}`))]})]})}function oo({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,b]=m.useState(null),[w,N]=m.useState(!1),[E,I]=m.useState(!1),C=o.verdict,f=C==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function j(){h(!0),b(null);try{if(!p.trim()){b("Note is required — explain how you manually verified this."),h(!1);return}await zt({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:C}),l()}catch(v){b(v instanceof Error?v.message:String(v))}finally{h(!1)}}async function x(){var v;I(!0),b(null);try{const k=(v=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:v.id;if(!k){b("No active tab — open the audited page first."),I(!1);return}const V=await ne({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:k,componentId:t,pageUrl:s});V.ok||b(V.error??"Re-run failed."),l()}catch(S){b(S instanceof Error?S.message:String(S))}finally{I(!1)}}return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${f}`,children:C}),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:C==="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:()=>N(v=>!v),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:w?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void x(),disabled:E,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",title:"Re-run AI walkthrough after fixing the page (will switch to the active tab)",children:E?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{d(v=>!v),b(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",children:"Mark verified manually"})]}),w&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2 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:v=>c(v.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 j(),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(""),b(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 lo({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 it=[{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)."}],co={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function uo({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([Ie(t),Ue([t])]);if(u)return;const b={};for(const N of h)b[N.criterionId]=N;a(b);const w={};for(const N of g)w[N.criterionId]=N;r(w)})(),()=>{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 ${it.length} criteria pending human verification`:`${l}/${it.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:it.map(u=>{const h=s[u.id],g=n[u.id],b=h==null?void 0:h.verdict,w=g?"pass":b,N=h?_t(h.reasoning):!1,E=h?ta(h.reasoning):!1,I=h?Dt(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":w?co[w]:"bg-slate-200 text-slate-500"}`,title:g?`Human verified at ${new Date(g.acknowledgedAt).toLocaleString()} — note: "${g.note}". (AI verdict was: ${b})`:w?`AI verdict: ${w}${I?` (cascade ${I})`:""}`:"AI did not produce a verdict on this criterion",children:g?"✓ verified":w||"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,E&&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}),N&&!E&&!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: ",b,"."]})]})]})]},u.id)})})]})}function po(){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(Re,{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(Re,{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(Re,{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(Re,{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(Re,{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(Re,{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(Re,{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 Re({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 ho({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 Ue([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(ts,{componentId:t??"",pageUrl:i.pageUrl,criterionId:i.criterionId,record:i,onChanged:()=>r(d=>d+1),ack:o[i.criterionId]??null})},i.criterionId))]})}function mo({results:t}){const s=y(i=>i.dismissedKeys),a=y(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=Mt(d);n.has(p)||(n.add(p),r.push(d))}r.sort((i,d)=>{const p=xt[i.impact]??99,c=xt[d.impact]??99;return p-c});const[o,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let i=!1;return Ie(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(ho,{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(Ze,{violation:i},Mt(i)))]})}const xo={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function go({pageUrl:t}){const s=y(p=>p.tier),a=Bt(s),n=gt(s,"autoExportAuditReports"),[r,o]=m.useState(null),[l,i]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await na();if(p||o(c),t){const u=await $n(t);p||i(u)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?xo[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 Pt="igtRuns";async function fo(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 Xe(r,l.map(i=>({key:Je(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 Xe(r,l.map(i=>({key:Ye(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}}const bo={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"}},vo={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"}},yo={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Fs(t,s){const a=await ue();if(!a)return;const n=s?bo[t]:vo[t];try{await be(a,n)}catch{}}async function wo(){const s=(await chrome.storage.local.get(Pt))[Pt];return s&&typeof s=="object"?s:{}}async function Ms(t){await chrome.storage.local.set({[Pt]:t})}function jo(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 No(){const t=y(c=>c.componentId),s=y(c=>c.results),[a,n]=m.useState({}),[r,o]=m.useState(null);if(m.useEffect(()=>{wo().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 b;const g={...a,[t]:{...l,[c]:{...l[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((b=l[c])==null?void 0:b.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(g),Ms(g),h.status==="pass"){const w=fe.find(E=>E.id===c),N=w==null?void 0:w.steps.find(E=>E.id===u);N!=null&&N.autoDismissActivity&&fo(N.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),Ms(h)}const p=fe.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(ko,{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."}),fe.map(c=>{const u=l[c.id],h=u?rn(u,c):null,g=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",b={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 ${b}`,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:w=>{w.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function ko({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]=jo(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 Fs(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",yo[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Fs(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(tt,{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(tt,{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(tt,{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(tt,{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 So={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 tt({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?So[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const ot="savedFlows";async function Ao(){const t=await chrome.storage.local.get(ot);return Array.isArray(t[ot])?t[ot]:[]}async function Ps(t){await chrome.storage.local.set({[ot]:t})}function Co(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,o]=m.useState(null);m.useEffect(()=>{Ao().then(s)},[]);async function l(){const c=await ue();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 ue();if(c)try{const u=await Ee(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()},b=[g,...t];s(b),await Ps(b),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 ue();if(u){o(`Replaying "${c.name}"…`);try{const h=await Ee(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 Ps(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 Io(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(Eo).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||o}}function Eo(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Ro(){const t=y(i=>i.baselineList),s=y(i=>i.tier),a=ra[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,o]=m.useState(!1);if(m.useEffect(()=>{pt().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 ne({type:"BASELINE_DELETE",componentId:i}),await pt()}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=Io(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(Te,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",i.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(Te,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(Te,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(Te,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(Te,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(Te,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(Te,{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 To={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 Te({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${To[t]}`,children:a})}const lt="wcagcheckr";function te(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Qe(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 $o(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Lo(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 Uo(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 _o(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 Do(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 (${te(t.receipt.tsaName)}) — anchored ${te(Qe(t.receipt.anchoredAt))}</td></tr>
19
19
  <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${te(t.receipt.serverKeyFingerprint)}</code></td></tr>
20
- ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${te(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${te(ct)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
20
+ ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${te(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${te(lt)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
21
21
  <article class="entry">
22
22
  <header class="entry-header">
23
- <span class="grade-badge ${Uo(t.grade)}">${te(t.grade)}</span>
23
+ <span class="grade-badge ${_o(t.grade)}">${te(t.grade)}</span>
24
24
  <div class="entry-headline">
25
25
  <div class="entry-time">${te(Qe(t.capturedAt))}</div>
26
26
  <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
@@ -34,15 +34,15 @@ Future audits will treat every detected violation as new (no delta filtering). T
34
34
  <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
35
35
  ${n}
36
36
  </table>
37
- </article>`}function _o(t){return`
37
+ </article>`}function Oo(t){return`
38
38
  <section class="component-section">
39
39
  <h2>
40
40
  <span class="component-id">${te(t.componentId)}</span>
41
41
  <span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
42
42
  </h2>
43
43
  <p class="component-url"><strong>Page audited:</strong> <code>${te(t.pageUrl)}</code></p>
44
- ${t.entries.map(Lo).join("")}
45
- </section>`}function Aa(t){const{entries:s,extensionVersion:a}=t,n=$o(s),r=To(s),o=(t.axeVersions??Ro(s)).join(", "),l=s.length,i=s.filter(c=>c.receipt).length,d=l-i,p=Qe(new Date().toISOString());return`<!doctype html>
44
+ ${t.entries.map(Do).join("")}
45
+ </section>`}function Ca(t){const{entries:s,extensionVersion:a}=t,n=Uo(s),r=Lo(s),o=(t.axeVersions??$o(s)).join(", "),l=s.length,i=s.filter(c=>c.receipt).length,d=l-i,p=Qe(new Date().toISOString());return`<!doctype html>
46
46
  <html lang="en">
47
47
  <head>
48
48
  <meta charset="utf-8" />
@@ -197,7 +197,7 @@ Future audits will treat every detected violation as new (no delta filtering). T
197
197
 
198
198
  <aside class="attestation">
199
199
  <h3>Attestation</h3>
200
- <p>The audit records summarized below were captured by the <strong>${te(ct)}</strong> Chrome extension, version <strong>${te(a)}</strong>, running <strong>axe-core</strong> ${o?`version(s) ${te(o)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
200
+ <p>The audit records summarized below were captured by the <strong>${te(lt)}</strong> Chrome extension, version <strong>${te(a)}</strong>, running <strong>axe-core</strong> ${o?`version(s) ${te(o)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
201
201
  <p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
202
202
  <p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
203
203
  </aside>
@@ -208,10 +208,10 @@ Future audits will treat every detected violation as new (no delta filtering). T
208
208
  <tr><th>Local-only audits</th><td>${d}</td></tr>
209
209
  <tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
210
210
  <tr><th>axe-core version(s) observed</th><td>${te(o||"n/a")}</td></tr>
211
- <tr><th>Tool</th><td>${te(ct)} ${te(a)}</td></tr>
211
+ <tr><th>Tool</th><td>${te(lt)} ${te(a)}</td></tr>
212
212
  </table>
213
213
 
214
- ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(_o).join("")}
214
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Oo).join("")}
215
215
 
216
216
  <section class="methodology">
217
217
  <h2>Methodology</h2>
@@ -235,17 +235,17 @@ Future audits will treat every detected violation as new (no delta filtering). T
235
235
  </section>
236
236
 
237
237
  <footer>
238
- <span>Generated ${te(p)} by ${te(ct)} ${te(a)}</span>
238
+ <span>Generated ${te(p)} by ${te(lt)} ${te(a)}</span>
239
239
  <span>${l} audit${l===1?"":"s"} · ${i} anchored · ${n.length} component${n.length===1?"":"s"}</span>
240
240
  </footer>
241
241
  </body>
242
- </html>`}async function ss(t){const s=Aa(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}const Do=Object.freeze(Object.defineProperty({__proto__:null,buildPreLitigationReportHtml:Aa,openPreLitigationReport:ss},Symbol.toStringTag,{value:"Module"})),Oo={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},Fo={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Mo={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function Ca({onBack:t}){const s=y(f=>f.siteCrawlStatus),a=y(f=>f.siteCrawlProgress),n=y(f=>f.siteCrawlReport),r=y(f=>f.siteCrawlError),[o,l]=m.useState("");m.useEffect(()=>{n!=null&&n.startUrl&&o===""&&l(n.startUrl)},[n==null?void 0:n.startUrl]);const[i,d]=m.useState(25),[p,c]=m.useState(Oe),[u,h]=m.useState(Oe[0].id);m.useEffect(()=>{Promise.all([ae({type:"SETTINGS_GET",key:"matrixPresets"}),ae({type:"SETTINGS_GET",key:"activePresetId"})]).then(([f,j])=>{const g=Array.isArray(f.data)?f.data:null;c(g&&g.length>0?g:Oe),typeof j.data=="string"&&h(j.data)})},[]);function x(f){const j=p.find(g=>g.id===f);j&&(h(f),ae({type:"SETTINGS_SET",key:"activePresetId",value:f}),ae({type:"SETTINGS_SET",key:"stateMatrix",value:j.matrix}))}const[b,w]=m.useState(""),[N,E]=m.useState("");o===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(f=>{var g;const j=(g=f[0])==null?void 0:g.url;j&&/^https?:\/\//.test(j)&&o===""&&l(j)});function I(f=!1){if(!o||i>=5&&!window.confirm(f?`Verify-fixes mode: ${i} crawled pages, but walkthroughs that already passed or were human-acked will be skipped. Estimated wall-clock: ~${Math.ceil(i*2.5)} minutes (vs. ${i*5} for a full re-crawl). Proceed?`:`Each of the ${i} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${i*5} minutes. Proceed?`))return;y.getState().setSiteCrawlStatus("running"),y.getState().setSiteCrawlReport(null),y.getState().setSiteCrawlError(null);const j=b.trim(),g=N.trim();for(const[v,S]of[["Include",j],["Exclude",g]])if(S)try{new RegExp(S)}catch(k){window.alert(`${v} regex is invalid:
242
+ </html>`}async function ss(t){const s=Ca(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}const Fo=Object.freeze(Object.defineProperty({__proto__:null,buildPreLitigationReportHtml:Ca,openPreLitigationReport:ss},Symbol.toStringTag,{value:"Module"})),Mo={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},Po={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Go={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function Ia({onBack:t}){const s=y(f=>f.siteCrawlStatus),a=y(f=>f.siteCrawlProgress),n=y(f=>f.siteCrawlReport),r=y(f=>f.siteCrawlError),[o,l]=m.useState("");m.useEffect(()=>{n!=null&&n.startUrl&&o===""&&l(n.startUrl)},[n==null?void 0:n.startUrl]);const[i,d]=m.useState(25),[p,c]=m.useState(Oe),[u,h]=m.useState(Oe[0].id);m.useEffect(()=>{Promise.all([ne({type:"SETTINGS_GET",key:"matrixPresets"}),ne({type:"SETTINGS_GET",key:"activePresetId"})]).then(([f,j])=>{const x=Array.isArray(f.data)?f.data:null;c(x&&x.length>0?x:Oe),typeof j.data=="string"&&h(j.data)})},[]);function g(f){const j=p.find(x=>x.id===f);j&&(h(f),ne({type:"SETTINGS_SET",key:"activePresetId",value:f}),ne({type:"SETTINGS_SET",key:"stateMatrix",value:j.matrix}))}const[b,w]=m.useState(""),[N,E]=m.useState("");o===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(f=>{var x;const j=(x=f[0])==null?void 0:x.url;j&&/^https?:\/\//.test(j)&&o===""&&l(j)});function I(f=!1){if(!o||i>=5&&!window.confirm(f?`Verify-fixes mode: ${i} crawled pages, but walkthroughs that already passed or were human-acked will be skipped. Estimated wall-clock: ~${Math.ceil(i*2.5)} minutes (vs. ${i*5} for a full re-crawl). Proceed?`:`Each of the ${i} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${i*5} minutes. Proceed?`))return;y.getState().setSiteCrawlStatus("running"),y.getState().setSiteCrawlReport(null),y.getState().setSiteCrawlError(null);const j=b.trim(),x=N.trim();for(const[v,S]of[["Include",j],["Exclude",x]])if(S)try{new RegExp(S)}catch(k){window.alert(`${v} regex is invalid:
243
243
 
244
244
  ${k instanceof Error?k.message:String(k)}
245
245
 
246
- Fix or clear the field and try again.`),y.getState().setSiteCrawlStatus("idle");return}Ne({type:"START_SITE_CRAWL",startUrl:o,maxPages:i,...j?{includeRegex:j}:{},...g?{excludeRegex:g}:{},...f?{verifyFixesOnly:!0}:{}})}function C(){ae({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),e.jsxs("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Heads-up if you're logged in."})," ","The crawler follows whatever links appear in the rendered page — so if you're authenticated to the target site, it will walk into the authenticated nav (admin pages, dashboards, account pages) and try to audit them. Some of those may 404 or behave unexpectedly without specific context. For a clean public-site crawl, log out first or run from an incognito window."]}),s!=="running"&&e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2.5 py-2 space-y-1.5",children:[e.jsx("label",{htmlFor:"crawl-preset",className:"block text-[11px] font-semibold text-slate-700",children:"Audit depth (state-matrix preset)"}),e.jsx("select",{id:"crawl-preset",value:u,onChange:f=>x(f.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5",title:"Each crawled page runs this preset's state matrix. Full = pseudo-states × themes × directions × breakpoints (slowest, most thorough). Quick = single state (fastest). Set this once and every page in the crawl uses it.",children:p.map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug",children:["Each crawled page runs the same single-page audit pipeline you see on the Dashboard. This selector overrides the persisted preset for BOTH surfaces. AI walkthroughs + disabled-rules list are still in ",e.jsx("strong",{children:"Settings → AI"})," and ",e.jsx("strong",{children:"Settings → State Matrix"}),"."]})]}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:o,onChange:f=>l(f.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:i,onChange:f=>d(Math.min(200,Math.max(1,parseInt(f.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your configured single-page pipeline — see Settings → State Matrix for what that means."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-include",className:"block text-[11px] text-slate-500 mb-1",children:"Include only URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-include",type:"text",value:b,onChange:f=>w(f.target.value),placeholder:"^https://example\\.com/products/",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["When set, only URLs matching this regex get crawled. Useful for scoping a crawl to one section, e.g. ",e.jsx("code",{children:"/blog/"}),"."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-exclude",className:"block text-[11px] text-slate-500 mb-1",children:"Exclude URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-exclude",type:"text",value:N,onChange:f=>E(f.target.value),placeholder:"/admin|/dashboard|/account|/login",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"URLs matching this regex are skipped. Helpful when logged in to the target site — keep the crawl on the public surface."})]}),e.jsx("button",{type:"button",onClick:()=>I(!1),disabled:!o,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"}),(()=>{const f=n&&n.startUrl===o,j=!o||!f;return e.jsxs("button",{type:"button",onClick:()=>I(!0),disabled:j,className:"w-full text-sm px-4 py-2.5 border border-emerald-400 text-emerald-700 bg-white rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed font-medium",title:o?f?"Re-crawl after fixes/acks. Walkthroughs that previously passed or were human-acked are skipped per page — saves AI calls + wall-clock without changing axe coverage.":"Run a full crawl on this URL first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.":"Enter a start URL first.",children:["Verify fixes only (skip passed walkthroughs)",!f&&o&&e.jsx("span",{className:"block text-[10px] text-emerald-600 font-normal mt-0.5",children:"Run a full crawl first to enable this."})]})})()]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:C,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Po,{report:n}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function Po({report:t}){function s(){ke(async()=>{const{renderSiteReportHtml:g}=await import("./site-report-renderer-DA-9wVvE.js");return{renderSiteReportHtml:g}},__vite__mapDeps([6,0,1,2,3,4])).then(({renderSiteReportHtml:g})=>{const v=g(t);$e(v)})}const[a,n]=m.useState(!1),[r,o]=m.useState({state:"idle"});async function l(){if(window.confirm(`Save the current crawl as the site baseline?
246
+ Fix or clear the field and try again.`),y.getState().setSiteCrawlStatus("idle");return}Ne({type:"START_SITE_CRAWL",startUrl:o,maxPages:i,...j?{includeRegex:j}:{},...x?{excludeRegex:x}:{},...f?{verifyFixesOnly:!0}:{}})}function C(){ne({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),e.jsxs("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Heads-up if you're logged in."})," ","The crawler follows whatever links appear in the rendered page — so if you're authenticated to the target site, it will walk into the authenticated nav (admin pages, dashboards, account pages) and try to audit them. Some of those may 404 or behave unexpectedly without specific context. For a clean public-site crawl, log out first or run from an incognito window."]}),s!=="running"&&e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2.5 py-2 space-y-1.5",children:[e.jsx("label",{htmlFor:"crawl-preset",className:"block text-[11px] font-semibold text-slate-700",children:"Audit depth (state-matrix preset)"}),e.jsx("select",{id:"crawl-preset",value:u,onChange:f=>g(f.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5",title:"Each crawled page runs this preset's state matrix. Full = pseudo-states × themes × directions × breakpoints (slowest, most thorough). Quick = single state (fastest). Set this once and every page in the crawl uses it.",children:p.map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug",children:["Each crawled page runs the same single-page audit pipeline you see on the Dashboard. This selector overrides the persisted preset for BOTH surfaces. AI walkthroughs + disabled-rules list are still in ",e.jsx("strong",{children:"Settings → AI"})," and ",e.jsx("strong",{children:"Settings → State Matrix"}),"."]})]}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:o,onChange:f=>l(f.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:i,onChange:f=>d(Math.min(200,Math.max(1,parseInt(f.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your configured single-page pipeline — see Settings → State Matrix for what that means."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-include",className:"block text-[11px] text-slate-500 mb-1",children:"Include only URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-include",type:"text",value:b,onChange:f=>w(f.target.value),placeholder:"^https://example\\.com/products/",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["When set, only URLs matching this regex get crawled. Useful for scoping a crawl to one section, e.g. ",e.jsx("code",{children:"/blog/"}),"."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-exclude",className:"block text-[11px] text-slate-500 mb-1",children:"Exclude URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-exclude",type:"text",value:N,onChange:f=>E(f.target.value),placeholder:"/admin|/dashboard|/account|/login",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"URLs matching this regex are skipped. Helpful when logged in to the target site — keep the crawl on the public surface."})]}),e.jsx("button",{type:"button",onClick:()=>I(!1),disabled:!o,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"}),(()=>{const f=n&&n.startUrl===o,j=!o||!f;return e.jsxs("button",{type:"button",onClick:()=>I(!0),disabled:j,className:"w-full text-sm px-4 py-2.5 border border-emerald-400 text-emerald-700 bg-white rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed font-medium",title:o?f?"Re-crawl after fixes/acks. Walkthroughs that previously passed or were human-acked are skipped per page — saves AI calls + wall-clock without changing axe coverage.":"Run a full crawl on this URL first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.":"Enter a start URL first.",children:["Verify fixes only (skip passed walkthroughs)",!f&&o&&e.jsx("span",{className:"block text-[10px] text-emerald-600 font-normal mt-0.5",children:"Run a full crawl first to enable this."})]})})()]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:C,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Vo,{report:n}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function Vo({report:t}){function s(){ke(async()=>{const{renderSiteReportHtml:x}=await import("./site-report-renderer-DA-9wVvE.js");return{renderSiteReportHtml:x}},__vite__mapDeps([6,0,1,2,3,4])).then(({renderSiteReportHtml:x})=>{const v=x(t);$e(v)})}const[a,n]=m.useState(!1),[r,o]=m.useState({state:"idle"});async function l(){if(window.confirm(`Save the current crawl as the site baseline?
247
247
 
248
- Each of the ${t.pagesAudited} crawled page${t.pagesAudited===1?"":"s"} will be saved as its own baseline. Future audits + re-crawls will show delta against these snapshots. Any existing baselines for these same components will be overwritten.`)){o({state:"running",current:0,total:t.pagesAudited});try{const S=(await Z({type:"SETTINGS_GET",key:"stateMatrix"})).data??qt,k=await dt();if(!k||k.length===0){o({state:"error",message:"No per-URL results found in storage. Re-run the crawl."});return}let T=0,V=0;for(let P=0;P<k.length;P++){const B=k[P];if(o({state:"running",current:P,total:k.length}),B.error||B.results.length===0||!B.componentId){V++;continue}try{const U=B.results.flatMap(F=>F.violations),q=B.results.flatMap(F=>F.announcements??[]),$=B.results.flatMap(F=>F.focusEvents??[]),_=B.results[0];await ae({type:"BASELINE_SET",componentId:B.componentId,violations:U,announcements:q,focusEvents:$,snapshotMeta:{url:B.url,axeVersion:_.axeVersion,matrixConfig:S,capturedAt:new Date().toISOString()}}),T++}catch(U){console.warn("[site-crawl-panel] BASELINE_SET failed for",B.url,U),V++}}try{const P=await Z({type:"BASELINE_LIST"});y.getState().setBaselineList(P.items)}catch{}o({state:"done",saved:T,failed:V})}catch(v){o({state:"error",message:v instanceof Error?v.message:String(v)})}}}const[i,d]=m.useState(null),[p,c]=m.useState(null),[u,h]=m.useState(!1),[x,b]=m.useState(!1);async function w(){c(null);try{const g=await dt();if(!g||g.length===0){c("No per-URL results found. Re-run the crawl.");return}if(!g.some(S=>{var k;return(((k=S.results)==null?void 0:k.length)??0)>0})){c("Crawled pages have no audit results to use.");return}h(!0)}catch(g){c(g instanceof Error?g.message:String(g))}}const[N,E]=m.useState({state:"idle"});async function I(){var V,P,B;const{createZip:g}=await ke(async()=>{const{createZip:U}=await import("./zip-encoder-CtULHXx_.js");return{createZip:U}},[]),{renderSiteReportHtml:v}=await ke(async()=>{const{renderSiteReportHtml:U}=await import("./site-report-renderer-DA-9wVvE.js");return{renderSiteReportHtml:U}},__vite__mapDeps([6,0,1,2,3,4])),S=[{format:"defense-bundle",filename:"defense-bundle.html"},{format:"deposition-packet",filename:"deposition-packet.html"},{format:"evidence-bundle",filename:"evidence-bundle.html"},{format:"vpat",filename:"vpat.html"},{format:"conformance-crosswalk",filename:"conformance-crosswalk.html"},{format:"methodology-doc",filename:"methodology-doc.html"},{format:"executive-report",filename:"executive-report.html"}],k=[],T=[];E({state:"running",current:"site-report.html",doneCount:0,totalCount:S.length+3});try{try{const M=v(t);T.push({name:"site-report.html",content:M})}catch{k.push("site-report.html")}E(M=>M.state==="running"?{...M,current:"ai-fix-prompt.md",doneCount:M.doneCount+1}:M);try{const M=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]});M!=null&&M.content&&M.content.length>50?T.push({name:"ai-fix-prompt.md",content:M.content}):k.push("ai-fix-prompt.md")}catch{k.push("ai-fix-prompt.md")}for(const{format:M,filename:ie}of S){E(A=>A.state==="running"?{...A,current:ie,doneCount:A.doneCount+1}:A);try{const A=await Z({type:"EXPORT_REQUEST",format:M,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});A!=null&&A.content&&A.content.length>50?T.push({name:ie,content:A.content}):k.push(ie)}catch(A){console.warn(`[bulk-export] ${M} failed`,A),k.push(ie)}}E(M=>M.state==="running"?{...M,current:"pre-litigation-report.html",doneCount:M.doneCount+1}:M);try{const M=await ut();if(M.length>0){const ie=typeof chrome<"u"&&((B=(P=(V=chrome.runtime)==null?void 0:V.getManifest)==null?void 0:P.call(V))==null?void 0:B.version)||"1.0.0",{buildPreLitigationReportHtml:A}=await ke(async()=>{const{buildPreLitigationReportHtml:W}=await Promise.resolve().then(()=>Do);return{buildPreLitigationReportHtml:W}},void 0),G=A({entries:M,extensionVersion:ie});T.push({name:"pre-litigation-report.html",content:G})}else k.push("pre-litigation-report.html (no forensic entries yet)")}catch{k.push("pre-litigation-report.html")}const U=`wcagcheckr — Site-wide compliance bundle
248
+ Each of the ${t.pagesAudited} crawled page${t.pagesAudited===1?"":"s"} will be saved as its own baseline. Future audits + re-crawls will show delta against these snapshots. Any existing baselines for these same components will be overwritten.`)){o({state:"running",current:0,total:t.pagesAudited});try{const S=(await Z({type:"SETTINGS_GET",key:"stateMatrix"})).data??qt,k=await ct();if(!k||k.length===0){o({state:"error",message:"No per-URL results found in storage. Re-run the crawl."});return}let T=0,V=0;for(let P=0;P<k.length;P++){const B=k[P];if(o({state:"running",current:P,total:k.length}),B.error||B.results.length===0||!B.componentId){V++;continue}try{const L=B.results.flatMap(F=>F.violations),q=B.results.flatMap(F=>F.announcements??[]),$=B.results.flatMap(F=>F.focusEvents??[]),_=B.results[0];await ne({type:"BASELINE_SET",componentId:B.componentId,violations:L,announcements:q,focusEvents:$,snapshotMeta:{url:B.url,axeVersion:_.axeVersion,matrixConfig:S,capturedAt:new Date().toISOString()}}),T++}catch(L){console.warn("[site-crawl-panel] BASELINE_SET failed for",B.url,L),V++}}try{const P=await Z({type:"BASELINE_LIST"});y.getState().setBaselineList(P.items)}catch{}o({state:"done",saved:T,failed:V})}catch(v){o({state:"error",message:v instanceof Error?v.message:String(v)})}}}const[i,d]=m.useState(null),[p,c]=m.useState(null),[u,h]=m.useState(!1),[g,b]=m.useState(!1);async function w(){c(null);try{const x=await ct();if(!x||x.length===0){c("No per-URL results found. Re-run the crawl.");return}if(!x.some(S=>{var k;return(((k=S.results)==null?void 0:k.length)??0)>0})){c("Crawled pages have no audit results to use.");return}h(!0)}catch(x){c(x instanceof Error?x.message:String(x))}}const[N,E]=m.useState({state:"idle"});async function I(){var V,P,B;const{createZip:x}=await ke(async()=>{const{createZip:L}=await import("./zip-encoder-CtULHXx_.js");return{createZip:L}},[]),{renderSiteReportHtml:v}=await ke(async()=>{const{renderSiteReportHtml:L}=await import("./site-report-renderer-DA-9wVvE.js");return{renderSiteReportHtml:L}},__vite__mapDeps([6,0,1,2,3,4])),S=[{format:"defense-bundle",filename:"defense-bundle.html"},{format:"deposition-packet",filename:"deposition-packet.html"},{format:"evidence-bundle",filename:"evidence-bundle.html"},{format:"vpat",filename:"vpat.html"},{format:"conformance-crosswalk",filename:"conformance-crosswalk.html"},{format:"methodology-doc",filename:"methodology-doc.html"},{format:"executive-report",filename:"executive-report.html"}],k=[],T=[];E({state:"running",current:"site-report.html",doneCount:0,totalCount:S.length+3});try{try{const M=v(t);T.push({name:"site-report.html",content:M})}catch{k.push("site-report.html")}E(M=>M.state==="running"?{...M,current:"ai-fix-prompt.md",doneCount:M.doneCount+1}:M);try{const M=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]});M!=null&&M.content&&M.content.length>50?T.push({name:"ai-fix-prompt.md",content:M.content}):k.push("ai-fix-prompt.md")}catch{k.push("ai-fix-prompt.md")}for(const{format:M,filename:ie}of S){E(A=>A.state==="running"?{...A,current:ie,doneCount:A.doneCount+1}:A);try{const A=await Z({type:"EXPORT_REQUEST",format:M,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});A!=null&&A.content&&A.content.length>50?T.push({name:ie,content:A.content}):k.push(ie)}catch(A){console.warn(`[bulk-export] ${M} failed`,A),k.push(ie)}}E(M=>M.state==="running"?{...M,current:"pre-litigation-report.html",doneCount:M.doneCount+1}:M);try{const M=await dt();if(M.length>0){const ie=typeof chrome<"u"&&((B=(P=(V=chrome.runtime)==null?void 0:V.getManifest)==null?void 0:P.call(V))==null?void 0:B.version)||"1.0.0",{buildPreLitigationReportHtml:A}=await ke(async()=>{const{buildPreLitigationReportHtml:W}=await Promise.resolve().then(()=>Fo);return{buildPreLitigationReportHtml:W}},void 0),G=A({entries:M,extensionVersion:ie});T.push({name:"pre-litigation-report.html",content:G})}else k.push("pre-litigation-report.html (no forensic entries yet)")}catch{k.push("pre-litigation-report.html")}const L=`wcagcheckr — Site-wide compliance bundle
249
249
  ========================================
250
250
 
251
251
  Generated: ${new Date().toISOString()}
@@ -265,12 +265,12 @@ Contents:
265
265
  `:"")+`Each HTML report opens directly in a browser. Use
266
266
  Ctrl+P → Save as PDF in the report you want sealed for legal
267
267
  or compliance submission.
268
- `;if(T.unshift({name:"README.txt",content:U}),T.length===0){E({state:"error",message:"No reports could be generated. Re-run the crawl and try again."});return}const q=g(T),$=new Date().toISOString().slice(0,10),_=t.startUrl.replace(/^https?:\/\//,"").replace(/[^a-z0-9]/gi,"-").replace(/-+/g,"-").slice(0,32).toLowerCase()||"crawl",F=`wcagcheckr-site-bundle-${$}-${_}.zip`,H=URL.createObjectURL(q),R=document.createElement("a");R.href=H,R.download=F,document.body.appendChild(R),R.click(),document.body.removeChild(R),setTimeout(()=>URL.revokeObjectURL(H),3e4),E({state:"done",included:T.length,skipped:k})}catch(U){E({state:"error",message:U instanceof Error?U.message:String(U)})}}async function C(){var g,v,S;b(!0),c(null);try{const k=await ut();if(k.length===0){c("No forensic-log entries yet. Generate a defense bundle or deposition packet first — those create the anchored entries the pre-litigation report documents.");return}const T=typeof chrome<"u"&&((S=(v=(g=chrome.runtime)==null?void 0:g.getManifest)==null?void 0:v.call(g))==null?void 0:S.version)||"1.0.0";await ss({entries:k,extensionVersion:T})}catch(k){c(k instanceof Error?k.message:String(k))}finally{b(!1)}}async function f(g,v){d(g),c(null);try{const S=`site:${t.startUrl}`,k=await Z({type:"EXPORT_REQUEST",format:g,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});if(!(k!=null&&k.content)||k.content.length<50){c(`Generation returned empty content for ${g}.`);return}if(v==="download"){const T=bt(g,S);et(k.content,T)}else $e(k.content)}catch(S){c(S instanceof Error?S.message:String(S))}finally{d(null)}}async function j(){n(!0);try{const g=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),v=(g==null?void 0:g.content)??"";if(!v){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(v)}catch{}$e(v,"text/markdown;charset=utf-8")}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Oo[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Fo[t.siteRisk]}`,children:rn[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited",(()=>{const g=t.totalUniqueViolations,v=t.totalWalkthroughFindings,S=t.totalNeedsReview,k=g+v,T=[];return g>0&&T.push(`${g} axe`),v>0&&T.push(`${v} AI walkthrough`),e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:k})," total finding",k===1?"":"s",T.length>0&&e.jsxs(e.Fragment,{children:[" (",T.join(" + "),")"]}),S>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:S})," need",S===1?"s":""," review"]})]})})(),t.walkthroughAcknowledgements.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{className:"text-emerald-700",children:t.walkthroughAcknowledgements.length})," human-verified"]}),t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 font-medium",children:"📊 Open full site report (standalone HTML)"}),e.jsx("button",{type:"button",onClick:j,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:r.state==="running",className:"w-full text-sm px-4 py-2.5 border border-emerald-500 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 font-medium",title:"Save each crawled page's current state as its baseline. Future audits + re-crawls show delta against this snapshot.",children:r.state==="running"?`Saving baselines… ${r.current+1}/${r.total}`:"📌 Set this crawl as the site baseline"}),r.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Saved ",r.saved," baseline",r.saved===1?"":"s",r.failed>0&&` · ${r.failed} failed (re-crawl those pages and retry)`]}),r.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",r.message]}),e.jsxs("div",{className:"border border-slate-200 rounded-lg p-3 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-700",children:"Site-wide compliance documents"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Generate the same legal / compliance / industry docs you can produce from a single-page audit — but covering the whole crawled site. Use these to respond to demand letters, file VPATs, or document remediation history."}),e.jsx("button",{type:"button",onClick:()=>void I(),disabled:N.state==="running",className:"w-full text-sm px-4 py-2.5 bg-slate-900 text-white rounded hover:bg-slate-800 disabled:opacity-50 font-medium",title:"Generate all compliance docs at once and download as a single .zip file",children:N.state==="running"?`Generating ${N.current} (${N.doneCount}/${N.totalCount})…`:"📦 Download all reports as a zip"}),N.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Bundled ",N.included," file",N.included===1?"":"s"," into the zip",N.skipped.length>0&&e.jsxs(e.Fragment,{children:[" ","· skipped ",N.skipped.length,":",e.jsx("ul",{className:"mt-0.5 ml-3 list-disc",children:N.skipped.map(g=>e.jsx("li",{className:"break-all",children:g},g))})]})]}),N.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",N.message]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[e.jsx(Ce,{label:"⚖ Defense bundle",sub:"Forensic-anchored HTML evidence — download + Ctrl+P to seal as PDF",busy:i==="defense-bundle",disabled:i!==null,onClick:()=>void f("defense-bundle","download")}),e.jsx(Ce,{label:"📜 Deposition packet",sub:"Court-grade — cover sheet, chain of custody, sworn declaration template",busy:i==="deposition-packet",disabled:i!==null,onClick:()=>void f("deposition-packet","download")}),e.jsx(Ce,{label:"📂 Evidence bundle",sub:"Same shape as Defense — neutral 'evidence' framing",busy:i==="evidence-bundle",disabled:i!==null,onClick:()=>void f("evidence-bundle","download")}),e.jsx(Ce,{label:"📋 VPAT (Voluntary Product Accessibility Template)",sub:"Formal industry conformance template — opens in new tab",busy:i==="vpat",disabled:i!==null,onClick:()=>void f("vpat","open-in-tab")}),e.jsx(Ce,{label:"🔄 Conformance crosswalk",sub:"WCAG 2.1 AA criterion-by-criterion conformance table",busy:i==="conformance-crosswalk",disabled:i!==null,onClick:()=>void f("conformance-crosswalk","open-in-tab")}),e.jsx(Ce,{label:"🔬 Methodology doc",sub:"How this audit was conducted — defensibility documentation",busy:i==="methodology-doc",disabled:i!==null,onClick:()=>void f("methodology-doc","open-in-tab")}),e.jsx(Ce,{label:"📊 Executive report",sub:"Stakeholder summary — grade hero, top risks, next steps. Print-ready.",busy:i==="executive-report",disabled:i!==null,onClick:()=>void f("executive-report","open-in-tab")}),e.jsx(Ce,{label:"📃 Accessibility statement",sub:"Public WCAG conformance statement (HTML or Markdown) — opens a dialog for org info",busy:!1,disabled:i!==null,onClick:()=>void w()}),e.jsx(Ce,{label:"📋 Pre-litigation report",sub:"Audit-history record across time — requires anchored entries (generate a defense bundle first)",busy:x,disabled:i!==null||x,onClick:()=>void C()})]}),p&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",p]})]}),e.jsx(ja,{open:u,onClose:()=>h(!1),results:[],siteCrawlSource:!0}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"This report is your do-the-work list."})," ","Each finding below is grouped by whether it's likely a"," ",e.jsx("strong",{children:"shared resource"})," (a CSS rule, component, or layout that affects multiple pages — fix it once, helps everywhere) or ",e.jsx("strong",{children:"page-specific"})," (only that one URL). Click any affected URL to open that page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)."]}),e.jsx(Ct,{title:"Shared resources — fix once, helps multiple pages",sectionKind:"shared-actionable",groups:t.findingGroups.filter(g=>g.isShared&&!g.needsReview),openPage:Be}),e.jsx(Ct,{title:"Page-specific — one-off; fix on that page",sectionKind:"local-actionable",groups:t.findingGroups.filter(g=>!g.isShared&&!g.needsReview),openPage:Be}),t.consistencyFindings.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700 mb-2",children:["Site-wide patterns (",t.consistencyFindings.length,")"]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:"Inconsistencies the comparators only see across pages — navigation order divergence, identification mismatches, redundant entry. WCAG 3.2.3 / 3.2.4 / 3.2.6."}),e.jsx("ul",{className:"space-y-2",children:t.consistencyFindings.map((g,v)=>e.jsxs("li",{className:"border border-blue-200 rounded p-2.5 bg-blue-50 text-xs",children:[e.jsxs("p",{className:"font-mono text-[10px] text-blue-700",children:[g.ruleId," · WCAG ",g.wcagCriterion," · ",g.impact]}),e.jsx("p",{className:"text-sm text-blue-900 mt-1",children:g.description}),g.details&&e.jsx("p",{className:"text-[11px] text-blue-800 mt-1 whitespace-pre-wrap leading-snug",children:g.details}),g.pages.length>0&&e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-blue-700",children:"Pages compared:"}),g.pages.map(S=>e.jsxs("button",{type:"button",onClick:()=>void Be(S.url),className:"block w-full text-left text-[11px] font-mono text-blue-800 hover:text-blue-900 hover:underline truncate",children:["→ ",S.url]},S.url))]})]},v))})]}),e.jsx(Ct,{title:"Needs human review",sectionKind:"needs-review",groups:t.findingGroups.filter(g=>g.needsReview),openPage:Be,hint:"AI flagged these as possibly failing but couldn't decide — you need to look + judge. They don't count toward the severity total above."}),t.findingGroups.length===0&&t.consistencyFindings.length===0&&e.jsxs("div",{className:"border border-emerald-200 rounded p-3 bg-emerald-50 text-xs text-emerald-900",children:[e.jsxs("strong",{children:["✓ No findings across the ",t.pagesAudited," crawled page",t.pagesAudited===1?"":"s","."]})," Per-page audits all completed cleanly. Drill into any page below to see the full per-page Findings if you want to verify or run guided manual checks."]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:[e.jsx("strong",{children:"Click any row"})," to expand it inline and see exactly what's wrong on that page — axe findings, AI walkthrough verdicts, and human acknowledgements with action buttons right there. Click the URL itself to open the audited page in a new tab."]}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:t.pages.map(g=>{const v=(t.findingGroups??[]).filter(S=>S.needsReview&&S.pages.some(k=>k.url===g.url)).length;return e.jsx(Vo,{page:g,findingGroups:t.findingGroups??[],needsReviewCount:v,onOpenSinglePage:()=>void Be(g.url)},g.url)})})]})]})}async function Be(t){try{const s=await dt(),a=s==null?void 0:s.find(n=>n.url===t);if(!a||a.results.length===0||!a.componentId){console.warn("[site-crawl-panel] no cached crawl results for",t);return}try{const{getResolutionsForPage:n}=await ke(async()=>{const{getResolutionsForPage:o}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(l=>l.aT);return{getResolutionsForPage:o}},__vite__mapDeps([0,1,2,3,4])),r=await n(t);y.getState().setResolutionsForUrl(t,r)}catch{}y.getState().setResults(a.results,a.delta,a.componentId),y.getState().setCrawlNavContext({mode:"page",url:t});try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}y.getState().setView("report"),y.getState().setFindingsLens("overview")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}function Ce({label:t,sub:s,busy:a,disabled:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,disabled:n,className:"w-full text-left px-3 py-2 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-medium text-slate-900",children:a?`Generating ${t.replace(/^[^a-zA-Z]+/,"")}…`:t}),e.jsx("div",{className:"text-[10px] text-slate-600 leading-snug mt-0.5",children:s})]})}function Ct({title:t,sectionKind:s,groups:a,openPage:n,hint:r}){if(a.length===0)return null;const o=s==="needs-review",l=o?"text-amber-700":"text-slate-500",i=o?"border-amber-200 bg-amber-50":"border-slate-200 bg-white",d=o?"bg-amber-200 text-amber-900":"";return e.jsxs("div",{children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wide mb-2 ${l}`,children:[t," (",a.length,")"]}),r&&e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:r}),e.jsx("ul",{className:"space-y-2",children:a.map((p,c)=>e.jsx(Go,{group:p,sectionKind:s,cardCls:i,labelCls:d,openPage:n},`${p.ruleId}::${p.representativeSelector}::${c}`))})]})}function Go({group:t,sectionKind:s,cardCls:a,labelCls:n,openPage:r}){const o=on(t.ruleId),i=o.whatsWrong&&o.whatsWrong!=="An accessibility rule failed on this page.",d=i?o.whatsWrong:t.axeDescription||`Rule "${t.ruleId}" was flagged — see axe-core docs for this rule.`,p=i?o.whyItMatters:null,c=i?o.howToFix:null,u=s==="needs-review",h=s==="shared-actionable",x=u?"review":t.impact,b=u?`${n} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`:`${Mo[t.impact]} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`;return e.jsxs("li",{className:`border rounded p-2.5 text-xs ${a}`,children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:b,children:x}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 mt-0.5 break-all",children:[t.ruleId,t.wcagCriterion&&` · WCAG ${t.wcagCriterion}`]}),e.jsxs("p",{className:"text-[11px] text-slate-600 mt-1",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Shared"})," — found on"," ",e.jsx("strong",{children:t.pages.length})," page",t.pages.length===1?"":"s",". Likely a shared component or CSS rule — fix once."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Page-specific"})," — only on this one page."]}),t.totalOccurrences>t.pages.length&&e.jsxs(e.Fragment,{children:[" · ",t.totalOccurrences," matrix-state occurrences"]})]})]})]}),(p||c)&&e.jsxs("div",{className:"ml-7 mb-2 space-y-1.5",children:[p&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Why it matters"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:p})]}),c&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"How to fix"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:c})]})]}),t.representativeSelector&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Where to find it"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-700 break-all",children:t.representativeSelector}),t.representativeOuterHTML&&e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 break-all mt-0.5 line-clamp-2",children:[t.representativeOuterHTML.slice(0,200),t.representativeOuterHTML.length>200?"…":""]})]}),t.failureSummary&&!i&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Detail"}),e.jsxs("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:[t.failureSummary.slice(0,600),t.failureSummary.length>600?"…":""]})]}),e.jsxs("div",{className:"ml-7",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-0.5",children:u?"Open to review":"Affected pages"}),e.jsx("ul",{className:"space-y-0.5",children:t.pages.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(w.url),className:"block w-full text-left text-[11px] font-mono text-brand-700 hover:text-brand-900 hover:underline truncate",title:"Open this page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)",children:["→ ",w.url]})},w.url))})]}),u&&e.jsx("div",{className:"ml-7 mt-2 pt-2 border-t border-dashed border-slate-200",children:e.jsx(Ia,{group:t})})]})}function Ia({group:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(""),[o,l]=m.useState(!1),[i,d]=m.useState(null),[p,c]=m.useState(!1);async function u(){l(!0),d(null);try{if(!n.trim()){d("Note is required — explain your review judgment."),l(!1);return}const h=await dt()??[],{acknowledgeFinding:x}=await ke(async()=>{const{acknowledgeFinding:w}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(N=>N.aS);return{acknowledgeFinding:w}},__vite__mapDeps([0,1,2,3,4]));let b=0;for(const w of t.pages){const N=h.find(E=>E.url===w.url);if(N)for(const E of N.results)for(const I of E.violations)I.ruleId===t.ruleId&&I.target.selector===w.selector&&(await x({componentId:N.componentId,matchKey:I.matchKey,ruleId:I.ruleId,note:n.trim()}),b++)}b===0?d("Could not find this finding in the persisted crawl data — re-run the crawl and try again."):(c(!0),a(!1))}catch(h){d(h instanceof Error?h.message:String(h))}finally{l(!1)}}return p?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2",children:e.jsxs("p",{className:"text-[11px] text-emerald-900",children:[e.jsx("strong",{children:"✓ Acknowledged."})," Re-run a crawl (or refresh the audit on the affected page) to see the finding drop out."]})}):s?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"Your review judgment (required, goes into the forensic record)"}),e.jsx("textarea",{value:n,onChange:h=>r(h.target.value),placeholder:"e.g., Verified — image is a portrait of the named founder; alt text correctly identifies subject and role.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:i}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:o?"Saving…":`Confirm — acknowledge on ${t.pages.length} page${t.pages.length===1?"":"s"}`}),e.jsx("button",{type:"button",onClick:()=>{a(!1),r(""),d(null)},disabled:o,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{a(!0),d(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",title:"Mark this needsReview finding as human-verified across all affected pages. The ack persists across crawls as long as the underlying content's matchKey is stable (which it is for ai-alt-uncertain unless the alt text or image structure changes).",children:"Mark verified manually"})}function Vo({page:t,findingGroups:s,needsReviewCount:a,onOpenSinglePage:n}){const[r,o]=m.useState(!1),l=t.walkthroughFindings??[],i=t.walkthroughAcknowledgements??[],d=Math.max(0,t.uniqueViolations-l.length-i.length),p=s.filter(x=>x.needsReview&&x.pages.some(b=>b.url===t.url)),c=s.filter(x=>!x.needsReview&&x.pages.some(b=>b.url===t.url)).map(x=>{var b;return{ruleId:x.ruleId,impact:x.impact,description:x.axeDescription,wcagCriterion:x.wcagCriterion,selector:((b=x.pages.find(w=>w.url===t.url))==null?void 0:b.selector)??x.representativeSelector}}).sort((x,b)=>{const w={critical:0,serious:1,moderate:2,minor:3};return(w[x.impact]??99)-(w[b.impact]??99)}),u=c.length>0||l.length>0||i.length>0||p.length>0||!!t.error,h=t.grade==="A"?"text-emerald-700":t.grade==="B"?"text-lime-700":t.grade==="C"?"text-yellow-700":t.grade==="D"?"text-orange-700":"text-rose-700";return e.jsxs("div",{className:"border-b border-slate-100 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>o(x=>!x),disabled:!u,className:"w-full flex items-center gap-2 text-left px-2 py-1.5 hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white text-xs","aria-expanded":r,children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${h}`,children:t.grade}),e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"font-mono text-[11px] text-brand-700 hover:underline break-all flex-1",title:"Open this page in a new browser tab",children:t.url}),e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0 tabular-nums",title:"axe violations only",children:[d," axe"]}),e.jsxs("span",{className:`text-[10px] shrink-0 tabular-nums font-medium ${l.length>0?"text-rose-700":i.length>0?"text-emerald-700":"text-slate-400"}`,children:[l.length," walkthru",i.length>0?` (${i.length}✓)`:""]}),a>0&&e.jsxs("span",{className:"text-[10px] shrink-0 tabular-nums font-medium text-amber-700",title:`${a} item${a===1?"":"s"} flagged for human review`,children:[a," review"]}),u&&e.jsx("span",{className:"text-[10px] text-slate-400 shrink-0 font-mono","aria-hidden":"true",children:r?"−":"+"})]}),r&&u&&e.jsx(Wo,{page:t,axeFindings:c,needsReviewGroups:p,onOpenSinglePage:n})]})}function Wo({page:t,axeFindings:s,needsReviewGroups:a,onOpenSinglePage:n}){const r=`${t.url}::dom:html`,[o,l]=m.useState([]),[i,d]=m.useState({}),[p,c]=m.useState(0);return m.useEffect(()=>{let u=!1;return Promise.all([Ie(r),Le([r])]).then(([h,x])=>{if(u)return;l(h.filter(w=>w.verdict!=="pass"));const b={};for(const w of x)b[w.criterionId]=w;d(b)}),()=>{u=!0}},[r,p]),e.jsxs("div",{className:"bg-slate-50 px-2 py-2 space-y-2 text-[11px]",children:[t.error&&e.jsxs("p",{className:"text-rose-700",children:["⚠ ",t.error]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["Axe findings (",s.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:s.map((u,h)=>e.jsxs("li",{className:"bg-white border border-slate-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:`font-mono text-[10px] font-bold uppercase px-1 rounded ${u.impact==="critical"?"bg-rose-200 text-rose-900":u.impact==="serious"?"bg-orange-200 text-orange-900":u.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:u.impact}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.description}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.selector})]},`${u.ruleId}::${u.selector}::${h}`))})]}),o.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["AI walkthrough findings (",o.length,")"]}),e.jsx("div",{className:"space-y-2",children:o.map(u=>e.jsx("div",{className:"bg-white border border-slate-200 rounded p-1.5",children:e.jsx(ts,{componentId:r,pageUrl:t.url,criterionId:u.criterionId,record:u,ack:i[u.criterionId]??null,onChanged:()=>c(h=>h+1)})},u.criterionId))})]}),Object.keys(i).length>0&&o.every(u=>i[u.criterionId])&&Object.keys(i).length>o.length&&e.jsx("p",{className:"text-[10px] text-emerald-700",children:"✓ All walkthroughs on this page either passed or are human-verified."}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-amber-700 mb-1",children:["Needs human review (",a.length,")"]}),e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"bg-white border border-amber-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"font-mono text-[10px] font-bold uppercase px-1 rounded bg-amber-200 text-amber-900",children:"review"}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.axeDescription}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.representativeSelector}),u.failureSummary&&e.jsxs("p",{className:"text-[10px] text-slate-600 mt-1 whitespace-pre-wrap",children:[u.failureSummary.slice(0,400),u.failureSummary.length>400?"…":""]}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Ia,{group:u})})]},`${u.ruleId}::${u.representativeSelector}`))})]}),e.jsx("div",{className:"pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-brand-600 hover:underline",children:"Open full single-page view (lenses, visualizers, guided checks) →"})})]})}const It="onboardingDismissed",Et=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function Bo(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(It).then(i=>{i[It]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[It]:!0}),s(!1),n(0)}const o=a===Et.length-1,l=Et[a];return e.jsxs(Me,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Et.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(i=>i-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),o?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(i=>i+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Ho(){const t=y(n=>n.status),s=y(n=>n.errorMessage),a=y(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Ko(){const t=y(d=>d.aiFailure),s=y(d=>d.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",o=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",l="⚠",i=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${o}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:l})," ",i]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Gs(){const[t,s]=m.useState(!1);return m.useEffect(()=>we("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),y.getState().setStatus("idle"))}),[]),e.jsxs(Me,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function zo(){var o;const[t,s]=m.useState(null);if(m.useEffect(()=>{ln().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await cs(),y.getState().startNewScan(),t.mode==="storybook-all"?Ne({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&Ne({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await cs(),s(null)}const r=t.mode==="storybook-all"?`Story ${((o=t.completedStories)==null?void 0:o.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Rt="storybook:hintDismissed";function qo(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var i;if((await chrome.storage.local.get(Rt))[Rt])return;const l=await ue();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((i=p.result)==null?void 0:i.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Rt]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function Qo(){var o;const t=y(l=>l.results),s=y(l=>l.baselineList),a=y(l=>l.status),n=(o=t[0])==null?void 0:o.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Yo(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function Yo(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const o=Math.round(r/60);if(o<60)return`${o}m ago`;const l=Math.round(o/60);if(l<24)return`${l}h ago`;const i=Math.round(l/24);return i<7?`${i}d ago`:a.toLocaleDateString()}function Jo(){const t=y(i=>i.results),s=y(i=>i.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let i=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(i)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{i=!0}},[s]),t.length===0)return null;const r=t.flatMap(i=>i.violations),o=cn(r,a.length>0?{runs:a,workflows:fe}:void 0),l=o.manual!==void 0&&o.manual.workflowsCompleted===o.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Xo(){const t=y(a=>a.setUserMode);function s(a){t(a),ae({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const Zo=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],el={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function tl(t){const s=new Set(Zo),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,p])=>({ruleId:d,instanceCount:p})).sort((d,p)=>p.instanceCount-d.instanceCount),r=n.length,o=Array.from(a.values()).reduce((d,p)=>d+p,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:o,flaggedRules:n,headline:el[l]}}const Ea={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},sl={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ea]},al={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ea]};function as(t){return t==="thorough"?al:sl}function Vs(t){const s=as(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Ra(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,o]=m.useState(0),[l,i]=m.useState(!1),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,x]=m.useState(""),[b,w]=m.useState(!1);if(m.useEffect(()=>{let f=!1;return s(null),n(null),ut().then(j=>{f||s(j)}).catch(j=>{f||n(j instanceof Error?j.message:String(j))}),()=>{f=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const N=t.length,E=t.filter(f=>f.receipt).length;async function I(){if(!(!t||t.length===0)){w(!0);try{await ss({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),i(!1)}finally{w(!1)}}}async function C(){if(!t||t.length===0)return;const f={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},j=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),g=URL.createObjectURL(j),v=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,S=document.createElement("a");S.href=g,S.download=v,S.click(),setTimeout(()=>URL.revokeObjectURL(g),1e3)}return N===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[N," ",N===1?"entry":"entries",E>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[E," RFC 3161-anchored"]})]}),E===0&&N>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>i(f=>!f),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void C(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>o(f=>f+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:f=>p(f.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:c,onChange:f=>u(f.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:h,onChange:f=>x(f.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:b||N===0,onClick:I,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:b?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(f=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${f.grade==="A"?"bg-emerald-100 text-emerald-700":f.grade==="B"?"bg-lime-100 text-lime-700":f.grade==="C"?"bg-yellow-100 text-yellow-700":f.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:f.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:f.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${f.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:f.receipt?`Anchored to ${f.receipt.tsaName} at ${f.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:f.receipt?`RFC 3161 (${f.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:f.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:f.capturedAt}),(f.totals.critical>0||f.totals.serious>0)&&e.jsxs("span",{children:[f.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[f.totals.critical," crit"]}),f.totals.critical>0&&f.totals.serious>0&&" · ",f.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[f.totals.serious," sev"]})]}),e.jsxs("span",{children:[f.statesAudited," ",f.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:f.hash,children:[f.hash.slice(0,12),"…"]})]})]},`${f.componentId}::${f.capturedAt}`))})]})}function nl(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let d=!1;return ut().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,o=t[t.length-1],l=t.slice(0,3),i=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",o&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:o.capturedAt.slice(0,10)})]}),i>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[i," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(Me,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(Ra,{})})})]})}function rl(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const il={eyebrow:"You're on a trial",headline:"Full features unlocked while you evaluate.",body:"When your trial ends, a paid plan keeps RFC 3161 trusted-timestamp anchoring, AI fix suggestions, and audit-history evidence active for every scan."},ol={eyebrow:"You're on the free tier",headline:"Audits run locally — but no forensic record is being kept.",body:"Upgrade to anchor every audit with court-grade trusted timestamps, unlock AI-powered fix suggestions, and build a third-party-verifiable history of your remediation effort."},ll={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},cl={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Ta(){const t=y(u=>u.tier),s=y(u=>u.trialDaysRemaining),a=y(u=>u.seatsUsed),n=y(u=>u.seatsTotal),r=y(u=>u.planCode),o=y(u=>u.licenseDaysRemaining),l=y(u=>u.pastDue),[i,d]=m.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=o,h=u!==null&&u<=7,x=u===null?"":u===0?"expires today":u===1?"1 day left":`${u} days left`;return e.jsxs("aside",{"aria-label":"License status",className:h?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:h?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),x&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",x]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void ae({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Lt,{open:i,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?cl:ll,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,x=t==="team"&&a!==null&&n!==null&&a>n,b=t==="team"&&a!==null&&n!==null&&a===n,w=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:b?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${w.bg} border-b ${w.border} px-3 py-2 space-y-1 text-[11px] ${w.shadow}`,children:[e.jsxs("div",{className:w.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:w.subtitle,children:[" · ",h]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),b&&!x&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void ae({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const p=t==="trial"?il:ol,c=t==="trial"?rl(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:p.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:c})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void ae({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Lt,{open:i,onClose:()=>d(!1)})]})}const dl={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},ul={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Ws={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},pl={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"},Bs={critical:0,serious:1,moderate:2,minor:3};function hl(){const t=y(u=>u.setUserMode),s=y(u=>u.status),a=y(u=>u.setStatus),n=y(u=>u.errorMessage),r=y(u=>u.setError),[o,l]=m.useState(!1),[i,d]=m.useState(!1),p=m.useRef(s);m.useEffect(()=>{if(p.current==="running"&&s==="complete"){d(!0);const u=setTimeout(()=>d(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),m.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{y.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(u)},[s,a,r]);function c(){t("dev"),ae({type:"SETTINGS_SET",key:"userMode",value:"dev"})}return e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(Ta,{}),e.jsx(ma,{}),e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"Lawsuit-target screener"}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-tight",children:"Find out if your site is on the ADA-targeting bots' radar"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ha,{}),e.jsx("button",{type:"button",onClick:c,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(ml,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{y.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[o?e.jsx(Ca,{onBack:()=>l(!1)}):e.jsx(gl,{onPickCrawl:()=>l(!0)}),i&&e.jsx(xl,{})]}),e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsx("div",{className:"px-3 py-1.5 text-center leading-tight",children:"Risk indicator based on the same automated WCAG checks ADA-targeting tools use, plus our extended DOM analyzers and AI walkthroughs covering all 50 WCAG 2.1 AA criteria."}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})]})}function ml(){const t=y(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void ae({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function xl(){return e.jsxs("div",{role:"status",className:"absolute top-3 left-1/2 -translate-x-1/2 bg-emerald-600 text-white text-xs font-medium px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 pointer-events-none",style:{zIndex:50},children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{children:"Scan complete"})]})}function gl({onPickCrawl:t}){const s=y(u=>u.status),a=y(u=>u.results),[n,r]=m.useState("quick"),[o,l]=m.useState("all"),i=s==="running",d=a.flatMap(u=>u.violations),p=a.length>0;function c(){Ne({type:"START_AUDIT",mode:"full-page",matrixOverride:as(n)}),y.getState().startNewScan(),ge.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:c,disabled:i,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:i,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(bl,{depth:n,onChange:r,disabled:i})]}),!p&&!i&&e.jsx(fl,{}),p&&e.jsx(vl,{violations:d,severityFilter:o,onSeverityFilterChange:l,scanDepth:n})]})}function fl(){return e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex items-center justify-center w-24 bg-slate-300 text-white shrink-0","aria-label":"Not yet audited",children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:"X"})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"Not yet audited"}),e.jsxs("p",{className:"text-xs mt-1 leading-snug text-slate-600",children:["WCAG compliance level unknown. Open the page you want to check in this tab, then click ",e.jsx("strong",{children:"Scan this page"})," above. Use",e.jsx("strong",{children:" Whole site"})," for a multi-page report."]})]})]})})}function bl({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(Hs,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Vs("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Hs,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Vs("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Hs({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})]})}function vl({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var g;const r=y(v=>v.status),o=y(v=>v.results),l=y(v=>v.freshThisSession),i=y(v=>v.componentId),d=(g=o[0])==null?void 0:g.startedAt,p=tl(t),c=r==="running",[u,h]=m.useState([]);m.useEffect(()=>{if(!i){h([]);return}let v=!1;return chrome.storage.local.get("igtRuns").then(S=>{if(v)return;const T=((S==null?void 0:S.igtRuns)??{})[i]??{};h(Object.values(T))}),()=>{v=!0}},[i]);const x=y(v=>v.acknowledgedKeys),b=o.length>0?ea(o,{runs:u,workflows:fe},"2.1","AA",x):void 0;function w(){Ne({type:"START_AUDIT",mode:"full-page",matrixOverride:as(n)}),y.getState().startNewScan(),ge.polite("Re-scanning this page now.")}const N=s==="lawsuit-risk"?t.filter(v=>v.impact==="critical"||v.impact==="serious"):t,E=new Map;for(const v of N){const S=Ue(v.ruleId,v.target.selector);E.has(S)||E.set(S,v)}const I=Array.from(E.values()),C=new Map;for(const v of I){const S=C.get(v.ruleId)??[];S.push(v),C.set(v.ruleId,S)}const f=Array.from(C.entries()).sort((v,S)=>(Bs[v[1][0].impact]??99)-(Bs[S[1][0].impact]??99)),j=t.filter(v=>v.impact==="critical"||v.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Sl,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void yt(),disabled:c,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:w,disabled:c,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:c?"Scanning…":"↻ Scan again"})]})]}),c?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${dl[p.tier]}`,children:[!l&&d&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ul[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${Ws[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Ws[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged",p.flaggedInstanceCount>p.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:p.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!c&&b&&!b.canClaimConformance&&e.jsx(yl,{coverage:b}),!c&&b&&b.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",b.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(kl,{}),e.jsx(nl,{}),t.length>0&&e.jsx(wl,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:j}),e.jsxs("div",{className:"space-y-2",children:[f.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),f.map(([v,S])=>e.jsx(jl,{ruleId:v,violations:S},v))]})]})}function yl({coverage:t}){const s=y(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),ae({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function wl({filter:t,onChange:s,totalCount:a,lawsuitRiskCount:n}){return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Show"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("button",{type:"button",onClick:()=>s("all"),"aria-pressed":t==="all",className:`text-left rounded p-2 border transition-colors ${t==="all"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"All issues"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[a," total"]})]}),e.jsxs("button",{type:"button",onClick:()=>s("lawsuit-risk"),"aria-pressed":t==="lawsuit-risk",className:`text-left rounded p-2 border transition-colors ${t==="lawsuit-risk"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"Lawsuit risk only"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[n," critical/serious"]})]})]})]})}function jl({ruleId:t,violations:s}){var u;const[a,n]=m.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,o=dn(t,r),l=s[0].impact,i=s[0],p=o.whatsWrong==="An accessibility rule failed on this page."&&i.description?i.description:o.whatsWrong,c=i.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${pl[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",o.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",o.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,x)=>e.jsx(Nl,{violation:h},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function Nl({violation:t}){const s=y(o=>{var l;return(l=o.results[0])==null?void 0:l.frameId}),[a,n]=m.useState(null);async function r(o){o.stopPropagation();const l=await ue();if(l)try{const i=await Ee(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(i.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const at=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function kl(){const t=y(c=>c.results),s=y(c=>c.componentId),[a,n]=m.useState(null),[r,o]=m.useState(!1),[l,i]=m.useState(null);async function d(c,u){if(t.length!==0){n(c);try{const h=await Z({type:"EXPORT_REQUEST",format:c,results:t,wallClockMs:y.getState().lastAuditWallClockMs??void 0});if(c==="defense-bundle"||c==="evidence-bundle"){const x=bt(c,s);await ia()?et(h.content,x):i({open:!0,format:c,content:h.content,filename:x})}else if(u)$e(h.content);else{try{await navigator.clipboard.writeText(h.content),ge.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const b=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
268
+ `;if(T.unshift({name:"README.txt",content:L}),T.length===0){E({state:"error",message:"No reports could be generated. Re-run the crawl and try again."});return}const q=x(T),$=new Date().toISOString().slice(0,10),_=t.startUrl.replace(/^https?:\/\//,"").replace(/[^a-z0-9]/gi,"-").replace(/-+/g,"-").slice(0,32).toLowerCase()||"crawl",F=`wcagcheckr-site-bundle-${$}-${_}.zip`,H=URL.createObjectURL(q),R=document.createElement("a");R.href=H,R.download=F,document.body.appendChild(R),R.click(),document.body.removeChild(R),setTimeout(()=>URL.revokeObjectURL(H),3e4),E({state:"done",included:T.length,skipped:k})}catch(L){E({state:"error",message:L instanceof Error?L.message:String(L)})}}async function C(){var x,v,S;b(!0),c(null);try{const k=await dt();if(k.length===0){c("No forensic-log entries yet. Generate a defense bundle or deposition packet first — those create the anchored entries the pre-litigation report documents.");return}const T=typeof chrome<"u"&&((S=(v=(x=chrome.runtime)==null?void 0:x.getManifest)==null?void 0:v.call(x))==null?void 0:S.version)||"1.0.0";await ss({entries:k,extensionVersion:T})}catch(k){c(k instanceof Error?k.message:String(k))}finally{b(!1)}}async function f(x,v){d(x),c(null);try{const S=`site:${t.startUrl}`,k=await Z({type:"EXPORT_REQUEST",format:x,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});if(!(k!=null&&k.content)||k.content.length<50){c(`Generation returned empty content for ${x}.`);return}if(v==="download"){const T=ft(x,S);et(k.content,T)}else $e(k.content)}catch(S){c(S instanceof Error?S.message:String(S))}finally{d(null)}}async function j(){n(!0);try{const x=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),v=(x==null?void 0:x.content)??"";if(!v){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(v)}catch{}$e(v,"text/markdown;charset=utf-8")}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Mo[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Po[t.siteRisk]}`,children:on[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited",(()=>{const x=t.totalUniqueViolations,v=t.totalWalkthroughFindings,S=t.totalNeedsReview,k=x+v,T=[];return x>0&&T.push(`${x} axe`),v>0&&T.push(`${v} AI walkthrough`),e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:k})," total finding",k===1?"":"s",T.length>0&&e.jsxs(e.Fragment,{children:[" (",T.join(" + "),")"]}),S>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:S})," need",S===1?"s":""," review"]})]})})(),t.walkthroughAcknowledgements.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{className:"text-emerald-700",children:t.walkthroughAcknowledgements.length})," human-verified"]}),t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 font-medium",children:"📊 Open full site report (standalone HTML)"}),e.jsx("button",{type:"button",onClick:j,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:r.state==="running",className:"w-full text-sm px-4 py-2.5 border border-emerald-500 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 font-medium",title:"Save each crawled page's current state as its baseline. Future audits + re-crawls show delta against this snapshot.",children:r.state==="running"?`Saving baselines… ${r.current+1}/${r.total}`:"📌 Set this crawl as the site baseline"}),r.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Saved ",r.saved," baseline",r.saved===1?"":"s",r.failed>0&&` · ${r.failed} failed (re-crawl those pages and retry)`]}),r.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",r.message]}),e.jsxs("div",{className:"border border-slate-200 rounded-lg p-3 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-700",children:"Site-wide compliance documents"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Generate the same legal / compliance / industry docs you can produce from a single-page audit — but covering the whole crawled site. Use these to respond to demand letters, file VPATs, or document remediation history."}),e.jsx("button",{type:"button",onClick:()=>void I(),disabled:N.state==="running",className:"w-full text-sm px-4 py-2.5 bg-slate-900 text-white rounded hover:bg-slate-800 disabled:opacity-50 font-medium",title:"Generate all compliance docs at once and download as a single .zip file",children:N.state==="running"?`Generating ${N.current} (${N.doneCount}/${N.totalCount})…`:"📦 Download all reports as a zip"}),N.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Bundled ",N.included," file",N.included===1?"":"s"," into the zip",N.skipped.length>0&&e.jsxs(e.Fragment,{children:[" ","· skipped ",N.skipped.length,":",e.jsx("ul",{className:"mt-0.5 ml-3 list-disc",children:N.skipped.map(x=>e.jsx("li",{className:"break-all",children:x},x))})]})]}),N.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",N.message]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[e.jsx(Ce,{label:"⚖ Defense bundle",sub:"Forensic-anchored HTML evidence — download + Ctrl+P to seal as PDF",busy:i==="defense-bundle",disabled:i!==null,onClick:()=>void f("defense-bundle","download")}),e.jsx(Ce,{label:"📜 Deposition packet",sub:"Court-grade — cover sheet, chain of custody, sworn declaration template",busy:i==="deposition-packet",disabled:i!==null,onClick:()=>void f("deposition-packet","download")}),e.jsx(Ce,{label:"📂 Evidence bundle",sub:"Same shape as Defense — neutral 'evidence' framing",busy:i==="evidence-bundle",disabled:i!==null,onClick:()=>void f("evidence-bundle","download")}),e.jsx(Ce,{label:"📋 VPAT (Voluntary Product Accessibility Template)",sub:"Formal industry conformance template — opens in new tab",busy:i==="vpat",disabled:i!==null,onClick:()=>void f("vpat","open-in-tab")}),e.jsx(Ce,{label:"🔄 Conformance crosswalk",sub:"WCAG 2.1 AA criterion-by-criterion conformance table",busy:i==="conformance-crosswalk",disabled:i!==null,onClick:()=>void f("conformance-crosswalk","open-in-tab")}),e.jsx(Ce,{label:"🔬 Methodology doc",sub:"How this audit was conducted — defensibility documentation",busy:i==="methodology-doc",disabled:i!==null,onClick:()=>void f("methodology-doc","open-in-tab")}),e.jsx(Ce,{label:"📊 Executive report",sub:"Stakeholder summary — grade hero, top risks, next steps. Print-ready.",busy:i==="executive-report",disabled:i!==null,onClick:()=>void f("executive-report","open-in-tab")}),e.jsx(Ce,{label:"📃 Accessibility statement",sub:"Public WCAG conformance statement (HTML or Markdown) — opens a dialog for org info",busy:!1,disabled:i!==null,onClick:()=>void w()}),e.jsx(Ce,{label:"📋 Pre-litigation report",sub:"Audit-history record across time — requires anchored entries (generate a defense bundle first)",busy:g,disabled:i!==null||g,onClick:()=>void C()})]}),p&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",p]})]}),e.jsx(Na,{open:u,onClose:()=>h(!1),results:[],siteCrawlSource:!0}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"This report is your do-the-work list."})," ","Each finding below is grouped by whether it's likely a"," ",e.jsx("strong",{children:"shared resource"})," (a CSS rule, component, or layout that affects multiple pages — fix it once, helps everywhere) or ",e.jsx("strong",{children:"page-specific"})," (only that one URL). Click any affected URL to open that page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)."]}),e.jsx(Ct,{title:"Shared resources — fix once, helps multiple pages",sectionKind:"shared-actionable",groups:t.findingGroups.filter(x=>x.isShared&&!x.needsReview),openPage:Be}),e.jsx(Ct,{title:"Page-specific — one-off; fix on that page",sectionKind:"local-actionable",groups:t.findingGroups.filter(x=>!x.isShared&&!x.needsReview),openPage:Be}),t.consistencyFindings.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700 mb-2",children:["Site-wide patterns (",t.consistencyFindings.length,")"]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:"Inconsistencies the comparators only see across pages — navigation order divergence, identification mismatches, redundant entry. WCAG 3.2.3 / 3.2.4 / 3.2.6."}),e.jsx("ul",{className:"space-y-2",children:t.consistencyFindings.map((x,v)=>e.jsxs("li",{className:"border border-blue-200 rounded p-2.5 bg-blue-50 text-xs",children:[e.jsxs("p",{className:"font-mono text-[10px] text-blue-700",children:[x.ruleId," · WCAG ",x.wcagCriterion," · ",x.impact]}),e.jsx("p",{className:"text-sm text-blue-900 mt-1",children:x.description}),x.details&&e.jsx("p",{className:"text-[11px] text-blue-800 mt-1 whitespace-pre-wrap leading-snug",children:x.details}),x.pages.length>0&&e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-blue-700",children:"Pages compared:"}),x.pages.map(S=>e.jsxs("button",{type:"button",onClick:()=>void Be(S.url),className:"block w-full text-left text-[11px] font-mono text-blue-800 hover:text-blue-900 hover:underline truncate",children:["→ ",S.url]},S.url))]})]},v))})]}),e.jsx(Ct,{title:"Needs human review",sectionKind:"needs-review",groups:t.findingGroups.filter(x=>x.needsReview),openPage:Be,hint:"AI flagged these as possibly failing but couldn't decide — you need to look + judge. They don't count toward the severity total above."}),t.findingGroups.length===0&&t.consistencyFindings.length===0&&e.jsxs("div",{className:"border border-emerald-200 rounded p-3 bg-emerald-50 text-xs text-emerald-900",children:[e.jsxs("strong",{children:["✓ No findings across the ",t.pagesAudited," crawled page",t.pagesAudited===1?"":"s","."]})," Per-page audits all completed cleanly. Drill into any page below to see the full per-page Findings if you want to verify or run guided manual checks."]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:[e.jsx("strong",{children:"Click any row"})," to expand it inline and see exactly what's wrong on that page — axe findings, AI walkthrough verdicts, and human acknowledgements with action buttons right there. Click the URL itself to open the audited page in a new tab."]}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:t.pages.map(x=>{const v=(t.findingGroups??[]).filter(S=>S.needsReview&&S.pages.some(k=>k.url===x.url)).length;return e.jsx(Bo,{page:x,findingGroups:t.findingGroups??[],needsReviewCount:v,onOpenSinglePage:()=>void Be(x.url)},x.url)})})]})]})}async function Be(t){try{const s=await ct(),a=s==null?void 0:s.find(n=>n.url===t);if(!a||a.results.length===0||!a.componentId){console.warn("[site-crawl-panel] no cached crawl results for",t);return}try{const{getResolutionsForPage:n}=await ke(async()=>{const{getResolutionsForPage:o}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(l=>l.aT);return{getResolutionsForPage:o}},__vite__mapDeps([0,1,2,3,4])),r=await n(t);y.getState().setResolutionsForUrl(t,r)}catch{}y.getState().setResults(a.results,a.delta,a.componentId),y.getState().setCrawlNavContext({mode:"page",url:t});try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}y.getState().setView("report"),y.getState().setFindingsLens("overview")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}function Ce({label:t,sub:s,busy:a,disabled:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,disabled:n,className:"w-full text-left px-3 py-2 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-medium text-slate-900",children:a?`Generating ${t.replace(/^[^a-zA-Z]+/,"")}…`:t}),e.jsx("div",{className:"text-[10px] text-slate-600 leading-snug mt-0.5",children:s})]})}function Ct({title:t,sectionKind:s,groups:a,openPage:n,hint:r}){if(a.length===0)return null;const o=s==="needs-review",l=o?"text-amber-700":"text-slate-500",i=o?"border-amber-200 bg-amber-50":"border-slate-200 bg-white",d=o?"bg-amber-200 text-amber-900":"";return e.jsxs("div",{children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wide mb-2 ${l}`,children:[t," (",a.length,")"]}),r&&e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:r}),e.jsx("ul",{className:"space-y-2",children:a.map((p,c)=>e.jsx(Wo,{group:p,sectionKind:s,cardCls:i,labelCls:d,openPage:n},`${p.ruleId}::${p.representativeSelector}::${c}`))})]})}function Wo({group:t,sectionKind:s,cardCls:a,labelCls:n,openPage:r}){const o=ln(t.ruleId),i=o.whatsWrong&&o.whatsWrong!=="An accessibility rule failed on this page.",d=i?o.whatsWrong:t.axeDescription||`Rule "${t.ruleId}" was flagged — see axe-core docs for this rule.`,p=i?o.whyItMatters:null,c=i?o.howToFix:null,u=s==="needs-review",h=s==="shared-actionable",g=u?"review":t.impact,b=u?`${n} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`:`${Go[t.impact]} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`;return e.jsxs("li",{className:`border rounded p-2.5 text-xs ${a}`,children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:b,children:g}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 mt-0.5 break-all",children:[t.ruleId,t.wcagCriterion&&` · WCAG ${t.wcagCriterion}`]}),e.jsxs("p",{className:"text-[11px] text-slate-600 mt-1",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Shared"})," — found on"," ",e.jsx("strong",{children:t.pages.length})," page",t.pages.length===1?"":"s",". Likely a shared component or CSS rule — fix once."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Page-specific"})," — only on this one page."]}),t.totalOccurrences>t.pages.length&&e.jsxs(e.Fragment,{children:[" · ",t.totalOccurrences," matrix-state occurrences"]})]})]})]}),(p||c)&&e.jsxs("div",{className:"ml-7 mb-2 space-y-1.5",children:[p&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Why it matters"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:p})]}),c&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"How to fix"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:c})]})]}),t.representativeSelector&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Where to find it"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-700 break-all",children:t.representativeSelector}),t.representativeOuterHTML&&e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 break-all mt-0.5 line-clamp-2",children:[t.representativeOuterHTML.slice(0,200),t.representativeOuterHTML.length>200?"…":""]})]}),t.failureSummary&&!i&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Detail"}),e.jsxs("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:[t.failureSummary.slice(0,600),t.failureSummary.length>600?"…":""]})]}),e.jsxs("div",{className:"ml-7",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-0.5",children:u?"Open to review":"Affected pages"}),e.jsx("ul",{className:"space-y-0.5",children:t.pages.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(w.url),className:"block w-full text-left text-[11px] font-mono text-brand-700 hover:text-brand-900 hover:underline truncate",title:"Open this page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)",children:["→ ",w.url]})},w.url))})]}),u&&e.jsx("div",{className:"ml-7 mt-2 pt-2 border-t border-dashed border-slate-200",children:e.jsx(Ea,{group:t})})]})}function Ea({group:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(""),[o,l]=m.useState(!1),[i,d]=m.useState(null),[p,c]=m.useState(!1);async function u(){l(!0),d(null);try{if(!n.trim()){d("Note is required — explain your review judgment."),l(!1);return}const h=await ct()??[],{acknowledgeFinding:g}=await ke(async()=>{const{acknowledgeFinding:w}=await import("./scheduled-audit-runner-QcMYcqgA.js").then(N=>N.aS);return{acknowledgeFinding:w}},__vite__mapDeps([0,1,2,3,4]));let b=0;for(const w of t.pages){const N=h.find(E=>E.url===w.url);if(N)for(const E of N.results)for(const I of E.violations)I.ruleId===t.ruleId&&I.target.selector===w.selector&&(await g({componentId:N.componentId,matchKey:I.matchKey,ruleId:I.ruleId,note:n.trim()}),b++)}b===0?d("Could not find this finding in the persisted crawl data — re-run the crawl and try again."):(c(!0),a(!1))}catch(h){d(h instanceof Error?h.message:String(h))}finally{l(!1)}}return p?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2",children:e.jsxs("p",{className:"text-[11px] text-emerald-900",children:[e.jsx("strong",{children:"✓ Acknowledged."})," Re-run a crawl (or refresh the audit on the affected page) to see the finding drop out."]})}):s?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"Your review judgment (required, goes into the forensic record)"}),e.jsx("textarea",{value:n,onChange:h=>r(h.target.value),placeholder:"e.g., Verified — image is a portrait of the named founder; alt text correctly identifies subject and role.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:i}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:o?"Saving…":`Confirm — acknowledge on ${t.pages.length} page${t.pages.length===1?"":"s"}`}),e.jsx("button",{type:"button",onClick:()=>{a(!1),r(""),d(null)},disabled:o,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{a(!0),d(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",title:"Mark this needsReview finding as human-verified across all affected pages. The ack persists across crawls as long as the underlying content's matchKey is stable (which it is for ai-alt-uncertain unless the alt text or image structure changes).",children:"Mark verified manually"})}function Bo({page:t,findingGroups:s,needsReviewCount:a,onOpenSinglePage:n}){const[r,o]=m.useState(!1),l=t.walkthroughFindings??[],i=t.walkthroughAcknowledgements??[],d=Math.max(0,t.uniqueViolations-l.length-i.length),p=s.filter(g=>g.needsReview&&g.pages.some(b=>b.url===t.url)),c=s.filter(g=>!g.needsReview&&g.pages.some(b=>b.url===t.url)).map(g=>{var b;return{ruleId:g.ruleId,impact:g.impact,description:g.axeDescription,wcagCriterion:g.wcagCriterion,selector:((b=g.pages.find(w=>w.url===t.url))==null?void 0:b.selector)??g.representativeSelector}}).sort((g,b)=>{const w={critical:0,serious:1,moderate:2,minor:3};return(w[g.impact]??99)-(w[b.impact]??99)}),u=c.length>0||l.length>0||i.length>0||p.length>0||!!t.error,h=t.grade==="A"?"text-emerald-700":t.grade==="B"?"text-lime-700":t.grade==="C"?"text-yellow-700":t.grade==="D"?"text-orange-700":"text-rose-700";return e.jsxs("div",{className:"border-b border-slate-100 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>o(g=>!g),disabled:!u,className:"w-full flex items-center gap-2 text-left px-2 py-1.5 hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white text-xs","aria-expanded":r,children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${h}`,children:t.grade}),e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",onClick:g=>g.stopPropagation(),className:"font-mono text-[11px] text-brand-700 hover:underline break-all flex-1",title:"Open this page in a new browser tab",children:t.url}),e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0 tabular-nums",title:"axe violations only",children:[d," axe"]}),e.jsxs("span",{className:`text-[10px] shrink-0 tabular-nums font-medium ${l.length>0?"text-rose-700":i.length>0?"text-emerald-700":"text-slate-400"}`,children:[l.length," walkthru",i.length>0?` (${i.length}✓)`:""]}),a>0&&e.jsxs("span",{className:"text-[10px] shrink-0 tabular-nums font-medium text-amber-700",title:`${a} item${a===1?"":"s"} flagged for human review`,children:[a," review"]}),u&&e.jsx("span",{className:"text-[10px] text-slate-400 shrink-0 font-mono","aria-hidden":"true",children:r?"−":"+"})]}),r&&u&&e.jsx(Ho,{page:t,axeFindings:c,needsReviewGroups:p,onOpenSinglePage:n})]})}function Ho({page:t,axeFindings:s,needsReviewGroups:a,onOpenSinglePage:n}){const r=`${t.url}::dom:html`,[o,l]=m.useState([]),[i,d]=m.useState({}),[p,c]=m.useState(0);return m.useEffect(()=>{let u=!1;return Promise.all([Ie(r),Ue([r])]).then(([h,g])=>{if(u)return;l(h.filter(w=>w.verdict!=="pass"));const b={};for(const w of g)b[w.criterionId]=w;d(b)}),()=>{u=!0}},[r,p]),e.jsxs("div",{className:"bg-slate-50 px-2 py-2 space-y-2 text-[11px]",children:[t.error&&e.jsxs("p",{className:"text-rose-700",children:["⚠ ",t.error]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["Axe findings (",s.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:s.map((u,h)=>e.jsxs("li",{className:"bg-white border border-slate-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:`font-mono text-[10px] font-bold uppercase px-1 rounded ${u.impact==="critical"?"bg-rose-200 text-rose-900":u.impact==="serious"?"bg-orange-200 text-orange-900":u.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:u.impact}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.description}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.selector})]},`${u.ruleId}::${u.selector}::${h}`))})]}),o.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["AI walkthrough findings (",o.length,")"]}),e.jsx("div",{className:"space-y-2",children:o.map(u=>e.jsx("div",{className:"bg-white border border-slate-200 rounded p-1.5",children:e.jsx(ts,{componentId:r,pageUrl:t.url,criterionId:u.criterionId,record:u,ack:i[u.criterionId]??null,onChanged:()=>c(h=>h+1)})},u.criterionId))})]}),Object.keys(i).length>0&&o.every(u=>i[u.criterionId])&&Object.keys(i).length>o.length&&e.jsx("p",{className:"text-[10px] text-emerald-700",children:"✓ All walkthroughs on this page either passed or are human-verified."}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-amber-700 mb-1",children:["Needs human review (",a.length,")"]}),e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"bg-white border border-amber-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"font-mono text-[10px] font-bold uppercase px-1 rounded bg-amber-200 text-amber-900",children:"review"}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.axeDescription}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.representativeSelector}),u.failureSummary&&e.jsxs("p",{className:"text-[10px] text-slate-600 mt-1 whitespace-pre-wrap",children:[u.failureSummary.slice(0,400),u.failureSummary.length>400?"…":""]}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Ea,{group:u})})]},`${u.ruleId}::${u.representativeSelector}`))})]}),e.jsx("div",{className:"pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-brand-600 hover:underline",children:"Open full single-page view (lenses, visualizers, guided checks) →"})})]})}const It="onboardingDismissed",Et=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function Ko(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(It).then(i=>{i[It]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[It]:!0}),s(!1),n(0)}const o=a===Et.length-1,l=Et[a];return e.jsxs(Me,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Et.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(i=>i-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),o?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(i=>i+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function zo(){const t=y(n=>n.status),s=y(n=>n.errorMessage),a=y(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function qo(){const t=y(d=>d.aiFailure),s=y(d=>d.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",o=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",l="⚠",i=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${o}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:l})," ",i]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Gs(){const[t,s]=m.useState(!1);return m.useEffect(()=>we("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),y.getState().setStatus("idle"))}),[]),e.jsxs(Me,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function Qo(){var o;const[t,s]=m.useState(null);if(m.useEffect(()=>{cn().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await cs(),y.getState().startNewScan(),t.mode==="storybook-all"?Ne({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&Ne({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await cs(),s(null)}const r=t.mode==="storybook-all"?`Story ${((o=t.completedStories)==null?void 0:o.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Rt="storybook:hintDismissed";function Yo(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var i;if((await chrome.storage.local.get(Rt))[Rt])return;const l=await ue();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((i=p.result)==null?void 0:i.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Rt]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function Jo(){var o;const t=y(l=>l.results),s=y(l=>l.baselineList),a=y(l=>l.status),n=(o=t[0])==null?void 0:o.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Xo(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function Xo(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const o=Math.round(r/60);if(o<60)return`${o}m ago`;const l=Math.round(o/60);if(l<24)return`${l}h ago`;const i=Math.round(l/24);return i<7?`${i}d ago`:a.toLocaleDateString()}function Zo(){const t=y(i=>i.results),s=y(i=>i.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let i=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(i)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{i=!0}},[s]),t.length===0)return null;const r=t.flatMap(i=>i.violations),o=dn(r,a.length>0?{runs:a,workflows:fe}:void 0),l=o.manual!==void 0&&o.manual.workflowsCompleted===o.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}const el=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],tl={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function sl(t){const s=new Set(el),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,p])=>({ruleId:d,instanceCount:p})).sort((d,p)=>p.instanceCount-d.instanceCount),r=n.length,o=Array.from(a.values()).reduce((d,p)=>d+p,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:o,flaggedRules:n,headline:tl[l]}}const Ra={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},al={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ra]},nl={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ra]};function as(t){return t==="thorough"?nl:al}function Vs(t){const s=as(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Ta(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,o]=m.useState(0),[l,i]=m.useState(!1),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,g]=m.useState(""),[b,w]=m.useState(!1);if(m.useEffect(()=>{let f=!1;return s(null),n(null),dt().then(j=>{f||s(j)}).catch(j=>{f||n(j instanceof Error?j.message:String(j))}),()=>{f=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const N=t.length,E=t.filter(f=>f.receipt).length;async function I(){if(!(!t||t.length===0)){w(!0);try{await ss({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),i(!1)}finally{w(!1)}}}async function C(){if(!t||t.length===0)return;const f={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},j=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),x=URL.createObjectURL(j),v=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,S=document.createElement("a");S.href=x,S.download=v,S.click(),setTimeout(()=>URL.revokeObjectURL(x),1e3)}return N===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[N," ",N===1?"entry":"entries",E>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[E," RFC 3161-anchored"]})]}),E===0&&N>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>i(f=>!f),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void C(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>o(f=>f+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:f=>p(f.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:c,onChange:f=>u(f.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:h,onChange:f=>g(f.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:b||N===0,onClick:I,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:b?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(f=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${f.grade==="A"?"bg-emerald-100 text-emerald-700":f.grade==="B"?"bg-lime-100 text-lime-700":f.grade==="C"?"bg-yellow-100 text-yellow-700":f.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:f.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:f.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${f.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:f.receipt?`Anchored to ${f.receipt.tsaName} at ${f.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:f.receipt?`RFC 3161 (${f.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:f.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:f.capturedAt}),(f.totals.critical>0||f.totals.serious>0)&&e.jsxs("span",{children:[f.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[f.totals.critical," crit"]}),f.totals.critical>0&&f.totals.serious>0&&" · ",f.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[f.totals.serious," sev"]})]}),e.jsxs("span",{children:[f.statesAudited," ",f.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:f.hash,children:[f.hash.slice(0,12),"…"]})]})]},`${f.componentId}::${f.capturedAt}`))})]})}function rl(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let d=!1;return dt().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,o=t[t.length-1],l=t.slice(0,3),i=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",o&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:o.capturedAt.slice(0,10)})]}),i>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[i," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(Me,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(Ta,{})})})]})}function il(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const ol={eyebrow:"You're on a trial",headline:"Full features unlocked while you evaluate.",body:"When your trial ends, a paid plan keeps RFC 3161 trusted-timestamp anchoring, AI fix suggestions, and audit-history evidence active for every scan."},ll={eyebrow:"You're on the free tier",headline:"Audits run locally — but no forensic record is being kept.",body:"Upgrade to anchor every audit with court-grade trusted timestamps, unlock AI-powered fix suggestions, and build a third-party-verifiable history of your remediation effort."},cl={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},dl={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function $a(){const t=y(u=>u.tier),s=y(u=>u.trialDaysRemaining),a=y(u=>u.seatsUsed),n=y(u=>u.seatsTotal),r=y(u=>u.planCode),o=y(u=>u.licenseDaysRemaining),l=y(u=>u.pastDue),[i,d]=m.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=o,h=u!==null&&u<=7,g=u===null?"":u===0?"expires today":u===1?"1 day left":`${u} days left`;return e.jsxs("aside",{"aria-label":"License status",className:h?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:h?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),g&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",g]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void ne({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ut,{open:i,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?dl:cl,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,g=t==="team"&&a!==null&&n!==null&&a>n,b=t==="team"&&a!==null&&n!==null&&a===n,w=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:g?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:b?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${w.bg} border-b ${w.border} px-3 py-2 space-y-1 text-[11px] ${w.shadow}`,children:[e.jsxs("div",{className:w.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:w.subtitle,children:[" · ",h]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),g&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),b&&!g&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void ne({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const p=t==="trial"?ol:ll,c=t==="trial"?il(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:p.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:c})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void ne({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Ut,{open:i,onClose:()=>d(!1)})]})}const ul={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},pl={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Ws={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},hl={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"},Bs={critical:0,serious:1,moderate:2,minor:3};function ml(){y(p=>p.setUserMode);const t=y(p=>p.status),s=y(p=>p.setStatus),a=y(p=>p.errorMessage),n=y(p=>p.setError),[r,o]=m.useState(!1),[l,i]=m.useState(!1),d=m.useRef(t);return m.useEffect(()=>{if(d.current==="running"&&t==="complete"){i(!0);const p=setTimeout(()=>i(!1),3500);return d.current=t,()=>clearTimeout(p)}d.current=t},[t]),m.useEffect(()=>{if(t!=="running")return;const p=setTimeout(()=>{y.getState().status==="running"&&(s("idle"),n("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(p)},[t,s,n]),e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx($a,{}),e.jsx(ma,{}),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(xa,{}),e.jsx(ha,{})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"Lawsuit-target screener"}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-tight",children:"Find out if your site is on the ADA-targeting bots' radar"})]})]}),t==="running"&&e.jsx(xl,{}),t==="failed"&&a&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:a}),e.jsx("button",{type:"button",onClick:()=>{y.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[r?e.jsx(Ia,{onBack:()=>o(!1)}):e.jsx(fl,{onPickCrawl:()=>o(!0)}),l&&e.jsx(gl,{})]}),e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsx("div",{className:"px-3 py-1.5 text-center leading-tight",children:"Risk indicator based on the same automated WCAG checks ADA-targeting tools use, plus our extended DOM analyzers and AI walkthroughs covering all 50 WCAG 2.1 AA criteria."}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})]})}function xl(){const t=y(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void ne({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function gl(){return e.jsxs("div",{role:"status",className:"absolute top-3 left-1/2 -translate-x-1/2 bg-emerald-600 text-white text-xs font-medium px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 pointer-events-none",style:{zIndex:50},children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{children:"Scan complete"})]})}function fl({onPickCrawl:t}){const s=y(u=>u.status),a=y(u=>u.results),[n,r]=m.useState("quick"),[o,l]=m.useState("all"),i=s==="running",d=a.flatMap(u=>u.violations),p=a.length>0;function c(){Ne({type:"START_AUDIT",mode:"full-page",matrixOverride:as(n)}),y.getState().startNewScan(),ge.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:c,disabled:i,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:i,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(vl,{depth:n,onChange:r,disabled:i})]}),!p&&!i&&e.jsx(bl,{}),p&&e.jsx(yl,{violations:d,severityFilter:o,onSeverityFilterChange:l,scanDepth:n})]})}function bl(){return e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex items-center justify-center w-24 bg-slate-300 text-white shrink-0","aria-label":"Not yet audited",children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:"X"})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"Not yet audited"}),e.jsxs("p",{className:"text-xs mt-1 leading-snug text-slate-600",children:["WCAG compliance level unknown. Open the page you want to check in this tab, then click ",e.jsx("strong",{children:"Scan this page"})," above. Use",e.jsx("strong",{children:" Whole site"})," for a multi-page report."]})]})]})})}function vl({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(Hs,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Vs("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Hs,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Vs("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Hs({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})]})}function yl({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var x;const r=y(v=>v.status),o=y(v=>v.results),l=y(v=>v.freshThisSession),i=y(v=>v.componentId),d=(x=o[0])==null?void 0:x.startedAt,p=sl(t),c=r==="running",[u,h]=m.useState([]);m.useEffect(()=>{if(!i){h([]);return}let v=!1;return chrome.storage.local.get("igtRuns").then(S=>{if(v)return;const T=((S==null?void 0:S.igtRuns)??{})[i]??{};h(Object.values(T))}),()=>{v=!0}},[i]);const g=y(v=>v.acknowledgedKeys),b=o.length>0?ea(o,{runs:u,workflows:fe},"2.1","AA",g):void 0;function w(){Ne({type:"START_AUDIT",mode:"full-page",matrixOverride:as(n)}),y.getState().startNewScan(),ge.polite("Re-scanning this page now.")}const N=s==="lawsuit-risk"?t.filter(v=>v.impact==="critical"||v.impact==="serious"):t,E=new Map;for(const v of N){const S=Le(v.ruleId,v.target.selector);E.has(S)||E.set(S,v)}const I=Array.from(E.values()),C=new Map;for(const v of I){const S=C.get(v.ruleId)??[];S.push(v),C.set(v.ruleId,S)}const f=Array.from(C.entries()).sort((v,S)=>(Bs[v[1][0].impact]??99)-(Bs[S[1][0].impact]??99)),j=t.filter(v=>v.impact==="critical"||v.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Al,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void vt(),disabled:c,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:w,disabled:c,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:c?"Scanning…":"↻ Scan again"})]})]}),c?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${ul[p.tier]}`,children:[!l&&d&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${pl[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${Ws[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Ws[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged",p.flaggedInstanceCount>p.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:p.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!c&&b&&!b.canClaimConformance&&e.jsx(wl,{coverage:b}),!c&&b&&b.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",b.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(Sl,{}),e.jsx(rl,{}),t.length>0&&e.jsx(jl,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:j}),e.jsxs("div",{className:"space-y-2",children:[f.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),f.map(([v,S])=>e.jsx(Nl,{ruleId:v,violations:S},v))]})]})}function wl({coverage:t}){const s=y(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),ne({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function jl({filter:t,onChange:s,totalCount:a,lawsuitRiskCount:n}){return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Show"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("button",{type:"button",onClick:()=>s("all"),"aria-pressed":t==="all",className:`text-left rounded p-2 border transition-colors ${t==="all"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"All issues"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[a," total"]})]}),e.jsxs("button",{type:"button",onClick:()=>s("lawsuit-risk"),"aria-pressed":t==="lawsuit-risk",className:`text-left rounded p-2 border transition-colors ${t==="lawsuit-risk"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"Lawsuit risk only"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[n," critical/serious"]})]})]})]})}function Nl({ruleId:t,violations:s}){var u;const[a,n]=m.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,o=un(t,r),l=s[0].impact,i=s[0],p=o.whatsWrong==="An accessibility rule failed on this page."&&i.description?i.description:o.whatsWrong,c=i.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${hl[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",o.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",o.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,g)=>e.jsx(kl,{violation:h},g))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function kl({violation:t}){const s=y(o=>{var l;return(l=o.results[0])==null?void 0:l.frameId}),[a,n]=m.useState(null);async function r(o){o.stopPropagation();const l=await ue();if(l)try{const i=await Ee(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(i.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const st=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function Sl(){const t=y(c=>c.results),s=y(c=>c.componentId),[a,n]=m.useState(null),[r,o]=m.useState(!1),[l,i]=m.useState(null);async function d(c,u){if(t.length!==0){n(c);try{const h=await Z({type:"EXPORT_REQUEST",format:c,results:t,wallClockMs:y.getState().lastAuditWallClockMs??void 0});if(c==="defense-bundle"||c==="evidence-bundle"){const g=ft(c,s);await ia()?et(h.content,g):i({open:!0,format:c,content:h.content,filename:g})}else if(u)$e(h.content);else{try{await navigator.clipboard.writeText(h.content),ge.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const b=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
269
269
  <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
270
270
  .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
271
271
  pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
272
272
  <div class="banner"><strong>✓ Copied to clipboard.</strong> Paste this into ChatGPT, Claude, or your favorite AI assistant. The AI will walk you through fixes for your specific situation.</div>
273
- <pre>${h.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`;$e(b,"text/html")}}finally{n(null)}}}const p=r?at:at.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:p.map(c=>e.jsx("button",{type:"button",onClick:()=>void d(c.id,c.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:c.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:c.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:c.desc})]}),a===c.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},c.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",at.length-2," more report option",at.length-2===1?"":"s"," ↓"]}),l&&e.jsx(wa,{open:l.open,onClose:()=>i(null),format:l.format,content:l.content,filename:l.filename})]})}function Sl({iso:t}){const[,s]=m.useState(0);m.useEffect(()=>{const n=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(n)},[]);const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<5?e.jsx("span",{children:"just now"}):a<60?e.jsxs("span",{children:[a," seconds ago"]}):a<120?e.jsx("span",{children:"1 minute ago"}):a<3600?e.jsxs("span",{children:[Math.floor(a/60)," minutes ago"]}):a<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(a/3600)," hours ago"]})}function Al(t,s,a){const n=new Set,r=[];let o=!1;for(const[l,i]of s)for(const d of i){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),o=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:l,selector:c.target.selector})}const p=d.axeRulesEvaluated;if(p){for(const c of p.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of p.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of p.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),o=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:o}}function Cl(t,s,a){const n=[];let r=0,o=0,l=0,i=0;for(const p of a){const c=p.steps.filter(u=>u.wcag===t);if(c.length!==0){r+=c.length;for(const[u,h]of s){const x=h[p.id];if(!x){o+=c.length;continue}for(const b of c){const w=x.steps[b.id];if(!w){o++;continue}w.status==="fail"?(l++,n.push({source:"igt",ruleOrStepId:`${p.id}.${b.id}`,description:b.question,pageUrl:u,notes:w.notes})):w.status==="skip"?o++:w.status==="not-applicable"?(l++,i++):l++}}}}const d=l>0&&i===l;return{stepsCovering:r,failures:n,unanswered:o,allNotApplicable:d}}function Il(t,s,a,n){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":n&&t.axeRulesFiringForCriterion===0?"not-applicable":"pass"}function El(t,s,a){switch(s){case"pass":return`${a.axeRulesFiringForCriterion+a.igtStepsCoveringCriterion} signal(s) covered this criterion; no failures recorded.`;case"fail":return`${a.axeFailures.length} automated finding(s), ${a.igtFailures.length} manual finding(s) failed this criterion.`;case"inconclusive":return"Some manual checks for this criterion are unanswered or skipped; rerun the relevant IGT workflow to resolve.";case"not-evaluated":return"No automated rule and no guided-test step in the wcagcheckr ruleset maps to this criterion. Manual review required.";case"not-applicable":return"Marked not applicable by the evaluator."}}function Rl(t,s){var u;const a=[];for(const h of s.auditsByUrl.values())a.push(...h);const n=[];for(const h of s.igtRunsByUrl.values())n.push(...Object.values(h));const r=Kt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),o=un(t.targetVersion,t.targetLevel),l=[];for(const h of o){const x=Al(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),b=Cl(h.id,s.igtRunsByUrl,s.workflows),w=x.rulesFiring.size===0&&b.stepsCovering===0,N={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:b.stepsCovering,igtFailures:b.failures,unmapped:w},E=(u=t.overrides)==null?void 0:u[h.id];let I,C,f=!1;if(E)I=E.verdict,C=E.rationale,f=!0;else{const j=r.get(h.id);j?I=j.state:I=Il(N,b.unanswered,x.hasIncomplete,b.allNotApplicable),C=El(h,I,N)}l.push({criterion:h,understandingUrl:pn(h,t.targetVersion),verdict:I,signals:N,overridden:f,rationale:C})}const i={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of l)h.verdict==="pass"?i.pass++:h.verdict==="fail"?i.fail++:h.verdict==="inconclusive"?i.inconclusive++:h.verdict==="not-applicable"?i.notApplicable++:h.verdict==="not-evaluated"&&i.notEvaluated++;function d(h){const x={A:1,AA:2,AAA:3},b=x[h];return l.every(w=>x[w.criterion.level]>b?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let p=null;d("AAA")?p="AAA":d("AA")?p="AA":d("A")&&(p="A");const c=p===t.targetLevel||p==="AAA"&&t.targetLevel==="AA"||p==="AAA"&&t.targetLevel==="A"||p==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:l,summary:{totalCriteria:l.length,pass:i.pass,fail:i.fail,inconclusive:i.inconclusive,notApplicable:i.notApplicable,notEvaluated:i.notEvaluated,levelAchieved:p,meetsTarget:c}}}const Tl={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Ks={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function D(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function He(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function $l(t,s,a,n){const{inputs:r,rows:o,summary:l,generatedAt:i}=t,d=l.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,p=new Map;for(const u of o){const h=u.criterion.id.split(".").slice(0,2).join("."),x=p.get(h)??[];x.push(u),p.set(h,x)}const c=Array.from(p.entries()).sort(([u],[h])=>u.localeCompare(h,void 0,{numeric:!0})).map(([u,h])=>`
273
+ <pre>${h.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`;$e(b,"text/html")}}finally{n(null)}}}const p=r?st:st.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:p.map(c=>e.jsx("button",{type:"button",onClick:()=>void d(c.id,c.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:c.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:c.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:c.desc})]}),a===c.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},c.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",st.length-2," more report option",st.length-2===1?"":"s"," ↓"]}),l&&e.jsx(ja,{open:l.open,onClose:()=>i(null),format:l.format,content:l.content,filename:l.filename})]})}function Al({iso:t}){const[,s]=m.useState(0);m.useEffect(()=>{const n=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(n)},[]);const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<5?e.jsx("span",{children:"just now"}):a<60?e.jsxs("span",{children:[a," seconds ago"]}):a<120?e.jsx("span",{children:"1 minute ago"}):a<3600?e.jsxs("span",{children:[Math.floor(a/60)," minutes ago"]}):a<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(a/3600)," hours ago"]})}function Cl(t,s,a){const n=new Set,r=[];let o=!1;for(const[l,i]of s)for(const d of i){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),o=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:l,selector:c.target.selector})}const p=d.axeRulesEvaluated;if(p){for(const c of p.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of p.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of p.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),o=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:o}}function Il(t,s,a){const n=[];let r=0,o=0,l=0,i=0;for(const p of a){const c=p.steps.filter(u=>u.wcag===t);if(c.length!==0){r+=c.length;for(const[u,h]of s){const g=h[p.id];if(!g){o+=c.length;continue}for(const b of c){const w=g.steps[b.id];if(!w){o++;continue}w.status==="fail"?(l++,n.push({source:"igt",ruleOrStepId:`${p.id}.${b.id}`,description:b.question,pageUrl:u,notes:w.notes})):w.status==="skip"?o++:w.status==="not-applicable"?(l++,i++):l++}}}}const d=l>0&&i===l;return{stepsCovering:r,failures:n,unanswered:o,allNotApplicable:d}}function El(t,s,a,n){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":n&&t.axeRulesFiringForCriterion===0?"not-applicable":"pass"}function Rl(t,s,a){switch(s){case"pass":return`${a.axeRulesFiringForCriterion+a.igtStepsCoveringCriterion} signal(s) covered this criterion; no failures recorded.`;case"fail":return`${a.axeFailures.length} automated finding(s), ${a.igtFailures.length} manual finding(s) failed this criterion.`;case"inconclusive":return"Some manual checks for this criterion are unanswered or skipped; rerun the relevant IGT workflow to resolve.";case"not-evaluated":return"No automated rule and no guided-test step in the wcagcheckr ruleset maps to this criterion. Manual review required.";case"not-applicable":return"Marked not applicable by the evaluator."}}function Tl(t,s){var u;const a=[];for(const h of s.auditsByUrl.values())a.push(...h);const n=[];for(const h of s.igtRunsByUrl.values())n.push(...Object.values(h));const r=Kt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),o=pn(t.targetVersion,t.targetLevel),l=[];for(const h of o){const g=Cl(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),b=Il(h.id,s.igtRunsByUrl,s.workflows),w=g.rulesFiring.size===0&&b.stepsCovering===0,N={axeRulesFiringForCriterion:g.rulesFiring.size,axeFailures:g.failures,igtStepsCoveringCriterion:b.stepsCovering,igtFailures:b.failures,unmapped:w},E=(u=t.overrides)==null?void 0:u[h.id];let I,C,f=!1;if(E)I=E.verdict,C=E.rationale,f=!0;else{const j=r.get(h.id);j?I=j.state:I=El(N,b.unanswered,g.hasIncomplete,b.allNotApplicable),C=Rl(h,I,N)}l.push({criterion:h,understandingUrl:hn(h,t.targetVersion),verdict:I,signals:N,overridden:f,rationale:C})}const i={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of l)h.verdict==="pass"?i.pass++:h.verdict==="fail"?i.fail++:h.verdict==="inconclusive"?i.inconclusive++:h.verdict==="not-applicable"?i.notApplicable++:h.verdict==="not-evaluated"&&i.notEvaluated++;function d(h){const g={A:1,AA:2,AAA:3},b=g[h];return l.every(w=>g[w.criterion.level]>b?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let p=null;d("AAA")?p="AAA":d("AA")?p="AA":d("A")&&(p="A");const c=p===t.targetLevel||p==="AAA"&&t.targetLevel==="AA"||p==="AAA"&&t.targetLevel==="A"||p==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:l,summary:{totalCriteria:l.length,pass:i.pass,fail:i.fail,inconclusive:i.inconclusive,notApplicable:i.notApplicable,notEvaluated:i.notEvaluated,levelAchieved:p,meetsTarget:c}}}const $l={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Ks={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function D(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function He(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function Ll(t,s,a,n){const{inputs:r,rows:o,summary:l,generatedAt:i}=t,d=l.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,p=new Map;for(const u of o){const h=u.criterion.id.split(".").slice(0,2).join("."),g=p.get(h)??[];g.push(u),p.set(h,g)}const c=Array.from(p.entries()).sort(([u],[h])=>u.localeCompare(h,void 0,{numeric:!0})).map(([u,h])=>`
274
274
  <h3 class="guideline-h">Guideline ${D(u)}</h3>
275
275
  <table class="criteria-table">
276
276
  <thead>
@@ -279,22 +279,22 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
279
279
  </tr>
280
280
  </thead>
281
281
  <tbody>
282
- ${h.map(x=>`
283
- <tr class="${Ks[x.verdict]}">
284
- <td><a href="${D(x.understandingUrl)}" target="_blank" rel="noopener">${D(x.criterion.id)}</a></td>
285
- <td>${D(x.criterion.title)}</td>
286
- <td>${D(x.criterion.level)}</td>
287
- <td><span class="verdict-badge ${Ks[x.verdict]}">${Tl[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
288
- <td class="rationale">${D(x.rationale)}</td>
282
+ ${h.map(g=>`
283
+ <tr class="${Ks[g.verdict]}">
284
+ <td><a href="${D(g.understandingUrl)}" target="_blank" rel="noopener">${D(g.criterion.id)}</a></td>
285
+ <td>${D(g.criterion.title)}</td>
286
+ <td>${D(g.criterion.level)}</td>
287
+ <td><span class="verdict-badge ${Ks[g.verdict]}">${$l[g.verdict]}</span>${g.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
288
+ <td class="rationale">${D(g.rationale)}</td>
289
289
  </tr>
290
- ${x.signals.axeFailures.length>0||x.signals.igtFailures.length>0?`
290
+ ${g.signals.axeFailures.length>0||g.signals.igtFailures.length>0?`
291
291
  <tr class="evidence-row">
292
292
  <td></td>
293
293
  <td colspan="4">
294
294
  <details>
295
- <summary>${x.signals.axeFailures.length+x.signals.igtFailures.length} failure instance${x.signals.axeFailures.length+x.signals.igtFailures.length===1?"":"s"}</summary>
295
+ <summary>${g.signals.axeFailures.length+g.signals.igtFailures.length} failure instance${g.signals.axeFailures.length+g.signals.igtFailures.length===1?"":"s"}</summary>
296
296
  <ul>
297
- ${[...x.signals.axeFailures,...x.signals.igtFailures].slice(0,20).map(b=>`
297
+ ${[...g.signals.axeFailures,...g.signals.igtFailures].slice(0,20).map(b=>`
298
298
  <li>
299
299
  <code>${D(b.ruleOrStepId)}</code>
300
300
  ${b.pageUrl?` on <a href="${D(b.pageUrl)}" target="_blank" rel="noopener"><code>${D(b.pageUrl)}</code></a>`:""}
@@ -303,7 +303,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
303
303
  ${b.notes?`<br><em>${D(b.notes)}</em>`:""}
304
304
  </li>
305
305
  `).join("")}
306
- ${x.signals.axeFailures.length+x.signals.igtFailures.length>20?`<li class="ev-more">…and ${x.signals.axeFailures.length+x.signals.igtFailures.length-20} more.</li>`:""}
306
+ ${g.signals.axeFailures.length+g.signals.igtFailures.length>20?`<li class="ev-more">…and ${g.signals.axeFailures.length+g.signals.igtFailures.length-20} more.</li>`:""}
307
307
  </ul>
308
308
  </details>
309
309
  </td>
@@ -572,9 +572,9 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
572
572
  <span>${l.totalCriteria} criteria · ${l.pass} pass · ${l.fail} fail · ${l.inconclusive} inconclusive</span>
573
573
  </footer>
574
574
  </body>
575
- </html>`}async function Ul(t,s,a,n){const r=$l(t,s,a,n),o=new Blob([r],{type:"text/html;charset=utf-8"}),l=URL.createObjectURL(o);await chrome.tabs.create({url:l})}const Tt=aa("wcag-em-anchor"),Ll="https://api.wcagcheckr.com",_l="wcagcheckr",Dl=15e3;function $a(t){return{scope:{siteName:t.inputs.siteName,siteUrl:t.inputs.siteUrl,targetVersion:t.inputs.targetVersion,targetLevel:t.inputs.targetLevel,accessibilitySupportBaseline:t.inputs.accessibilitySupportBaseline,additionalStandards:t.inputs.additionalStandards??[]},evaluator:{name:t.inputs.evaluator.name,organization:t.inputs.evaluator.organization??null,qualifications:t.inputs.evaluator.qualifications??null,contact:t.inputs.evaluator.contact??null},sample:{pages:t.inputs.pageSample.map(s=>({url:s.url,type:s.pageType,selectionType:s.selectionType,hasAuditData:s.hasAuditData}))},verdicts:t.rows.map(s=>({sc:s.criterion.id,level:s.criterion.level,verdict:s.verdict,overridden:s.overridden,axeFailureCount:s.signals.axeFailures.length,igtFailureCount:s.signals.igtFailures.length})),summary:{totalCriteria:t.summary.totalCriteria,pass:t.summary.pass,fail:t.summary.fail,inconclusive:t.summary.inconclusive,notApplicable:t.summary.notApplicable,notEvaluated:t.summary.notEvaluated,levelAchieved:t.summary.levelAchieved,meetsTarget:t.summary.meetsTarget},generatedAt:t.generatedAt}}async function Ol(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function Fl(t){return Ol(hn($a(t)))}function Ml(t){if(typeof t!="object"||t===null)return!1;const s=t;return s.schemaVersion!==1&&s.schemaVersion!==2||!(typeof s.anchoredAt=="string"&&typeof s.tsaName=="string"&&typeof s.rfc3161TokenBase64=="string"&&s.rfc3161TokenBase64.length>0&&typeof s.serverSignatureBase64=="string"&&s.serverSignatureBase64.length>0&&typeof s.serverKeyFingerprint=="string"&&s.serverKeyFingerprint.length>0)?!1:s.schemaVersion===2?typeof s.prevAuditHash=="string"&&/^[0-9a-f]{64}$/.test(s.prevAuditHash):!0}async function Pl(t,s){const a=await Fl(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Ll}/v1/products/${_l}/forensic/anchor`;try{const o=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Dl)});if(!o.ok)return Tt.warn(`anchor HTTP ${o.status}`),null;const l=await o.json();return Ml(l)?{reportHash:a,capturedAt:t.generatedAt,receipt:l}:(Tt.warn("anchor returned malformed receipt",l),null)}catch(o){return Tt.warn("anchor request failed",o),null}}function Gl(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:$a(t)}}const Gt="auditAttestations",Vt="auditAttestation:defaultSigner";function ns(t,s){return`${t}::${s}`}async function rs(){try{const s=(await chrome.storage.local.get(Gt))[Gt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ua(t){await chrome.storage.local.set({[Gt]:t})}async function Vl(t){const s=await rs();s[ns(t.componentId,t.auditCapturedAt)]=t,await Ua(s)}async function La(t,s){return(await rs())[ns(t,s)]??null}async function Wl(t,s){const a=await rs();delete a[ns(t,s)],await Ua(a)}async function Bl(){try{const s=(await chrome.storage.local.get(Vt))[Vt];return s&&typeof s=="object"?s:null}catch{return null}}async function Hl(t){await chrome.storage.local.set({[Vt]:t})}function Kl(t,s){return t.auditCapturedAt!==s}function zl(t){return`I attest that this audit, dated [DATE], represents a good-faith evaluation of ${t.scope} for WCAG ${t.targetVersion} Level ${t.targetLevel} conformance. The methodology relied on automated analysis + AI-assisted determinations, covering ${t.evaluatedCount} of ${t.totalCount} applicable criteria. I have reviewed the findings + spot-audit verifications and take responsibility for the conclusions presented.`}function ql(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[o,l]=m.useState(!1),[i,d]=m.useState(""),[p,c]=m.useState(""),[u,h]=m.useState(""),[x,b]=m.useState(""),[w,N]=m.useState("");m.useEffect(()=>{let j=!1;return Promise.all([La(t.componentId,t.auditCapturedAt),Bl()]).then(([g,v])=>{j||(a(g),g?(d(g.signerName),c(g.signerEmail),h(g.signerOrganization??""),b(g.signerQualifications??""),N(g.claim)):v&&(d(v.signerName),c(v.signerEmail),h(v.signerOrganization??""),b(v.signerQualifications??"")),N(S=>S||zl({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{j=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function E(){if(!i.trim()||!p.trim())return;const j={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:i.trim(),signerEmail:p.trim(),signerOrganization:u.trim()||void 0,signerQualifications:x.trim()||void 0,claim:w.trim(),scope:t.scope};await Vl(j),await Hl({signerName:j.signerName,signerEmail:j.signerEmail,signerOrganization:j.signerOrganization,signerQualifications:j.signerQualifications}),a(j),l(!1)}async function I(){await Wl(t.componentId,t.auditCapturedAt),a(null),l(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const C=s&&Kl(s,t.auditCapturedAt);if(s&&!C&&!o)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void I(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&C&&!o)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const f=i.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:i,onChange:j=>d(j.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:p,onChange:j=>c(j.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:u,onChange:j=>h(j.target.value),placeholder:"Acme Corp",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Qualifications"}),e.jsx("input",{type:"text",value:x,onChange:j=>b(j.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:w,onChange:j=>N(j.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[o&&e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!f,onClick:()=>void E(),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"🔏 Sign and seal"})]})]})}const Wt="spotAuditReviews";function _a(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function is(){try{const s=(await chrome.storage.local.get(Wt))[Wt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Da(t){await chrome.storage.local.set({[Wt]:t})}async function Ql(t){const s=await is();s[t.key]=t,await Da(s)}async function Yl(t){const s=await is();delete s[t],await Da(s)}async function Oa(){const t=await is();return Object.values(t)}function Fa(t,s){const a=new Map(s.map(l=>[l.key,l]));let n=0,r=0,o=0;for(const l of t){const i=a.get(l);i&&(n++,i.verdict==="agreed"?r++:o++)}return{total:t.length,reviewed:n,agreed:r,disagreed:o}}function Jl(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),o=a[n];a[n]=a[r],a[r]=o}return a.slice(0,Math.min(s,a.length))}function Xl(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const o of r.evidence){if(o.source!=="ai")continue;const l=o.ruleOrStepId.startsWith("ai-resolved::")?o.ruleOrStepId.slice(13):o.ruleOrStepId,i=o.pageUrl&&o.selector?a.get(`${o.pageUrl}::${l}::${o.selector}`):void 0;n.push({key:_a({criterionId:r.criterionId,ruleOrStepId:o.ruleOrStepId,pageUrl:o.pageUrl,selector:o.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:o.ruleOrStepId,outcome:o.outcome,pageUrl:o.pageUrl,selector:o.selector,resolutionHint:o.resolutionHint,aiReasoning:i})}return n}const Zl={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",incomplete:"bg-amber-100 text-amber-800",inapplicable:"bg-slate-100 text-slate-700",ack:"bg-sky-100 text-sky-800",skip:"bg-slate-100 text-slate-700","n/a":"bg-slate-100 text-slate-700"},ec={pass:"AI: pass",fail:"AI: fail",incomplete:"AI: uncertain",inapplicable:"AI: n/a",ack:"AI flagged · user acked",skip:"AI: skip","n/a":"AI: n/a"};function tc({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>Xl(t,s),[t,s]),[n,r]=m.useState([]),[o,l]=m.useState(!0),[i,d]=m.useState(null),[p,c]=m.useState(5),[u,h]=m.useState(!1);m.useEffect(()=>{let f=!1;return Oa().then(j=>{f||(r(j),l(!1))}),()=>{f=!0}},[]);const x=m.useMemo(()=>a.map(f=>f.key),[a]),b=m.useMemo(()=>Fa(x,n),[x,n]),N=(u?x:i||n.filter(f=>x.includes(f.key)).map(f=>f.key)).map(f=>a.find(j=>j.key===f)).filter(f=>!!f);async function E(f,j,g){const v={key:f.key,criterionId:f.criterionId,ruleOrStepId:f.ruleOrStepId,pageUrl:f.pageUrl,selector:f.selector,verdict:j,correction:(g==null?void 0:g.trim())||void 0,reviewedAt:new Date().toISOString()};await Ql(v),r(S=>[v,...S.filter(k=>k.key!==v.key)])}async function I(f){await Yl(f.key),r(j=>j.filter(g=>g.key!==f.key))}function C(){d(Jl(x,p)),h(!1)}return a.length===0?e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"mt-2 leading-snug",children:"This audit has no AI determinations yet. Spot-auditing becomes available once AI judgment runs against ambiguous findings (alt-text, color-only meaning, axe-incomplete, etc.)."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI did the determination work. You can audit a sample — pick a random N, review what the AI decided, and mark whether you agree. Your spot-check rate is included in the report."})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-center bg-slate-50 border border-slate-200 rounded p-2",children:[e.jsx(nt,{label:"AI determinations",value:b.total}),e.jsx(nt,{label:"Reviewed",value:b.reviewed,accent:"text-slate-900"}),e.jsx(nt,{label:"Agreed",value:b.agreed,accent:"text-emerald-700"}),e.jsx(nt,{label:"Disagreed",value:b.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:p,onChange:f=>c(Math.max(1,Math.min(a.length,Number(f.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:C,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{h(f=>!f),d(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:u?"Hide list":`Show all (${a.length})`}),i&&e.jsx("button",{type:"button",onClick:()=>d(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),o?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):N.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:N.map(f=>e.jsx(sc,{row:f,review:n.find(j=>j.key===f.key)??null,onAgree:()=>void E(f,"agreed"),onDisagree:j=>void E(f,"disagreed",j),onClear:()=>void I(f)},f.key))})]})}function nt({label:t,value:s,accent:a="text-slate-900"}){return e.jsxs("div",{children:[e.jsx("p",{className:`text-base font-bold ${a}`,children:s}),e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:t})]})}function sc(t){const{row:s,review:a}=t,[n,r]=m.useState(!1),[o,l]=m.useState((a==null?void 0:a.correction)??""),i=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${i==="agreed"?"border-emerald-300 bg-emerald-50/50":i==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${Zl[s.outcome]}`,children:ec[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${i==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${i==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),i&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&i==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:o,onChange:d=>l(d.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(o),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),l((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function _e(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[o,l]=m.useState(!1),[i,d]=m.useState(null),[p,c]=m.useState(null),[u,h]=m.useState(!1),[x,b]=m.useState(""),[w,N]=m.useState(!1),[E,I]=m.useState(null);m.useEffect(()=>{let v=!1;return Promise.all([mn(t.componentId,t.criterionId),xn(t.componentId,t.criterionId,t.pageUrl)]).then(([S,k])=>{v||(a(S),c(k),r(!1))}),()=>{v=!0}},[t.componentId,t.criterionId,t.pageUrl]);async function C(){l(!0),d(null);try{const S=await ae({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});S.ok?S.result&&a(S.result):d(S.error??"Audit failed.")}catch(v){d(v instanceof Error?v.message:String(v))}finally{l(!1)}}async function f(){await fn(t.componentId,t.criterionId),a(null)}async function j(){if(s){N(!0),I(null);try{if(!x||!x.trim()){I("Note is required — explain how you manually verified this."),N(!1);return}if(s.verdict==="pass"){I("This walkthrough already passed — no acknowledgement needed."),N(!1);return}const v={componentId:t.componentId,criterionId:t.criterionId,pageUrl:t.pageUrl,note:x.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:s.verdict};await zt(v),c(v),h(!1),b("")}catch(v){I(v instanceof Error?v.message:String(v))}finally{N(!1)}}}async function g(){N(!0);try{await gn(t.componentId,t.criterionId,t.pageUrl),c(null)}finally{N(!1)}}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!i&&e.jsx("button",{type:"button",onClick:()=>void C(),disabled:o,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:o?"Running AI walkthrough…":"Run AI walkthrough"}),i&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:i}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:o,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:o?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${_t(s.reasoning)?"border-2 border-amber-500 bg-amber-50":s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[_t(s.reasoning)&&e.jsxs("div",{className:"bg-amber-100 border border-amber-400 rounded p-2 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500 text-white font-bold uppercase tracking-wide",children:"AI cascade flagged this"})}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:["AI's automation paths all flagged this criterion. The verdict is",e.jsx("strong",{children:" fail"}),". The path forward is to fix the underlying issue on the page and re-audit. Read AI's reasoning below to see what it flagged."]}),e.jsxs("details",{className:"text-[11px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-40 overflow-y-auto bg-white/60 p-2 rounded",children:s.reasoning})]}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:o,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",title:"After fixing the page, re-run the walkthrough to confirm the fix.",children:o?"Re-running…":"Re-run walkthrough"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:ta(s.reasoning)?`Manual · ${s.verdict}`:Dt(s.reasoning)?`Cascade · ${Dt(s.reasoning)} → ${s.verdict}`:`AI: ${s.verdict}`}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug whitespace-pre-wrap",children:s.reasoning}),(()=>{const v=(s.steps??[]).filter(S=>S.action!=="initial").length;return v===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"Step-replay data not retained for past audits (saves storage). Re-run the walkthrough to see the live step recording."}):e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",v," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(S=>S.action!=="initial").map(S=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",S.focused.role||S.focused.tag,"]"]})," ",S.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:S.focused.selector})]},S.ordinal))})]})})(),s.verdict!=="pass"&&e.jsx("div",{className:"mt-2 pt-2 border-t border-dashed border-slate-300",children:p?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-200 text-emerald-900 font-bold uppercase tracking-wide",children:"✓ Human verified"}),e.jsx("span",{className:"text-[10px] text-emerald-800",children:new Date(p.acknowledgedAt).toLocaleString()})]}),e.jsxs("p",{className:"text-[11px] text-emerald-900 leading-snug",children:[e.jsx("strong",{children:"Verification note:"})," ",p.note]}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:w,className:"text-[10px] px-2 py-0.5 border border-emerald-300 bg-white text-emerald-800 rounded hover:bg-emerald-50 disabled:opacity-50",children:w?"Removing…":"Un-acknowledge"})]}):u?e.jsxs("div",{className:"bg-slate-50 border border-slate-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-slate-700 block",children:"Manual verification note (required)"}),e.jsxs("p",{className:"text-[10px] text-slate-600 leading-snug",children:["Describe what you did to verify this passes WCAG ",t.criterionId,". This note becomes part of the forensic record on every export — be specific."]}),e.jsx("textarea",{value:x,onChange:v=>b(v.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-slate-300 rounded resize-y min-h-[60px]",autoFocus:!0}),E&&e.jsx("p",{className:"text-[10px] text-rose-700",children:E}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void j(),disabled:w,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:w?"Saving…":"Confirm acknowledgement"}),e.jsx("button",{type:"button",onClick:()=>{h(!1),b(""),I(null)},disabled:w,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{h(!0),I(null)},className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",title:"After verifying manually that this criterion passes, log your verification here. Required note is preserved in the forensic record.",children:"Mark verified manually"})}),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void C(),disabled:o,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:o?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void f(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function ac(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return ue().then(r=>{n||a(r??null)}),()=>{n=!0}},[]),s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI drives a keyboard user through the page to evaluate criteria that require lived-experience judgment. Each walkthrough produces an AI verdict that flows into the conformance report. You can spot-check the AI's reasoning in the panel below."})]}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.3",criterionTitle:"Focus Order",description:"AI walks the page Tab-by-Tab, comparing the focus sequence to the visible layout. Verdict: does the order follow a logical reading sequence?"}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.1.2",criterionTitle:"No keyboard trap",description:"AI Tab-walks forward then Shift-Tab-walks backward, checking for traps: elements where focus gets stuck, or where Shift-Tab can't reverse out of a region. Verdict: can the user always leave?"}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.7",criterionTitle:"Focus visible",description:"AI Tab-walks the page and captures a screenshot at each focused element. Vision then judges whether a visible focus indicator (outline, ring, or compensating treatment) is present on every sampled element."}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.3.2",criterionTitle:"Meaningful Sequence (reading order)",description:"AI vision judges whether the heuristic-flagged DOM-vs-visual order divergences are real reading-order breaks or normal multi-column / banked layout patterns. Looks at the page screenshot + the flagged element list."}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.5.3",criterionTitle:"Label in Name",description:"Programmatic DOM walk + AI fallback. Scans every interactive control for a mismatch between its visible label text and its programmatically-determined accessible name — the failure mode that breaks speech recognition (e.g., visible 'Submit' but accessible 'Continue')."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const zs="igtRuns",nc={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",inconclusive:"bg-amber-100 text-amber-800","not-evaluated":"bg-slate-100 text-slate-700","not-applicable":"bg-slate-50 text-slate-500"},rc={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function ic(){var ne,le,pe;const t=y(L=>L.results),s=y(L=>L.acknowledgedKeys),[a,n]=m.useState(""),[r,o]=m.useState(""),l=vn,i=bn,[d,p]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,u]=m.useState(""),[h,x]=m.useState(""),[b,w]=m.useState(""),[N,E]=m.useState(""),[I,C]=m.useState(""),[f,j]=m.useState(""),[g,v]=m.useState({}),[S,k]=m.useState(!1),[T,V]=m.useState([]),[P,B]=m.useState([]),[U,q]=m.useState(null),[$,_]=m.useState(!1),[F,H]=m.useState(null);m.useEffect(()=>{let L=!1;return chrome.storage.local.get(zs).then(X=>{if(L)return;const z=X[zs]??{};v(z),k(!0)}).catch(()=>{L||k(!0)}),()=>{L=!0}},[]),m.useEffect(()=>{var he;const L=(he=t[0])==null?void 0:he.componentId;if(!L)return;let X=!1;const z=()=>{Ie(L).then(de=>{X||B(de.map(xe=>({criterionId:xe.criterionId,ruleId:`ai-interactive::${xe.criterionId}`,pageUrl:xe.pageUrl,verdict:xe.verdict,reasoning:xe.reasoning})))})};z();const Y=de=>{de.interactiveAuditResults&&z()};return chrome.storage.local.onChanged.addListener(Y),()=>{X=!0,chrome.storage.local.onChanged.removeListener(Y)}},[t]),m.useEffect(()=>{var L;if(!a&&((L=t[0])!=null&&L.pageUrl))try{const X=new URL(t[0].pageUrl);n(X.hostname),o(X.origin)}catch{}},[t,a]),m.useEffect(()=>{const L=new Set;for(const z of t)L.add(z.pageUrl??z.scope);if(L.size===0){V([]);return}let X=!1;return Promise.all(Array.from(L).map(z=>qe(z))).then(z=>{X||V(z.flat())}).catch(()=>{}),()=>{X=!0}},[t]);const R=m.useMemo(()=>{const L=new Map,X=new Map;for(const Y of t){const he=Y.pageUrl??Y.scope,de=L.get(he)??[];de.push(Y),L.set(he,de)}const z=new Map;for(const Y of t){const he=Y.pageUrl??Y.scope;z.set(Y.componentId,he)}for(const[Y,he]of Object.entries(g)){const de=z.get(Y);if(!de)continue;const xe=X.get(de)??{};Object.assign(xe,he),X.set(de,xe)}return{auditsByUrl:L,igtRunsByUrl:X,workflows:fe,acknowledgedMatchKeys:s,incompleteResolutions:T,interactiveAuditResults:P}},[t,g,s,T,P]),M=m.useMemo(()=>{const L=[],X=new Set;for(const z of R.auditsByUrl.keys())X.has(z)||(X.add(z),L.push({url:z,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const z of f.split(`
576
- `).map(Y=>Y.trim()).filter(Boolean))X.has(z)||(X.add(z),L.push({url:z,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return L},[R,f]),ie=m.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:l,targetLevel:i,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(L=>L.trim()).filter(Boolean),pageSample:M,evaluator:{name:h||"(evaluator name pending)",organization:b||void 0,qualifications:N||void 0,contact:I||void 0}}),[a,r,l,i,d,c,M,h,b,N,I]),A=m.useMemo(()=>S?Rl(ie,R):null,[ie,R,S]),G=m.useMemo(()=>{const L=Array.from(R.auditsByUrl.values()).flat(),X=Object.values(g).flatMap(z=>Object.values(z));return Kt({audits:L,igtRuns:X,workflows:fe,acknowledgedMatchKeys:s,incompleteResolutions:T,interactiveAuditResults:P})},[R,g,s,T,P]);async function W(){if(!A)return;const L=t[0],X=L!=null&&L.componentId&&(L!=null&&L.startedAt)?await La(L.componentId,L.startedAt):null,z=await Oa(),Y=[];for(const de of G.values())for(const xe of de.evidence)xe.source==="ai"&&Y.push(_a({criterionId:de.criterionId,ruleOrStepId:xe.ruleOrStepId,pageUrl:xe.pageUrl,selector:xe.selector}));const he=Fa(Y,z);await Ul(A,U,X,he)}async function K(){if(A){_(!0),H(null);try{const L=await Pl(A);if(!L){H("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}q(L)}finally{_(!1)}}}function oe(){var xe,O,ee;if(!A||!U)return;const L=((ee=(O=(xe=chrome.runtime).getManifest)==null?void 0:O.call(xe))==null?void 0:ee.version)??"0.0.0",X=Gl(A,U,L),z=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),Y=URL.createObjectURL(z),he=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,de=document.createElement("a");de.href=Y,de.download=he,de.click(),setTimeout(()=>URL.revokeObjectURL(Y),1e3)}return m.useEffect(()=>{q(null),H(null)},[a,r,d,c,h,b,N,I,f]),S?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),A&&A.summary.totalCriteria>0&&e.jsx(oc,{totalCriteria:A.summary.totalCriteria,pass:A.summary.pass,fail:A.summary.fail,inconclusive:A.summary.inconclusive,notEvaluated:A.summary.notEvaluated,notApplicable:A.summary.notApplicable,levelAchieved:A.summary.levelAchieved,meetsTarget:A.summary.meetsTarget,targetVersion:l,targetLevel:i,auditedUrlCount:R.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:L=>n(L.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:L=>o(L.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",l," Level ",i]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:L=>p(L.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:L=>u(L.target.value),placeholder:"Section 508 (Revised 2017), EN 301 549 v3.2.1, ADA Title III",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Page sample"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Audited pages are auto-included.",R.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:R.auditsByUrl.size})," URL",R.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:f,onChange:L=>j(L.target.value),rows:3,placeholder:`https://app.example.com/checkout
577
- https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:L=>x(L.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:b,onChange:L=>w(L.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:N,onChange:L=>E(L.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:I,onChange:L=>C(L.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),A&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",A.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:A.rows.map(L=>e.jsxs("li",{className:"px-2 py-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-mono text-[10px] text-slate-500",children:[L.criterion.id," · ",L.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:L.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${nc[L.verdict]}`,children:rc[L.verdict]})]},L.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),U?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[U.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",U.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),F&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:F}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!A||!a||!h||$,onClick:()=>void K(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:$?"Anchoring…":U?"Re-anchor":"Anchor this report"}),U&&e.jsx("button",{type:"button",onClick:oe,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),A&&((ne=t[0])==null?void 0:ne.componentId)&&e.jsx(ac,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),A&&e.jsx(tc,{verdicts:G,incompleteResolutions:T}),A&&((le=t[0])==null?void 0:le.componentId)&&((pe=t[0])==null?void 0:pe.startedAt)&&e.jsx(ql,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:l,targetLevel:i,evaluatedCount:A.summary.pass+A.summary.fail+A.summary.inconclusive+A.summary.notApplicable,totalCount:A.summary.totalCriteria,canClaimConformance:A.summary.meetsTarget}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!A||!a||!h,onClick:()=>void W(),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:"Generate WCAG-EM report →"})})]}):e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading IGT runs…"})}function oc({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:o,levelAchieved:l,meetsTarget:i,targetVersion:d,targetLevel:p,auditedUrlCount:c}){return e.jsxs("div",{className:`border rounded p-2 ${i?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${i?"text-emerald-900":"text-amber-900"}`,children:i?`Currently meeting WCAG ${d} Level ${p}`:`Does not currently meet WCAG ${d} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:l??"none"})," · ",t," applicable criteria across ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,o>0&&e.jsxs(e.Fragment,{children:[" · N/A ",o]})," · ","Not evaluated ",r]})]})}const lc={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function cc(t){if(!t)return"never";const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function dc(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+Nn[t.cadence]*6e4-Date.now();if(n<0)return"imminent";const r=Math.floor(n/6e4);return r<60?`in ${r} min`:`in ${Math.floor(r/60)}h`}function uc(){return crypto.randomUUID()}function pc(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,o]=m.useState(""),[l,i]=m.useState("daily"),[d,p]=m.useState(null),[c,u]=m.useState(!1),[h,x]=m.useState(yn),[b,w]=m.useState("idle"),[N,E]=m.useState(!1),[I,C]=m.useState(null);async function f(){n(!0);try{const k=await sa();k.sort((T,V)=>T.enabled!==V.enabled?T.enabled?-1:1:V.createdAt.localeCompare(T.createdAt)),s(k)}finally{n(!1)}}m.useEffect(()=>{f(),(async()=>{const k=await wn();x(k)})()},[]);async function j(k){if(C(null),k.webhookEnabled&&k.webhookUrl.trim().length>0)try{if(new URL(k.webhookUrl).protocol!=="https:"){C("Webhook URL must use https://");return}}catch{C("Webhook URL is not a valid https:// URL.");return}w("saving"),await jn(k),x(k),w("saved"),setTimeout(()=>w("idle"),1500)}async function g(){p(null);const k=r.trim();if(!k){p("URL is required.");return}try{new URL(k)}catch{p("Must be a valid URL (e.g. https://example.com/).");return}u(!0);try{const T={id:uc(),url:k,cadence:l,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await ds(T),await us(T),o(""),i("daily"),await f(),await kt()}finally{u(!1)}}async function v(k){const T={...k,enabled:!k.enabled};await ds(T),T.enabled?await us(T):await ps(k.id),await f(),await kt()}async function S(k){window.confirm(`Remove the scheduled audit for ${k.url}? Run history for this schedule will also be deleted.`)&&(await ps(k.id),await kn(k.id),await Sn(k.id),await f(),await kt())}return e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Scheduled audits"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Re-audit a URL on a cadence. Each scheduled run opens a background tab, runs the audit, compares to the saved baseline, and records the result. New violations vs. baseline trigger alerts when configured below."})]}),e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>E(k=>!k),"aria-expanded":N,className:"w-full flex items-center justify-between px-3 py-2 text-left font-medium hover:bg-slate-50",children:[e.jsxs("span",{children:["Alert preferences",h.emailEnabled||h.webhookEnabled?e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"on"}):e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"off"})]}),e.jsx("span",{className:"text-slate-500","aria-hidden":"true",children:N?"▾":"▸"})]}),N&&e.jsxs("div",{className:"px-3 pb-3 space-y-2.5 border-t border-slate-100 pt-3",children:[e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Alerts fire when a scheduled audit finds NEW violations vs. the saved baseline. Email goes to your license-registered address (server-enforced). Webhook is your own URL."}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-email-enabled",type:"checkbox",checked:h.emailEnabled,onChange:k=>void j({...h,emailEnabled:k.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Email alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"Sends to your team-license email address only."})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-webhook-enabled",type:"checkbox",checked:h.webhookEnabled,onChange:k=>void j({...h,webhookEnabled:k.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Webhook alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"POSTs the alert payload as JSON to your URL."})]})]}),h.webhookEnabled&&e.jsxs("div",{className:"ml-5 space-y-1",children:[e.jsx("label",{htmlFor:"alert-webhook-url",className:"block text-[11px] font-medium",children:"Webhook URL (https:// only)"}),e.jsx("input",{id:"alert-webhook-url",type:"url",value:h.webhookUrl,onChange:k=>x({...h,webhookUrl:k.target.value}),onBlur:()=>void j(h),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),I&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:I})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"alert-min-impact",className:"block text-[11px] font-medium mb-1",children:"Minimum impact to alert on"}),e.jsxs("select",{id:"alert-min-impact",value:h.minImpact,onChange:k=>void j({...h,minImpact:k.target.value}),className:"w-full border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"minor",children:"Minor (alert on everything)"}),e.jsx("option",{value:"moderate",children:"Moderate"}),e.jsx("option",{value:"serious",children:"Serious (recommended)"}),e.jsx("option",{value:"critical",children:"Critical only"})]})]}),b==="saved"&&e.jsx("p",{className:"text-[11px] text-emerald-700",role:"status",children:"✓ Saved"})]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-url",className:"block font-medium mb-1",children:"URL to audit"}),e.jsx("input",{id:"sched-url",type:"url",value:r,onChange:k=>o(k.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:l,onChange:k=>i(k.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),d&&e.jsx("div",{className:"text-rose-700",role:"alert",children:d}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:c||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:c?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(k=>e.jsx("li",{className:`border rounded p-2.5 ${k.enabled?"border-slate-200 bg-white":"border-slate-200 bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("p",{className:"font-mono text-[11px] text-slate-700 break-all",children:k.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[lc[k.cadence]," · last run ",cc(k.lastRunAt)," ·"," ","next ",dc(k)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[k.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",k.lastTotalViolations??0," violation",(k.lastTotalViolations??0)===1?"":"s"]}),k.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:k.lastError??"",children:"✗ failed"}),k.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),k.lastResult==="pending"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700",children:"pending first run"}),(k.lastNewViolationCount??0)>0&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-900",title:"New violations vs. saved baseline",children:["⚠ ",k.lastNewViolationCount," new vs baseline"]}),!k.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void v(k),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:k.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void S(k),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},k.id))})]})}const qs={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function Ma(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function hc(t){let s=0,a=0,n=0,r=0,o=0,l=0,i=0,d=0;for(const p of t){if(!p.enabled){a++;continue}s++;const c=Ma(p);c==="clean"?n++:c==="new-violations"?r++:c==="failed"?o++:c==="pending"&&l++,i+=p.lastNewViolationCount??0,d+=p.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:o,pendingCount:l,totalNewViolations:i,totalViolationsAcrossSchedules:d}}function mc(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,o=n.lastNewViolationCount??0;if(r!==o)return o-r;const l=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-l}).slice(0,s).map(a=>({scheduleId:a.id,url:a.url,cadence:a.cadence,lastRunAt:a.lastRunAt??null,lastTotalViolations:a.lastTotalViolations??0,lastNewViolationCount:a.lastNewViolationCount??0,state:Ma(a)}))}function xc(t,s,a=10){const n=new Map;for(const r of t)n.set(r.id,r.url);return[...s].sort((r,o)=>o.ranAt.localeCompare(r.ranAt)).slice(0,a).map(r=>({scheduleId:r.scheduleId,scheduleUrl:n.get(r.scheduleId)??"(deleted schedule)",ranAt:r.ranAt,totalViolations:r.totalViolations,newVsBaselineViolations:r.newVsBaselineViolations,durationMs:r.durationMs,error:r.error}))}function Pa(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),o=[];for(let i=s-1;i>=0;i--){const d=new Date(r.getTime()-i*864e5);o.push({date:d.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const l=new Map(o.map(i=>[i.date,i]));for(const i of t){const d=i.ranAt.slice(0,10),p=l.get(d);p&&(p.runs++,p.totalViolations+=i.totalViolations,p.newViolations+=i.newVsBaselineViolations)}return o}function gc(t,s,a=14,n=new Date){const r=s.filter(o=>o.scheduleId===t);return Pa(r,a,n)}function fc(t,s=new Date){const a=[];for(const n of t){if(!n.enabled)continue;n.lastResult==="failed"&&a.push({kind:"failed-run",scheduleId:n.id,url:n.url,detail:n.lastError??"audit failed"});const r=qs[n.cadence]*6e4;if(n.lastRunAt){const o=s.getTime()-new Date(n.lastRunAt).getTime();if(o>r*2){const l=Math.round(o/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${l}h (expected every ${qs[n.cadence]}min)`})}}(n.lastNewViolationCount??0)>10&&a.push({kind:"large-regression",scheduleId:n.id,url:n.url,detail:`${n.lastNewViolationCount} new violations vs baseline`})}return a}function Qs(t){const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function Ga(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function Ys({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(i=>i.totalViolations)),r=a/Math.max(1,t.length-1),o=t.map((i,d)=>{const p=d*r,c=s-i.totalViolations/n*(s-4)-2;return`${p.toFixed(1)},${c.toFixed(1)}`}),l=t.map((i,d)=>{const p=d*r,c=s-i.newViolations/n*(s-4)-2;return`${p.toFixed(1)},${c.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:o.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:l.join(" ")})]})}function rt({state:t,count:s}){const a={clean:"bg-emerald-100 text-emerald-800","new-violations":"bg-rose-100 text-rose-900",failed:"bg-amber-100 text-amber-900",pending:"bg-slate-100 text-slate-700"},n={clean:"clean","new-violations":"new violations",failed:"failed",pending:"pending"};return e.jsxs("div",{className:`px-2 py-1 rounded text-[11px] ${a[t]}`,children:[e.jsx("strong",{children:s})," ",n[t]]})}function bc({item:t}){const s={"failed-run":"✗ Failed","stale-schedule":"⏳ Stale","large-regression":"⚠ Regression"},a={"failed-run":"text-rose-700","stale-schedule":"text-amber-700","large-regression":"text-rose-700"};return e.jsxs("li",{className:"border-l-2 border-slate-200 pl-2 py-1",children:[e.jsx("div",{className:`text-[11px] font-medium ${a[t.kind]}`,children:s[t.kind]}),e.jsx("div",{className:"text-[11px] font-mono break-all",children:Ga(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function vc(){const[t,s]=m.useState([]),[a,n]=m.useState([]),[r,o]=m.useState(!0);m.useEffect(()=>{(async()=>{o(!0);try{const[u,h]=await Promise.all([sa(),An()]);s(u),n(h)}finally{o(!1)}})()},[]);const l=hc(t),i=mc(t,5),d=xc(t,a,10),p=Pa(a,30),c=fc(t);return r?e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading dashboard…"}):t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Nothing to summarize yet. Add a scheduled audit from the Schedules tab to start collecting cross-page compliance posture here."})]}):e.jsxs("div",{className:"p-3 space-y-4 text-xs","data-testid":"risk-view-root",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Aggregate posture across every scheduled audit. Read-only — schedules themselves are managed in the Schedules tab."})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 space-y-2 bg-white",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:["Posture · ",l.enabledSchedules," enabled",l.pausedSchedules>0?` · ${l.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(rt,{state:"clean",count:l.cleanCount}),e.jsx(rt,{state:"new-violations",count:l.newViolationsCount}),e.jsx(rt,{state:"failed",count:l.failedCount}),e.jsx(rt,{state:"pending",count:l.pendingCount})]}),l.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[l.totalNewViolations," new WCAG violation",l.totalNewViolations===1?"":"s"," vs baseline across all schedules."]})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-trend-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"30-day trend"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ys,{buckets:p}),e.jsxs("div",{className:"text-[10px] text-slate-500 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-slate-400 mr-1"})," total violations"]}),e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-rose-600 mr-1"})," new vs baseline"]}),e.jsxs("div",{className:"pt-1 text-slate-400",children:["Sum across ",l.enabledSchedules," schedule",l.enabledSchedules===1?"":"s"]})]})]})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",c.length]}),e.jsx("ul",{className:"space-y-1.5",children:c.map((u,h)=>e.jsx(bc,{item:u},`${u.kind}-${u.scheduleId}-${h}`))})]}),i.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-top-exposed-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Most exposed pages"}),e.jsx("ul",{className:"space-y-1.5",children:i.map(u=>{const h=gc(u.scheduleId,a,14),x=h.some(b=>b.runs>0);return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-mono text-[11px] break-all",children:u.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[u.lastTotalViolations," total · ",u.cadence," ·"," ","last run ",u.lastRunAt?Qs(u.lastRunAt):"never"]})]}),x&&e.jsx("span",{className:"shrink-0",title:"Last 14 days · new violations vs baseline","data-testid":"risk-top-exposed-sparkline",children:e.jsx(Ys,{buckets:h,height:20,width:56})}),u.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",u.lastNewViolationCount," new"]})]},u.scheduleId)})})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:d.map((u,h)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:Qs(u.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:Ga(u.scheduleUrl)}),u.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:u.error,children:"failed"}):u.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",u.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${u.scheduleId}-${u.ranAt}-${h}`))})]})]})}const yc="https://api.anthropic.com/v1/messages",wc="2023-06-01",jc="claude-sonnet-4-6",Nc={input:3/1e6,output:15/1e6},kc={input:1/1e6,output:5/1e6},Sc=`You are wcagcheckr's accessibility-audit co-pilot.
575
+ </html>`}async function Ul(t,s,a,n){const r=Ll(t,s,a,n),o=new Blob([r],{type:"text/html;charset=utf-8"}),l=URL.createObjectURL(o);await chrome.tabs.create({url:l})}const Tt=aa("wcag-em-anchor"),_l="https://api.wcagcheckr.com",Dl="wcagcheckr",Ol=15e3;function La(t){return{scope:{siteName:t.inputs.siteName,siteUrl:t.inputs.siteUrl,targetVersion:t.inputs.targetVersion,targetLevel:t.inputs.targetLevel,accessibilitySupportBaseline:t.inputs.accessibilitySupportBaseline,additionalStandards:t.inputs.additionalStandards??[]},evaluator:{name:t.inputs.evaluator.name,organization:t.inputs.evaluator.organization??null,qualifications:t.inputs.evaluator.qualifications??null,contact:t.inputs.evaluator.contact??null},sample:{pages:t.inputs.pageSample.map(s=>({url:s.url,type:s.pageType,selectionType:s.selectionType,hasAuditData:s.hasAuditData}))},verdicts:t.rows.map(s=>({sc:s.criterion.id,level:s.criterion.level,verdict:s.verdict,overridden:s.overridden,axeFailureCount:s.signals.axeFailures.length,igtFailureCount:s.signals.igtFailures.length})),summary:{totalCriteria:t.summary.totalCriteria,pass:t.summary.pass,fail:t.summary.fail,inconclusive:t.summary.inconclusive,notApplicable:t.summary.notApplicable,notEvaluated:t.summary.notEvaluated,levelAchieved:t.summary.levelAchieved,meetsTarget:t.summary.meetsTarget},generatedAt:t.generatedAt}}async function Fl(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function Ml(t){return Fl(mn(La(t)))}function Pl(t){if(typeof t!="object"||t===null)return!1;const s=t;return s.schemaVersion!==1&&s.schemaVersion!==2||!(typeof s.anchoredAt=="string"&&typeof s.tsaName=="string"&&typeof s.rfc3161TokenBase64=="string"&&s.rfc3161TokenBase64.length>0&&typeof s.serverSignatureBase64=="string"&&s.serverSignatureBase64.length>0&&typeof s.serverKeyFingerprint=="string"&&s.serverKeyFingerprint.length>0)?!1:s.schemaVersion===2?typeof s.prevAuditHash=="string"&&/^[0-9a-f]{64}$/.test(s.prevAuditHash):!0}async function Gl(t,s){const a=await Ml(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${_l}/v1/products/${Dl}/forensic/anchor`;try{const o=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Ol)});if(!o.ok)return Tt.warn(`anchor HTTP ${o.status}`),null;const l=await o.json();return Pl(l)?{reportHash:a,capturedAt:t.generatedAt,receipt:l}:(Tt.warn("anchor returned malformed receipt",l),null)}catch(o){return Tt.warn("anchor request failed",o),null}}function Vl(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:La(t)}}const Gt="auditAttestations",Vt="auditAttestation:defaultSigner";function ns(t,s){return`${t}::${s}`}async function rs(){try{const s=(await chrome.storage.local.get(Gt))[Gt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ua(t){await chrome.storage.local.set({[Gt]:t})}async function Wl(t){const s=await rs();s[ns(t.componentId,t.auditCapturedAt)]=t,await Ua(s)}async function _a(t,s){return(await rs())[ns(t,s)]??null}async function Bl(t,s){const a=await rs();delete a[ns(t,s)],await Ua(a)}async function Hl(){try{const s=(await chrome.storage.local.get(Vt))[Vt];return s&&typeof s=="object"?s:null}catch{return null}}async function Kl(t){await chrome.storage.local.set({[Vt]:t})}function zl(t,s){return t.auditCapturedAt!==s}function ql(t){return`I attest that this audit, dated [DATE], represents a good-faith evaluation of ${t.scope} for WCAG ${t.targetVersion} Level ${t.targetLevel} conformance. The methodology relied on automated analysis + AI-assisted determinations, covering ${t.evaluatedCount} of ${t.totalCount} applicable criteria. I have reviewed the findings + spot-audit verifications and take responsibility for the conclusions presented.`}function Ql(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[o,l]=m.useState(!1),[i,d]=m.useState(""),[p,c]=m.useState(""),[u,h]=m.useState(""),[g,b]=m.useState(""),[w,N]=m.useState("");m.useEffect(()=>{let j=!1;return Promise.all([_a(t.componentId,t.auditCapturedAt),Hl()]).then(([x,v])=>{j||(a(x),x?(d(x.signerName),c(x.signerEmail),h(x.signerOrganization??""),b(x.signerQualifications??""),N(x.claim)):v&&(d(v.signerName),c(v.signerEmail),h(v.signerOrganization??""),b(v.signerQualifications??"")),N(S=>S||ql({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{j=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function E(){if(!i.trim()||!p.trim())return;const j={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:i.trim(),signerEmail:p.trim(),signerOrganization:u.trim()||void 0,signerQualifications:g.trim()||void 0,claim:w.trim(),scope:t.scope};await Wl(j),await Kl({signerName:j.signerName,signerEmail:j.signerEmail,signerOrganization:j.signerOrganization,signerQualifications:j.signerQualifications}),a(j),l(!1)}async function I(){await Bl(t.componentId,t.auditCapturedAt),a(null),l(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const C=s&&zl(s,t.auditCapturedAt);if(s&&!C&&!o)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void I(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&C&&!o)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const f=i.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:i,onChange:j=>d(j.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:p,onChange:j=>c(j.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:u,onChange:j=>h(j.target.value),placeholder:"Acme Corp",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Qualifications"}),e.jsx("input",{type:"text",value:g,onChange:j=>b(j.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:w,onChange:j=>N(j.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[o&&e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!f,onClick:()=>void E(),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"🔏 Sign and seal"})]})]})}const Wt="spotAuditReviews";function Da(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function is(){try{const s=(await chrome.storage.local.get(Wt))[Wt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Oa(t){await chrome.storage.local.set({[Wt]:t})}async function Yl(t){const s=await is();s[t.key]=t,await Oa(s)}async function Jl(t){const s=await is();delete s[t],await Oa(s)}async function Fa(){const t=await is();return Object.values(t)}function Ma(t,s){const a=new Map(s.map(l=>[l.key,l]));let n=0,r=0,o=0;for(const l of t){const i=a.get(l);i&&(n++,i.verdict==="agreed"?r++:o++)}return{total:t.length,reviewed:n,agreed:r,disagreed:o}}function Xl(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),o=a[n];a[n]=a[r],a[r]=o}return a.slice(0,Math.min(s,a.length))}function Zl(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const o of r.evidence){if(o.source!=="ai")continue;const l=o.ruleOrStepId.startsWith("ai-resolved::")?o.ruleOrStepId.slice(13):o.ruleOrStepId,i=o.pageUrl&&o.selector?a.get(`${o.pageUrl}::${l}::${o.selector}`):void 0;n.push({key:Da({criterionId:r.criterionId,ruleOrStepId:o.ruleOrStepId,pageUrl:o.pageUrl,selector:o.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:o.ruleOrStepId,outcome:o.outcome,pageUrl:o.pageUrl,selector:o.selector,resolutionHint:o.resolutionHint,aiReasoning:i})}return n}const ec={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",incomplete:"bg-amber-100 text-amber-800",inapplicable:"bg-slate-100 text-slate-700",ack:"bg-sky-100 text-sky-800",skip:"bg-slate-100 text-slate-700","n/a":"bg-slate-100 text-slate-700"},tc={pass:"AI: pass",fail:"AI: fail",incomplete:"AI: uncertain",inapplicable:"AI: n/a",ack:"AI flagged · user acked",skip:"AI: skip","n/a":"AI: n/a"};function sc({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>Zl(t,s),[t,s]),[n,r]=m.useState([]),[o,l]=m.useState(!0),[i,d]=m.useState(null),[p,c]=m.useState(5),[u,h]=m.useState(!1);m.useEffect(()=>{let f=!1;return Fa().then(j=>{f||(r(j),l(!1))}),()=>{f=!0}},[]);const g=m.useMemo(()=>a.map(f=>f.key),[a]),b=m.useMemo(()=>Ma(g,n),[g,n]),N=(u?g:i||n.filter(f=>g.includes(f.key)).map(f=>f.key)).map(f=>a.find(j=>j.key===f)).filter(f=>!!f);async function E(f,j,x){const v={key:f.key,criterionId:f.criterionId,ruleOrStepId:f.ruleOrStepId,pageUrl:f.pageUrl,selector:f.selector,verdict:j,correction:(x==null?void 0:x.trim())||void 0,reviewedAt:new Date().toISOString()};await Yl(v),r(S=>[v,...S.filter(k=>k.key!==v.key)])}async function I(f){await Jl(f.key),r(j=>j.filter(x=>x.key!==f.key))}function C(){d(Xl(g,p)),h(!1)}return a.length===0?e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"mt-2 leading-snug",children:"This audit has no AI determinations yet. Spot-auditing becomes available once AI judgment runs against ambiguous findings (alt-text, color-only meaning, axe-incomplete, etc.)."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI did the determination work. You can audit a sample — pick a random N, review what the AI decided, and mark whether you agree. Your spot-check rate is included in the report."})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-center bg-slate-50 border border-slate-200 rounded p-2",children:[e.jsx(at,{label:"AI determinations",value:b.total}),e.jsx(at,{label:"Reviewed",value:b.reviewed,accent:"text-slate-900"}),e.jsx(at,{label:"Agreed",value:b.agreed,accent:"text-emerald-700"}),e.jsx(at,{label:"Disagreed",value:b.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:p,onChange:f=>c(Math.max(1,Math.min(a.length,Number(f.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:C,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{h(f=>!f),d(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:u?"Hide list":`Show all (${a.length})`}),i&&e.jsx("button",{type:"button",onClick:()=>d(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),o?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):N.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:N.map(f=>e.jsx(ac,{row:f,review:n.find(j=>j.key===f.key)??null,onAgree:()=>void E(f,"agreed"),onDisagree:j=>void E(f,"disagreed",j),onClear:()=>void I(f)},f.key))})]})}function at({label:t,value:s,accent:a="text-slate-900"}){return e.jsxs("div",{children:[e.jsx("p",{className:`text-base font-bold ${a}`,children:s}),e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:t})]})}function ac(t){const{row:s,review:a}=t,[n,r]=m.useState(!1),[o,l]=m.useState((a==null?void 0:a.correction)??""),i=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${i==="agreed"?"border-emerald-300 bg-emerald-50/50":i==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${ec[s.outcome]}`,children:tc[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${i==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${i==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),i&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&i==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:o,onChange:d=>l(d.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(o),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),l((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function _e(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[o,l]=m.useState(!1),[i,d]=m.useState(null),[p,c]=m.useState(null),[u,h]=m.useState(!1),[g,b]=m.useState(""),[w,N]=m.useState(!1),[E,I]=m.useState(null);m.useEffect(()=>{let v=!1;return Promise.all([xn(t.componentId,t.criterionId),gn(t.componentId,t.criterionId,t.pageUrl)]).then(([S,k])=>{v||(a(S),c(k),r(!1))}),()=>{v=!0}},[t.componentId,t.criterionId,t.pageUrl]);async function C(){l(!0),d(null);try{const S=await ne({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});S.ok?S.result&&a(S.result):d(S.error??"Audit failed.")}catch(v){d(v instanceof Error?v.message:String(v))}finally{l(!1)}}async function f(){await bn(t.componentId,t.criterionId),a(null)}async function j(){if(s){N(!0),I(null);try{if(!g||!g.trim()){I("Note is required — explain how you manually verified this."),N(!1);return}if(s.verdict==="pass"){I("This walkthrough already passed — no acknowledgement needed."),N(!1);return}const v={componentId:t.componentId,criterionId:t.criterionId,pageUrl:t.pageUrl,note:g.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:s.verdict};await zt(v),c(v),h(!1),b("")}catch(v){I(v instanceof Error?v.message:String(v))}finally{N(!1)}}}async function x(){N(!0);try{await fn(t.componentId,t.criterionId,t.pageUrl),c(null)}finally{N(!1)}}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!i&&e.jsx("button",{type:"button",onClick:()=>void C(),disabled:o,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:o?"Running AI walkthrough…":"Run AI walkthrough"}),i&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:i}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:o,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:o?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${_t(s.reasoning)?"border-2 border-amber-500 bg-amber-50":s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[_t(s.reasoning)&&e.jsxs("div",{className:"bg-amber-100 border border-amber-400 rounded p-2 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500 text-white font-bold uppercase tracking-wide",children:"AI cascade flagged this"})}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:["AI's automation paths all flagged this criterion. The verdict is",e.jsx("strong",{children:" fail"}),". The path forward is to fix the underlying issue on the page and re-audit. Read AI's reasoning below to see what it flagged."]}),e.jsxs("details",{className:"text-[11px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-40 overflow-y-auto bg-white/60 p-2 rounded",children:s.reasoning})]}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:o,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",title:"After fixing the page, re-run the walkthrough to confirm the fix.",children:o?"Re-running…":"Re-run walkthrough"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:ta(s.reasoning)?`Manual · ${s.verdict}`:Dt(s.reasoning)?`Cascade · ${Dt(s.reasoning)} → ${s.verdict}`:`AI: ${s.verdict}`}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug whitespace-pre-wrap",children:s.reasoning}),(()=>{const v=(s.steps??[]).filter(S=>S.action!=="initial").length;return v===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"Step-replay data not retained for past audits (saves storage). Re-run the walkthrough to see the live step recording."}):e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",v," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(S=>S.action!=="initial").map(S=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",S.focused.role||S.focused.tag,"]"]})," ",S.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:S.focused.selector})]},S.ordinal))})]})})(),s.verdict!=="pass"&&e.jsx("div",{className:"mt-2 pt-2 border-t border-dashed border-slate-300",children:p?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-200 text-emerald-900 font-bold uppercase tracking-wide",children:"✓ Human verified"}),e.jsx("span",{className:"text-[10px] text-emerald-800",children:new Date(p.acknowledgedAt).toLocaleString()})]}),e.jsxs("p",{className:"text-[11px] text-emerald-900 leading-snug",children:[e.jsx("strong",{children:"Verification note:"})," ",p.note]}),e.jsx("button",{type:"button",onClick:()=>void x(),disabled:w,className:"text-[10px] px-2 py-0.5 border border-emerald-300 bg-white text-emerald-800 rounded hover:bg-emerald-50 disabled:opacity-50",children:w?"Removing…":"Un-acknowledge"})]}):u?e.jsxs("div",{className:"bg-slate-50 border border-slate-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-slate-700 block",children:"Manual verification note (required)"}),e.jsxs("p",{className:"text-[10px] text-slate-600 leading-snug",children:["Describe what you did to verify this passes WCAG ",t.criterionId,". This note becomes part of the forensic record on every export — be specific."]}),e.jsx("textarea",{value:g,onChange:v=>b(v.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-slate-300 rounded resize-y min-h-[60px]",autoFocus:!0}),E&&e.jsx("p",{className:"text-[10px] text-rose-700",children:E}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void j(),disabled:w,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:w?"Saving…":"Confirm acknowledgement"}),e.jsx("button",{type:"button",onClick:()=>{h(!1),b(""),I(null)},disabled:w,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{h(!0),I(null)},className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",title:"After verifying manually that this criterion passes, log your verification here. Required note is preserved in the forensic record.",children:"Mark verified manually"})}),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void C(),disabled:o,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:o?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void f(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function nc(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return ue().then(r=>{n||a(r??null)}),()=>{n=!0}},[]),s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI drives a keyboard user through the page to evaluate criteria that require lived-experience judgment. Each walkthrough produces an AI verdict that flows into the conformance report. You can spot-check the AI's reasoning in the panel below."})]}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.3",criterionTitle:"Focus Order",description:"AI walks the page Tab-by-Tab, comparing the focus sequence to the visible layout. Verdict: does the order follow a logical reading sequence?"}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.1.2",criterionTitle:"No keyboard trap",description:"AI Tab-walks forward then Shift-Tab-walks backward, checking for traps: elements where focus gets stuck, or where Shift-Tab can't reverse out of a region. Verdict: can the user always leave?"}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.7",criterionTitle:"Focus visible",description:"AI Tab-walks the page and captures a screenshot at each focused element. Vision then judges whether a visible focus indicator (outline, ring, or compensating treatment) is present on every sampled element."}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.3.2",criterionTitle:"Meaningful Sequence (reading order)",description:"AI vision judges whether the heuristic-flagged DOM-vs-visual order divergences are real reading-order breaks or normal multi-column / banked layout patterns. Looks at the page screenshot + the flagged element list."}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."}),e.jsx(_e,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.5.3",criterionTitle:"Label in Name",description:"Programmatic DOM walk + AI fallback. Scans every interactive control for a mismatch between its visible label text and its programmatically-determined accessible name — the failure mode that breaks speech recognition (e.g., visible 'Submit' but accessible 'Continue')."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const zs="igtRuns",rc={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",inconclusive:"bg-amber-100 text-amber-800","not-evaluated":"bg-slate-100 text-slate-700","not-applicable":"bg-slate-50 text-slate-500"},ic={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function oc(){var ae,le,pe;const t=y(U=>U.results),s=y(U=>U.acknowledgedKeys),[a,n]=m.useState(""),[r,o]=m.useState(""),l=yn,i=vn,[d,p]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,u]=m.useState(""),[h,g]=m.useState(""),[b,w]=m.useState(""),[N,E]=m.useState(""),[I,C]=m.useState(""),[f,j]=m.useState(""),[x,v]=m.useState({}),[S,k]=m.useState(!1),[T,V]=m.useState([]),[P,B]=m.useState([]),[L,q]=m.useState(null),[$,_]=m.useState(!1),[F,H]=m.useState(null);m.useEffect(()=>{let U=!1;return chrome.storage.local.get(zs).then(X=>{if(U)return;const z=X[zs]??{};v(z),k(!0)}).catch(()=>{U||k(!0)}),()=>{U=!0}},[]),m.useEffect(()=>{var he;const U=(he=t[0])==null?void 0:he.componentId;if(!U)return;let X=!1;const z=()=>{Ie(U).then(de=>{X||B(de.map(xe=>({criterionId:xe.criterionId,ruleId:`ai-interactive::${xe.criterionId}`,pageUrl:xe.pageUrl,verdict:xe.verdict,reasoning:xe.reasoning})))})};z();const Y=de=>{de.interactiveAuditResults&&z()};return chrome.storage.local.onChanged.addListener(Y),()=>{X=!0,chrome.storage.local.onChanged.removeListener(Y)}},[t]),m.useEffect(()=>{var U;if(!a&&((U=t[0])!=null&&U.pageUrl))try{const X=new URL(t[0].pageUrl);n(X.hostname),o(X.origin)}catch{}},[t,a]),m.useEffect(()=>{const U=new Set;for(const z of t)U.add(z.pageUrl??z.scope);if(U.size===0){V([]);return}let X=!1;return Promise.all(Array.from(U).map(z=>qe(z))).then(z=>{X||V(z.flat())}).catch(()=>{}),()=>{X=!0}},[t]);const R=m.useMemo(()=>{const U=new Map,X=new Map;for(const Y of t){const he=Y.pageUrl??Y.scope,de=U.get(he)??[];de.push(Y),U.set(he,de)}const z=new Map;for(const Y of t){const he=Y.pageUrl??Y.scope;z.set(Y.componentId,he)}for(const[Y,he]of Object.entries(x)){const de=z.get(Y);if(!de)continue;const xe=X.get(de)??{};Object.assign(xe,he),X.set(de,xe)}return{auditsByUrl:U,igtRunsByUrl:X,workflows:fe,acknowledgedMatchKeys:s,incompleteResolutions:T,interactiveAuditResults:P}},[t,x,s,T,P]),M=m.useMemo(()=>{const U=[],X=new Set;for(const z of R.auditsByUrl.keys())X.has(z)||(X.add(z),U.push({url:z,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const z of f.split(`
576
+ `).map(Y=>Y.trim()).filter(Boolean))X.has(z)||(X.add(z),U.push({url:z,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return U},[R,f]),ie=m.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:l,targetLevel:i,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(U=>U.trim()).filter(Boolean),pageSample:M,evaluator:{name:h||"(evaluator name pending)",organization:b||void 0,qualifications:N||void 0,contact:I||void 0}}),[a,r,l,i,d,c,M,h,b,N,I]),A=m.useMemo(()=>S?Tl(ie,R):null,[ie,R,S]),G=m.useMemo(()=>{const U=Array.from(R.auditsByUrl.values()).flat(),X=Object.values(x).flatMap(z=>Object.values(z));return Kt({audits:U,igtRuns:X,workflows:fe,acknowledgedMatchKeys:s,incompleteResolutions:T,interactiveAuditResults:P})},[R,x,s,T,P]);async function W(){if(!A)return;const U=t[0],X=U!=null&&U.componentId&&(U!=null&&U.startedAt)?await _a(U.componentId,U.startedAt):null,z=await Fa(),Y=[];for(const de of G.values())for(const xe of de.evidence)xe.source==="ai"&&Y.push(Da({criterionId:de.criterionId,ruleOrStepId:xe.ruleOrStepId,pageUrl:xe.pageUrl,selector:xe.selector}));const he=Ma(Y,z);await Ul(A,L,X,he)}async function K(){if(A){_(!0),H(null);try{const U=await Gl(A);if(!U){H("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}q(U)}finally{_(!1)}}}function oe(){var xe,O,ee;if(!A||!L)return;const U=((ee=(O=(xe=chrome.runtime).getManifest)==null?void 0:O.call(xe))==null?void 0:ee.version)??"0.0.0",X=Vl(A,L,U),z=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),Y=URL.createObjectURL(z),he=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,de=document.createElement("a");de.href=Y,de.download=he,de.click(),setTimeout(()=>URL.revokeObjectURL(Y),1e3)}return m.useEffect(()=>{q(null),H(null)},[a,r,d,c,h,b,N,I,f]),S?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),A&&A.summary.totalCriteria>0&&e.jsx(lc,{totalCriteria:A.summary.totalCriteria,pass:A.summary.pass,fail:A.summary.fail,inconclusive:A.summary.inconclusive,notEvaluated:A.summary.notEvaluated,notApplicable:A.summary.notApplicable,levelAchieved:A.summary.levelAchieved,meetsTarget:A.summary.meetsTarget,targetVersion:l,targetLevel:i,auditedUrlCount:R.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:U=>n(U.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:U=>o(U.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",l," Level ",i]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:U=>p(U.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:U=>u(U.target.value),placeholder:"Section 508 (Revised 2017), EN 301 549 v3.2.1, ADA Title III",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Page sample"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Audited pages are auto-included.",R.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:R.auditsByUrl.size})," URL",R.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:f,onChange:U=>j(U.target.value),rows:3,placeholder:`https://app.example.com/checkout
577
+ https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:U=>g(U.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:b,onChange:U=>w(U.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:N,onChange:U=>E(U.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:I,onChange:U=>C(U.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),A&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",A.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:A.rows.map(U=>e.jsxs("li",{className:"px-2 py-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-mono text-[10px] text-slate-500",children:[U.criterion.id," · ",U.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:U.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${rc[U.verdict]}`,children:ic[U.verdict]})]},U.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),L?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[L.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",L.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),F&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:F}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!A||!a||!h||$,onClick:()=>void K(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:$?"Anchoring…":L?"Re-anchor":"Anchor this report"}),L&&e.jsx("button",{type:"button",onClick:oe,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),A&&((ae=t[0])==null?void 0:ae.componentId)&&e.jsx(nc,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),A&&e.jsx(sc,{verdicts:G,incompleteResolutions:T}),A&&((le=t[0])==null?void 0:le.componentId)&&((pe=t[0])==null?void 0:pe.startedAt)&&e.jsx(Ql,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:l,targetLevel:i,evaluatedCount:A.summary.pass+A.summary.fail+A.summary.inconclusive+A.summary.notApplicable,totalCount:A.summary.totalCriteria,canClaimConformance:A.summary.meetsTarget}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!A||!a||!h,onClick:()=>void W(),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:"Generate WCAG-EM report →"})})]}):e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading IGT runs…"})}function lc({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:o,levelAchieved:l,meetsTarget:i,targetVersion:d,targetLevel:p,auditedUrlCount:c}){return e.jsxs("div",{className:`border rounded p-2 ${i?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${i?"text-emerald-900":"text-amber-900"}`,children:i?`Currently meeting WCAG ${d} Level ${p}`:`Does not currently meet WCAG ${d} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:l??"none"})," · ",t," applicable criteria across ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,o>0&&e.jsxs(e.Fragment,{children:[" · N/A ",o]})," · ","Not evaluated ",r]})]})}const cc={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function dc(t){if(!t)return"never";const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function uc(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+kn[t.cadence]*6e4-Date.now();if(n<0)return"imminent";const r=Math.floor(n/6e4);return r<60?`in ${r} min`:`in ${Math.floor(r/60)}h`}function pc(){return crypto.randomUUID()}function hc(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,o]=m.useState(""),[l,i]=m.useState("daily"),[d,p]=m.useState(null),[c,u]=m.useState(!1),[h,g]=m.useState(wn),[b,w]=m.useState("idle"),[N,E]=m.useState(!1),[I,C]=m.useState(null);async function f(){n(!0);try{const k=await sa();k.sort((T,V)=>T.enabled!==V.enabled?T.enabled?-1:1:V.createdAt.localeCompare(T.createdAt)),s(k)}finally{n(!1)}}m.useEffect(()=>{f(),(async()=>{const k=await jn();g(k)})()},[]);async function j(k){if(C(null),k.webhookEnabled&&k.webhookUrl.trim().length>0)try{if(new URL(k.webhookUrl).protocol!=="https:"){C("Webhook URL must use https://");return}}catch{C("Webhook URL is not a valid https:// URL.");return}w("saving"),await Nn(k),g(k),w("saved"),setTimeout(()=>w("idle"),1500)}async function x(){p(null);const k=r.trim();if(!k){p("URL is required.");return}try{new URL(k)}catch{p("Must be a valid URL (e.g. https://example.com/).");return}u(!0);try{const T={id:pc(),url:k,cadence:l,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await ds(T),await us(T),o(""),i("daily"),await f(),await kt()}finally{u(!1)}}async function v(k){const T={...k,enabled:!k.enabled};await ds(T),T.enabled?await us(T):await ps(k.id),await f(),await kt()}async function S(k){window.confirm(`Remove the scheduled audit for ${k.url}? Run history for this schedule will also be deleted.`)&&(await ps(k.id),await Sn(k.id),await An(k.id),await f(),await kt())}return e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Scheduled audits"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Re-audit a URL on a cadence. Each scheduled run opens a background tab, runs the audit, compares to the saved baseline, and records the result. New violations vs. baseline trigger alerts when configured below."})]}),e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>E(k=>!k),"aria-expanded":N,className:"w-full flex items-center justify-between px-3 py-2 text-left font-medium hover:bg-slate-50",children:[e.jsxs("span",{children:["Alert preferences",h.emailEnabled||h.webhookEnabled?e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"on"}):e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"off"})]}),e.jsx("span",{className:"text-slate-500","aria-hidden":"true",children:N?"▾":"▸"})]}),N&&e.jsxs("div",{className:"px-3 pb-3 space-y-2.5 border-t border-slate-100 pt-3",children:[e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Alerts fire when a scheduled audit finds NEW violations vs. the saved baseline. Email goes to your license-registered address (server-enforced). Webhook is your own URL."}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-email-enabled",type:"checkbox",checked:h.emailEnabled,onChange:k=>void j({...h,emailEnabled:k.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Email alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"Sends to your team-license email address only."})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-webhook-enabled",type:"checkbox",checked:h.webhookEnabled,onChange:k=>void j({...h,webhookEnabled:k.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Webhook alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"POSTs the alert payload as JSON to your URL."})]})]}),h.webhookEnabled&&e.jsxs("div",{className:"ml-5 space-y-1",children:[e.jsx("label",{htmlFor:"alert-webhook-url",className:"block text-[11px] font-medium",children:"Webhook URL (https:// only)"}),e.jsx("input",{id:"alert-webhook-url",type:"url",value:h.webhookUrl,onChange:k=>g({...h,webhookUrl:k.target.value}),onBlur:()=>void j(h),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),I&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:I})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"alert-min-impact",className:"block text-[11px] font-medium mb-1",children:"Minimum impact to alert on"}),e.jsxs("select",{id:"alert-min-impact",value:h.minImpact,onChange:k=>void j({...h,minImpact:k.target.value}),className:"w-full border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"minor",children:"Minor (alert on everything)"}),e.jsx("option",{value:"moderate",children:"Moderate"}),e.jsx("option",{value:"serious",children:"Serious (recommended)"}),e.jsx("option",{value:"critical",children:"Critical only"})]})]}),b==="saved"&&e.jsx("p",{className:"text-[11px] text-emerald-700",role:"status",children:"✓ Saved"})]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-url",className:"block font-medium mb-1",children:"URL to audit"}),e.jsx("input",{id:"sched-url",type:"url",value:r,onChange:k=>o(k.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:l,onChange:k=>i(k.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),d&&e.jsx("div",{className:"text-rose-700",role:"alert",children:d}),e.jsx("button",{type:"button",onClick:()=>void x(),disabled:c||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:c?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(k=>e.jsx("li",{className:`border rounded p-2.5 ${k.enabled?"border-slate-200 bg-white":"border-slate-200 bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("p",{className:"font-mono text-[11px] text-slate-700 break-all",children:k.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[cc[k.cadence]," · last run ",dc(k.lastRunAt)," ·"," ","next ",uc(k)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[k.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",k.lastTotalViolations??0," violation",(k.lastTotalViolations??0)===1?"":"s"]}),k.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:k.lastError??"",children:"✗ failed"}),k.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),k.lastResult==="pending"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700",children:"pending first run"}),(k.lastNewViolationCount??0)>0&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-900",title:"New violations vs. saved baseline",children:["⚠ ",k.lastNewViolationCount," new vs baseline"]}),!k.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void v(k),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:k.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void S(k),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},k.id))})]})}const qs={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function Pa(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function mc(t){let s=0,a=0,n=0,r=0,o=0,l=0,i=0,d=0;for(const p of t){if(!p.enabled){a++;continue}s++;const c=Pa(p);c==="clean"?n++:c==="new-violations"?r++:c==="failed"?o++:c==="pending"&&l++,i+=p.lastNewViolationCount??0,d+=p.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:o,pendingCount:l,totalNewViolations:i,totalViolationsAcrossSchedules:d}}function xc(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,o=n.lastNewViolationCount??0;if(r!==o)return o-r;const l=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-l}).slice(0,s).map(a=>({scheduleId:a.id,url:a.url,cadence:a.cadence,lastRunAt:a.lastRunAt??null,lastTotalViolations:a.lastTotalViolations??0,lastNewViolationCount:a.lastNewViolationCount??0,state:Pa(a)}))}function gc(t,s,a=10){const n=new Map;for(const r of t)n.set(r.id,r.url);return[...s].sort((r,o)=>o.ranAt.localeCompare(r.ranAt)).slice(0,a).map(r=>({scheduleId:r.scheduleId,scheduleUrl:n.get(r.scheduleId)??"(deleted schedule)",ranAt:r.ranAt,totalViolations:r.totalViolations,newVsBaselineViolations:r.newVsBaselineViolations,durationMs:r.durationMs,error:r.error}))}function Ga(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),o=[];for(let i=s-1;i>=0;i--){const d=new Date(r.getTime()-i*864e5);o.push({date:d.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const l=new Map(o.map(i=>[i.date,i]));for(const i of t){const d=i.ranAt.slice(0,10),p=l.get(d);p&&(p.runs++,p.totalViolations+=i.totalViolations,p.newViolations+=i.newVsBaselineViolations)}return o}function fc(t,s,a=14,n=new Date){const r=s.filter(o=>o.scheduleId===t);return Ga(r,a,n)}function bc(t,s=new Date){const a=[];for(const n of t){if(!n.enabled)continue;n.lastResult==="failed"&&a.push({kind:"failed-run",scheduleId:n.id,url:n.url,detail:n.lastError??"audit failed"});const r=qs[n.cadence]*6e4;if(n.lastRunAt){const o=s.getTime()-new Date(n.lastRunAt).getTime();if(o>r*2){const l=Math.round(o/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${l}h (expected every ${qs[n.cadence]}min)`})}}(n.lastNewViolationCount??0)>10&&a.push({kind:"large-regression",scheduleId:n.id,url:n.url,detail:`${n.lastNewViolationCount} new violations vs baseline`})}return a}function Qs(t){const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function Va(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function Ys({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(i=>i.totalViolations)),r=a/Math.max(1,t.length-1),o=t.map((i,d)=>{const p=d*r,c=s-i.totalViolations/n*(s-4)-2;return`${p.toFixed(1)},${c.toFixed(1)}`}),l=t.map((i,d)=>{const p=d*r,c=s-i.newViolations/n*(s-4)-2;return`${p.toFixed(1)},${c.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:o.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:l.join(" ")})]})}function nt({state:t,count:s}){const a={clean:"bg-emerald-100 text-emerald-800","new-violations":"bg-rose-100 text-rose-900",failed:"bg-amber-100 text-amber-900",pending:"bg-slate-100 text-slate-700"},n={clean:"clean","new-violations":"new violations",failed:"failed",pending:"pending"};return e.jsxs("div",{className:`px-2 py-1 rounded text-[11px] ${a[t]}`,children:[e.jsx("strong",{children:s})," ",n[t]]})}function vc({item:t}){const s={"failed-run":"✗ Failed","stale-schedule":"⏳ Stale","large-regression":"⚠ Regression"},a={"failed-run":"text-rose-700","stale-schedule":"text-amber-700","large-regression":"text-rose-700"};return e.jsxs("li",{className:"border-l-2 border-slate-200 pl-2 py-1",children:[e.jsx("div",{className:`text-[11px] font-medium ${a[t.kind]}`,children:s[t.kind]}),e.jsx("div",{className:"text-[11px] font-mono break-all",children:Va(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function yc(){const[t,s]=m.useState([]),[a,n]=m.useState([]),[r,o]=m.useState(!0);m.useEffect(()=>{(async()=>{o(!0);try{const[u,h]=await Promise.all([sa(),Cn()]);s(u),n(h)}finally{o(!1)}})()},[]);const l=mc(t),i=xc(t,5),d=gc(t,a,10),p=Ga(a,30),c=bc(t);return r?e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading dashboard…"}):t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Nothing to summarize yet. Add a scheduled audit from the Schedules tab to start collecting cross-page compliance posture here."})]}):e.jsxs("div",{className:"p-3 space-y-4 text-xs","data-testid":"risk-view-root",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Aggregate posture across every scheduled audit. Read-only — schedules themselves are managed in the Schedules tab."})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 space-y-2 bg-white",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:["Posture · ",l.enabledSchedules," enabled",l.pausedSchedules>0?` · ${l.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(nt,{state:"clean",count:l.cleanCount}),e.jsx(nt,{state:"new-violations",count:l.newViolationsCount}),e.jsx(nt,{state:"failed",count:l.failedCount}),e.jsx(nt,{state:"pending",count:l.pendingCount})]}),l.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[l.totalNewViolations," new WCAG violation",l.totalNewViolations===1?"":"s"," vs baseline across all schedules."]})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-trend-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"30-day trend"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ys,{buckets:p}),e.jsxs("div",{className:"text-[10px] text-slate-500 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-slate-400 mr-1"})," total violations"]}),e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-rose-600 mr-1"})," new vs baseline"]}),e.jsxs("div",{className:"pt-1 text-slate-400",children:["Sum across ",l.enabledSchedules," schedule",l.enabledSchedules===1?"":"s"]})]})]})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",c.length]}),e.jsx("ul",{className:"space-y-1.5",children:c.map((u,h)=>e.jsx(vc,{item:u},`${u.kind}-${u.scheduleId}-${h}`))})]}),i.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-top-exposed-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Most exposed pages"}),e.jsx("ul",{className:"space-y-1.5",children:i.map(u=>{const h=fc(u.scheduleId,a,14),g=h.some(b=>b.runs>0);return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-mono text-[11px] break-all",children:u.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[u.lastTotalViolations," total · ",u.cadence," ·"," ","last run ",u.lastRunAt?Qs(u.lastRunAt):"never"]})]}),g&&e.jsx("span",{className:"shrink-0",title:"Last 14 days · new violations vs baseline","data-testid":"risk-top-exposed-sparkline",children:e.jsx(Ys,{buckets:h,height:20,width:56})}),u.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",u.lastNewViolationCount," new"]})]},u.scheduleId)})})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:d.map((u,h)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:Qs(u.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:Va(u.scheduleUrl)}),u.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:u.error,children:"failed"}):u.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",u.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${u.scheduleId}-${u.ranAt}-${h}`))})]})]})}const wc="https://api.anthropic.com/v1/messages",jc="2023-06-01",Nc="claude-sonnet-4-6",kc={input:3/1e6,output:15/1e6},Sc={input:1/1e6,output:5/1e6},Ac=`You are wcagcheckr's accessibility-audit co-pilot.
578
578
 
579
579
  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.
580
580
 
@@ -585,10 +585,10 @@ Rules:
585
585
  - When you cite a WCAG criterion, use the dotted SC number (e.g. 1.4.3).
586
586
  - Don't be cheerful or evangelical. Be factual.
587
587
  - If the user asks for the impact-priority order, sort: critical > serious > moderate > minor.
588
- - The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function Ac(t,s,a){const n=a.includes("haiku")?kc:Nc;return t*n.input+s*n.output}async function Cc(t){const s=t.model||jc,a=t.maxTokens??800;if(t.messages.length===0||t.messages[t.messages.length-1].role!=="user")throw new Error("chatComplete: messages must end with a user turn");let n=t.system??Sc;!t.system&&t.auditContext&&(n+=`
588
+ - The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function Cc(t,s,a){const n=a.includes("haiku")?Sc:kc;return t*n.input+s*n.output}async function Ic(t){const s=t.model||Nc,a=t.maxTokens??800;if(t.messages.length===0||t.messages[t.messages.length-1].role!=="user")throw new Error("chatComplete: messages must end with a user turn");let n=t.system??Ac;!t.system&&t.auditContext&&(n+=`
589
589
 
590
590
  <audit-context>
591
591
  ${t.auditContext}
592
- </audit-context>`);const r=await fetch(yc,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":wc,"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(`
593
- `).trim(),i=o.usage.input_tokens,d=o.usage.output_tokens,p=Ac(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 Ic(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(`
594
- `)}const Js="aiConfig";function Ec(){var C;const t=y(f=>f.results),s=y(f=>f.componentId),[a,n]=m.useState([]),[r,o]=m.useState(""),[l,i]=m.useState(!1),[d,p]=m.useState(!1),[c,u]=m.useState("claude-sonnet-4-6"),h=m.useRef(""),x=m.useRef(null);m.useEffect(()=>{(async()=>{const j=(await chrome.storage.local.get(Js))[Js];h.current=(j==null?void 0:j.apiKey)??"",p(!!(j!=null&&j.apiKey)),j!=null&&j.model&&u(j.model)})()},[]),m.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[a.length]);const b=t.flatMap(f=>f.violations),w=Ic({componentId:s??void 0,pageUrl:(C=t[0])==null?void 0:C.pageUrl,violations:b.map(f=>({ruleId:f.ruleId,wcagCriterion:f.wcagCriterion,wcagLevel:f.wcagLevel,impact:f.impact,description:f.description,target:{selector:f.target.selector,outerHTML:f.target.outerHTML}}))}),N=a.reduce((f,j)=>f+(j.costUsd??0),0);async function E(){const f=r.trim();if(!f||l||!h.current)return;o("");const j={role:"user",content:f},g=[...a,j];n(g),i(!0);try{const v=g.map(k=>({role:k.role,content:k.content})),S=await Cc({apiKey:h.current,model:c,messages:v,auditContext:w});n([...g,{role:"assistant",content:S.text,costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens}])}catch(v){n([...g,{role:"assistant",content:"",error:v instanceof Error?v.message:String(v)}])}finally{i(!1)}}function I(){n([])}return d?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",N.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:I,className:"text-slate-600 hover:text-slate-900 underline",children:"Clear"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Ask questions about THIS audit (",b.length," violation",b.length===1?"":"s","). The model answers from the structured audit data only — it won't invent findings or check the live page."]}),e.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto space-y-2 border border-slate-200 rounded p-2 bg-white min-h-[200px]","data-testid":"copilot-transcript",children:[a.length===0?e.jsx("p",{className:"text-slate-400 italic text-[11px]",children:`Try: "Which 3 issues are highest priority?" · "Explain finding #1 in plain language" · "What's the cheapest fix on this page?"`}):a.map((f,j)=>e.jsxs("div",{className:f.role==="user"?"border-l-2 border-brand-400 pl-2 py-1":"border-l-2 border-emerald-400 pl-2 py-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-slate-500",children:f.role==="user"?"You":"Co-pilot"}),f.error?e.jsx("p",{className:"text-rose-700 whitespace-pre-wrap",children:f.error}):e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:f.content}),f.role==="assistant"&&f.costUsd!==void 0&&e.jsxs("p",{className:"text-[10px] text-slate-400 mt-1",children:["$",f.costUsd.toFixed(4)," · ",f.inputTokens,"→",f.outputTokens," tok"]})]},j)),l&&e.jsx("div",{className:"border-l-2 border-emerald-200 pl-2 py-1 text-[11px] text-slate-400 italic",children:"Thinking…"})]}),e.jsxs("form",{onSubmit:f=>{f.preventDefault(),E()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:f=>o(f.target.value),placeholder:"Ask about this audit…",disabled:l,"aria-label":"Co-pilot prompt",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50"}),e.jsx("button",{type:"submit",disabled:l||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:l?"Sending…":"Send"})]})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("p",{className:"text-slate-600 leading-snug",children:["The co-pilot uses your own Anthropic API key (BYOK) to answer questions about the current audit. Configure your key in ",e.jsx("strong",{children:"Settings → AI"})," to enable."]})]})}function Rc(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(""),[d,p]=m.useState(new Set);async function c(){o(null),n(!0);try{const x=await ue();if(!x){o("No audited tab. Open a page to audit, then return here.");return}const b=await Z({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:x});if(!b.ok||!b.nodes){o(b.error??"Snapshot failed for an unknown reason.");return}s(b.nodes)}finally{n(!1)}}function u(x){p(b=>{const w=new Set(b);return w.has(x)?w.delete(x):w.add(x),w})}const h=t&&l?t.filter(x=>x.role.toLowerCase().includes(l.toLowerCase())||x.name.toLowerCase().includes(l.toLowerCase())):t;return e.jsxs("div",{className:"p-3 text-xs flex flex-col h-full","data-testid":"ax-tree-view",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Accessibility tree"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"Snapshot of the browser's computed AX tree — what screen readers actually consume."})]}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value:l,onChange:x=>i(x.target.value),placeholder:"Filter by role or name…","aria-label":"Filter ax-tree",className:"flex-1 min-w-[140px] border border-slate-300 rounded px-2 py-1"}),e.jsxs("span",{className:"text-slate-500","data-testid":"ax-tree-node-count",children:[(h==null?void 0:h.length)??0," node",((h==null?void 0:h.length)??0)===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto border border-slate-200 rounded bg-white p-2 font-mono text-[11px]",children:[!t&&!a&&e.jsxs("p",{className:"text-slate-400 italic text-center pt-8",children:["Click ",e.jsx("strong",{children:"Snapshot tree"})," above to capture the audited tab's accessibility tree."]}),t&&h&&e.jsx(Tc,{nodes:t,filtered:h,collapsed:d,onToggle:u})]})]})}function Tc({nodes:t,filtered:s,collapsed:a,onToggle:n}){if(s.length!==t.length)return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:s.map(l=>e.jsx("li",{role:"treeitem",children:e.jsx(Wa,{node:l,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},l.nodeId))});const r=new Map;for(const l of t){const i=l.parentId,d=r.get(i)??[];d.push(l),r.set(i,d)}const o=r.get(void 0)??t.filter(l=>!l.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:o.map(l=>e.jsx(Va,{node:l,depth:0,byParent:r,collapsed:a,onToggle:n},l.nodeId))})}function Va({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const o=a.get(t.nodeId)??[],l=o.length>0,i=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":l?!i:void 0,children:[e.jsx(Wa,{node:t,depth:s,collapsed:i,onToggle:()=>r(t.nodeId),hasChildren:l}),!i&&l&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:o.map(d=>e.jsx(Va,{node:d,depth:s+1,byParent:a,collapsed:n,onToggle:r},d.nodeId))})]})}function Wa({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const o=t.properties.filter(l=>l.value!==!1&&l.value!==""&&l.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),o.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:o.map(l=>`${l.name}=${String(l.value)}`).join(" · ")})]})}function $c(){const t=y(p=>p.results),[s,a]=m.useState(!1),[n,r]=m.useState(null),[o,l]=m.useState(null);async function i(){r(null),a(!0);try{const p=await ue();if(!p){r("No audited tab. Open a page first.");return}const c=await Ee(p,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:p});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const u=new Map;for(const b of t)for(const w of b.violations)u.has(w.target.selector)||u.set(w.target.selector,w.matchKey);const h=c.references.map(b=>({violationMatchKey:u.get(b.selector)??null,referencedTokens:b.referencedTokens})),x=c.tokens;l(Un(x,h))}finally{a(!1)}}const d=o?$n(o):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void i(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":o?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),d&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(Ke,{label:"Total tokens",value:d.totalTokens}),e.jsx(Ke,{label:"Color tokens",value:d.colorTokens}),e.jsx(Ke,{label:"Used",value:d.usedTokens}),e.jsx(Ke,{label:"Unused",value:d.unusedTokens,tint:d.unusedTokens>0?"amber":"slate"}),e.jsx(Ke,{label:"In violations",value:d.violatingTokens,tint:d.violatingTokens>0?"rose":"slate"})]}),o&&o.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:o.map(p=>e.jsxs("li",{className:"px-3 py-2 space-y-1","data-testid":"ds-token-row",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:p.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:p.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",p.token.value]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["declared on ",e.jsx("code",{children:p.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[p.usageCount," usage",p.usageCount===1?"":"s"]}),p.violationMatchKeys.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"text-rose-700 font-semibold",children:[p.violationMatchKeys.length," violation",p.violationMatchKeys.length===1?"":"s"]})]})]})]},p.token.name))})]}):o?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function Ke({label:t,value:s,tint:a}){const n={slate:"bg-slate-50 text-slate-700",amber:"bg-amber-50 text-amber-800",rose:"bg-rose-50 text-rose-900"};return e.jsxs("div",{className:`px-2 py-1.5 rounded ${n[a??"slate"]}`,children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide",children:t}),e.jsx("div",{className:"text-base font-semibold leading-tight",children:s})]})}const $t="onboarding:dismissed",Ut="onboarding:exportTried",it="onboarding:collapsed";function Uc(){const t=y(v=>v.tier),s=y(v=>v.results),a=y(v=>v.baselineList),[n,r]=m.useState(!1),[o,l]=m.useState(!1),[i,d]=m.useState(!1),[p,c]=m.useState(!1),[u,h]=m.useState(null);m.useEffect(()=>{(async()=>{const v=await chrome.storage.local.get([$t,Ut,it]);r(v[$t]===!0),d(v[Ut]===!0),typeof v[it]=="boolean"&&h(v[it]);const S=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],k=await Promise.all(S.map(T=>Z({type:"SETTINGS_GET",key:T})));c(k.some(T=>typeof T.data=="string"&&T.data.length>0)),l(!0)})()},[]);const x=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:i?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:p?"done":"pending",optional:!0}],b=x.filter(v=>!v.optional),w=x.filter(v=>v.state==="done").length,N=b.filter(v=>v.state==="done").length,E=w===x.length,I=N===b.length;if(!o||n||I)return null;async function C(){r(!0),await chrome.storage.local.set({[$t]:!0})}async function f(){const v=!i;d(v),await chrome.storage.local.set({[Ut]:v})}const j=u??w>0;async function g(){const v=!j;h(v),await chrome.storage.local.set({[it]:v})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void g(),"aria-expanded":!j,"aria-controls":"onboarding-checklist-body",className:"flex-1 text-left flex items-center gap-1.5 hover:text-amber-950",children:[e.jsx("span",{className:"text-amber-800 text-[10px]","aria-hidden":"true",children:j?"▸":"▾"}),e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",w," of ",x.length," done"]})]}),e.jsx("button",{type:"button",onClick:()=>void C(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none",children:"✕"})]}),!j&&e.jsxs("div",{id:"onboarding-checklist-body",className:"mt-1.5",children:[e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug mb-1.5",children:["Quick checklist to get you started. ",E?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:x.map(v=>e.jsx("li",{className:"flex items-start gap-1.5",children:v.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:v.state==="done",onChange:()=>void f(),className:"mt-0.5","aria-label":v.label}),e.jsx("span",{className:v.state==="done"?"line-through text-amber-700":"text-amber-900",children:v.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:v.state==="done"?"✓":"○"}),e.jsxs("span",{className:v.state==="done"?"line-through text-amber-700":"text-amber-900",children:[v.label,v.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},v.id))})]})]})}function Lc(){const[t,s]=m.useState(""),[a,n]=m.useState(!1),[r,o]=m.useState(null);async function l(){if(!t.trim()){o("Paste a license token first.");return}n(!0),o(null);try{const i=await ae({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(i!=null&&i.validated)){const d=i!=null&&i.seatClaim&&"reason"in i.seatClaim?i.seatClaim.reason:null,p=i!=null&&i.seatClaim&&"hint"in i.seatClaim?i.seatClaim.hint:void 0;o(d==="cap-reached"?`License is at seat capacity. ${p??"Release a seat from another device or contact support."}`:d==="not-found"?"License not found. Check the token and try again.":d==="network"?`Network error: ${i!=null&&i.seatClaim&&"message"in i.seatClaim?i.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(i){o(i instanceof Error?i.message:String(i))}finally{n(!1)}}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white border border-slate-200 rounded-lg shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Private build phase"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"wcagcheckr is still in private development. Access is currently limited to issued team licenses. If you've been given a license token, paste it below to activate."}),e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:["If you don't have a license and would like beta access, email"," ",e.jsx("a",{href:"mailto:cliff@locustware.com?subject=wcagcheckr%20beta%20access",className:"text-brand-700 hover:underline",children:"cliff@locustware.com"}),". The public launch is coming."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"lockout-license-token",className:"block text-xs font-medium text-slate-700",children:"License token"}),e.jsx("textarea",{id:"lockout-license-token",value:t,onChange:i=>s(i.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function Wc(){const t=y(l=>l.view),s=y(l=>l.userMode),a=y(l=>l.tier),[n,r]=m.useState(!1);m.useEffect(()=>{const l=setTimeout(()=>r(!0),600);return()=>clearTimeout(l)},[]);const o=n&&Bt(a);return m.useEffect(()=>{const l=Bn(),d=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),p=Fn();oa({forceRefresh:!0}).catch(()=>{}),ht().catch(()=>{}),Wn().catch(()=>{}),Hn().catch(()=>{}),Gn().catch(()=>{}),Cn().then(h=>{y.getState().setAcknowledgedKeys(new Set(h.map(x=>x.matchKey)))}).catch(()=>{});const c=y.subscribe((h,x)=>{var N,E;const b=(N=h.results[0])==null?void 0:N.pageUrl,w=(E=x.results[0])==null?void 0:E.pageUrl;!b||b===w||Jt(b).then(I=>{y.getState().setDismissedKeys(new Set(Object.keys(I)))}).catch(()=>{})});In().then(h=>{h&&y.setState(x=>{const b={siteCrawlReport:h};return x.view==="matrix"&&x.results.length===0&&(b.view="crawl"),b})}).catch(()=>{});const u=h=>{if(h.key!=="Escape")return;const{pinnedMatchKey:x,setPinned:b,results:w}=y.getState();x&&(b(null),ue().then(N=>{var E;N&&be(N,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:N},(E=w[0])==null?void 0:E.frameId).catch(()=>{})}))};return window.addEventListener("keydown",u),()=>{p(),l.disconnect(),d==null||d.disconnect(),window.removeEventListener("keydown",u),c()}},[]),o?e.jsxs(e.Fragment,{children:[e.jsx(Lc,{}),e.jsx(tt,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Xo,{}),e.jsx(tt,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(hl,{}),e.jsx(Gs,{}),e.jsx(tt,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx(Ta,{}),e.jsx(ma,{}),e.jsx(ir,{}),e.jsx(Uc,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[t==="matrix"&&e.jsxs(e.Fragment,{children:[e.jsx(dr,{}),e.jsx(gr,{}),e.jsx(qo,{}),e.jsx(zo,{})]}),e.jsx(br,{}),e.jsx(Ho,{}),e.jsx(Ko,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Nr,{}),t==="report"&&e.jsx(Zi,{}),t==="delta"&&e.jsx(Na,{}),t==="activity"&&e.jsx(ya,{}),t==="guided"&&e.jsx(wo,{}),t==="flows"&&e.jsx(So,{}),t==="scorecard"&&e.jsx(Io,{}),t==="crawl"&&e.jsx(Ca,{}),t==="forensic"&&e.jsx(Ra,{}),t==="compliance"&&e.jsx(ic,{}),t==="schedules"&&e.jsx(pc,{}),t==="risk"&&e.jsx(vc,{}),t==="copilot"&&e.jsx(Ec,{}),t==="ax-tree"&&e.jsx(Rc,{}),t==="wcag3"&&e.jsx(Sa,{}),t==="tokens"&&e.jsx($c,{})]})]}),e.jsx(Jo,{}),e.jsx(Qo,{}),e.jsx(Bo,{}),e.jsx(Gs,{}),e.jsx(tt,{})]})}class Bc extends ze.Component{constructor(){super(...arguments);ls(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{Wc as A,Bc as E,yt as a,ht as b,Cc as c,Wn as d,Gn as e,Vc as f,Ne as l,Hn as p,oa as r,Bn as s,y as u,Fn as w};
592
+ </audit-context>`);const r=await fetch(wc,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":jc,"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(`
593
+ `).trim(),i=o.usage.input_tokens,d=o.usage.output_tokens,p=Cc(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 Ec(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(`
594
+ `)}const Js="aiConfig";function Rc(){var C;const t=y(f=>f.results),s=y(f=>f.componentId),[a,n]=m.useState([]),[r,o]=m.useState(""),[l,i]=m.useState(!1),[d,p]=m.useState(!1),[c,u]=m.useState("claude-sonnet-4-6"),h=m.useRef(""),g=m.useRef(null);m.useEffect(()=>{(async()=>{const j=(await chrome.storage.local.get(Js))[Js];h.current=(j==null?void 0:j.apiKey)??"",p(!!(j!=null&&j.apiKey)),j!=null&&j.model&&u(j.model)})()},[]),m.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[a.length]);const b=t.flatMap(f=>f.violations),w=Ec({componentId:s??void 0,pageUrl:(C=t[0])==null?void 0:C.pageUrl,violations:b.map(f=>({ruleId:f.ruleId,wcagCriterion:f.wcagCriterion,wcagLevel:f.wcagLevel,impact:f.impact,description:f.description,target:{selector:f.target.selector,outerHTML:f.target.outerHTML}}))}),N=a.reduce((f,j)=>f+(j.costUsd??0),0);async function E(){const f=r.trim();if(!f||l||!h.current)return;o("");const j={role:"user",content:f},x=[...a,j];n(x),i(!0);try{const v=x.map(k=>({role:k.role,content:k.content})),S=await Ic({apiKey:h.current,model:c,messages:v,auditContext:w});n([...x,{role:"assistant",content:S.text,costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens}])}catch(v){n([...x,{role:"assistant",content:"",error:v instanceof Error?v.message:String(v)}])}finally{i(!1)}}function I(){n([])}return d?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",N.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:I,className:"text-slate-600 hover:text-slate-900 underline",children:"Clear"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Ask questions about THIS audit (",b.length," violation",b.length===1?"":"s","). The model answers from the structured audit data only — it won't invent findings or check the live page."]}),e.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto space-y-2 border border-slate-200 rounded p-2 bg-white min-h-[200px]","data-testid":"copilot-transcript",children:[a.length===0?e.jsx("p",{className:"text-slate-400 italic text-[11px]",children:`Try: "Which 3 issues are highest priority?" · "Explain finding #1 in plain language" · "What's the cheapest fix on this page?"`}):a.map((f,j)=>e.jsxs("div",{className:f.role==="user"?"border-l-2 border-brand-400 pl-2 py-1":"border-l-2 border-emerald-400 pl-2 py-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-slate-500",children:f.role==="user"?"You":"Co-pilot"}),f.error?e.jsx("p",{className:"text-rose-700 whitespace-pre-wrap",children:f.error}):e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:f.content}),f.role==="assistant"&&f.costUsd!==void 0&&e.jsxs("p",{className:"text-[10px] text-slate-400 mt-1",children:["$",f.costUsd.toFixed(4)," · ",f.inputTokens,"→",f.outputTokens," tok"]})]},j)),l&&e.jsx("div",{className:"border-l-2 border-emerald-200 pl-2 py-1 text-[11px] text-slate-400 italic",children:"Thinking…"})]}),e.jsxs("form",{onSubmit:f=>{f.preventDefault(),E()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:f=>o(f.target.value),placeholder:"Ask about this audit…",disabled:l,"aria-label":"Co-pilot prompt",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50"}),e.jsx("button",{type:"submit",disabled:l||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:l?"Sending…":"Send"})]})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("p",{className:"text-slate-600 leading-snug",children:["The co-pilot uses your own Anthropic API key (BYOK) to answer questions about the current audit. Configure your key in ",e.jsx("strong",{children:"Settings → AI"})," to enable."]})]})}function Tc(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(""),[d,p]=m.useState(new Set);async function c(){o(null),n(!0);try{const g=await ue();if(!g){o("No audited tab. Open a page to audit, then return here.");return}const b=await Z({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:g});if(!b.ok||!b.nodes){o(b.error??"Snapshot failed for an unknown reason.");return}s(b.nodes)}finally{n(!1)}}function u(g){p(b=>{const w=new Set(b);return w.has(g)?w.delete(g):w.add(g),w})}const h=t&&l?t.filter(g=>g.role.toLowerCase().includes(l.toLowerCase())||g.name.toLowerCase().includes(l.toLowerCase())):t;return e.jsxs("div",{className:"p-3 text-xs flex flex-col h-full","data-testid":"ax-tree-view",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Accessibility tree"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"Snapshot of the browser's computed AX tree — what screen readers actually consume."})]}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value:l,onChange:g=>i(g.target.value),placeholder:"Filter by role or name…","aria-label":"Filter ax-tree",className:"flex-1 min-w-[140px] border border-slate-300 rounded px-2 py-1"}),e.jsxs("span",{className:"text-slate-500","data-testid":"ax-tree-node-count",children:[(h==null?void 0:h.length)??0," node",((h==null?void 0:h.length)??0)===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto border border-slate-200 rounded bg-white p-2 font-mono text-[11px]",children:[!t&&!a&&e.jsxs("p",{className:"text-slate-400 italic text-center pt-8",children:["Click ",e.jsx("strong",{children:"Snapshot tree"})," above to capture the audited tab's accessibility tree."]}),t&&h&&e.jsx($c,{nodes:t,filtered:h,collapsed:d,onToggle:u})]})]})}function $c({nodes:t,filtered:s,collapsed:a,onToggle:n}){if(s.length!==t.length)return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:s.map(l=>e.jsx("li",{role:"treeitem",children:e.jsx(Ba,{node:l,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},l.nodeId))});const r=new Map;for(const l of t){const i=l.parentId,d=r.get(i)??[];d.push(l),r.set(i,d)}const o=r.get(void 0)??t.filter(l=>!l.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:o.map(l=>e.jsx(Wa,{node:l,depth:0,byParent:r,collapsed:a,onToggle:n},l.nodeId))})}function Wa({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const o=a.get(t.nodeId)??[],l=o.length>0,i=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":l?!i:void 0,children:[e.jsx(Ba,{node:t,depth:s,collapsed:i,onToggle:()=>r(t.nodeId),hasChildren:l}),!i&&l&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:o.map(d=>e.jsx(Wa,{node:d,depth:s+1,byParent:a,collapsed:n,onToggle:r},d.nodeId))})]})}function Ba({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const o=t.properties.filter(l=>l.value!==!1&&l.value!==""&&l.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),o.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:o.map(l=>`${l.name}=${String(l.value)}`).join(" · ")})]})}function Lc(){const t=y(p=>p.results),[s,a]=m.useState(!1),[n,r]=m.useState(null),[o,l]=m.useState(null);async function i(){r(null),a(!0);try{const p=await ue();if(!p){r("No audited tab. Open a page first.");return}const c=await Ee(p,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:p});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const u=new Map;for(const b of t)for(const w of b.violations)u.has(w.target.selector)||u.set(w.target.selector,w.matchKey);const h=c.references.map(b=>({violationMatchKey:u.get(b.selector)??null,referencedTokens:b.referencedTokens})),g=c.tokens;l(Un(g,h))}finally{a(!1)}}const d=o?Ln(o):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void i(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":o?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),d&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(Ke,{label:"Total tokens",value:d.totalTokens}),e.jsx(Ke,{label:"Color tokens",value:d.colorTokens}),e.jsx(Ke,{label:"Used",value:d.usedTokens}),e.jsx(Ke,{label:"Unused",value:d.unusedTokens,tint:d.unusedTokens>0?"amber":"slate"}),e.jsx(Ke,{label:"In violations",value:d.violatingTokens,tint:d.violatingTokens>0?"rose":"slate"})]}),o&&o.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:o.map(p=>e.jsxs("li",{className:"px-3 py-2 space-y-1","data-testid":"ds-token-row",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:p.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:p.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",p.token.value]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["declared on ",e.jsx("code",{children:p.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[p.usageCount," usage",p.usageCount===1?"":"s"]}),p.violationMatchKeys.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"text-rose-700 font-semibold",children:[p.violationMatchKeys.length," violation",p.violationMatchKeys.length===1?"":"s"]})]})]})]},p.token.name))})]}):o?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function Ke({label:t,value:s,tint:a}){const n={slate:"bg-slate-50 text-slate-700",amber:"bg-amber-50 text-amber-800",rose:"bg-rose-50 text-rose-900"};return e.jsxs("div",{className:`px-2 py-1.5 rounded ${n[a??"slate"]}`,children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide",children:t}),e.jsx("div",{className:"text-base font-semibold leading-tight",children:s})]})}const $t="onboarding:dismissed",Lt="onboarding:exportTried",rt="onboarding:collapsed";function Uc(){const t=y(v=>v.tier),s=y(v=>v.results),a=y(v=>v.baselineList),[n,r]=m.useState(!1),[o,l]=m.useState(!1),[i,d]=m.useState(!1),[p,c]=m.useState(!1),[u,h]=m.useState(null);m.useEffect(()=>{(async()=>{const v=await chrome.storage.local.get([$t,Lt,rt]);r(v[$t]===!0),d(v[Lt]===!0),typeof v[rt]=="boolean"&&h(v[rt]);const S=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],k=await Promise.all(S.map(T=>Z({type:"SETTINGS_GET",key:T})));c(k.some(T=>typeof T.data=="string"&&T.data.length>0)),l(!0)})()},[]);const g=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:i?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:p?"done":"pending",optional:!0}],b=g.filter(v=>!v.optional),w=g.filter(v=>v.state==="done").length,N=b.filter(v=>v.state==="done").length,E=w===g.length,I=N===b.length;if(!o||n||I)return null;async function C(){r(!0),await chrome.storage.local.set({[$t]:!0})}async function f(){const v=!i;d(v),await chrome.storage.local.set({[Lt]:v})}const j=u??w>0;async function x(){const v=!j;h(v),await chrome.storage.local.set({[rt]:v})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void x(),"aria-expanded":!j,"aria-controls":"onboarding-checklist-body",className:"flex-1 text-left flex items-center gap-1.5 hover:text-amber-950",children:[e.jsx("span",{className:"text-amber-800 text-[10px]","aria-hidden":"true",children:j?"▸":"▾"}),e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",w," of ",g.length," done"]})]}),e.jsx("button",{type:"button",onClick:()=>void C(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none",children:"✕"})]}),!j&&e.jsxs("div",{id:"onboarding-checklist-body",className:"mt-1.5",children:[e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug mb-1.5",children:["Quick checklist to get you started. ",E?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:g.map(v=>e.jsx("li",{className:"flex items-start gap-1.5",children:v.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:v.state==="done",onChange:()=>void f(),className:"mt-0.5","aria-label":v.label}),e.jsx("span",{className:v.state==="done"?"line-through text-amber-700":"text-amber-900",children:v.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:v.state==="done"?"✓":"○"}),e.jsxs("span",{className:v.state==="done"?"line-through text-amber-700":"text-amber-900",children:[v.label,v.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},v.id))})]})]})}function _c(){const[t,s]=m.useState(""),[a,n]=m.useState(!1),[r,o]=m.useState(null);async function l(){if(!t.trim()){o("Paste a license token first.");return}n(!0),o(null);try{const i=await ne({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(i!=null&&i.validated)){const d=i!=null&&i.seatClaim&&"reason"in i.seatClaim?i.seatClaim.reason:null,p=i!=null&&i.seatClaim&&"hint"in i.seatClaim?i.seatClaim.hint:void 0;o(d==="cap-reached"?`License is at seat capacity. ${p??"Release a seat from another device or contact support."}`:d==="not-found"?"License not found. Check the token and try again.":d==="network"?`Network error: ${i!=null&&i.seatClaim&&"message"in i.seatClaim?i.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(i){o(i instanceof Error?i.message:String(i))}finally{n(!1)}}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white border border-slate-200 rounded-lg shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Private build phase"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"wcagcheckr is still in private development. Access is currently limited to issued team licenses. If you've been given a license token, paste it below to activate."}),e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:["If you don't have a license and would like beta access, email"," ",e.jsx("a",{href:"mailto:cliff@locustware.com?subject=wcagcheckr%20beta%20access",className:"text-brand-700 hover:underline",children:"cliff@locustware.com"}),". The public launch is coming."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"lockout-license-token",className:"block text-xs font-medium text-slate-700",children:"License token"}),e.jsx("textarea",{id:"lockout-license-token",value:t,onChange:i=>s(i.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function Bc(){const t=y(l=>l.view),s=y(l=>l.userMode),a=y(l=>l.tier),[n,r]=m.useState(!1);m.useEffect(()=>{const l=setTimeout(()=>r(!0),600);return()=>clearTimeout(l)},[]);const o=n&&Bt(a);return m.useEffect(()=>{const l=Hn(),d=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),p=Mn();oa({forceRefresh:!0}).catch(()=>{}),pt().catch(()=>{}),Bn().catch(()=>{}),Kn().catch(()=>{}),Vn().catch(()=>{}),In().then(h=>{y.getState().setAcknowledgedKeys(new Set(h.map(g=>g.matchKey)))}).catch(()=>{});const c=y.subscribe((h,g)=>{var N,E;const b=(N=h.results[0])==null?void 0:N.pageUrl,w=(E=g.results[0])==null?void 0:E.pageUrl;!b||b===w||Jt(b).then(I=>{y.getState().setDismissedKeys(new Set(Object.keys(I)))}).catch(()=>{})});En().then(h=>{h&&y.setState(g=>{const b={siteCrawlReport:h};return g.view==="matrix"&&g.results.length===0&&(b.view="crawl"),b})}).catch(()=>{});const u=h=>{if(h.key!=="Escape")return;const{pinnedMatchKey:g,setPinned:b,results:w}=y.getState();g&&(b(null),ue().then(N=>{var E;N&&be(N,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:N},(E=w[0])==null?void 0:E.frameId).catch(()=>{})}))};return window.addEventListener("keydown",u),()=>{p(),l.disconnect(),d==null||d.disconnect(),window.removeEventListener("keydown",u),c()}},[]),o?e.jsxs(e.Fragment,{children:[e.jsx(_c,{}),e.jsx(Nt,{})]}):s==="owner"||s===null?e.jsxs(e.Fragment,{children:[e.jsx(ml,{}),e.jsx(Gs,{}),e.jsx(Nt,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx($a,{}),e.jsx(ma,{}),e.jsx(lr,{}),e.jsx(Uc,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[t==="matrix"&&e.jsxs(e.Fragment,{children:[e.jsx(pr,{}),e.jsx(br,{}),e.jsx(Yo,{}),e.jsx(Qo,{})]}),e.jsx(yr,{}),e.jsx(zo,{}),e.jsx(qo,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Sr,{}),t==="report"&&e.jsx(to,{}),t==="delta"&&e.jsx(ka,{}),t==="activity"&&e.jsx(wa,{}),t==="guided"&&e.jsx(No,{}),t==="flows"&&e.jsx(Co,{}),t==="scorecard"&&e.jsx(Ro,{}),t==="crawl"&&e.jsx(Ia,{}),t==="forensic"&&e.jsx(Ta,{}),t==="compliance"&&e.jsx(oc,{}),t==="schedules"&&e.jsx(hc,{}),t==="risk"&&e.jsx(yc,{}),t==="copilot"&&e.jsx(Rc,{}),t==="ax-tree"&&e.jsx(Tc,{}),t==="wcag3"&&e.jsx(Aa,{}),t==="tokens"&&e.jsx(Lc,{})]})]}),e.jsx(Zo,{}),e.jsx(Jo,{}),e.jsx(Ko,{}),e.jsx(Gs,{}),e.jsx(Nt,{})]})}class Hc extends ze.Component{constructor(){super(...arguments);ls(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{Bc as A,Hc as E,xa as P,vt as a,pt as b,Ic as c,Bn as d,Vn as e,Wc as f,Ne as l,Kn as p,oa as r,Hn as s,y as u,Mn as w};