@wcag-checkr/ci 1.0.0-rc.153 → 1.0.0-rc.155
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.
- package/dist/assets/{ErrorBoundary-CdSTiTs9.js → ErrorBoundary-Cg6DhMfS.js} +92 -92
- package/dist/assets/{copy-ai-fixer-prompt-DVAS4M9I.js → copy-ai-fixer-prompt-BHcnobbQ.js} +2 -2
- package/dist/assets/{devtools-panel-Bn5R7BTh.js → devtools-panel-Cp1MJfjg.js} +1 -1
- package/dist/assets/{options-ClxG2liN.js → options-BSkpv6po.js} +1 -1
- package/dist/assets/{parallel-tab-flow-BbWRe96L.js → parallel-tab-flow-BGAqpb6Z.js} +1 -1
- package/dist/assets/{scheduled-audit-runner-3nAUxKGr.js → scheduled-audit-runner-ClDJTr8Y.js} +32 -32
- package/dist/assets/{service-worker.ts-CF6EmdXS.js → service-worker.ts-CdVRBBhd.js} +3 -3
- package/dist/assets/{side-panel-DqXk3mGm.js → side-panel-B0ZYHuqY.js} +1 -1
- package/dist/assets/{site-report-renderer-CzL3uuvq.js → site-report-renderer-Cxo8Bmrd.js} +1 -1
- package/dist/assets/styles-C4gep7iU.css +1 -0
- package/dist/devtools/panel.html +5 -5
- package/dist/manifest.json +3 -5
- package/dist/options/options.html +3 -3
- package/dist/service-worker-loader.js +1 -1
- package/dist/side-panel/side-panel.html +5 -5
- package/package.json +1 -1
- package/dist/assets/styles-g9acj6NU.css +0 -1
- /package/dist/assets/{styles-CQDHUn-m.js → styles-DE1o3-OY.js} +0 -0
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-
|
|
2
|
-
var na=Object.defineProperty;var ra=(t,s,a)=>s in t?na(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var At=(t,s,a)=>ra(t,typeof s!="symbol"?s+"":s,a);import{R as Ie,i as le,r as m,j as e,M as ve,C as nt,l as ia,o as pt,t as ht,m as ms,s as xs,k as Te}from"./styles-CQDHUn-m.js";import{s as oa,g as la,a as ae,b as ca,u as da,c as ua,d as pa,e as ha,f as mt,h as gs,A as ie,l as xt,i as ma,j as De,k as fs,m as xa,n as gt,o as ga,p as fa,N as ba,q as va,O as ya,r as wa,t as ja,v as Na,w as Ct,x as ka,y as bs,z as Sa,B as Aa,C as Ca,D as Ia,E as Ea,F as Ra,T as Ta,G as $a,H as Ua,I as La,J as vs,K as _a,L as It,M as Et,P as qe,Q as Da,R as Rt,S as Oa,U as Ma,V as Fa,W as Pa,X as Ga,Y as Va}from"./scheduled-audit-runner-3nAUxKGr.js";import{_ as ft}from"./diff-DA41zYPc.js";import{o as pe,r as ee,s as re,c as ys,b as de,d as me}from"./crash-reporter-Dc5lvxvY.js";import{B as Qe,i as ws,f as js,T as Ns}from"./ai-usage-log-DBBVxutJ.js";import{s as Wa,t as Ba}from"./design-system-audit-DpxJrxnb.js";const Tt=t=>{let s;const a=new Set,n=(u,d)=>{const p=typeof u=="function"?u(s):u;if(!Object.is(p,s)){const h=s;s=d??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(x=>x(s,h))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>c,subscribe:u=>(a.add(u),()=>a.delete(u))},c=s=t(n,r,l);return l},Ha=t=>t?Tt(t):Tt,za=t=>t;function Ka(t,s=za){const a=Ie.useSyncExternalStore(t.subscribe,Ie.useCallback(()=>s(t.getState()),[t,s]),Ie.useCallback(()=>s(t.getInitialState()),[t,s]));return Ie.useDebugValue(a),a}const $t=t=>{const s=Ha(t),a=n=>Ka(s,n);return Object.assign(a,s),a},qa=t=>t?$t(t):$t,v=qa(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",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,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}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),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}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),oa(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}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),Fe="sidePanel:lastAudit";function Qa(){const t=[];return t.push(pe("AUDIT_PROGRESS_EVENT",s=>{const a=v.getState().status==="running";v.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),v.getState().setStatus("running"),a||le.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(pe("AUDIT_COMPLETE_EVENT",s=>{var i;v.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.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"}.`;le.polite(r),Ya({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(pe("AUDIT_FAILED_EVENT",s=>{v.getState().setError(s.error.message)})),t.push(pe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=v.getState().aiProgress;v.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||le.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(pe("AI_AUGMENTATION_FAILED_EVENT",s=>{v.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(pe("SCORECARD_UPDATED_EVENT",()=>{Pe()})),t.push(pe("LICENSE_CHANGED_EVENT",()=>{ks()})),t.push(pe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&le.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(pe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),le.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(pe("SITE_CRAWL_FAILED_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),le.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Ya(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Fe]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Ja(){const s=(await chrome.storage.local.get(Fe))[Fe];s&&v.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Xa(){await chrome.storage.local.remove(Fe)}async function He(){v.getState().clearResults(),await Xa()}async function Pe(){const t=await ee({type:"BASELINE_LIST"});v.getState().setBaselineList(t.items)}async function ks(t){const s=await ee({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});v.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Ss()}async function Ss(){const{fetchMessages:t}=await ft(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>ln);return{fetchMessages:n}},void 0),s=v.getState().userMode,a=await t(s);a&&v.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Za(){const s=(await ee({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;v.getState().setUserMode(a)}function en(){return chrome.runtime.connect({name:"audit-keepalive"})}let Ge=null;async function tn(){if(Ge===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Ge=t.id)}catch{}}function As(){if(Ge===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ge}).catch(()=>{})}function he(t){As(),re(t)}function sn({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[i,o]=m.useState(!0),[l,c]=m.useState(""),[u,d]=m.useState(!1),[p,h]=m.useState(null);async function x(g){var j;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),h(null);try{const A=await ee({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});A.success?(h({ok:!0,msg:`Sent (ref: ${A.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((j=A.error)==null?void 0:j.message)??"Failed to send"})}finally{d(!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:g=>a(g.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:g=>r(g.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:l,onChange:g=>c(g.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:g=>o(g.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)."})]}),p&&e.jsx("p",{id:"support-form-result",role:p.ok?"status":"alert",className:`text-xs ${p.ok?"text-green-700":"text-red-700"}`,children:p.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:u,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:u?"Sending…":"Send"})]})]})}function Ut({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 Ve=ys("messages-client"),an="https://api.wcagcheckr.com",Cs="wcagcheckr",nn=1e4;function rn(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Is(t,s){const a=await la();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":rn()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${an}${t}`,{...s,headers:n,signal:AbortSignal.timeout(nn)})}async function on(t){try{const s=await Is(`/v1/products/${Cs}/messages`,{userMode:t??null});return s.ok?await s.json():(Ve.warn("fetchMessages http",s.status),null)}catch(s){return Ve.warn("fetchMessages failed",s),null}}async function ge(t,s){try{const a=await Is(`/v1/products/${Cs}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Ve.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Ve.warn("ackMessage failed",a),!1}}const ln=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ge,fetchMessages:on},Symbol.toStringTag,{value:"Module"})),cn=["http:","https:"];function dn(t){try{const s=new URL(t);return cn.includes(s.protocol)}catch{return!1}}function Lt(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),c=t.slice(i+2,o);dn(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(m.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(m.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function Es({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Lt(c)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,u)=>e.jsx("li",{children:Lt(c)},u))},`u-${i++}`)),n=[])}for(const c of s){const u=c.trimEnd();if(u===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(u);if(d){o(),n.push(d[1]);continue}l(),r.push(u)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const un={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},pn={critical:"bg-rose-50 border-rose-200"};function Rs(){const t=v(h=>h.unreadMessageCount),s=v(h=>h.messages),a=v(h=>h.applyMessageAck),[n,r]=m.useState(!1),i=m.useRef(-1),[o,l]=m.useState(!1);m.useEffect(()=>{const h=s.filter(g=>!g.seen);if(h.length===0)return;const x=Math.max(...h.map(g=>g.id));if(x>i.current){i.current=x,l(!0);const g=setTimeout(()=>l(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const h=s.filter(x=>!x.seen);if(h.length!==0)for(const x of h)a(x.id,"seen"),ge(x.id,"seen")}function u(){const h=!n;r(h),h&&c()}async function d(h){a(h.id,"dismissed"),await ge(h.id,"dismissed")}async function p(h){h.ctaUrl&&(a(h.id,"clicked"),ge(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:u,"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 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(hn,{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(mn,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:p})]})}function hn({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 mn({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=m.useRef(null);return m.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[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:()=>{Ss()},className:"text-[11px] text-brand-700 hover:underline",children:"Refresh"})]}),t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-[11px]",children:"No messages."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(i=>e.jsx("li",{className:`p-3 ${i.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${un[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(Es,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function Ts(){const t=v(i=>i.messages),s=v(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ge(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ge(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${pn.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(Es,{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 ye=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","risk","copilot","ax-tree","wcag3","tokens","forensic","compliance"];function xn(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function gn(){var p,h;const t=v(x=>x.view),s=v(x=>x.setView),a=v(x=>x.setUserMode),n=v(x=>x.results),r=v(x=>x.status),[i,o]=m.useState(!1),l=((p=n[0])==null?void 0:p.pageUrl)??((h=n[0])==null?void 0:h.scope),c=xn(l),u=n.length>0&&r!=="running";function d(){a("owner"),re({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:d,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(Rs,{}),e.jsx(Ut,{onClick:()=>void re({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Ut,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),u&&c&&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 ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void He(),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(fn,{view:t,setView:s}),e.jsx(ve,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(sn,{onClose:()=>o(!1)})})]})}function fn({view:t,setView:s}){const a=m.useRef([]);function n(i){var c;const o=(i+ye.length)%ye.length,l=ye[o];l&&(s(l),(c=a.current[o])==null||c.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ye.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ye.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{a.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function bn({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(nt,{open:a,onClose:()=>n(!1)})]})}const vn="https://wcagcheckr.com/upgrade";function yn(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState(null),[c,u]=m.useState(Qe),[d,p]=m.useState(Qe[0].id),[h,x]=m.useState("none"),[g,j]=m.useState(null),A=v(F=>F.status),T=v(F=>F.tier),k=v(F=>F.results.length>0),w=A==="running";m.useEffect(()=>{Promise.all([ee({type:"SETTINGS_GET",key:"matrixPresets"}),ee({type:"SETTINGS_GET",key:"activePresetId"})]).then(([F,Z])=>{const se=Array.isArray(F.data)?F.data:null;u(se&&se.length>0?se:Qe),typeof Z.data=="string"&&p(Z.data)})},[]);function f(F){const Z=c.find(se=>se.id===F);Z&&(p(F),re({type:"SETTINGS_SET",key:"activePresetId",value:F}),re({type:"SETTINGS_SET",key:"stateMatrix",value:Z.matrix}))}const S=ws(T,"storybookAutoIterate");m.useEffect(()=>{const F=pe("ELEMENT_PICKED_EVENT",(se,E)=>{n(!1);const q=E.frameId;D(q),i({selector:se.selector,frameId:q,speech:se.speech})}),Z=pe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{F(),Z()}},[]);async function N(){const F=await ae();F&&(n(!0),await de(F,{type:"PICKER_ACTIVATE_REQUEST",tabId:F}))}function I(){r&&(D(r.frameId),he({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),v.getState().startNewScan())}function U(){if(!S){l("storybook:auto-iterate");return}D(),he({type:"START_AUDIT",mode:"storybook-all"}),v.getState().startNewScan()}function y(){D(),he({type:"START_AUDIT",mode:"all-frames"}),v.getState().startNewScan()}function L(){D(),he({type:"START_AUDIT",mode:"full-page"}),v.getState().startNewScan()}function H(){D(),he({type:"START_AUDIT",mode:"quick-scan"}),v.getState().startNewScan()}function C(){D(),he({type:"START_AUDIT",mode:"parallel-scan"}),v.getState().startNewScan()}function M(){re({type:"CANCEL_AUDIT"})}async function D(F){v.getState().setPinned(null);const Z=await ae();if(Z)try{await de(Z,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:Z},F)}catch{}}async function X(F){j(null);const Z=await ae();if(!Z){j("No audited tab; open a page first.");return}if(F==="none"){const E=await ee({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:Z});E.ok||j(E.error??"Failed to clear throttle."),x("none");return}const se=await ee({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:Z,profile:F});if(!se.ok){j(se.error??"Failed to apply throttle.");return}x(F)}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:F=>s(F.target.value),disabled:w||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)",S?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:F=>f(F.target.value),disabled:w||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:c.map(F=>e.jsx("option",{value:F.id,children:F.name},F.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:F=>void X(F.target.value),disabled:w||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(jn,{picking:a,picked:r,isRunning:w,onPick:N,onRun:I,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:L,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:H,disabled:w,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:w?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:C,disabled:w,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:w?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:y,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:U,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all stories"}),w&&e.jsx("button",{onClick:M,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&k&&e.jsx("button",{type:"button",onClick:()=>void He(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),g&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",g]}),t==="single-element"&&r&&!a&&!w&&e.jsx(Nn,{selector:r.selector,onRepick:N,onClear:()=>i(null)})]}),e.jsx(ve,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(bn,{feature:o??"",upgradeUrl:vn})})]})}function wn({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 jn({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}),e.jsx(wn,{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 Nn({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 kn={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Sn={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function An(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState("off"),u=v(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await ae();g&&(l(x),x==="off"?await de(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await de(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function p(x){const g=await ae();if(g){if(t&&await de(g,{type:kn[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await de(g,{type:Sn[x],tabId:g}).catch(()=>{}),s(x)}}async function h(){const x=await ae();if(x){if(a){await de(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(u.length===0){i("Run an audit first.");return}try{const g=await me(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:u});n(!0),i(`Previewing ${g.visualFixCount} visual fix${g.visualFixCount===1?"":"es"} + ${g.annotationCount} annotation${g.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(we,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(we,{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:()=>p("tab-order")}),e.jsx(we,{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:()=>p("reading-order")}),e.jsx(we,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(we,{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:o,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="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 we({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 Cn(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 In(){const t=v(c=>c.status),s=v(c=>c.progress),a=v(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":Cn(s.currentState),o=n?100:s.current/s.total*100,l=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(_t,{label:r,detail:i,pct:o,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"}),l&&e.jsx(_t,{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 _t({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){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 ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}function $s(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Dt(t){if(!$s())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/copy-ai-fixer-prompt-BHcnobbQ.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-Cxo8Bmrd.js","assets/scheduled-audit-runner-ClDJTr8Y.js","assets/ai-usage-log-DBBVxutJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var ra=Object.defineProperty;var ia=(t,s,a)=>s in t?ra(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Ct=(t,s,a)=>ia(t,typeof s!="symbol"?s+"":s,a);import{R as Ie,i as le,r as m,j as e,M as ve,C as rt,l as oa,o as ht,t as mt,m as xs,s as gs,k as Te}from"./styles-DE1o3-OY.js";import{s as la,g as ca,a as ae,b as da,u as ua,c as pa,d as ha,e as ma,f as xt,h as fs,A as ie,l as gt,i as xa,j as Oe,k as bs,m as ga,n as ft,o as fa,p as ba,N as va,q as ya,O as wa,r as ja,t as Na,v as ka,w as It,x as Sa,y as vs,z as Aa,B as Ca,C as Ia,D as Ea,E as Ra,F as Ta,T as $a,G as Ua,H as La,I as _a,J as ys,K as Da,L as Et,M as Rt,P as Qe,Q as Oa,R as Tt,S as Ma,U as Fa,V as Pa,W as Ga,X as Va,Y as Wa}from"./scheduled-audit-runner-ClDJTr8Y.js";import{_ as bt}from"./diff-DA41zYPc.js";import{o as pe,r as ee,s as re,c as ws,b as de,d as me}from"./crash-reporter-Dc5lvxvY.js";import{B as Ye,i as js,f as Ns,T as ks}from"./ai-usage-log-DBBVxutJ.js";import{s as Ba,t as Ha}from"./design-system-audit-DpxJrxnb.js";const $t=t=>{let s;const a=new Set,n=(u,d)=>{const p=typeof u=="function"?u(s):u;if(!Object.is(p,s)){const h=s;s=d??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(x=>x(s,h))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>c,subscribe:u=>(a.add(u),()=>a.delete(u))},c=s=t(n,r,l);return l},za=t=>t?$t(t):$t,Ka=t=>t;function qa(t,s=Ka){const a=Ie.useSyncExternalStore(t.subscribe,Ie.useCallback(()=>s(t.getState()),[t,s]),Ie.useCallback(()=>s(t.getInitialState()),[t,s]));return Ie.useDebugValue(a),a}const Ut=t=>{const s=za(t),a=n=>qa(s,n);return Object.assign(a,s),a},Qa=t=>t?Ut(t):Ut,y=Qa(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",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,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}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),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}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),la(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}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),Pe="sidePanel:lastAudit";function Ya(){const t=[];return t.push(pe("AUDIT_PROGRESS_EVENT",s=>{const a=y.getState().status==="running";y.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),y.getState().setStatus("running"),a||le.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(pe("AUDIT_COMPLETE_EVENT",s=>{var i;y.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.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"}.`;le.polite(r),Ja({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(pe("AUDIT_FAILED_EVENT",s=>{y.getState().setError(s.error.message)})),t.push(pe("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||le.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(pe("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(pe("SCORECARD_UPDATED_EVENT",()=>{Ge()})),t.push(pe("LICENSE_CHANGED_EVENT",()=>{Ss()})),t.push(pe("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&&le.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(pe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=y.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),le.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(pe("SITE_CRAWL_FAILED_EVENT",s=>{const a=y.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),le.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Ja(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Pe]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Xa(){const s=(await chrome.storage.local.get(Pe))[Pe];s&&y.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Za(){await chrome.storage.local.remove(Pe)}async function ze(){y.getState().clearResults(),await Za()}async function Ge(){const t=await ee({type:"BASELINE_LIST"});y.getState().setBaselineList(t.items)}async function Ss(t){const s=await ee({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}),As()}async function As(){const{fetchMessages:t}=await bt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>cn);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 en(){const s=(await ee({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;y.getState().setUserMode(a)}function tn(){return chrome.runtime.connect({name:"audit-keepalive"})}let Ve=null;async function sn(){if(Ve===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Ve=t.id)}catch{}}function Cs(){if(Ve===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ve}).catch(()=>{})}function he(t){Cs(),re(t)}function an({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[i,o]=m.useState(!0),[l,c]=m.useState(""),[u,d]=m.useState(!1),[p,h]=m.useState(null);async function x(g){var j;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),h(null);try{const S=await ee({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});S.success?(h({ok:!0,msg:`Sent (ref: ${S.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((j=S.error)==null?void 0:j.message)??"Failed to send"})}finally{d(!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:g=>a(g.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:g=>r(g.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:l,onChange:g=>c(g.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:g=>o(g.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)."})]}),p&&e.jsx("p",{id:"support-form-result",role:p.ok?"status":"alert",className:`text-xs ${p.ok?"text-green-700":"text-red-700"}`,children:p.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:u,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:u?"Sending…":"Send"})]})]})}function Lt({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 We=ws("messages-client"),nn="https://api.wcagcheckr.com",Is="wcagcheckr",rn=1e4;function on(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Es(t,s){const a=await ca();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":on()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${nn}${t}`,{...s,headers:n,signal:AbortSignal.timeout(rn)})}async function ln(t){try{const s=await Es(`/v1/products/${Is}/messages`,{userMode:t??null});return s.ok?await s.json():(We.warn("fetchMessages http",s.status),null)}catch(s){return We.warn("fetchMessages failed",s),null}}async function ge(t,s){try{const a=await Es(`/v1/products/${Is}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(We.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return We.warn("ackMessage failed",a),!1}}const cn=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ge,fetchMessages:ln},Symbol.toStringTag,{value:"Module"})),dn=["http:","https:"];function un(t){try{const s=new URL(t);return dn.includes(s.protocol)}catch{return!1}}function _t(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),c=t.slice(i+2,o);un(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(m.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(m.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function Rs({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:_t(c)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,u)=>e.jsx("li",{children:_t(c)},u))},`u-${i++}`)),n=[])}for(const c of s){const u=c.trimEnd();if(u===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(u);if(d){o(),n.push(d[1]);continue}l(),r.push(u)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const pn={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},hn={critical:"bg-rose-50 border-rose-200"};function Ts(){const t=y(h=>h.unreadMessageCount),s=y(h=>h.messages),a=y(h=>h.applyMessageAck),[n,r]=m.useState(!1),i=m.useRef(-1),[o,l]=m.useState(!1);m.useEffect(()=>{const h=s.filter(g=>!g.seen);if(h.length===0)return;const x=Math.max(...h.map(g=>g.id));if(x>i.current){i.current=x,l(!0);const g=setTimeout(()=>l(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const h=s.filter(x=>!x.seen);if(h.length!==0)for(const x of h)a(x.id,"seen"),ge(x.id,"seen")}function u(){const h=!n;r(h),h&&c()}async function d(h){a(h.id,"dismissed"),await ge(h.id,"dismissed")}async function p(h){h.ctaUrl&&(a(h.id,"clicked"),ge(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:u,"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 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(mn,{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(xn,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:p})]})}function mn({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 xn({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=m.useRef(null);return m.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[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:()=>{As()},className:"text-[11px] text-brand-700 hover:underline",children:"Refresh"})]}),t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-[11px]",children:"No messages."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(i=>e.jsx("li",{className:`p-3 ${i.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${pn[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(Rs,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function $s(){const t=y(i=>i.messages),s=y(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ge(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ge(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${hn.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(Rs,{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 ye=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","risk","copilot","ax-tree","wcag3","tokens","forensic","compliance"];function gn(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function fn(){var p,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),[i,o]=m.useState(!1),l=((p=n[0])==null?void 0:p.pageUrl)??((h=n[0])==null?void 0:h.scope),c=gn(l),u=n.length>0&&r!=="running";function d(){a("owner"),re({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:d,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(Ts,{}),e.jsx(Lt,{onClick:()=>void re({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Lt,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),u&&c&&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 ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void ze(),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(bn,{view:t,setView:s}),e.jsx(ve,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(an,{onClose:()=>o(!1)})})]})}function bn({view:t,setView:s}){const a=m.useRef([]);function n(i){var c;const o=(i+ye.length)%ye.length,l=ye[o];l&&(s(l),(c=a.current[o])==null||c.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ye.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ye.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{a.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function vn({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(rt,{open:a,onClose:()=>n(!1)})]})}const yn="https://wcagcheckr.com/upgrade";function wn(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState(null),[c,u]=m.useState(Ye),[d,p]=m.useState(Ye[0].id),[h,x]=m.useState("none"),[g,j]=m.useState(null),S=y(F=>F.status),T=y(F=>F.tier),w=y(F=>F.results.length>0),C=S==="running";m.useEffect(()=>{Promise.all([ee({type:"SETTINGS_GET",key:"matrixPresets"}),ee({type:"SETTINGS_GET",key:"activePresetId"})]).then(([F,Q])=>{const se=Array.isArray(F.data)?F.data:null;u(se&&se.length>0?se:Ye),typeof Q.data=="string"&&p(Q.data)})},[]);function f(F){const Q=c.find(se=>se.id===F);Q&&(p(F),re({type:"SETTINGS_SET",key:"activePresetId",value:F}),re({type:"SETTINGS_SET",key:"stateMatrix",value:Q.matrix}))}const N=js(T,"storybookAutoIterate");m.useEffect(()=>{const F=pe("ELEMENT_PICKED_EVENT",(se,E)=>{n(!1);const Y=E.frameId;_(Y),i({selector:se.selector,frameId:Y,speech:se.speech})}),Q=pe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{F(),Q()}},[]);async function I(){const F=await ae();F&&(n(!0),await de(F,{type:"PICKER_ACTIVATE_REQUEST",tabId:F}))}function k(){r&&(_(r.frameId),he({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),y.getState().startNewScan())}function L(){if(!N){l("storybook:auto-iterate");return}_(),he({type:"START_AUDIT",mode:"storybook-all"}),y.getState().startNewScan()}function b(){_(),he({type:"START_AUDIT",mode:"all-frames"}),y.getState().startNewScan()}function $(){_(),he({type:"START_AUDIT",mode:"full-page"}),y.getState().startNewScan()}function H(){_(),he({type:"START_AUDIT",mode:"quick-scan"}),y.getState().startNewScan()}function A(){_(),he({type:"START_AUDIT",mode:"parallel-scan"}),y.getState().startNewScan()}function M(){re({type:"CANCEL_AUDIT"})}async function _(F){y.getState().setPinned(null);const Q=await ae();if(Q)try{await de(Q,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:Q},F)}catch{}}async function q(F){j(null);const Q=await ae();if(!Q){j("No audited tab; open a page first.");return}if(F==="none"){const E=await ee({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:Q});E.ok||j(E.error??"Failed to clear throttle."),x("none");return}const se=await ee({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:Q,profile:F});if(!se.ok){j(se.error??"Failed to apply throttle.");return}x(F)}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:F=>s(F.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)",N?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:F=>f(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:c.map(F=>e.jsx("option",{value:F.id,children:F.name},F.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:F=>void q(F.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(Nn,{picking:a,picked:r,isRunning:C,onPick:I,onRun:k,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:$,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:H,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:C?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:A,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:b,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:L,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:M,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!C&&w&&e.jsx("button",{type:"button",onClick:()=>void ze(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),g&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",g]}),t==="single-element"&&r&&!a&&!C&&e.jsx(kn,{selector:r.selector,onRepick:I,onClear:()=>i(null)})]}),e.jsx(ve,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(vn,{feature:o??"",upgradeUrl:yn})})]})}function jn({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 Nn({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}),e.jsx(jn,{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 kn({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 Sn={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},An={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Cn(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState("off"),u=y(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await ae();g&&(l(x),x==="off"?await de(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await de(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function p(x){const g=await ae();if(g){if(t&&await de(g,{type:Sn[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await de(g,{type:An[x],tabId:g}).catch(()=>{}),s(x)}}async function h(){const x=await ae();if(x){if(a){await de(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(u.length===0){i("Run an audit first.");return}try{const g=await me(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:u});n(!0),i(`Previewing ${g.visualFixCount} visual fix${g.visualFixCount===1?"":"es"} + ${g.annotationCount} annotation${g.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(we,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(we,{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:()=>p("tab-order")}),e.jsx(we,{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:()=>p("reading-order")}),e.jsx(we,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(we,{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:o,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="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 we({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 In(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 En(){const t=y(c=>c.status),s=y(c=>c.progress),a=y(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":In(s.currentState),o=n?100:s.current/s.total*100,l=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(Dt,{label:r,detail:i,pct:o,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"}),l&&e.jsx(Dt,{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 Dt({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){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 ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}function Us(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Ot(t){if(!Us())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,(i,o)=>{a(o?!1:i===!0)})})}const
|
|
9
|
-
${h?"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 ${Wn[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(qn,{violation:t}),e.jsx(Jn,{violation:t}),e.jsx(Yn,{violation:t}),e.jsx(Qn,{text:t.target.failureSummary}),e.jsx(Xn,{ruleId:t.ruleId}),h&&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: ",Bn(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:A,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),A(k))},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:T,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),T(k))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),$s()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:k=>{k.preventDefault(),k.stopPropagation(),Dt(t.target.selector)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),Dt(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"})]}),x&&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."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:p?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:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:k=>{k.stopPropagation(),d(t.matchKey),zn(t,l)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:k=>{k.stopPropagation(),u(t.matchKey),Hn(t,l)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:k=>k.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Bn(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 Hn(t,s){await ua({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Us(t.componentId,s)}async function zn(t,s){await da(t.componentId,t.matchKey),await Us(t.componentId,s)}async function Us(t,s){const a=s.flatMap(n=>n.violations);try{const n=await ee({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});v.getState().setDelta(n.delta)}catch{}}function Kn(){const t=js.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Ls(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function qn({violation:t}){const s=Ls(t);if(!s)return null;const a=s.ratio>=s.required,n=Gn(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 Qn({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 Yn({violation:t}){const s=Vn(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 Jn({violation:t}){const s=Ls(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let i=!1;return ca(t.matchKey).then(o=>{o&&!i&&n({kind:"ready",suggestion:o})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await ee({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(c=>c.matchKey===t.matchKey);l?(await pa(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function Xn({ruleId:t}){const s=ha(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}const rt=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]}];function bt(t){const s=rt.map(r=>er(r,t)),a=Zn(s.map(r=>r.letter)),n=s.filter(r=>r.letter==="D"||r.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:n,isLawsuitRisk:n.length>0}}function Zn(t){const s=t.filter(o=>o==="A").length,a=t.filter(o=>o==="C").length,n=t.filter(o=>o==="D").length,r=t.filter(o=>o==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function er(t,s){const a=new Set(t.axeRules),n=s.violations.filter(C=>a.has(C.ruleId)),r=s.manualRuns.filter(C=>t.igtWorkflowIds.includes(C.workflowId)),i=t.igtWorkflowIds.map(C=>s.workflows.find(M=>M.id===C)).filter(C=>C!=null);let o=i.length>0;for(const C of i){const M=r.find(X=>X.workflowId===C.id);if((M?Object.keys(M.steps).length:0)!==C.steps.length){o=!1;break}}const l=r.some(C=>Object.keys(C.steps).length>0),c=t.verifiedByWorkflowIds??[],u=s.manualRuns.filter(C=>c.includes(C.workflowId)),d=c.map(C=>s.workflows.find(M=>M.id===C)).filter(C=>C!=null);let p=c.length>0&&d.length===c.length;for(const C of d){const M=u.find(X=>X.workflowId===C.id);if((M?Object.keys(M.steps).length:0)!==C.steps.length){p=!1;break}}let h=null;if(p)for(const C of u)C.completedAt&&(h===null||C.completedAt>h)&&(h=C.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,j=s.interactiveAuditVerdicts,A=[];j&&(t.id==="tab-order"&&j.focusOrder&&A.push({verdict:j.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(j.keyboardTrap&&A.push({verdict:j.keyboardTrap,criterionId:"2.1.2"}),j.focusVisible&&A.push({verdict:j.focusVisible,criterionId:"2.4.7"})));const T=A.some(C=>C.verdict==="fail");if(A.length>0&&A.every(C=>C.verdict==="pass")&&c.length>0&&!p)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:A.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:A.map(C=>C.criterionId)};if(p&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const w=t.axeRules.length>0||t.heuristic!=null,f=t.igtWorkflowIds.length>0;if(w?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:f||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const N={critical:0,serious:0,moderate:0,minor:0};for(const C of mt(n))N[C.impact]++;A.length>0&&A.every(C=>C.verdict==="pass")||(N.serious+=x),T&&(N.serious+=A.filter(C=>C.verdict==="fail").length);for(const C of r){const M=i.find(D=>D.id===C.workflowId);if(M)for(const D of M.steps){const X=C.steps[D.id];(X==null?void 0:X.status)==="fail"&&(D.severity==="required"?N.serious++:N.moderate++)}}const U=N.critical>0,y=N.serious>0;let L;N.critical>=5?L="F":N.critical>=1?L="D":N.serious>=1?L="C":N.moderate>=1?L="B":L="A";const H=L!=="A"&&(f&&!o||c.length>0&&!p);return{id:t.id,label:t.label,letter:L,untested:!1,needsIgt:H,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:N,caps:{cappedAtC:U,cappedAtB:y}}}const it="dismissedFindings";function ze(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function fe(t){return`reading-order::${t}`}function be(t){return`tab-order::${t}`}async function Ke(){try{const t=await chrome.storage.local.get(it),s=t==null?void 0:t[it];if(s&&typeof s=="object")return s}catch{}return{}}async function vt(t){await chrome.storage.local.set({[it]:t})}async function Be(t){return(await Ke())[ze(t)]??{}}async function _s(t,s,a,n){const r=await Ke(),i=ze(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await vt(r)}async function Re(t,s){if(s.length===0)return;const a=await Ke(),n=ze(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await vt(a)}async function Ds(t,s){const a=await Ke(),n=ze(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await vt(a))}const Ll=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:_s,addDismissals:Re,dismissalKeyForReadingOrder:fe,dismissalKeyForTabOrder:be,getDismissalsForUrl:Be,removeDismissal:Ds},Symbol.toStringTag,{value:"Module"}));function Os(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ms(t){return`${xt(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function tr(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Ms(n),i=s.get(r);i?i.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const Wt={critical:0,serious:1,moderate:2,minor:3};function sr(){var k,w,f,S;const t=v(N=>N.results),s=v(N=>N.componentId),a=v(N=>N.setView),n=((k=t[0])==null?void 0:k.pageUrl)??((w=t[0])==null?void 0:w.scope)??"",[r,i]=m.useState({}),[o,l]=m.useState(new Set),[c,u]=m.useState({});if(m.useEffect(()=>{if(!s){u({});return}let N=!1;const I=async()=>{const y=await gs(s);if(N)return;const L={};for(const H of y)H.criterionId==="2.4.3"?L.focusOrder=H.verdict:H.criterionId==="2.1.2"?L.keyboardTrap=H.verdict:H.criterionId==="2.4.7"?L.focusVisible=H.verdict:H.criterionId==="1.3.2"&&(L.readingOrder=H.verdict);u(L)};I();const U=y=>{y.interactiveAuditResults&&I()};return chrome.storage.local.onChanged.addListener(U),()=>{N=!0,chrome.storage.local.onChanged.removeListener(U)}},[s]),m.useEffect(()=>{if(!n)return;Be(n).then(i);const N=()=>{document.visibilityState==="visible"&&n&&Be(n).then(i)};return document.addEventListener("visibilitychange",N),()=>document.removeEventListener("visibilitychange",N)},[n]),m.useEffect(()=>{if(!s){l(new Set);return}let N=!1;const I=async()=>{const y=await chrome.storage.local.get("igtRuns");if(N)return;const H=((y==null?void 0:y.igtRuns)??{})[s]??{},C=new Set;for(const M of ie){const D=H[M.id];D&&Object.keys(D.steps).length===M.steps.length&&C.add(M.id)}l(C)};I();const U=()=>{document.visibilityState==="visible"&&I()};return document.addEventListener("visibilitychange",U),()=>{N=!0,document.removeEventListener("visibilitychange",U)}},[s]),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 to start."});const d=t.reduce((N,I)=>N+I.durationMs,0),p=t.reduce((N,I)=>N+I.violations.length,0),h=tr(t);h.sort((N,I)=>{const U=Wt[N.representative.impact]??99,y=Wt[I.representative.impact]??99;return U!==y?U-y:I.states.length-N.states.length});const x=t.map(N=>Os(N.state)).join(`
|
|
10
|
-
`),
|
|
11
|
-
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const lr={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 dr({violations:t,componentId:s}){var F,Z,se,E,q,oe,ne;const[a,n]=m.useState([]),[r,i]=m.useState([]),[o,l]=m.useState(new Set),[c,u]=m.useState(null),[d,p]=m.useState({}),[h,x]=m.useState(new Set),g=v(b=>b.status),j=v(b=>b.progress),A=v(b=>b.freshThisSession),T=v(b=>b.results),k=(F=T[0])==null?void 0:F.startedAt,w=((Z=T[0])==null?void 0:Z.pageUrl)??((se=T[0])==null?void 0:se.scope)??null;if(m.useEffect(()=>{if(!s){n([]);return}let b=!1;return chrome.storage.local.get("igtRuns").then(O=>{if(b)return;const G=((O==null?void 0:O.igtRuns)??{})[s]??{};n(Object.values(G))}),()=>{b=!0}},[s]),m.useEffect(()=>{if(!w){i([]);return}let b=!1;return De(w).then(O=>{b||i(O)}),()=>{b=!0}},[w]),g==="running")return e.jsx(fr,{current:j==null?void 0:j.current,total:j==null?void 0:j.total});const f=bt({violations:t,auditRan:T.length>0,manualRuns:a,workflows:ie,heuristicCounts:{tabOrder:((q=(E=T[0])==null?void 0:E.tabOrderIssues)==null?void 0:q.length)??0,readingOrder:((ne=(oe=T[0])==null?void 0:oe.readingOrderIssues)==null?void 0:ne.length)??0}}),S=v(b=>b.acknowledgedKeys),N=T.length>0?fs(T,{runs:a,workflows:ie},"2.1","AA",S,r):void 0,I=T.length>0?xa(gt({audits:T,igtRuns:a,workflows:ie,acknowledgedMatchKeys:S,incompleteResolutions:r}),ie):void 0,U=N?N.failingCriteria.length>0||N.inconclusiveCriteria.length>0:!1,y=U&&f.overallLetter==="A"?"B":f.overallLetter;async function L(b){var Y;if(!w||!((Y=N==null?void 0:N.inconclusiveReasons)!=null&&Y[b]))return;const P=N.inconclusiveReasons[b].filter(V=>V.source==="axe-incomplete"&&V.elements&&V.elements.length>0);if(P.length===0)return;l(V=>new Set(V).add(b)),u(null);const G=[];let z=0;try{for(const B of P){const R=await re({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:B.ruleOrStepId,pageUrl:B.pageUrl??w,wcagCriterion:b,elements:B.elements??[],targetLevel:"AA"});if(R!=null&&R.unavailableReason){u(R.unavailableReason);break}R!=null&&R.resolutions&&(G.push(...R.resolutions),z+=R.totalCostUsd??0)}if(w){const B=await De(w);i(B)}const V={total:G.length,pass:G.filter(B=>B.verdict==="pass").length,fail:G.filter(B=>B.verdict==="fail").length,uncertain:G.filter(B=>B.verdict==="uncertain").length,costUsd:z,resolutions:G};p(B=>({...B,[b]:V}))}finally{l(V=>{const B=new Set(V);return B.delete(b),B})}}function H(b){x(O=>{const P=new Set(O);return P.has(b)?P.delete(b):P.add(b),P})}async function C(b){var R,K;if(!w)return;const O=((R=N==null?void 0:N.inconclusiveReasons)==null?void 0:R[b])??[],P=((K=N==null?void 0:N.failingReasons)==null?void 0:K[b])??[],G=[],z=new Set;for(const _ of O){if(_.source!=="axe-incomplete"||!_.elements)continue;const W=_.pageUrl??w;for(const J of _.elements){const te=`${W}::${_.ruleOrStepId}::${J.selector}`;z.has(te)||(z.add(te),G.push({ruleId:_.ruleOrStepId,pageUrl:W,selector:J.selector}))}}for(const _ of P){if(_.source!=="ai"||!_.selector)continue;const W=_.ruleOrStepId.startsWith("ai-resolved::")?_.ruleOrStepId.slice(13):_.ruleOrStepId,J=_.pageUrl??w,te=`${J}::${W}::${_.selector}`;z.has(te)||(z.add(te),G.push({ruleId:W,pageUrl:J,selector:_.selector}))}if(G.length===0)return;const Y=new Date().toISOString(),V=[];for(const _ of G){const W=r.find(J=>J.pageUrl===_.pageUrl&&J.ruleId===_.ruleId&&J.selector===_.selector);W&&W.verdict==="pass"&&W.reasoning.startsWith("Marked as visually verified")||V.push({pageUrl:_.pageUrl,ruleId:_.ruleId,selector:_.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${Y.slice(0,10)}.`,resolvedAt:Y,costUsd:0,wcagCriterion:b})}if(V.length===0)return;await ga(V);const B=await De(w);i(B),p(_=>({..._,[b]:{total:V.length,pass:V.length,fail:0,uncertain:0,costUsd:0,resolutions:V}}))}const M=(()=>{if(!U||f.overallLetter!=="A"||!N)return null;const b=N.inconclusiveCriteria.length,O=N.failingCriteria.length,P=[];O>0&&P.push(`${O} WCAG ${N.targetLevel} ${O===1?"criterion":"criteria"} failing`),b>0&&P.push(`${b} WCAG ${N.targetLevel} ${b===1?"criterion":"criteria"} inconclusive`);const G=O>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${P.join(" + ")}. ${G}`})();let D=0;for(const b of ie){const O=a.find(G=>G.workflowId===b.id);if(!O)continue;b.steps.every(G=>{const z=O.steps[G.id];return(z==null?void 0:z.status)==="pass"||(z==null?void 0:z.status)==="fail"||(z==null?void 0:z.status)==="skip"||(z==null?void 0:z.status)==="not-applicable"})&&D++}const X=mt(t.filter(b=>!S.has(b.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!A&&k&&e.jsx(br,{scannedAt:k}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${lr[y]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:y})}),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 ",f.subGrades.length," verification areas below. Untested areas count as F until verified."]}),M&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:M})]})]}),f.isLawsuitRisk&&e.jsx(hr,{areas:f.warningAreas}),e.jsx(mr,{grades:f.subGrades}),N&&e.jsx(ur,{coverage:N,onResolveWithAi:L,onMarkVisuallyVerified:C,resolving:o,resolveError:c,lastResolveResult:d,expandedResultFor:h,onToggleResultDetail:H}),I&&e.jsx(pr,{layers:I}),e.jsx(gr,{violationsRemaining:X,manualCompleted:D,manualTotal:ie.length}),D>0||T.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:D})," of ",e.jsx("strong",{children:ie.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:`${D/ie.length*100}%`}})})]}):null]})}function ur({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[u,d]=m.useState(c>0&&c<=3),p=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),h=t.canClaimConformance,x=[];return t.failingCriteria.length>0&&x.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&x.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&x.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${h?"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 ${h?"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 (",p,"%)"]}),h&&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)."]}),!h&&(()=>{const g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const j=g.length===0?"unresolved":g.length===1?g[0]:g.length===2?`${g[0]} or ${g[1]}`:`${g.slice(0,-1).join(", ")}, or ${g[g.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",j,"."]})})(),!h&&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."]}),!h&&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."]})]}),!h&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),className:"text-[11px] underline shrink-0 self-start",children:u?"hide":"show list"})]}),u&&!h&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[x.map(g=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${g.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[g.kind==="untested"?"Untested":g.kind==="inconclusive"?"Inconclusive":"Failing"," (",g.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:g.ids.map(j=>{var I,U;const A=g.kind==="inconclusive"?(I=t.inconclusiveReasons)==null?void 0:I[j]:void 0,T=g.kind==="failing"?(U=t.failingReasons)==null?void 0:U[j]:void 0,k=A==null?void 0:A.some(y=>y.source==="axe-incomplete"&&y.elements&&y.elements.length>0),w=T==null?void 0:T.some(y=>y.source==="ai"),f=(n==null?void 0:n.has(j))??!1,S=i==null?void 0:i[j],N=(o==null?void 0:o.has(j))??!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("code",{className:"font-mono text-[11px]",children:["· ",j]}),(g.kind==="inconclusive"&&k||g.kind==="failing"&&w)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[g.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:f,onClick:()=>s(j),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:f?"Resolving…":S?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:f,onClick:()=>a(j),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:g.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"})]})]}),S&&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 ",S.total," ",S.total===1?"verdict":"verdicts",":",S.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",S.pass," pass"]}),S.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",S.fail," fail"]}),S.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",S.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",S.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(j),className:"ml-auto text-[10px] underline text-brand-700",children:N?"hide reasoning":"show reasoning"})]}),S.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",S.uncertain," ",S.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),S.pass===S.total&&S.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."]}),N&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:S.resolutions.map((y,L)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:y.verdict==="pass"?"text-emerald-700 font-semibold":y.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:y.verdict==="pass"?"✓":y.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:y.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:y.reasoning})]},L))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map((y,L)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[y.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),y.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," fail — "]}),y.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," fail — "]}),y.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:y.selector}),y.notes&&e.jsx("span",{className:"text-rose-700",children:y.notes})]},L))}),A&&A.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:A.map((y,L)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[y.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," — "]}),y.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," skipped — "]}),y.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," — "]}),y.resolutionHint,y.elements&&y.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",y.elements.length===1?"element":`${y.elements.length} elements`,":"," ",y.elements.slice(0,3).map((H,C,M)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:H.selector}),C<M.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},C)),y.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",y.elements.length-3," more"]})]})]},L))}):g.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.)"})]},j)})})]},g.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 Ht={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 pr({layers:t}){const s=v(n=>n.setView),a=["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:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,c=r.cleared,u=i>0&&o===0&&l===0,d=u?"text-emerald-700":o>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 ${u?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:u?"✓":o>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:Ht[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:Ht[n].hint}),n==="human"&&l>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function hr({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 mr({grades:t}){const s=v(a=>a.setView);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.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${cr[a.letter]}`,"aria-label":`Grade ${a.letter}`,children:a.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:a.label}),e.jsx(xr,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function xr({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=ie.find(i=>i.id===n);return(r==null?void 0:r.name)??n};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 n=t.verifiedAt?Fs(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",n?` ${n} ago`:""]})}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)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function gr({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=v(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);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:r.map((o,l)=>{const c=l===i,u=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:u?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:u?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:c?"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:[o.label," →"]}):e.jsx("span",{className:u?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function fr({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 br({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 (",Fs(s)," old). Re-scan to grade the current page state."]})]})}function Fs(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 vr(){const t=v(a=>a.results),s=v(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(dr,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(yr,{})]})}function yr(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(Ne,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(Ne,{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. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(Ne,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(Ne,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(Ne,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function Ne({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const wr={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 jr({ruleId:t,violations:s}){const[a,n]=m.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(We,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),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 ${wr[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),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((c,u)=>e.jsx(We,{violation:c},u))})]})}function Nr(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 kr={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function Ps({open:t,onClose:s,format:a,content:n,filename:r}){const i=ia(new Blob([n]).size);function o(){ht(n,r),s()}function l(){pt(n),s()}return e.jsxs(ve,{open:t,onClose:s,title:kr[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,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:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const zt=7800;function Sr(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const p=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===p);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
|
|
12
|
-
`),c=new URLSearchParams({title:i,body:l});let u=`${n}/issues/new?${c.toString()}`;return u.length>
|
|
13
|
-
`),c=new URLSearchParams({summary:i,description:l});let u=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return u.length>
|
|
14
|
-
`),u=new URLSearchParams({"[Title]":o,"[Description]":c});let d=`${r}/_workitems/create/${encodeURIComponent(n)}?${u.toString()}`;return d.length>
|
|
15
|
-
`),c=new URLSearchParams({"issue[title]":i,"issue[description]":l});let u=`${n}/-/issues/new?${c.toString()}`;return u.length>Qt&&(u=u.slice(0,Qt)),{url:u,title:i,description:l}}const Yt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Er=["wcag-component-auditor","wcag-forensic-log"];async function Rr(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Yt);s=Object.keys(n).length,await chrome.storage.local.remove(Yt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Er)try{await Tr(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 Tr(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 ot="accessibilityStatementInputs:v1";async function $r(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(ot))[ot];return s&&typeof s=="object"?s:null}async function Ur(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[ot]:t})}function Lr({open:t,onClose:s,results:a}){const[n,r]=m.useState("eaa"),[i,o]=m.useState(""),[l,c]=m.useState(""),[u,d]=m.useState("partial"),[p,h]=m.useState(""),[x,g]=m.useState(""),[j,A]=m.useState(""),[T,k]=m.useState(""),[w,f]=m.useState("English"),[S,N]=m.useState("wcagcheckr (self-evaluation)"),[I,U]=m.useState("2.1"),[y,L]=m.useState("AA"),[H,C]=m.useState(!1),[M,D]=m.useState(null),X=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var q,oe,ne,b;const E=await $r();if(E&&(E.framing&&r(E.framing),E.organizationName&&o(E.organizationName),E.siteUrl&&c(E.siteUrl),E.conformanceStatus&&d(E.conformanceStatus),(q=E.contact)!=null&&q.email&&h(E.contact.email),(oe=E.contact)!=null&&oe.phone&&g(E.contact.phone),(ne=E.contact)!=null&&ne.formUrl&&A(E.contact.formUrl),E.countryCode&&k(E.countryCode),E.language&&f(E.language),E.auditedBy&&N(E.auditedBy),E.wcagVersion&&U(E.wcagVersion),E.wcagLevel&&L(E.wcagLevel)),!(E!=null&&E.siteUrl)&&((b=a[0])!=null&&b.pageUrl))try{const O=new URL(a[0].pageUrl);c(`${O.protocol}//${O.host}/`)}catch{}E!=null&&E.conformanceStatus||d(fa(a)),setTimeout(()=>{var O;return(O=X.current)==null?void 0:O.focus()},50)})()},[t,a]),!t)return null;function F(){var ne;const E=new Date().toISOString().slice(0,10),q=(ne=a[0])!=null&&ne.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):E,oe={};return p.trim()&&(oe.email=p.trim()),x.trim()&&(oe.phone=x.trim()),j.trim()&&(oe.formUrl=j.trim()),{framing:n,organizationName:i.trim(),siteUrl:l.trim(),conformanceStatus:u,preparedAt:E,evaluatedAt:q,contact:oe,countryCode:T||null,language:w.trim()||"English",auditedBy:S.trim()||"wcagcheckr (self-evaluation)",wcagVersion:I,wcagLevel:y}}function Z(E){if(!E.organizationName)return"Organization name is required.";if(!E.siteUrl)return"Site URL is required.";try{new URL(E.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!E.contact.email&&!E.contact.phone&&!E.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 se(E){D(null);const q=F(),oe=Z(q);if(oe){D(oe);return}C(!0);try{await Ur(q);const ne=await ee({type:"EXPORT_REQUEST",format:E==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:q}),b=(ne==null?void 0:ne.content)??"";if(!b||b.startsWith("# Accessibility statement — error")){D(b||"Export failed — no response.");return}try{await navigator.clipboard.writeText(b)}catch{}const O=new Blob([b],{type:E==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),P=URL.createObjectURL(O);window.open(P,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(P),6e4),s()}catch(ne){D(ne instanceof Error?ne.message:String(ne))}finally{C(!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:E=>E.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:n==="eaa",onChange:()=>r("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:n==="wad",onChange:()=>r("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:X,type:"text",value:i,onChange:E=>o(E.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:l,onChange:E=>c(E.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:u,onChange:E=>d(E.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:I,onChange:E=>U(E.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:y,onChange:E=>L(E.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:p,onChange:E=>h(E.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:E=>g(E.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:j,onChange:E=>A(E.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:T,onChange:E=>k(E.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(ba).map(([E,q])=>e.jsxs("option",{value:E,children:[E," — ",q.name.replace(/^[A-Z]+\s*—\s*/,"")]},E))]}),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:w,onChange:E=>f(E.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:S,onChange:E=>N(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),M&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:M})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void se("markdown"),disabled:H,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:H?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void se("html"),disabled:H,className:"text-xs px-3 py-1.5 border border-brand-500 text-brand-700 hover:bg-brand-50 rounded disabled:opacity-50 font-medium",children:H?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:H,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function _r(){const t=v(b=>b.delta),s=v(b=>b.componentId),a=v(b=>b.results),n=v(b=>b.tier),r=v(b=>b.baselineList),i=v(b=>b.siteCrawlReport),[o,l]=m.useState(""),[c,u]=m.useState(""),[d,p]=m.useState(""),[h,x]=m.useState(""),[g,j]=m.useState(!1),[A,T]=m.useState(!1),[k,w]=m.useState(null),[f,S]=m.useState(null),[N,I]=m.useState(!1),[U,y]=m.useState(!1),[L,H]=m.useState(null),[C,M]=m.useState(!1);m.useEffect(()=>{Promise.all([ee({type:"SETTINGS_GET",key:"githubRepoUrl"}),ee({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),ee({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),ee({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([b,O,P,G])=>{l(typeof b.data=="string"?b.data:""),u(typeof O.data=="string"?O.data:""),p(typeof P.data=="string"?P.data:""),x(typeof G.data=="string"?G.data:"")})},[]),m.useEffect(()=>pe("BADGE_CLICKED_EVENT",O=>{const P=`viol-row-${O.violationId}`,G=document.getElementById(P);G&&(G.scrollIntoView({behavior:"smooth",block:"center"}),G.classList.add("ring-2","ring-rose-500"),setTimeout(()=>G.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const b=await ae();b&&(U&&await de(b,{type:"BADGES_HIDE_REQUEST",tabId:b}).catch(()=>{}),C&&await de(b,{type:"HEATMAP_HIDE_REQUEST",tabId:b}).catch(()=>{}))})()},[]);async function D(){const b=await ae();if(!b){le.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(U){await de(b,{type:"BADGES_HIDE_REQUEST",tabId:b}).catch(()=>{}),y(!1),H(null);return}const O={critical:4,serious:3,moderate:2,minor:1},P=new Map;for(const V of a)for(const B of V.violations)P.has(B.matchKey)||P.set(B.matchKey,B);const z=Array.from(P.values()).sort((V,B)=>O[B.impact]-O[V.impact]).map((V,B)=>({id:V.matchKey,index:B+1,selector:V.target.selector,impact:V.impact,ruleId:V.ruleId,wcagCriterion:V.wcagCriterion}));if(z.length===0){le.polite("No violations to badge.");return}const Y=await me(b,{type:"BADGES_SHOW_REQUEST",tabId:b,violations:z}).catch(()=>null);Y&&(y(!0),H({rendered:Y.rendered,requested:Y.requested,clustered:Y.clustered}),le.polite(`${Y.rendered} violation badges shown on the page.`))}async function X(){const b=await ae();if(!b){le.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(C){await de(b,{type:"HEATMAP_HIDE_REQUEST",tabId:b}).catch(()=>{}),M(!1);return}const O=new Map;for(const z of a)for(const Y of z.violations)O.has(Y.matchKey)||O.set(Y.matchKey,Y);const P=Array.from(O.values()).map(z=>({selector:z.target.selector,impact:z.impact}));if(P.length===0){le.polite("No violations to heatmap.");return}const G=await me(b,{type:"HEATMAP_SHOW_REQUEST",tabId:b,violations:P}).catch(()=>null);G&&(M(!0),le.polite(`Heatmap shown with ${G.rendered} violation blobs.`))}const F=ws(n,"exportJson"),Z=Ns[n].maxBaselines,se=r.some(b=>b.componentId===s),E=se||r.length<Z;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 q(){if(!s||a.length===0)return;const b=a.flatMap(B=>B.violations),O=a.flatMap(B=>B.announcements??[]),P=a.flatMap(B=>B.focusEvents??[]),G=a[0],Y=(await ee({type:"SETTINGS_GET",key:"stateMatrix"})).data??js;await re({type:"BASELINE_SET",componentId:s,violations:b,announcements:O,focusEvents:P,snapshotMeta:{url:window.location.href,axeVersion:G.axeVersion,matrixConfig:Y,capturedAt:new Date().toISOString()}});const V=await ee({type:"BASELINE_COMPARE",componentId:s,currentViolations:b,announcements:O,focusEvents:P,currentMatrix:Y});v.getState().setDelta(V.delta),le.polite(`Baseline saved for ${s}.`)}async function oe(){if(!s||!se||!window.confirm(`Remove the saved baseline for "${s}"?
|
|
8
|
+
})()`;s.inspectedWindow.eval(r,(i,o)=>{a(o?!1:i===!0)})})}const Mt=.022,Rn=1.414,Je=2.4,Tn=.2126729,$n=.7151522,Un=.072175,Ln=.56,_n=.57,Dn=.62,On=.65,Ft=1.14,Pt=.1,Mn=.027,Fn=.027,Pn=5e-4;function Gt(t,s,a){const n=t/255,r=s/255,i=a/255;return Tn*Math.pow(n,Je)+$n*Math.pow(r,Je)+Un*Math.pow(i,Je)}function Vt(t){return t<0?0:t<Mt?t+Math.pow(Mt-t,Rn):t}function Gn(t,s){const a=Vt(Gt(t[0],t[1],t[2])),n=Vt(Gt(s[0],s[1],s[2]));if(Math.abs(n-a)<Pn)return 0;let r=0;return n>a?(r=(Math.pow(n,Ln)-Math.pow(a,_n))*Ft,r<Pt?0:(r-Mn)*100):(r=(Math.pow(n,On)-Math.pow(a,Dn))*Ft,r>-Pt?0:(r+Fn)*100)}function Wt(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 Vn(t,s,a=75){const n=Wt(t),r=Wt(s);if(!n||!r)return null;const i=Gn(n,r);return{lc:i,passes:Math.abs(i)>=a,threshold:a}}const je={"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 Wn(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const Bn={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 Be({violation:t,alreadyAcknowledged:s}){const a=y(w=>w.pinnedMatchKey),n=y(w=>w.pinnedFound),r=y(w=>w.setPinned),i=y(w=>{var C;return(C=w.results[0])==null?void 0:C.frameId}),o=y(w=>{var C;return(C=w.results[0])==null?void 0:C.scope}),l=y(w=>w.results),c=y(w=>w.acknowledgedKeys.has(t.matchKey)),u=y(w=>w.markAcknowledged),d=y(w=>w.markUnacknowledged),p=s||c,h=a===t.matchKey,x=h&&!n;async function g(w){try{return(await me(w,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:w,selector:t.target.selector},i)).found}catch{return!0}}async function j(){const w=await ae();if(!w)return;if(h){r(null);try{await de(w,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:w},i)}catch{}return}const C=await g(w);r(t.matchKey,C)}function S(w){w.stopPropagation(),t.currentState.breakpoint.width<=640&&Cs(),(async()=>{const C=await ae();if(!C)return;try{await ee({type:"STATE_DRIVE_REQUEST",tabId:C,state:t.currentState,scope:o,frameId:i})}catch{}const f=await g(C);r(t.matchKey,f)})()}async function T(w){w.stopPropagation();const C=await ae();if(!C)return;try{await ee({type:"STATE_DRIVE_REQUEST",tabId:C,state:qn(),scope:o,frameId:i})}catch{re({type:"STATE_RESET_REQUEST",tabId:C})}const f=await g(C);r(t.matchKey,f)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:j,"aria-pressed":h,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
9
|
+
${h?"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 ${Bn[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(Qn,{violation:t}),e.jsx(Xn,{violation:t}),e.jsx(Jn,{violation:t}),e.jsx(Yn,{text:t.target.failureSummary}),e.jsx(Zn,{ruleId:t.ruleId}),h&&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: ",Hn(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),S(w))},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:T,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),T(w))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),Us()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:w=>{w.preventDefault(),w.stopPropagation(),Ot(t.target.selector)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),Ot(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"})]}),x&&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."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:p?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:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:w=>{w.stopPropagation(),d(t.matchKey),Kn(t,l)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:w=>{w.stopPropagation(),u(t.matchKey),zn(t,l)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:w=>w.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Hn(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 zn(t,s){await pa({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Ls(t.componentId,s)}async function Kn(t,s){await ua(t.componentId,t.matchKey),await Ls(t.componentId,s)}async function Ls(t,s){const a=s.flatMap(n=>n.violations);try{const n=await ee({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});y.getState().setDelta(n.delta)}catch{}}function qn(){const t=Ns.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function _s(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function Qn({violation:t}){const s=_s(t);if(!s)return null;const a=s.ratio>=s.required,n=Vn(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 Yn({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 Jn({violation:t}){const s=Wn(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 Xn({violation:t}){const s=_s(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let i=!1;return da(t.matchKey).then(o=>{o&&!i&&n({kind:"ready",suggestion:o})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await ee({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(c=>c.matchKey===t.matchKey);l?(await ha(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function Zn({ruleId:t}){const s=ma(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}const it=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]}];function vt(t){const s=it.map(r=>tr(r,t)),a=er(s.map(r=>r.letter)),n=s.filter(r=>r.letter==="D"||r.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:n,isLawsuitRisk:n.length>0}}function er(t){const s=t.filter(o=>o==="A").length,a=t.filter(o=>o==="C").length,n=t.filter(o=>o==="D").length,r=t.filter(o=>o==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function tr(t,s){const a=new Set(t.axeRules),n=s.violations.filter(A=>a.has(A.ruleId)),r=s.manualRuns.filter(A=>t.igtWorkflowIds.includes(A.workflowId)),i=t.igtWorkflowIds.map(A=>s.workflows.find(M=>M.id===A)).filter(A=>A!=null);let o=i.length>0;for(const A of i){const M=r.find(q=>q.workflowId===A.id);if((M?Object.keys(M.steps).length:0)!==A.steps.length){o=!1;break}}const l=r.some(A=>Object.keys(A.steps).length>0),c=t.verifiedByWorkflowIds??[],u=s.manualRuns.filter(A=>c.includes(A.workflowId)),d=c.map(A=>s.workflows.find(M=>M.id===A)).filter(A=>A!=null);let p=c.length>0&&d.length===c.length;for(const A of d){const M=u.find(q=>q.workflowId===A.id);if((M?Object.keys(M.steps).length:0)!==A.steps.length){p=!1;break}}let h=null;if(p)for(const A of u)A.completedAt&&(h===null||A.completedAt>h)&&(h=A.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,j=s.interactiveAuditVerdicts,S=[];j&&(t.id==="tab-order"&&j.focusOrder&&S.push({verdict:j.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(j.keyboardTrap&&S.push({verdict:j.keyboardTrap,criterionId:"2.1.2"}),j.focusVisible&&S.push({verdict:j.focusVisible,criterionId:"2.4.7"})));const T=S.some(A=>A.verdict==="fail");if(S.length>0&&S.every(A=>A.verdict==="pass")&&c.length>0&&!p)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:S.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:S.map(A=>A.criterionId)};if(p&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const C=t.axeRules.length>0||t.heuristic!=null,f=t.igtWorkflowIds.length>0;if(C?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:f||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const I={critical:0,serious:0,moderate:0,minor:0};for(const A of xt(n))I[A.impact]++;S.length>0&&S.every(A=>A.verdict==="pass")||(I.serious+=x),T&&(I.serious+=S.filter(A=>A.verdict==="fail").length);for(const A of r){const M=i.find(_=>_.id===A.workflowId);if(M)for(const _ of M.steps){const q=A.steps[_.id];(q==null?void 0:q.status)==="fail"&&(_.severity==="required"?I.serious++:I.moderate++)}}const L=I.critical>0,b=I.serious>0;let $;I.critical>=5?$="F":I.critical>=1?$="D":I.serious>=1?$="C":I.moderate>=1?$="B":$="A";const H=$!=="A"&&(f&&!o||c.length>0&&!p);return{id:t.id,label:t.label,letter:$,untested:!1,needsIgt:H,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:I,caps:{cappedAtC:L,cappedAtB:b}}}const ot="dismissedFindings";function Ke(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function fe(t){return`reading-order::${t}`}function be(t){return`tab-order::${t}`}async function qe(){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 He(t){return(await qe())[Ke(t)]??{}}async function Ds(t,s,a,n){const r=await qe(),i=Ke(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await yt(r)}async function Re(t,s){if(s.length===0)return;const a=await qe(),n=Ke(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await yt(a)}async function Os(t,s){const a=await qe(),n=Ke(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 _l=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Ds,addDismissals:Re,dismissalKeyForReadingOrder:fe,dismissalKeyForTabOrder:be,getDismissalsForUrl:He,removeDismissal:Os},Symbol.toStringTag,{value:"Module"}));function Ms(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Fs(t){return`${gt(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function sr(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Fs(n),i=s.get(r);i?i.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const Bt={critical:0,serious:1,moderate:2,minor:3};function ar(){var N,I,k,L;const t=y(b=>b.results),s=y(b=>b.componentId),a=y(b=>b.setView),n=y(b=>b.status),r=y(b=>b.progress),i=y(b=>b.errorMessage),o=((N=t[0])==null?void 0:N.pageUrl)??((I=t[0])==null?void 0:I.scope)??"",[l,c]=m.useState({}),[u,d]=m.useState(new Set),[p,h]=m.useState({});if(m.useEffect(()=>{if(!s){h({});return}let b=!1;const $=async()=>{const A=await fs(s);if(b)return;const M={};for(const _ of A)_.criterionId==="2.4.3"?M.focusOrder=_.verdict:_.criterionId==="2.1.2"?M.keyboardTrap=_.verdict:_.criterionId==="2.4.7"?M.focusVisible=_.verdict:_.criterionId==="1.3.2"&&(M.readingOrder=_.verdict);h(M)};$();const H=A=>{A.interactiveAuditResults&&$()};return chrome.storage.local.onChanged.addListener(H),()=>{b=!0,chrome.storage.local.onChanged.removeListener(H)}},[s]),m.useEffect(()=>{if(!o)return;He(o).then(c);const b=()=>{document.visibilityState==="visible"&&o&&He(o).then(c)};return document.addEventListener("visibilitychange",b),()=>document.removeEventListener("visibilitychange",b)},[o]),m.useEffect(()=>{if(!s){d(new Set);return}let b=!1;const $=async()=>{const A=await chrome.storage.local.get("igtRuns");if(b)return;const _=((A==null?void 0:A.igtRuns)??{})[s]??{},q=new Set;for(const F of ie){const Q=_[F.id];Q&&Object.keys(Q.steps).length===F.steps.length&&q.add(F.id)}d(q)};$();const H=()=>{document.visibilityState==="visible"&&$()};return document.addEventListener("visibilitychange",H),()=>{b=!0,document.removeEventListener("visibilitychange",H)}},[s]),t.length===0){if(n==="running"){const b=r&&r.total>0?Math.round(r.current/r.total*100):null;return e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsxs("p",{className:"font-medium text-slate-700",children:["Audit running…",r&&e.jsxs(e.Fragment,{children:[" ",r.current," of ",r.total," states",b!==null?` (${b}%)`:""]})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Grades + per-area cards appear here as soon as the first state lands."})]})}return n==="failed"||n==="interrupted"?e.jsxs("div",{className:"p-4 text-center text-sm space-y-2",children:[e.jsxs("p",{className:"font-medium text-rose-700",children:["Last audit didn't complete",n==="interrupted"?" (stopped)":"","."]}),i&&e.jsx("p",{className:"text-xs text-slate-600",children:i}),e.jsx("p",{className:"text-xs text-slate-500",children:"Run the audit again from the controls above."})]}):e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."})}const x=t.reduce((b,$)=>b+$.durationMs,0),g=t.reduce((b,$)=>b+$.violations.length,0),j=sr(t);j.sort((b,$)=>{const H=Bt[b.representative.impact]??99,A=Bt[$.representative.impact]??99;return H!==A?H-A:$.states.length-b.states.length});const S=t.map(b=>Ms(b.state)).join(`
|
|
10
|
+
`),T=p.focusOrder!==void 0||p.keyboardTrap==="pass",w=u.has("keyboard")||T?0:(((k=t[0])==null?void 0:k.tabOrderIssues)??[]).filter(b=>!(be(b.selector)in l)).length,C=p.readingOrder!==void 0,f=u.has("page-structure")||C?0:(((L=t[0])==null?void 0:L.readingOrderIssues)??[]).filter(b=>!(fe(b.selector)in l)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(or,{violations:t.flatMap(b=>b.violations),componentId:s,manualRuns:[],interactiveVerdicts:p}),(w>0||f>0)&&e.jsxs("button",{type:"button",onClick:()=>a("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[w>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:w})," tab-order issue",w===1?"":"s"," (WCAG 2.4.3)"]}),w>0&&f>0&&" · ",f>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:f})," reading-order issue",f===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:S,"aria-label":`${t.length} states tested: ${S.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",j.length," unique ",j.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",g," across all states)"]})," · ",(x/1e3).toFixed(1),"s"]}),e.jsx(rr,{groups:j,totalStates:t.length,violations:t.flatMap(b=>b.violations),interactiveVerdicts:p})]})}const nr={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({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=vt({violations:a,auditRan:!0,manualRuns:[],workflows:ie,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,o=new Set;for(const c of it){for(const u of c.axeRules)o.add(u);i.set(c.id,[])}const l=[];for(const c of t){let u=!1;for(const d of it)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),u=!0;break}u||l.push(c)}return e.jsxs("div",{className:"space-y-1.5",children:[r.subGrades.map(c=>{const u=i.get(c.id)??[];return e.jsx(Ht,{subGrade:c,groups:u,totalStates:s},c.id)}),l.length>0&&e.jsx(Ht,{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:l,totalStates:s})]})}function Ht({subGrade:t,groups:s,totalStates:a}){const[n,r]=m.useState(!1),[i,o]=m.useState("idle"),[l,c]=m.useState(null),[u,d]=m.useState(0),p=s.length>0,h=nr[t.letter],x=s.filter(S=>S.representative.ruleId==="color-contrast"||S.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function j(S){S.stopPropagation(),o("loading"),c(null);try{const T=x.map(C=>{const f=C.representative.target.outerHTML,N=C.representative.target.failureSummary,I=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(N),k=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(N);if(!I||!k)return null;const L=C.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:C.representative.matchKey,foreground:I[1],background:k[1],fontSize:16,fontWeight:400,targetLevel:L,_html:f}}).filter(C=>C!==null);if(T.length===0){o("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const w=await ee({type:"AI_COLOR_SUGGEST_REQUEST",inputs:T.map(({_html:C,...f})=>f)});if(w.unavailableReason&&w.results.length===0){o("error"),c(w.unavailableReason);return}await xa(w.results),o("done"),d(C=>C+1),n||r(!0)}catch(T){o("error"),c(T instanceof Error?T.message:String(T))}}return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>r(S=>!S),"aria-expanded":n,disabled:!p,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 ${h}`,"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:p?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),g&&e.jsx("span",{role:"button",tabIndex:0,onClick:S=>void j(S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),j(S))},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 ${x.length} contrast issues at once`,children:i==="loading"?"Asking AI…":i==="done"?`✓ Suggested for all ${x.length}`:`✨ Suggest for all ${x.length}`}),p&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),i==="error"&&l&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:l}),n&&p&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(S=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Be,{violation:S.representative}),e.jsx(lr,{states:S.states,totalStates:a})]},`${Fs(S.representative)}::${u}`))})]})}const ir={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 or({violations:t,componentId:s,manualRuns:a,interactiveVerdicts:n}){const r=y(u=>u.setView),o=vt({violations:t,auditRan:!0,manualRuns:a,workflows:ie,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=xt(t).length;return e.jsx("div",{className:"sticky top-0 z-10 border border-slate-200 rounded-lg bg-white overflow-hidden shadow-sm",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${ir[o]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:o})}),e.jsxs("div",{className:"flex-1 p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:c===0?"No issues found by automation":`${c} issue${c===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Grade is the mean of 9 verification areas."," ","See the Report tab for the full breakdown."]})]}),e.jsx("button",{type:"button",onClick:()=>r("report"),className:"shrink-0 text-[11px] font-medium px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"View Full Report →"})]})]})})}function lr({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(Ms))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
|
|
11
|
+
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const cr={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},dr={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 ur({violations:t,componentId:s}){var F,Q,se,E,Y,oe,ne;const[a,n]=m.useState([]),[r,i]=m.useState([]),[o,l]=m.useState(new Set),[c,u]=m.useState(null),[d,p]=m.useState({}),[h,x]=m.useState(new Set),g=y(v=>v.status),j=y(v=>v.progress),S=y(v=>v.freshThisSession),T=y(v=>v.results),w=(F=T[0])==null?void 0:F.startedAt,C=((Q=T[0])==null?void 0:Q.pageUrl)??((se=T[0])==null?void 0:se.scope)??null;if(m.useEffect(()=>{if(!s){n([]);return}let v=!1;return chrome.storage.local.get("igtRuns").then(O=>{if(v)return;const G=((O==null?void 0:O.igtRuns)??{})[s]??{};n(Object.values(G))}),()=>{v=!0}},[s]),m.useEffect(()=>{if(!C){i([]);return}let v=!1;return Oe(C).then(O=>{v||i(O)}),()=>{v=!0}},[C]),g==="running")return e.jsx(br,{current:j==null?void 0:j.current,total:j==null?void 0:j.total});const f=vt({violations:t,auditRan:T.length>0,manualRuns:a,workflows:ie,heuristicCounts:{tabOrder:((Y=(E=T[0])==null?void 0:E.tabOrderIssues)==null?void 0:Y.length)??0,readingOrder:((ne=(oe=T[0])==null?void 0:oe.readingOrderIssues)==null?void 0:ne.length)??0}}),N=y(v=>v.acknowledgedKeys),I=T.length>0?bs(T,{runs:a,workflows:ie},"2.1","AA",N,r):void 0,k=T.length>0?ga(ft({audits:T,igtRuns:a,workflows:ie,acknowledgedMatchKeys:N,incompleteResolutions:r}),ie):void 0,L=I?I.failingCriteria.length>0||I.inconclusiveCriteria.length>0:!1,b=L&&f.overallLetter==="A"?"B":f.overallLetter;async function $(v){var X;if(!C||!((X=I==null?void 0:I.inconclusiveReasons)!=null&&X[v]))return;const P=I.inconclusiveReasons[v].filter(V=>V.source==="axe-incomplete"&&V.elements&&V.elements.length>0);if(P.length===0)return;l(V=>new Set(V).add(v)),u(null);const G=[];let z=0;try{for(const B of P){const R=await re({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:B.ruleOrStepId,pageUrl:B.pageUrl??C,wcagCriterion:v,elements:B.elements??[],targetLevel:"AA"});if(R!=null&&R.unavailableReason){u(R.unavailableReason);break}R!=null&&R.resolutions&&(G.push(...R.resolutions),z+=R.totalCostUsd??0)}if(C){const B=await Oe(C);i(B)}const V={total:G.length,pass:G.filter(B=>B.verdict==="pass").length,fail:G.filter(B=>B.verdict==="fail").length,uncertain:G.filter(B=>B.verdict==="uncertain").length,costUsd:z,resolutions:G};p(B=>({...B,[v]:V}))}finally{l(V=>{const B=new Set(V);return B.delete(v),B})}}function H(v){x(O=>{const P=new Set(O);return P.has(v)?P.delete(v):P.add(v),P})}async function A(v){var R,K;if(!C)return;const O=((R=I==null?void 0:I.inconclusiveReasons)==null?void 0:R[v])??[],P=((K=I==null?void 0:I.failingReasons)==null?void 0:K[v])??[],G=[],z=new Set;for(const D of O){if(D.source!=="axe-incomplete"||!D.elements)continue;const W=D.pageUrl??C;for(const Z of D.elements){const te=`${W}::${D.ruleOrStepId}::${Z.selector}`;z.has(te)||(z.add(te),G.push({ruleId:D.ruleOrStepId,pageUrl:W,selector:Z.selector}))}}for(const D of P){if(D.source!=="ai"||!D.selector)continue;const W=D.ruleOrStepId.startsWith("ai-resolved::")?D.ruleOrStepId.slice(13):D.ruleOrStepId,Z=D.pageUrl??C,te=`${Z}::${W}::${D.selector}`;z.has(te)||(z.add(te),G.push({ruleId:W,pageUrl:Z,selector:D.selector}))}if(G.length===0)return;const X=new Date().toISOString(),V=[];for(const D of G){const W=r.find(Z=>Z.pageUrl===D.pageUrl&&Z.ruleId===D.ruleId&&Z.selector===D.selector);W&&W.verdict==="pass"&&W.reasoning.startsWith("Marked as visually verified")||V.push({pageUrl:D.pageUrl,ruleId:D.ruleId,selector:D.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${X.slice(0,10)}.`,resolvedAt:X,costUsd:0,wcagCriterion:v})}if(V.length===0)return;await fa(V);const B=await Oe(C);i(B),p(D=>({...D,[v]:{total:V.length,pass:V.length,fail:0,uncertain:0,costUsd:0,resolutions:V}}))}const M=(()=>{if(!L||f.overallLetter!=="A"||!I)return null;const v=I.inconclusiveCriteria.length,O=I.failingCriteria.length,P=[];O>0&&P.push(`${O} WCAG ${I.targetLevel} ${O===1?"criterion":"criteria"} failing`),v>0&&P.push(`${v} WCAG ${I.targetLevel} ${v===1?"criterion":"criteria"} inconclusive`);const G=O>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${P.join(" + ")}. ${G}`})();let _=0;for(const v of ie){const O=a.find(G=>G.workflowId===v.id);if(!O)continue;v.steps.every(G=>{const z=O.steps[G.id];return(z==null?void 0:z.status)==="pass"||(z==null?void 0:z.status)==="fail"||(z==null?void 0:z.status)==="skip"||(z==null?void 0:z.status)==="not-applicable"})&&_++}const q=xt(t.filter(v=>!N.has(v.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!S&&w&&e.jsx(vr,{scannedAt:w}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${cr[b]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:b})}),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 ",f.subGrades.length," verification areas below. Untested areas count as F until verified."]}),M&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:M})]})]}),f.isLawsuitRisk&&e.jsx(mr,{areas:f.warningAreas}),e.jsx(xr,{grades:f.subGrades}),I&&e.jsx(pr,{coverage:I,onResolveWithAi:$,onMarkVisuallyVerified:A,resolving:o,resolveError:c,lastResolveResult:d,expandedResultFor:h,onToggleResultDetail:H}),k&&e.jsx(hr,{layers:k}),e.jsx(fr,{violationsRemaining:q,manualCompleted:_,manualTotal:ie.length}),_>0||T.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:_})," of ",e.jsx("strong",{children:ie.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:`${_/ie.length*100}%`}})})]}):null]})}function pr({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[u,d]=m.useState(c>0&&c<=3),p=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),h=t.canClaimConformance,x=[];return t.failingCriteria.length>0&&x.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&x.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&x.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${h?"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 ${h?"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 (",p,"%)"]}),h&&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)."]}),!h&&(()=>{const g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const j=g.length===0?"unresolved":g.length===1?g[0]:g.length===2?`${g[0]} or ${g[1]}`:`${g.slice(0,-1).join(", ")}, or ${g[g.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",j,"."]})})(),!h&&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."]}),!h&&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."]})]}),!h&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),className:"text-[11px] underline shrink-0 self-start",children:u?"hide":"show list"})]}),u&&!h&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[x.map(g=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${g.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[g.kind==="untested"?"Untested":g.kind==="inconclusive"?"Inconclusive":"Failing"," (",g.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:g.ids.map(j=>{var k,L;const S=g.kind==="inconclusive"?(k=t.inconclusiveReasons)==null?void 0:k[j]:void 0,T=g.kind==="failing"?(L=t.failingReasons)==null?void 0:L[j]:void 0,w=S==null?void 0:S.some(b=>b.source==="axe-incomplete"&&b.elements&&b.elements.length>0),C=T==null?void 0:T.some(b=>b.source==="ai"),f=(n==null?void 0:n.has(j))??!1,N=i==null?void 0:i[j],I=(o==null?void 0:o.has(j))??!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("code",{className:"font-mono text-[11px]",children:["· ",j]}),(g.kind==="inconclusive"&&w||g.kind==="failing"&&C)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[g.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:f,onClick:()=>s(j),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:f?"Resolving…":N?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:f,onClick:()=>a(j),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:g.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"})]})]}),N&&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 ",N.total," ",N.total===1?"verdict":"verdicts",":",N.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",N.pass," pass"]}),N.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",N.fail," fail"]}),N.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",N.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",N.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(j),className:"ml-auto text-[10px] underline text-brand-700",children:I?"hide reasoning":"show reasoning"})]}),N.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",N.uncertain," ",N.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),N.pass===N.total&&N.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."]}),I&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:N.resolutions.map((b,$)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:b.verdict==="pass"?"text-emerald-700 font-semibold":b.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:b.verdict==="pass"?"✓":b.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:b.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:b.reasoning})]},$))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map((b,$)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[b.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:b.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),b.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:b.ruleOrStepId})," fail — "]}),b.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:b.ruleOrStepId})," fail — "]}),b.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:b.selector}),b.notes&&e.jsx("span",{className:"text-rose-700",children:b.notes})]},$))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((b,$)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[b.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:b.ruleOrStepId})," — "]}),b.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:b.ruleOrStepId})," skipped — "]}),b.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:b.ruleOrStepId})," — "]}),b.resolutionHint,b.elements&&b.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",b.elements.length===1?"element":`${b.elements.length} elements`,":"," ",b.elements.slice(0,3).map((H,A,M)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:H.selector}),A<M.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},A)),b.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",b.elements.length-3," more"]})]})]},$))}):g.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.)"})]},j)})})]},g.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 zt={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 hr({layers:t}){const s=y(n=>n.setView),a=["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:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,c=r.cleared,u=i>0&&o===0&&l===0,d=u?"text-emerald-700":o>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 ${u?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:u?"✓":o>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:zt[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:zt[n].hint}),n==="human"&&l>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function mr({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 xr({grades:t}){const s=y(a=>a.setView);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.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${dr[a.letter]}`,"aria-label":`Grade ${a.letter}`,children:a.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:a.label}),e.jsx(gr,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function gr({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=ie.find(i=>i.id===n);return(r==null?void 0:r.name)??n};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 n=t.verifiedAt?Ps(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",n?` ${n} ago`:""]})}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)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function fr({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=y(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);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:r.map((o,l)=>{const c=l===i,u=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:u?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:u?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:c?"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:[o.label," →"]}):e.jsx("span",{className:u?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function br({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 vr({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 (",Ps(s)," old). Re-scan to grade the current page state."]})]})}function Ps(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 yr(){const t=y(a=>a.results),s=y(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(ur,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(wr,{})]})}function wr(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(Ne,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(Ne,{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. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(Ne,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(Ne,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(Ne,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function Ne({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}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 Nr({ruleId:t,violations:s}){const[a,n]=m.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Be,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),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 ${jr[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),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((c,u)=>e.jsx(Be,{violation:c},u))})]})}function kr(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 Sr={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function Gs({open:t,onClose:s,format:a,content:n,filename:r}){const i=oa(new Blob([n]).size);function o(){mt(n,r),s()}function l(){ht(n),s()}return e.jsxs(ve,{open:t,onClose:s,title:Sr[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,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:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Kt=7800;function Ar(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const p=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===p);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
|
|
12
|
+
`),c=new URLSearchParams({title:i,body:l});let u=`${n}/issues/new?${c.toString()}`;return u.length>Kt&&(u=u.slice(0,Kt)),{url:u,title:i,body:l}}const qt=7800;function Cr(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const p=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===p);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`Component: ${s??"unknown"}`),o.push(""),o.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`Rule: ${d.ruleId} (${d.impact})`),o.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),o.push(`Description: ${d.description}`),o.push(`Selector: ${d.target.selector}`),o.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&o.push(`More info: ${d.helpUrl}`),o.push(""),o.push(`HTML: ${d.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const l=o.join(`
|
|
13
|
+
`),c=new URLSearchParams({summary:i,description:l});let u=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return u.length>qt&&(u=u.slice(0,qt)),{url:u,summary:i,description:l}}const Qt=7800;function Ir(t,s,a,n="Bug"){const r=t.replace(/\/$/,""),i=[];for(const p of a){const h=`${p.ruleId}::${p.target.selector}`,x=`:${p.currentState.pseudoState} · ${p.currentState.theme} · ${p.currentState.direction}`,g=i.find(j=>`${j.ruleId}::${j.target.selector}`===h);if(g){g._states.includes(x)||g._states.push(x);continue}i.push({...p,_states:[x]})}const o=`a11y: ${i.length} new violation${i.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 p of i)l.push(`### \`${p.ruleId}\` — ${p.impact}`),l.push(""),l.push(p.description),l.push(""),l.push(`- **WCAG:** ${p.wcagCriterion} (${p.wcagLevel})`),l.push(`- **Selector:** \`${p.target.selector}\``),l.push(`- **Found in state(s):** ${p._states.join(", ")}`),p.helpUrl&&l.push(`- **More info:** ${p.helpUrl}`),l.push(""),l.push("```html"),l.push(p.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const c=l.join(`
|
|
14
|
+
`),u=new URLSearchParams({"[Title]":o,"[Description]":c});let d=`${r}/_workitems/create/${encodeURIComponent(n)}?${u.toString()}`;return d.length>Qt&&(d=d.slice(0,Qt)),{url:d,title:o,description:c}}const Yt=7800;function Er(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const p=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===p);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
|
|
15
|
+
`),c=new URLSearchParams({"issue[title]":i,"issue[description]":l});let u=`${n}/-/issues/new?${c.toString()}`;return u.length>Yt&&(u=u.slice(0,Yt)),{url:u,title:i,description:l}}const Jt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Rr=["wcag-component-auditor","wcag-forensic-log"];async function Tr(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Jt);s=Object.keys(n).length,await chrome.storage.local.remove(Jt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Rr)try{await $r(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 $r(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 lt="accessibilityStatementInputs:v1";async function Ur(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(lt))[lt];return s&&typeof s=="object"?s:null}async function Lr(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[lt]:t})}function _r({open:t,onClose:s,results:a}){const[n,r]=m.useState("eaa"),[i,o]=m.useState(""),[l,c]=m.useState(""),[u,d]=m.useState("partial"),[p,h]=m.useState(""),[x,g]=m.useState(""),[j,S]=m.useState(""),[T,w]=m.useState(""),[C,f]=m.useState("English"),[N,I]=m.useState("wcagcheckr (self-evaluation)"),[k,L]=m.useState("2.1"),[b,$]=m.useState("AA"),[H,A]=m.useState(!1),[M,_]=m.useState(null),q=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var Y,oe,ne,v;const E=await Ur();if(E&&(E.framing&&r(E.framing),E.organizationName&&o(E.organizationName),E.siteUrl&&c(E.siteUrl),E.conformanceStatus&&d(E.conformanceStatus),(Y=E.contact)!=null&&Y.email&&h(E.contact.email),(oe=E.contact)!=null&&oe.phone&&g(E.contact.phone),(ne=E.contact)!=null&&ne.formUrl&&S(E.contact.formUrl),E.countryCode&&w(E.countryCode),E.language&&f(E.language),E.auditedBy&&I(E.auditedBy),E.wcagVersion&&L(E.wcagVersion),E.wcagLevel&&$(E.wcagLevel)),!(E!=null&&E.siteUrl)&&((v=a[0])!=null&&v.pageUrl))try{const O=new URL(a[0].pageUrl);c(`${O.protocol}//${O.host}/`)}catch{}E!=null&&E.conformanceStatus||d(ba(a)),setTimeout(()=>{var O;return(O=q.current)==null?void 0:O.focus()},50)})()},[t,a]),!t)return null;function F(){var ne;const E=new Date().toISOString().slice(0,10),Y=(ne=a[0])!=null&&ne.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):E,oe={};return p.trim()&&(oe.email=p.trim()),x.trim()&&(oe.phone=x.trim()),j.trim()&&(oe.formUrl=j.trim()),{framing:n,organizationName:i.trim(),siteUrl:l.trim(),conformanceStatus:u,preparedAt:E,evaluatedAt:Y,contact:oe,countryCode:T||null,language:C.trim()||"English",auditedBy:N.trim()||"wcagcheckr (self-evaluation)",wcagVersion:k,wcagLevel:b}}function Q(E){if(!E.organizationName)return"Organization name is required.";if(!E.siteUrl)return"Site URL is required.";try{new URL(E.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!E.contact.email&&!E.contact.phone&&!E.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 se(E){_(null);const Y=F(),oe=Q(Y);if(oe){_(oe);return}A(!0);try{await Lr(Y);const ne=await ee({type:"EXPORT_REQUEST",format:E==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:Y}),v=(ne==null?void 0:ne.content)??"";if(!v||v.startsWith("# Accessibility statement — error")){_(v||"Export failed — no response.");return}try{await navigator.clipboard.writeText(v)}catch{}const O=new Blob([v],{type:E==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),P=URL.createObjectURL(O);window.open(P,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(P),6e4),s()}catch(ne){_(ne instanceof Error?ne.message:String(ne))}finally{A(!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:E=>E.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:n==="eaa",onChange:()=>r("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:n==="wad",onChange:()=>r("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:q,type:"text",value:i,onChange:E=>o(E.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:l,onChange:E=>c(E.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:u,onChange:E=>d(E.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:k,onChange:E=>L(E.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:b,onChange:E=>$(E.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:p,onChange:E=>h(E.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:E=>g(E.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:j,onChange:E=>S(E.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:T,onChange:E=>w(E.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(va).map(([E,Y])=>e.jsxs("option",{value:E,children:[E," — ",Y.name.replace(/^[A-Z]+\s*—\s*/,"")]},E))]}),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:C,onChange:E=>f(E.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:N,onChange:E=>I(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),M&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:M})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void se("markdown"),disabled:H,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:H?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void se("html"),disabled:H,className:"text-xs px-3 py-1.5 border border-brand-500 text-brand-700 hover:bg-brand-50 rounded disabled:opacity-50 font-medium",children:H?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:H,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function Dr(){const t=y(v=>v.delta),s=y(v=>v.componentId),a=y(v=>v.results),n=y(v=>v.tier),r=y(v=>v.baselineList),i=y(v=>v.siteCrawlReport),[o,l]=m.useState(""),[c,u]=m.useState(""),[d,p]=m.useState(""),[h,x]=m.useState(""),[g,j]=m.useState(!1),[S,T]=m.useState(!1),[w,C]=m.useState(null),[f,N]=m.useState(null),[I,k]=m.useState(!1),[L,b]=m.useState(!1),[$,H]=m.useState(null),[A,M]=m.useState(!1);m.useEffect(()=>{Promise.all([ee({type:"SETTINGS_GET",key:"githubRepoUrl"}),ee({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),ee({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),ee({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([v,O,P,G])=>{l(typeof v.data=="string"?v.data:""),u(typeof O.data=="string"?O.data:""),p(typeof P.data=="string"?P.data:""),x(typeof G.data=="string"?G.data:"")})},[]),m.useEffect(()=>pe("BADGE_CLICKED_EVENT",O=>{const P=`viol-row-${O.violationId}`,G=document.getElementById(P);G&&(G.scrollIntoView({behavior:"smooth",block:"center"}),G.classList.add("ring-2","ring-rose-500"),setTimeout(()=>G.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const v=await ae();v&&(L&&await de(v,{type:"BADGES_HIDE_REQUEST",tabId:v}).catch(()=>{}),A&&await de(v,{type:"HEATMAP_HIDE_REQUEST",tabId:v}).catch(()=>{}))})()},[]);async function _(){const v=await ae();if(!v){le.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(L){await de(v,{type:"BADGES_HIDE_REQUEST",tabId:v}).catch(()=>{}),b(!1),H(null);return}const O={critical:4,serious:3,moderate:2,minor:1},P=new Map;for(const V of a)for(const B of V.violations)P.has(B.matchKey)||P.set(B.matchKey,B);const z=Array.from(P.values()).sort((V,B)=>O[B.impact]-O[V.impact]).map((V,B)=>({id:V.matchKey,index:B+1,selector:V.target.selector,impact:V.impact,ruleId:V.ruleId,wcagCriterion:V.wcagCriterion}));if(z.length===0){le.polite("No violations to badge.");return}const X=await me(v,{type:"BADGES_SHOW_REQUEST",tabId:v,violations:z}).catch(()=>null);X&&(b(!0),H({rendered:X.rendered,requested:X.requested,clustered:X.clustered}),le.polite(`${X.rendered} violation badges shown on the page.`))}async function q(){const v=await ae();if(!v){le.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(A){await de(v,{type:"HEATMAP_HIDE_REQUEST",tabId:v}).catch(()=>{}),M(!1);return}const O=new Map;for(const z of a)for(const X of z.violations)O.has(X.matchKey)||O.set(X.matchKey,X);const P=Array.from(O.values()).map(z=>({selector:z.target.selector,impact:z.impact}));if(P.length===0){le.polite("No violations to heatmap.");return}const G=await me(v,{type:"HEATMAP_SHOW_REQUEST",tabId:v,violations:P}).catch(()=>null);G&&(M(!0),le.polite(`Heatmap shown with ${G.rendered} violation blobs.`))}const F=js(n,"exportJson"),Q=ks[n].maxBaselines,se=r.some(v=>v.componentId===s),E=se||r.length<Q;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 Y(){if(!s||a.length===0)return;const v=a.flatMap(B=>B.violations),O=a.flatMap(B=>B.announcements??[]),P=a.flatMap(B=>B.focusEvents??[]),G=a[0],X=(await ee({type:"SETTINGS_GET",key:"stateMatrix"})).data??Ns;await re({type:"BASELINE_SET",componentId:s,violations:v,announcements:O,focusEvents:P,snapshotMeta:{url:window.location.href,axeVersion:G.axeVersion,matrixConfig:X,capturedAt:new Date().toISOString()}});const V=await ee({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:O,focusEvents:P,currentMatrix:X});y.getState().setDelta(V.delta),le.polite(`Baseline saved for ${s}.`)}async function oe(){if(!s||!se||!window.confirm(`Remove the saved baseline for "${s}"?
|
|
16
16
|
|
|
17
|
-
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await re({type:"BASELINE_DELETE",componentId:s});const O=a.flatMap(V=>V.violations),P=a.flatMap(V=>V.announcements??[]),G=a.flatMap(V=>V.focusEvents??[]),z=await ee({type:"BASELINE_COMPARE",componentId:s,currentViolations:O,announcements:P,focusEvents:G});v.getState().setDelta(z.delta);const Y=await ee({type:"BASELINE_LIST"});v.getState().setBaselineList(Y.items),le.polite(`Baseline cleared for ${s}.`)}async function ne(b,O=!1){if(a.length===0)return;if(b==="ai-prompt"){const{copyAiFixerPrompt:W}=await ft(async()=>{const{copyAiFixerPrompt:J}=await import("./copy-ai-fixer-prompt-DVAS4M9I.js");return{copyAiFixerPrompt:J}},__vite__mapDeps([0,1,2]));await W({results:a,componentId:s,delta:O?void 0:t,siteCrawlReport:i});return}let P;if((b==="defense-bundle"||b==="evidence-bundle"||b==="deposition-packet")&&s){const W=await chrome.storage.local.get("igtRuns"),te=((W==null?void 0:W.igtRuns)??{})[s]??{};P=Object.values(te)}const Y=await ee({type:"EXPORT_REQUEST",format:b,results:a,delta:O?void 0:t??void 0,manualRuns:P,dismissedKeys:void 0,incompleteResolutions:void 0});if(b==="defense-bundle"||b==="evidence-bundle"||b==="deposition-packet"){const W=ms(b,s);await xs()?ht(Y.content,W):S({open:!0,format:b,content:Y.content,filename:W});return}if(b==="html-print"||b==="vpat"||b==="methodology-doc"||b==="conformance-crosswalk"||b==="executive-report"){pt(Y.content);return}const V=b==="json"?"application/json":b==="sarif"?"application/sarif+json":b==="ticket-bundle"?"text/markdown":"application/xml",B=b==="junit"?"xml":b==="ticket-bundle"?"md":b,R=new Blob([Y.content],{type:V}),K=URL.createObjectURL(R),_=document.createElement("a");_.href=K,_.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${B}`,_.click(),URL.revokeObjectURL(K)}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:q,disabled:!E,title:E?void 0:`Free tier limits you to ${Z} 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"}),se&&e.jsx("button",{onClick:oe,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:()=>j(!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 D(),"aria-pressed":U,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:U?"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:U?"Hide badges":"Show badges 🎯"}),U&&L&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[L.rendered," of ",L.requested," rendered",L.clustered>0?` · ${L.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void X(),"aria-pressed":C,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:C?"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:C?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(Gr,{disabled:!F,onExport:ne,onAccessibilityStatement:()=>I(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!E&&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 b=Je(t.new),O=Je(t.persistent),P=Je(t.fixed),G=[...b.review,...O.review];return e.jsxs(e.Fragment,{children:[e.jsx(ke,{title:"New",violations:b.findings,count:b.findings.length,accent:"red",actions:[...o&&b.findings.length>0?[{label:"File GitHub issue",onClick:()=>Or(o,s,b.findings)}]:[],...c&&b.findings.length>0?[{label:"File Jira issue",onClick:()=>Mr(c,s,b.findings)}]:[],...d&&b.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Fr(d,s,b.findings)}]:[],...h&&b.findings.length>0?[{label:"File GitLab issue",onClick:()=>Pr(h,s,b.findings)}]:[]]}),e.jsx(ke,{title:"Persistent",violations:O.findings,count:O.findings.length,accent:"slate"}),e.jsx(ke,{title:"Fixed",violations:P.findings,count:t.fixedCount,accent:"green"}),G.length>0&&e.jsx(ke,{title:"Needs review (does not affect grade)",violations:G,count:G.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ke,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),f&&e.jsx(Ps,{open:f.open,onClose:()=>S(null),format:f.format,content:f.content,filename:f.filename}),e.jsx(Lr,{open:N,onClose:()=>I(!1),results:a}),g&&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"})]})]}),k&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",k.chromeStorageKeysCleared," chrome.storage key",k.chromeStorageKeysCleared===1?"":"s"," + ",k.indexedDbsCleared.length," database",k.indexedDbsCleared.length===1?"":"s",".",k.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",k.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:k?e.jsx("button",{type:"button",onClick:()=>{j(!1),w(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:()=>j(!1),disabled:A,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()=>{T(!0);try{const b=await Rr();w(b),await He(),le.polite("Audit data reset. Ready for a fresh scan.")}catch(b){w({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[b instanceof Error?b.message:String(b)]})}finally{T(!1)}},disabled:A,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:A?"Resetting…":"Reset everything"})]})})]})})]})}const Dr={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Je(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 ke({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=m.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${Dr[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,u)=>e.jsx(We,{violation:c,alreadyAcknowledged:!0},u)):Nr(s).map(c=>e.jsx(jr,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Or(t,s,a){if(a.length===0)return;const{url:n}=Sr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Mr(t,s,a){if(a.length===0)return;const{url:n}=Ar(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Fr(t,s,a){if(a.length===0)return;const{url:n}=Cr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Pr(t,s,a){if(a.length===0)return;const{url:n}=Ir(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Gr({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=m.useState(!1),[o,l]=m.useState(!1);function c(u){i(!1),s(u,o)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(u=>!u),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] 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:o,onChange:u=>l(u.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ue,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ue,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ue,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ue,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ue,{onClick:()=>c("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(ue,{onClick:()=>c("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(ue,{onClick:()=>c("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(ue,{onClick:()=>c("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(ue,{onClick:()=>c("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(ue,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ue,{onClick:()=>c("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx(ue,{onClick:()=>c("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(ue,{onClick:()=>{i(!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 ue({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 Jt="igtRuns";async function Vr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Jt))[Jt];return s&&typeof s=="object"?s:{}}async function Wr(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Vr())[t];if(i)for(const c of ie){const u=i[c.id];if(u)for(const d of c.steps){if(!d.autoDismissActivity||((l=(o=u.steps)==null?void 0:o[d.id])==null?void 0:l.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:be(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const Br=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"]),Hr=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 zr(t){return Br.has(t.ruleId)}function Kr(t){return Hr.has(t.ruleId)}function qr(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Qr(){var U,y,L,H;const t=v(C=>C.results),s=v(C=>C.delta),a=v(C=>C.componentId),n=((U=t[0])==null?void 0:U.pageUrl)??((y=t[0])==null?void 0:y.scope)??"",[r,i]=m.useState({}),[o,l]=m.useState(0);m.useEffect(()=>{if(!n)return;let C=!1;return(async()=>{if(a&&t.length>0)try{await Wr(a,t)}catch{}if(C)return;const M=await Be(n);C||i(M)})(),()=>{C=!0}},[n,o,a,t]);async function c(C,M){if(!n)return;const D=window.prompt(`Why is this finding a false positive?
|
|
17
|
+
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await re({type:"BASELINE_DELETE",componentId:s});const O=a.flatMap(V=>V.violations),P=a.flatMap(V=>V.announcements??[]),G=a.flatMap(V=>V.focusEvents??[]),z=await ee({type:"BASELINE_COMPARE",componentId:s,currentViolations:O,announcements:P,focusEvents:G});y.getState().setDelta(z.delta);const X=await ee({type:"BASELINE_LIST"});y.getState().setBaselineList(X.items),le.polite(`Baseline cleared for ${s}.`)}async function ne(v,O=!1){if(a.length===0)return;if(v==="ai-prompt"){const{copyAiFixerPrompt:W}=await bt(async()=>{const{copyAiFixerPrompt:Z}=await import("./copy-ai-fixer-prompt-BHcnobbQ.js");return{copyAiFixerPrompt:Z}},__vite__mapDeps([0,1,2]));await W({results:a,componentId:s,delta:O?void 0:t,siteCrawlReport:i});return}let P;if((v==="defense-bundle"||v==="evidence-bundle"||v==="deposition-packet")&&s){const W=await chrome.storage.local.get("igtRuns"),te=((W==null?void 0:W.igtRuns)??{})[s]??{};P=Object.values(te)}const X=await ee({type:"EXPORT_REQUEST",format:v,results:a,delta:O?void 0:t??void 0,manualRuns:P,dismissedKeys:void 0,incompleteResolutions:void 0});if(v==="defense-bundle"||v==="evidence-bundle"||v==="deposition-packet"){const W=xs(v,s);await gs()?mt(X.content,W):N({open:!0,format:v,content:X.content,filename:W});return}if(v==="html-print"||v==="vpat"||v==="methodology-doc"||v==="conformance-crosswalk"||v==="executive-report"){ht(X.content);return}const V=v==="json"?"application/json":v==="sarif"?"application/sarif+json":v==="ticket-bundle"?"text/markdown":"application/xml",B=v==="junit"?"xml":v==="ticket-bundle"?"md":v,R=new Blob([X.content],{type:V}),K=URL.createObjectURL(R),D=document.createElement("a");D.href=K,D.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${B}`,D.click(),URL.revokeObjectURL(K)}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:Y,disabled:!E,title:E?void 0:`Free tier limits you to ${Q} 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"}),se&&e.jsx("button",{onClick:oe,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:()=>j(!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 _(),"aria-pressed":L,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:L?"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:L?"Hide badges":"Show badges 🎯"}),L&&$&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[$.rendered," of ",$.requested," rendered",$.clustered>0?` · ${$.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void q(),"aria-pressed":A,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:A?"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:A?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(Vr,{disabled:!F,onExport:ne,onAccessibilityStatement:()=>k(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!E&&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 v=Xe(t.new),O=Xe(t.persistent),P=Xe(t.fixed),G=[...v.review,...O.review];return e.jsxs(e.Fragment,{children:[e.jsx(ke,{title:"New",violations:v.findings,count:v.findings.length,accent:"red",actions:[...o&&v.findings.length>0?[{label:"File GitHub issue",onClick:()=>Mr(o,s,v.findings)}]:[],...c&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>Fr(c,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Pr(d,s,v.findings)}]:[],...h&&v.findings.length>0?[{label:"File GitLab issue",onClick:()=>Gr(h,s,v.findings)}]:[]]}),e.jsx(ke,{title:"Persistent",violations:O.findings,count:O.findings.length,accent:"slate"}),e.jsx(ke,{title:"Fixed",violations:P.findings,count:t.fixedCount,accent:"green"}),G.length>0&&e.jsx(ke,{title:"Needs review (does not affect grade)",violations:G,count:G.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ke,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),f&&e.jsx(Gs,{open:f.open,onClose:()=>N(null),format:f.format,content:f.content,filename:f.filename}),e.jsx(_r,{open:I,onClose:()=>k(!1),results:a}),g&&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"})]})]}),w&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",w.chromeStorageKeysCleared," chrome.storage key",w.chromeStorageKeysCleared===1?"":"s"," + ",w.indexedDbsCleared.length," database",w.indexedDbsCleared.length===1?"":"s",".",w.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",w.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:w?e.jsx("button",{type:"button",onClick:()=>{j(!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:()=>j(!1),disabled:S,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()=>{T(!0);try{const v=await Tr();C(v),await ze(),le.polite("Audit data reset. Ready for a fresh scan.")}catch(v){C({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[v instanceof Error?v.message:String(v)]})}finally{T(!1)}},disabled:S,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:S?"Resetting…":"Reset everything"})]})})]})})]})}const Or={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Xe(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 ke({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=m.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${Or[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,u)=>e.jsx(Be,{violation:c,alreadyAcknowledged:!0},u)):kr(s).map(c=>e.jsx(Nr,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Mr(t,s,a){if(a.length===0)return;const{url:n}=Ar(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Fr(t,s,a){if(a.length===0)return;const{url:n}=Cr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Pr(t,s,a){if(a.length===0)return;const{url:n}=Ir(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Gr(t,s,a){if(a.length===0)return;const{url:n}=Er(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Vr({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=m.useState(!1),[o,l]=m.useState(!1);function c(u){i(!1),s(u,o)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(u=>!u),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] 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:o,onChange:u=>l(u.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ue,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ue,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ue,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ue,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ue,{onClick:()=>c("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(ue,{onClick:()=>c("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(ue,{onClick:()=>c("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(ue,{onClick:()=>c("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(ue,{onClick:()=>c("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(ue,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ue,{onClick:()=>c("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx(ue,{onClick:()=>c("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(ue,{onClick:()=>{i(!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 ue({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 Xt="igtRuns";async function Wr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Xt))[Xt];return s&&typeof s=="object"?s:{}}async function Br(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Wr())[t];if(i)for(const c of ie){const u=i[c.id];if(u)for(const d of c.steps){if(!d.autoDismissActivity||((l=(o=u.steps)==null?void 0:o[d.id])==null?void 0:l.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:be(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const Hr=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"]),zr=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 Kr(t){return Hr.has(t.ruleId)}function qr(t){return zr.has(t.ruleId)}function Qr(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Yr(){var L,b,$,H;const t=y(A=>A.results),s=y(A=>A.delta),a=y(A=>A.componentId),n=((L=t[0])==null?void 0:L.pageUrl)??((b=t[0])==null?void 0:b.scope)??"",[r,i]=m.useState({}),[o,l]=m.useState(0);m.useEffect(()=>{if(!n)return;let A=!1;return(async()=>{if(a&&t.length>0)try{await Br(a,t)}catch{}if(A)return;const M=await He(n);A||i(M)})(),()=>{A=!0}},[n,o,a,t]);async function c(A,M){if(!n)return;const _=window.prompt(`Why is this finding a false positive?
|
|
18
18
|
|
|
19
|
-
(Recorded with the dismissal so future you remembers the reasoning.)`,"");D!==null&&(await _s(n,C,D||"(no reason given)",M),l(X=>X+1))}async function u(C){n&&(await Ds(n,C),l(M=>M+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 d=t.reduce((C,M)=>{var D;return C+(((D=M.announcements)==null?void 0:D.length)??0)},0),p=t.reduce((C,M)=>{var D;return C+(((D=M.focusEvents)==null?void 0:D.length)??0)},0),h=t.reduce((C,M)=>{var D;return C+(((D=M.focusEvents)==null?void 0:D.filter(X=>X.isFocusReset).length)??0)},0),x=Xt(t,zr),g=Xt(t,Kr),j=x.length,A=g.length,T=((L=t[0])==null?void 0:L.readingOrderIssues)??[],k=((H=t[0])==null?void 0:H.tabOrderIssues)??[],w=T.filter(C=>!(fe(C.selector)in r)),f=T.filter(C=>fe(C.selector)in r),S=k.filter(C=>!(be(C.selector)in r)),N=k.filter(C=>be(C.selector)in r);if(d===0&&p===0&&j===0&&A===0&&w.length===0&&S.length===0&&f.length===0&&N.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 I=f.length+N.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:[j," structural · ",A," form ·"," ",S.length," tab-order ·"," ",w.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",p," focus ",p===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),I>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",I," dismissed"]})]}),S.length>0&&e.jsx(Xr,{issues:S,onDismiss:c}),w.length>0&&e.jsx(Zr,{issues:w,onDismiss:c}),I>0&&e.jsx(ei,{dismissedReadingOrder:f,dismissedTabOrder:N,dismissals:r,onRestore:u}),j>0&&e.jsx(Zt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:x}),A>0&&e.jsx(Zt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:g}),e.jsx(Yr,{delta:s}),t.map((C,M)=>{const D=C.announcements??[],X=C.focusEvents??[];return D.length===0&&X.length===0?null:e.jsx(Jr,{state:C.state,announcements:D,focusEvents:X},M)})]})}function Yr({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function Xt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=xt(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function Zt({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 Jr({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:qr(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 Xr({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Zr({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 ei({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=m.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),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(l=>{const c=`tab-order::${l.selector}`,u=a[c];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:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,u=a[c];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:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const lt="igtRuns";async function ti(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Re(r,o.map(l=>({key:be(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Re(r,o.map(l=>({key:fe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const si={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"}},ai={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"}},ni={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function es(t,s){const a=await ae();if(!a)return;const n=s?si[t]:ai[t];try{await de(a,n)}catch{}}async function ri(){const s=(await chrome.storage.local.get(lt))[lt];return s&&typeof s=="object"?s:{}}async function ts(t){await chrome.storage.local.set({[lt]:t})}function ii(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 oi(){const t=v(d=>d.componentId),s=v(d=>d.results),[a,n]=m.useState({}),[r,i]=m.useState(null);if(m.useEffect(()=>{ri().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 o=a[t]??{};function l(d,p,h){var g;const x={...a,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=o[d])==null?void 0:g.steps)??{},[p]:h},completedAt:new Date().toISOString()}}};if(n(x),ts(x),h.status==="pass"){const j=ie.find(T=>T.id===d),A=j==null?void 0:j.steps.find(T=>T.id===p);A!=null&&A.autoDismissActivity&&ti(A.autoDismissActivity,s,p)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[d];const h={...a,[t]:p};n(h),ts(h)}const u=ie.find(d=>d.id===r);if(u){const d=o[u.id];return e.jsx(li,{workflow:u,run:d,results:s,onAnswer:(p,h)=>l(u.id,p,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),ie.map(d=>{const p=o[d.id],h=p?va(p,d):null,x=p?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",g={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:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,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:d.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:d.blurb}),p&&e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function li({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=m.useMemo(()=>{const c={};for(const u of t.steps)c[u.id]=ii(u,a);return c},[t,a]);function o(){for(const c of t.steps){const u=i[c.id];(u==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`})}}const l=t.steps.filter(c=>{var u;return((u=i[c.id])==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[c.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}),l>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:[l," step",l===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:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,u)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.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:[u+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const p=i[c.id];return p?p.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:p.ruleId})," ran clean across ",p.statesAudited," state",p.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.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:p.ruleId})," already found ",p.violationCount," violation",p.violationCount===1?"":"s"," in"," ",p.states.length," state",p.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${p.ruleId}, ${p.violationCount} hits in: ${p.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})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void es(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",ni[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void es(c.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($e,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx($e,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx($e,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx($e,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:p=>n(c.id,{status:d.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const ci={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 $e({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?ci[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Oe="savedFlows";async function di(){const t=await chrome.storage.local.get(Oe);return Array.isArray(t[Oe])?t[Oe]:[]}async function ss(t){await chrome.storage.local.set({[Oe]:t})}function ui(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,i]=m.useState(null);m.useEffect(()=>{di().then(s)},[]);async function o(){const d=await ae();if(!d){i("No audit-target tab found.");return}try{await de(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const d=await ae();if(d)try{const p=await me(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),p.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${p.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:p.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await ss(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(p){i(`Stop failed: ${p instanceof Error?p.message:String(p)}`)}}async function c(d){const p=await ae();if(p){i(`Replaying "${d.name}"…`);try{const h=await me(p,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function u(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(h=>h.id!==d);s(p),await ss(p)}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:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,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(d=>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:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),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:()=>u(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function pi(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(hi).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function hi(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function mi(){const t=v(l=>l.baselineList),s=v(l=>l.tier),a=Ns[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=m.useState(!1);if(m.useEffect(()=>{Pe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>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"})]},l))});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 o(l){await re({type:"BASELINE_DELETE",componentId:l}),await Pe()}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(l=>{const c=pi(l.componentId),u=l.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:l.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),u&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(xe,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),u.criticalCount>0&&e.jsxs(xe,{tone:"rose",title:`${u.criticalCount} critical violations`,children:[u.criticalCount," critical"]}),u.seriousCount>0&&e.jsxs(xe,{tone:"orange",title:`${u.seriousCount} serious violations`,children:[u.seriousCount," serious"]}),u.focusResetCount>0&&e.jsxs(xe,{tone:"rose",title:`${u.focusResetCount} focus resets observed`,children:[u.focusResetCount," focus reset",u.focusResetCount===1?"":"s"]}),u.targetSizeFailCount>0&&e.jsxs(xe,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[u.targetSizeFailCount," small targets"]}),u.hoverContrastFail&&e.jsx(xe,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),u.announcementCount>0&&e.jsxs(xe,{tone:"indigo",title:"aria-live announcements observed",children:[u.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const xi={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 xe({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${xi[t]}`,children:a})}const gi={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"},fi={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},bi={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 Gs({onBack:t}){const s=v(p=>p.siteCrawlStatus),a=v(p=>p.siteCrawlProgress),n=v(p=>p.siteCrawlReport),r=v(p=>p.siteCrawlError),[i,o]=m.useState(""),[l,c]=m.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(p=>{var x;const h=(x=p[0])==null?void 0:x.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function u(){i&&(l>=5&&!window.confirm(`Each of the ${l} 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 ${l*5} minutes. Proceed?`)||(v.getState().setSiteCrawlStatus("running"),v.getState().setSiteCrawlReport(null),v.getState().setSiteCrawlError(null),he({type:"START_SITE_CRAWL",startUrl:i,maxPages:l})))}function d(){re({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."}),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:i,onChange:p=>o(p.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:l,onChange:p=>c(Math.min(200,Math.max(1,parseInt(p.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 full single-page audit pipeline (matrix + analyzers + AI)."})]}),e.jsx("button",{type:"button",onClick:u,disabled:!i,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"})]}),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:d,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(vi,{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 vi({report:t}){function s(){ft(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-CzL3uuvq.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const o=i(t),l=new Blob([o],{type:"text/html"}),c=URL.createObjectURL(l);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=m.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),o=(i==null?void 0:i.content)??"";if(!o){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(o)}catch{}const l=new Blob([o],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(l);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${gi[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${fi[t.siteRisk]}`,children:ya[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsx("button",{type:"button",onClick:r,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.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:"Two ways to use this report."}),' The crawl above is for triage + bulk AI hand-off — knock out the big stuff across the whole site in one shot. For granular control on any single page (acknowledge individual findings, run guided manual checks, preview fixes on the live page, run interactive walkthroughs), click that page in the "Pages, worst first" list below.']}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(i=>{const o=wa(i.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${bi[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:o.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:i.urlsAffected})," page",i.urlsAffected===1?"":"s"," · ",i.totalOccurrences," total spot",i.totalOccurrences===1?"":"s"]})]})]})},i.ruleId)})})]}),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:["The crawl is for triage + bulk AI fix-prompt generation. ",e.jsx("strong",{children:"Click any page"})," to open it in the active tab and load its crawl results into the single-page view — there you get per-finding acknowledgements, visualizers, guided manual checks, and fix-preview overlays."]}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(i=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void yi(i.url),className:"w-full flex items-center gap-2 text-left px-1.5 py-1 rounded hover:bg-slate-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500",title:"Open this page in the active tab and load its crawl results into the single-page view for granular fix work",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${i.grade==="A"?"text-emerald-700":i.grade==="B"?"text-lime-700":i.grade==="C"?"text-yellow-700":i.grade==="D"?"text-orange-700":"text-rose-700"}`,children:i.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:i.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:i.uniqueViolations}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},i.url))})]})]})}async function yi(t){try{const s=await ja(),a=s==null?void 0:s.find(n=>n.url===t);try{const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];r!=null&&r.id?await chrome.tabs.update(r.id,{url:t,active:!0}):await chrome.tabs.create({url:t,active:!0})}catch{}if(a&&a.results.length>0&&a.componentId){v.getState().setResults(a.results,a.delta,a.componentId);try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}}v.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const Xe="onboardingDismissed",Ze=[{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 wi(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(Xe).then(l=>{l[Xe]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Xe]:!0}),s(!1),n(0)}const i=a===Ze.length-1,o=Ze[a];return e.jsxs(ve,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.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," / ",Ze.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function ji(){const t=v(n=>n.status),s=v(n=>n.errorMessage),a=v(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 Ni(){const t=v(c=>c.aiFailure),s=v(c=>c.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),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((c,u)=>e.jsx("li",{children:c},u))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function as(){const[t,s]=m.useState(!1);return m.useEffect(()=>pe("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),v.getState().setStatus("idle"))}),[]),e.jsxs(ve,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function ki(){var i;const[t,s]=m.useState(null);if(m.useEffect(()=>{Na().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await Ct(),v.getState().startNewScan(),t.mode==="storybook-all"?he({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&he({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Ct(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const et="storybook:hintDismissed";function Si(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(et))[et])return;const o=await ae();if(o)try{const u=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(p=d.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(d=>{var p;return(p=d.result)==null?void 0:p.detected});u&&(n((l=u.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[et]:!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 Ai(){var i;const t=v(o=>o.results),s=v(o=>o.baselineList),a=v(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Ci(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 Ci(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function Ii(){const t=v(l=>l.results),s=v(l=>l.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=ka(r,a.length>0?{runs:a,workflows:ie}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"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 Ei(){const t=v(a=>a.setUserMode);function s(a){t(a),re({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 Ri=["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"],Ti={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 $i(t){const s=new Set(Ri),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,u])=>({ruleId:c,instanceCount:u})).sort((c,u)=>u.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,u)=>c+u,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Ti[o]}}const Vs={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Ui={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Vs]},Li={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Vs]};function yt(t){return t==="thorough"?Li:Ui}function ns(t){const s=yt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Me="wcagcheckr";function Q(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ee(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 _i(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Di(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 Oi(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 Mi(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 Fi(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 (${Q(t.receipt.tsaName)}) — anchored ${Q(Ee(t.receipt.anchoredAt))}</td></tr>
|
|
20
|
-
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${
|
|
21
|
-
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${
|
|
19
|
+
(Recorded with the dismissal so future you remembers the reasoning.)`,"");_!==null&&(await Ds(n,A,_||"(no reason given)",M),l(q=>q+1))}async function u(A){n&&(await Os(n,A),l(M=>M+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 d=t.reduce((A,M)=>{var _;return A+(((_=M.announcements)==null?void 0:_.length)??0)},0),p=t.reduce((A,M)=>{var _;return A+(((_=M.focusEvents)==null?void 0:_.length)??0)},0),h=t.reduce((A,M)=>{var _;return A+(((_=M.focusEvents)==null?void 0:_.filter(q=>q.isFocusReset).length)??0)},0),x=Zt(t,Kr),g=Zt(t,qr),j=x.length,S=g.length,T=(($=t[0])==null?void 0:$.readingOrderIssues)??[],w=((H=t[0])==null?void 0:H.tabOrderIssues)??[],C=T.filter(A=>!(fe(A.selector)in r)),f=T.filter(A=>fe(A.selector)in r),N=w.filter(A=>!(be(A.selector)in r)),I=w.filter(A=>be(A.selector)in r);if(d===0&&p===0&&j===0&&S===0&&C.length===0&&N.length===0&&f.length===0&&I.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 k=f.length+I.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:[j," structural · ",S," form ·"," ",N.length," tab-order ·"," ",C.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",p," focus ",p===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),k>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",k," dismissed"]})]}),N.length>0&&e.jsx(Zr,{issues:N,onDismiss:c}),C.length>0&&e.jsx(ei,{issues:C,onDismiss:c}),k>0&&e.jsx(ti,{dismissedReadingOrder:f,dismissedTabOrder:I,dismissals:r,onRestore:u}),j>0&&e.jsx(es,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:x}),S>0&&e.jsx(es,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:g}),e.jsx(Jr,{delta:s}),t.map((A,M)=>{const _=A.announcements??[],q=A.focusEvents??[];return _.length===0&&q.length===0?null:e.jsx(Xr,{state:A.state,announcements:_,focusEvents:q},M)})]})}function Jr({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function Zt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=gt(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function es({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 Xr({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:Qr(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 Zr({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function ei({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 ti({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=m.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),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(l=>{const c=`tab-order::${l.selector}`,u=a[c];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:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,u=a[c];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:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const ct="igtRuns";async function si(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Re(r,o.map(l=>({key:be(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Re(r,o.map(l=>({key:fe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const ai={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"}},ni={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"}},ri={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ts(t,s){const a=await ae();if(!a)return;const n=s?ai[t]:ni[t];try{await de(a,n)}catch{}}async function ii(){const s=(await chrome.storage.local.get(ct))[ct];return s&&typeof s=="object"?s:{}}async function ss(t){await chrome.storage.local.set({[ct]:t})}function oi(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 li(){const t=y(d=>d.componentId),s=y(d=>d.results),[a,n]=m.useState({}),[r,i]=m.useState(null);if(m.useEffect(()=>{ii().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 o=a[t]??{};function l(d,p,h){var g;const x={...a,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=o[d])==null?void 0:g.steps)??{},[p]:h},completedAt:new Date().toISOString()}}};if(n(x),ss(x),h.status==="pass"){const j=ie.find(T=>T.id===d),S=j==null?void 0:j.steps.find(T=>T.id===p);S!=null&&S.autoDismissActivity&&si(S.autoDismissActivity,s,p)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[d];const h={...a,[t]:p};n(h),ss(h)}const u=ie.find(d=>d.id===r);if(u){const d=o[u.id];return e.jsx(ci,{workflow:u,run:d,results:s,onAnswer:(p,h)=>l(u.id,p,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),ie.map(d=>{const p=o[d.id],h=p?ya(p,d):null,x=p?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",g={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:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,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:d.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:d.blurb}),p&&e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function ci({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=m.useMemo(()=>{const c={};for(const u of t.steps)c[u.id]=oi(u,a);return c},[t,a]);function o(){for(const c of t.steps){const u=i[c.id];(u==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`})}}const l=t.steps.filter(c=>{var u;return((u=i[c.id])==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[c.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}),l>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:[l," step",l===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:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,u)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.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:[u+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const p=i[c.id];return p?p.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:p.ruleId})," ran clean across ",p.statesAudited," state",p.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.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:p.ruleId})," already found ",p.violationCount," violation",p.violationCount===1?"":"s"," in"," ",p.states.length," state",p.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${p.ruleId}, ${p.violationCount} hits in: ${p.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})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ts(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",ri[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ts(c.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($e,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx($e,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx($e,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx($e,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:p=>n(c.id,{status:d.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const di={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 $e({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?di[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Me="savedFlows";async function ui(){const t=await chrome.storage.local.get(Me);return Array.isArray(t[Me])?t[Me]:[]}async function as(t){await chrome.storage.local.set({[Me]:t})}function pi(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,i]=m.useState(null);m.useEffect(()=>{ui().then(s)},[]);async function o(){const d=await ae();if(!d){i("No audit-target tab found.");return}try{await de(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const d=await ae();if(d)try{const p=await me(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),p.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${p.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:p.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await as(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(p){i(`Stop failed: ${p instanceof Error?p.message:String(p)}`)}}async function c(d){const p=await ae();if(p){i(`Replaying "${d.name}"…`);try{const h=await me(p,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function u(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(h=>h.id!==d);s(p),await as(p)}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:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,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(d=>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:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),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:()=>u(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function hi(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(mi).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function mi(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function xi(){const t=y(l=>l.baselineList),s=y(l=>l.tier),a=ks[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=m.useState(!1);if(m.useEffect(()=>{Ge().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>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"})]},l))});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 o(l){await re({type:"BASELINE_DELETE",componentId:l}),await Ge()}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(l=>{const c=hi(l.componentId),u=l.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:l.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),u&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(xe,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),u.criticalCount>0&&e.jsxs(xe,{tone:"rose",title:`${u.criticalCount} critical violations`,children:[u.criticalCount," critical"]}),u.seriousCount>0&&e.jsxs(xe,{tone:"orange",title:`${u.seriousCount} serious violations`,children:[u.seriousCount," serious"]}),u.focusResetCount>0&&e.jsxs(xe,{tone:"rose",title:`${u.focusResetCount} focus resets observed`,children:[u.focusResetCount," focus reset",u.focusResetCount===1?"":"s"]}),u.targetSizeFailCount>0&&e.jsxs(xe,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[u.targetSizeFailCount," small targets"]}),u.hoverContrastFail&&e.jsx(xe,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),u.announcementCount>0&&e.jsxs(xe,{tone:"indigo",title:"aria-live announcements observed",children:[u.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const gi={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 xe({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${gi[t]}`,children:a})}const fi={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"},bi={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},vi={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 Vs({onBack:t}){const s=y(p=>p.siteCrawlStatus),a=y(p=>p.siteCrawlProgress),n=y(p=>p.siteCrawlReport),r=y(p=>p.siteCrawlError),[i,o]=m.useState(""),[l,c]=m.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(p=>{var x;const h=(x=p[0])==null?void 0:x.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function u(){i&&(l>=5&&!window.confirm(`Each of the ${l} 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 ${l*5} minutes. Proceed?`)||(y.getState().setSiteCrawlStatus("running"),y.getState().setSiteCrawlReport(null),y.getState().setSiteCrawlError(null),he({type:"START_SITE_CRAWL",startUrl:i,maxPages:l})))}function d(){re({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."}),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:i,onChange:p=>o(p.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:l,onChange:p=>c(Math.min(200,Math.max(1,parseInt(p.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 full single-page audit pipeline (matrix + analyzers + AI)."})]}),e.jsx("button",{type:"button",onClick:u,disabled:!i,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"})]}),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:d,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(yi,{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 yi({report:t}){function s(){bt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-Cxo8Bmrd.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const o=i(t),l=new Blob([o],{type:"text/html"}),c=URL.createObjectURL(l);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=m.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),o=(i==null?void 0:i.content)??"";if(!o){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(o)}catch{}const l=new Blob([o],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(l);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${fi[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${bi[t.siteRisk]}`,children:wa[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsx("button",{type:"button",onClick:r,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.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:"Two ways to use this report."}),' The crawl above is for triage + bulk AI hand-off — knock out the big stuff across the whole site in one shot. For granular control on any single page (acknowledge individual findings, run guided manual checks, preview fixes on the live page, run interactive walkthroughs), click that page in the "Pages, worst first" list below.']}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(i=>{const o=ja(i.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${vi[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:o.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:i.urlsAffected})," page",i.urlsAffected===1?"":"s"," · ",i.totalOccurrences," total spot",i.totalOccurrences===1?"":"s"]})]})]})},i.ruleId)})})]}),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:["The crawl is for triage + bulk AI fix-prompt generation. ",e.jsx("strong",{children:"Click any page"})," to open it in the active tab and load its crawl results into the single-page view — there you get per-finding acknowledgements, visualizers, guided manual checks, and fix-preview overlays."]}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(i=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void wi(i.url),className:"w-full flex items-center gap-2 text-left px-1.5 py-1 rounded hover:bg-slate-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500",title:"Open this page in the active tab and load its crawl results into the single-page view for granular fix work",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${i.grade==="A"?"text-emerald-700":i.grade==="B"?"text-lime-700":i.grade==="C"?"text-yellow-700":i.grade==="D"?"text-orange-700":"text-rose-700"}`,children:i.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:i.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:i.uniqueViolations}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},i.url))})]})]})}async function wi(t){try{const s=await Na(),a=s==null?void 0:s.find(n=>n.url===t);try{const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];r!=null&&r.id?await chrome.tabs.update(r.id,{url:t,active:!0}):await chrome.tabs.create({url:t,active:!0})}catch{}if(a&&a.results.length>0&&a.componentId){y.getState().setResults(a.results,a.delta,a.componentId);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("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const Ze="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 ji(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(Ze).then(l=>{l[Ze]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ze]:!0}),s(!1),n(0)}const i=a===et.length-1,o=et[a];return e.jsxs(ve,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.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(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Ni(){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 ki(){const t=y(c=>c.aiFailure),s=y(c=>c.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),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((c,u)=>e.jsx("li",{children:c},u))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function ns(){const[t,s]=m.useState(!1);return m.useEffect(()=>pe("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),y.getState().setStatus("idle"))}),[]),e.jsxs(ve,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function Si(){var i;const[t,s]=m.useState(null);if(m.useEffect(()=>{ka().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await It(),y.getState().startNewScan(),t.mode==="storybook-all"?he({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&he({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await It(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const tt="storybook:hintDismissed";function Ai(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(tt))[tt])return;const o=await ae();if(o)try{const u=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(p=d.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(d=>{var p;return(p=d.result)==null?void 0:p.detected});u&&(n((l=u.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[tt]:!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 Ci(){var i;const t=y(o=>o.results),s=y(o=>o.baselineList),a=y(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Ii(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 Ii(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function Ei(){const t=y(l=>l.results),s=y(l=>l.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=Sa(r,a.length>0?{runs:a,workflows:ie}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"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 Ri(){const t=y(a=>a.setUserMode);function s(a){t(a),re({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 Ti=["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"],$i={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 Ui(t){const s=new Set(Ti),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,u])=>({ruleId:c,instanceCount:u})).sort((c,u)=>u.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,u)=>c+u,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:$i[o]}}const Ws={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Li={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ws]},_i={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ws]};function wt(t){return t==="thorough"?_i:Li}function rs(t){const s=wt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Fe="wcagcheckr";function J(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ee(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 Di(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Oi(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 Mi(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 Fi(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 Pi(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 (${J(t.receipt.tsaName)}) — anchored ${J(Ee(t.receipt.anchoredAt))}</td></tr>
|
|
20
|
+
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${J(t.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
21
|
+
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${J(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${J(Fe)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
|
|
22
22
|
<article class="entry">
|
|
23
23
|
<header class="entry-header">
|
|
24
|
-
<span class="grade-badge ${
|
|
24
|
+
<span class="grade-badge ${Fi(t.grade)}">${J(t.grade)}</span>
|
|
25
25
|
<div class="entry-headline">
|
|
26
|
-
<div class="entry-time">${
|
|
26
|
+
<div class="entry-time">${J(Ee(t.capturedAt))}</div>
|
|
27
27
|
<div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
|
|
28
28
|
</div>
|
|
29
29
|
</header>
|
|
30
30
|
<table class="entry-fields">
|
|
31
|
-
<tr><th>Audit identity hash</th><td><code class="hash">${
|
|
32
|
-
<tr><th>Page URL</th><td><code>${
|
|
33
|
-
<tr><th>Scope</th><td><code>${
|
|
34
|
-
<tr><th>axe-core version</th><td>${
|
|
31
|
+
<tr><th>Audit identity hash</th><td><code class="hash">${J(t.hash)}</code></td></tr>
|
|
32
|
+
<tr><th>Page URL</th><td><code>${J(t.pageUrl)}</code></td></tr>
|
|
33
|
+
<tr><th>Scope</th><td><code>${J(t.scope)}</code></td></tr>
|
|
34
|
+
<tr><th>axe-core version</th><td>${J(t.axeVersion)}</td></tr>
|
|
35
35
|
<tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
|
|
36
36
|
${n}
|
|
37
37
|
</table>
|
|
38
|
-
</article>`}function
|
|
38
|
+
</article>`}function Gi(t){return`
|
|
39
39
|
<section class="component-section">
|
|
40
40
|
<h2>
|
|
41
|
-
<span class="component-id">${
|
|
41
|
+
<span class="component-id">${J(t.componentId)}</span>
|
|
42
42
|
<span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
|
|
43
43
|
</h2>
|
|
44
|
-
<p class="component-url"><strong>Page audited:</strong> <code>${
|
|
45
|
-
${t.entries.map(
|
|
46
|
-
</section>`}function
|
|
44
|
+
<p class="component-url"><strong>Page audited:</strong> <code>${J(t.pageUrl)}</code></p>
|
|
45
|
+
${t.entries.map(Pi).join("")}
|
|
46
|
+
</section>`}function Vi(t){const{entries:s,extensionVersion:a}=t,n=Mi(s),r=Oi(s),i=(t.axeVersions??Di(s)).join(", "),o=s.length,l=s.filter(d=>d.receipt).length,c=o-l,u=Ee(new Date().toISOString());return`<!doctype html>
|
|
47
47
|
<html lang="en">
|
|
48
48
|
<head>
|
|
49
49
|
<meta charset="utf-8" />
|
|
50
|
-
<title>Pre-litigation accessibility audit report — ${
|
|
50
|
+
<title>Pre-litigation accessibility audit report — ${J(t.matterReference??u)}</title>
|
|
51
51
|
<style>
|
|
52
52
|
*, *::before, *::after { box-sizing: border-box; }
|
|
53
53
|
:root {
|
|
@@ -188,17 +188,17 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
188
188
|
<p class="eyebrow">Accessibility audit — pre-litigation report</p>
|
|
189
189
|
<h1>Audit history & chain-of-custody</h1>
|
|
190
190
|
<dl class="cover-meta">
|
|
191
|
-
${t.matterReference?`<dt>Matter reference</dt><dd>${
|
|
192
|
-
${t.preparedBy?`<dt>Prepared by</dt><dd>${
|
|
193
|
-
${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${
|
|
194
|
-
<dt>Report generated</dt><dd>${
|
|
195
|
-
<dt>Audit period</dt><dd>${r?`${
|
|
191
|
+
${t.matterReference?`<dt>Matter reference</dt><dd>${J(t.matterReference)}</dd>`:""}
|
|
192
|
+
${t.preparedBy?`<dt>Prepared by</dt><dd>${J(t.preparedBy)}</dd>`:""}
|
|
193
|
+
${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${J(t.jurisdiction)}</dd>`:""}
|
|
194
|
+
<dt>Report generated</dt><dd>${J(u)}</dd>
|
|
195
|
+
<dt>Audit period</dt><dd>${r?`${J(Ee(r.earliest))} — ${J(Ee(r.latest))}`:"No audits recorded"}</dd>
|
|
196
196
|
</dl>
|
|
197
197
|
</section>
|
|
198
198
|
|
|
199
199
|
<aside class="attestation">
|
|
200
200
|
<h3>Attestation</h3>
|
|
201
|
-
<p>The audit records summarized below were captured by the <strong>${
|
|
201
|
+
<p>The audit records summarized below were captured by the <strong>${J(Fe)}</strong> Chrome extension, version <strong>${J(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${J(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
|
|
202
202
|
<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>
|
|
203
203
|
<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>
|
|
204
204
|
</aside>
|
|
@@ -208,11 +208,11 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
208
208
|
<tr><th>RFC 3161-anchored audits</th><td>${l}</td></tr>
|
|
209
209
|
<tr><th>Local-only audits</th><td>${c}</td></tr>
|
|
210
210
|
<tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
|
|
211
|
-
<tr><th>axe-core version(s) observed</th><td>${
|
|
212
|
-
<tr><th>Tool</th><td>${
|
|
211
|
+
<tr><th>axe-core version(s) observed</th><td>${J(i||"n/a")}</td></tr>
|
|
212
|
+
<tr><th>Tool</th><td>${J(Fe)} ${J(a)}</td></tr>
|
|
213
213
|
</table>
|
|
214
214
|
|
|
215
|
-
${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(
|
|
215
|
+
${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Gi).join("")}
|
|
216
216
|
|
|
217
217
|
<section class="methodology">
|
|
218
218
|
<h2>Methodology</h2>
|
|
@@ -236,17 +236,17 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
236
236
|
</section>
|
|
237
237
|
|
|
238
238
|
<footer>
|
|
239
|
-
<span>Generated ${
|
|
239
|
+
<span>Generated ${J(u)} by ${J(Fe)} ${J(a)}</span>
|
|
240
240
|
<span>${o} audit${o===1?"":"s"} · ${l} anchored · ${n.length} component${n.length===1?"":"s"}</span>
|
|
241
241
|
</footer>
|
|
242
242
|
</body>
|
|
243
|
-
</html>`}async function Vi(t){const s=Gi(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Ws(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,i]=m.useState(0),[o,l]=m.useState(!1),[c,u]=m.useState(""),[d,p]=m.useState(""),[h,x]=m.useState(""),[g,j]=m.useState(!1);if(m.useEffect(()=>{let f=!1;return s(null),n(null),bs().then(S=>{f||s(S)}).catch(S=>{f||n(S instanceof Error?S.message:String(S))}),()=>{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 A=t.length,T=t.filter(f=>f.receipt).length;async function k(){if(!(!t||t.length===0)){j(!0);try{await Vi({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:h.trim()||void 0}),l(!1)}finally{j(!1)}}}async function w(){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},S=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),N=URL.createObjectURL(S),I=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,U=document.createElement("a");U.href=N,U.download=I,U.click(),setTimeout(()=>URL.revokeObjectURL(N),1e3)}return A===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:[A," ",A===1?"entry":"entries",T>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[T," RFC 3161-anchored"]})]}),T===0&&A>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:()=>l(f=>!f),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void w(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(f=>f+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&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:c,onChange:f=>u(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:d,onChange:f=>p(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:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||A===0,onClick:k,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:g?"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 Wi(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let c=!1;return bs().then(u=>{c||s(u)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," 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:o.map(c=>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 ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(ve,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(Ws,{})})})]})}function Bi(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Hi={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."},zi={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."},Ki={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},qi={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Bs(){const t=v(p=>p.tier),s=v(p=>p.trialDaysRemaining),a=v(p=>p.seatsUsed),n=v(p=>p.seatsTotal),r=v(p=>p.planCode),i=v(p=>p.licenseDaysRemaining),o=v(p=>p.pastDue),[l,c]=m.useState(!1);if(t==="solo"&&r==="solo-single-month"){const p=i,h=p!==null&&p<=7,x=p===null?"":p===0?"expires today":p===1?"1 day left":`${p} 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:()=>c(!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 re({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(nt,{open:l,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?qi:Ki,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:p.perks,x=t==="team"&&a!==null&&n!==null&&a>n,g=t==="team"&&a!==null&&n!==null&&a===n,j=o?{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"}:g?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${j.bg} border-b ${j.border} px-3 py-2 space-y-1 text-[11px] ${j.shadow}`,children:[e.jsxs("div",{className:j.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",p.label]}),e.jsxs("span",{className:j.subtitle,children:[" · ",h]})]}),o&&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."}),g&&!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 re({type:"OPEN_SETTINGS"}),className:j.link,children:"Manage license →"})})]})}const u=t==="trial"?Hi:zi,d=t==="trial"?Bi(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:u.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:d})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:u.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:u.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>c(!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 re({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(nt,{open:l,onClose:()=>c(!1)})]})}const Qi={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"},Yi={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},rs={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Ji={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"},is={critical:0,serious:1,moderate:2,minor:3};function Xi(){const t=v(p=>p.setUserMode),s=v(p=>p.status),a=v(p=>p.setStatus),n=v(p=>p.errorMessage),r=v(p=>p.setError),[i,o]=m.useState(!1),[l,c]=m.useState(!1),u=m.useRef(s);m.useEffect(()=>{if(u.current==="running"&&s==="complete"){c(!0);const p=setTimeout(()=>c(!1),3500);return u.current=s,()=>clearTimeout(p)}u.current=s},[s]),m.useEffect(()=>{if(s!=="running")return;const p=setTimeout(()=>{v.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(p)},[s,a,r]);function d(){t("dev"),re({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(Bs,{}),e.jsx(Ts,{}),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(Rs,{}),e.jsx("button",{type:"button",onClick:d,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(Zi,{}),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:()=>{v.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:[i?e.jsx(Gs,{onBack:()=>o(!1)}):e.jsx(to,{onPickCrawl:()=>o(!0)}),l&&e.jsx(eo,{})]}),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. Automated checks catch ~30–50% of accessibility issues; a human review covers the rest."}),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 Zi(){const t=v(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 re({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 eo(){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 to({onPickCrawl:t}){const s=v(p=>p.status),a=v(p=>p.results),[n,r]=m.useState("quick"),[i,o]=m.useState("all"),l=s==="running",c=a.flatMap(p=>p.violations),u=a.length>0;function d(){he({type:"START_AUDIT",mode:"full-page",matrixOverride:yt(n)}),v.getState().startNewScan(),le.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:d,disabled:l,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:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,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(ao,{depth:n,onChange:r,disabled:l})]}),!u&&!l&&e.jsx(so,{}),u&&e.jsx(no,{violations:c,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function so(){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 ao({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(os,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${ns("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(os,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${ns("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function os({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:i}){return e.jsxs("button",{type:"button",onClick:a,disabled:s,"aria-pressed":t,className:`text-left rounded p-2 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"} disabled:opacity-50`,children:[e.jsx("div",{className:"font-medium text-slate-900",children:n}),e.jsx("div",{className:"text-slate-600 text-[10px]",children:r}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:i})]})}function no({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var N;const r=v(I=>I.status),i=v(I=>I.results),o=v(I=>I.freshThisSession),l=v(I=>I.componentId),c=(N=i[0])==null?void 0:N.startedAt,u=$i(t),d=r==="running",[p,h]=m.useState([]);m.useEffect(()=>{if(!l){h([]);return}let I=!1;return chrome.storage.local.get("igtRuns").then(U=>{if(I)return;const L=((U==null?void 0:U.igtRuns)??{})[l]??{};h(Object.values(L))}),()=>{I=!0}},[l]);const x=v(I=>I.acknowledgedKeys),g=i.length>0?fs(i,{runs:p,workflows:ie},"2.1","AA",x):void 0;function j(){he({type:"START_AUDIT",mode:"full-page",matrixOverride:yt(n)}),v.getState().startNewScan(),le.polite("Re-scanning this page now.")}const A=s==="lawsuit-risk"?t.filter(I=>I.impact==="critical"||I.impact==="serious"):t,T=new Map;for(const I of A){const U=xt(I.ruleId,I.target.selector);T.has(U)||T.set(U,I)}const k=Array.from(T.values()),w=new Map;for(const I of k){const U=w.get(I.ruleId)??[];U.push(I),w.set(I.ruleId,U)}const f=Array.from(w.entries()).sort((I,U)=>(is[I[1][0].impact]??99)-(is[U[1][0].impact]??99)),S=t.filter(I=>I.impact==="critical"||I.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:[c&&e.jsxs("span",{children:["Last scanned: ",e.jsx(uo,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void He(),disabled:d,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:j,disabled:d,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:d?"Scanning…":"↻ Scan again"})]})]}),d?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 ${Qi[u.tier]}`,children:[!o&&c&&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 ${Yi[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${rs[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${rs[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"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."]})]})]})]}),!d&&g&&!g.canClaimConformance&&e.jsx(ro,{coverage:g}),!d&&g&&g.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 ",g.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(co,{}),e.jsx(Wi,{}),t.length>0&&e.jsx(io,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:S}),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(([I,U])=>e.jsx(oo,{ruleId:I,violations:U},I))]})]})}function ro({coverage:t}){const s=v(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"),re({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 io({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 oo({ruleId:t,violations:s}){var p;const[a,n]=m.useState(!1),r=(p=s.find(h=>h.target.opacityContext))==null?void 0:p.target.opacityContext,i=Sa(t,r),o=s[0].impact,l=s[0],u=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,d=l.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 ${Ji[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:u}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,x)=>e.jsx(lo,{violation:h},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function lo({violation:t}){const s=v(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=m.useState(null);async function r(i){i.stopPropagation();const o=await ae();if(o)try{const l=await me(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.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 Ue=[{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 co(){const t=v(d=>d.results),s=v(d=>d.componentId),[a,n]=m.useState(null),[r,i]=m.useState(!1),[o,l]=m.useState(null);async function c(d,p){if(t.length!==0){n(d);try{const h=await ee({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=ms(d,s);await xs()?ht(h.content,x):l({open:!0,format:d,content:h.content,filename:x})}else if(p)pt(h.content);else{try{await navigator.clipboard.writeText(h.content),le.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
|
|
243
|
+
</html>`}async function Wi(t){const s=Vi(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Bs(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,i]=m.useState(0),[o,l]=m.useState(!1),[c,u]=m.useState(""),[d,p]=m.useState(""),[h,x]=m.useState(""),[g,j]=m.useState(!1);if(m.useEffect(()=>{let f=!1;return s(null),n(null),vs().then(N=>{f||s(N)}).catch(N=>{f||n(N instanceof Error?N.message:String(N))}),()=>{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 S=t.length,T=t.filter(f=>f.receipt).length;async function w(){if(!(!t||t.length===0)){j(!0);try{await Wi({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:h.trim()||void 0}),l(!1)}finally{j(!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},N=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),I=URL.createObjectURL(N),k=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,L=document.createElement("a");L.href=I,L.download=k,L.click(),setTimeout(()=>URL.revokeObjectURL(I),1e3)}return S===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[S," ",S===1?"entry":"entries",T>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[T," RFC 3161-anchored"]})]}),T===0&&S>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(f=>!f),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"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:()=>i(f=>f+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&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:c,onChange:f=>u(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:d,onChange:f=>p(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:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||S===0,onClick:w,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:g?"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 Bi(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let c=!1;return vs().then(u=>{c||s(u)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," 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:o.map(c=>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 ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(ve,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(Bs,{})})})]})}function Hi(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const zi={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."},Ki={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."},qi={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Qi={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Hs(){const t=y(p=>p.tier),s=y(p=>p.trialDaysRemaining),a=y(p=>p.seatsUsed),n=y(p=>p.seatsTotal),r=y(p=>p.planCode),i=y(p=>p.licenseDaysRemaining),o=y(p=>p.pastDue),[l,c]=m.useState(!1);if(t==="solo"&&r==="solo-single-month"){const p=i,h=p!==null&&p<=7,x=p===null?"":p===0?"expires today":p===1?"1 day left":`${p} 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:()=>c(!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 re({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(rt,{open:l,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?Qi:qi,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:p.perks,x=t==="team"&&a!==null&&n!==null&&a>n,g=t==="team"&&a!==null&&n!==null&&a===n,j=o?{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"}:g?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${j.bg} border-b ${j.border} px-3 py-2 space-y-1 text-[11px] ${j.shadow}`,children:[e.jsxs("div",{className:j.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",p.label]}),e.jsxs("span",{className:j.subtitle,children:[" · ",h]})]}),o&&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."}),g&&!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 re({type:"OPEN_SETTINGS"}),className:j.link,children:"Manage license →"})})]})}const u=t==="trial"?zi:Ki,d=t==="trial"?Hi(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:u.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:d})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:u.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:u.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>c(!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 re({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(rt,{open:l,onClose:()=>c(!1)})]})}const Yi={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"},Ji={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},is={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Xi={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"},os={critical:0,serious:1,moderate:2,minor:3};function Zi(){const t=y(p=>p.setUserMode),s=y(p=>p.status),a=y(p=>p.setStatus),n=y(p=>p.errorMessage),r=y(p=>p.setError),[i,o]=m.useState(!1),[l,c]=m.useState(!1),u=m.useRef(s);m.useEffect(()=>{if(u.current==="running"&&s==="complete"){c(!0);const p=setTimeout(()=>c(!1),3500);return u.current=s,()=>clearTimeout(p)}u.current=s},[s]),m.useEffect(()=>{if(s!=="running")return;const p=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(p)},[s,a,r]);function d(){t("dev"),re({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(Hs,{}),e.jsx($s,{}),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(Ts,{}),e.jsx("button",{type:"button",onClick:d,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(eo,{}),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:[i?e.jsx(Vs,{onBack:()=>o(!1)}):e.jsx(so,{onPickCrawl:()=>o(!0)}),l&&e.jsx(to,{})]}),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. Automated checks catch ~30–50% of accessibility issues; a human review covers the rest."}),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 eo(){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 re({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 to(){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 so({onPickCrawl:t}){const s=y(p=>p.status),a=y(p=>p.results),[n,r]=m.useState("quick"),[i,o]=m.useState("all"),l=s==="running",c=a.flatMap(p=>p.violations),u=a.length>0;function d(){he({type:"START_AUDIT",mode:"full-page",matrixOverride:wt(n)}),y.getState().startNewScan(),le.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:d,disabled:l,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:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,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(no,{depth:n,onChange:r,disabled:l})]}),!u&&!l&&e.jsx(ao,{}),u&&e.jsx(ro,{violations:c,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function ao(){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 no({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(ls,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${rs("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(ls,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${rs("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function ls({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:i}){return e.jsxs("button",{type:"button",onClick:a,disabled:s,"aria-pressed":t,className:`text-left rounded p-2 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"} disabled:opacity-50`,children:[e.jsx("div",{className:"font-medium text-slate-900",children:n}),e.jsx("div",{className:"text-slate-600 text-[10px]",children:r}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:i})]})}function ro({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var I;const r=y(k=>k.status),i=y(k=>k.results),o=y(k=>k.freshThisSession),l=y(k=>k.componentId),c=(I=i[0])==null?void 0:I.startedAt,u=Ui(t),d=r==="running",[p,h]=m.useState([]);m.useEffect(()=>{if(!l){h([]);return}let k=!1;return chrome.storage.local.get("igtRuns").then(L=>{if(k)return;const $=((L==null?void 0:L.igtRuns)??{})[l]??{};h(Object.values($))}),()=>{k=!0}},[l]);const x=y(k=>k.acknowledgedKeys),g=i.length>0?bs(i,{runs:p,workflows:ie},"2.1","AA",x):void 0;function j(){he({type:"START_AUDIT",mode:"full-page",matrixOverride:wt(n)}),y.getState().startNewScan(),le.polite("Re-scanning this page now.")}const S=s==="lawsuit-risk"?t.filter(k=>k.impact==="critical"||k.impact==="serious"):t,T=new Map;for(const k of S){const L=gt(k.ruleId,k.target.selector);T.has(L)||T.set(L,k)}const w=Array.from(T.values()),C=new Map;for(const k of w){const L=C.get(k.ruleId)??[];L.push(k),C.set(k.ruleId,L)}const f=Array.from(C.entries()).sort((k,L)=>(os[k[1][0].impact]??99)-(os[L[1][0].impact]??99)),N=t.filter(k=>k.impact==="critical"||k.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:[c&&e.jsxs("span",{children:["Last scanned: ",e.jsx(po,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void ze(),disabled:d,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:j,disabled:d,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:d?"Scanning…":"↻ Scan again"})]})]}),d?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 ${Yi[u.tier]}`,children:[!o&&c&&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 ${Ji[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${is[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${is[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"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."]})]})]})]}),!d&&g&&!g.canClaimConformance&&e.jsx(io,{coverage:g}),!d&&g&&g.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 ",g.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(uo,{}),e.jsx(Bi,{}),t.length>0&&e.jsx(oo,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:N}),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(([k,L])=>e.jsx(lo,{ruleId:k,violations:L},k))]})]})}function io({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"),re({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 oo({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 lo({ruleId:t,violations:s}){var p;const[a,n]=m.useState(!1),r=(p=s.find(h=>h.target.opacityContext))==null?void 0:p.target.opacityContext,i=Aa(t,r),o=s[0].impact,l=s[0],u=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,d=l.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 ${Xi[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:u}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,x)=>e.jsx(co,{violation:h},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function co({violation:t}){const s=y(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=m.useState(null);async function r(i){i.stopPropagation();const o=await ae();if(o)try{const l=await me(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.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 Ue=[{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 uo(){const t=y(d=>d.results),s=y(d=>d.componentId),[a,n]=m.useState(null),[r,i]=m.useState(!1),[o,l]=m.useState(null);async function c(d,p){if(t.length!==0){n(d);try{const h=await ee({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=xs(d,s);await gs()?mt(h.content,x):l({open:!0,format:d,content:h.content,filename:x})}else if(p)ht(h.content);else{try{await navigator.clipboard.writeText(h.content),le.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
|
|
244
244
|
<style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
|
|
245
245
|
.banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
|
|
246
246
|
pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
|
|
247
247
|
<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>
|
|
248
|
-
<pre>${h.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`,j=new Blob([g],{type:"text/html"}),
|
|
249
|
-
<h3 class="guideline-h">Guideline ${
|
|
248
|
+
<pre>${h.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`,j=new Blob([g],{type:"text/html"}),S=URL.createObjectURL(j);window.open(S,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(S),6e4)}}finally{n(null)}}}const u=r?Ue:Ue.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:u.map(d=>e.jsx("button",{type:"button",onClick:()=>void c(d.id,d.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:d.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:d.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:d.desc})]}),a===d.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},d.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",Ue.length-2," more report option",Ue.length-2===1?"":"s"," ↓"]}),o&&e.jsx(Gs,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function po({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 ho(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const c of l){for(const d of c.violations)if(d.wcagCriterion===t){if(a!=null&&a.has(d.matchKey)){n.add(d.ruleId);continue}if(d.needsReview){n.add(d.ruleId),i=!0;continue}n.add(d.ruleId),r.push({source:"axe",ruleOrStepId:d.ruleId,description:d.description||d.ruleId,pageUrl:o,selector:d.target.selector})}const u=c.axeRulesEvaluated;if(u){for(const d of u.passed)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of u.inapplicable)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of u.incomplete)d.wcagCriterion===t&&(n.add(d.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function mo(t,s,a){const n=[];let r=0,i=0,o=0,l=0;for(const u of a){const d=u.steps.filter(p=>p.wcag===t);if(d.length!==0){r+=d.length;for(const[p,h]of s){const x=h[u.id];if(!x){i+=d.length;continue}for(const g of d){const j=x.steps[g.id];if(!j){i++;continue}j.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${u.id}.${g.id}`,description:g.question,pageUrl:p,notes:j.notes})):j.status==="skip"?i++:j.status==="not-applicable"?(o++,l++):o++}}}}const c=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:c}}function xo(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 go(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 fo(t,s){var p;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=ft({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=Ca(t.targetVersion,t.targetLevel),o=[];for(const h of i){const x=ho(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=mo(h.id,s.igtRunsByUrl,s.workflows),j=x.rulesFiring.size===0&&g.stepsCovering===0,S={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:j},T=(p=t.overrides)==null?void 0:p[h.id];let w,C,f=!1;if(T)w=T.verdict,C=T.rationale,f=!0;else{const N=r.get(h.id);N?w=N.state:w=xo(S,g.unanswered,x.hasIncomplete,g.allNotApplicable),C=go(h,w,S)}o.push({criterion:h,understandingUrl:Ia(h,t.targetVersion),verdict:w,signals:S,overridden:f,rationale:C})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of o)h.verdict==="pass"?l.pass++:h.verdict==="fail"?l.fail++:h.verdict==="inconclusive"?l.inconclusive++:h.verdict==="not-applicable"?l.notApplicable++:h.verdict==="not-evaluated"&&l.notEvaluated++;function c(h){const x={A:1,AA:2,AAA:3},g=x[h];return o.every(j=>x[j.criterion.level]>g?!0:j.verdict==="pass"||j.verdict==="not-applicable")}let u=null;c("AAA")?u="AAA":c("AA")?u="AA":c("A")&&(u="A");const d=u===t.targetLevel||u==="AAA"&&t.targetLevel==="AA"||u==="AAA"&&t.targetLevel==="A"||u==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:o,summary:{totalCriteria:o.length,pass:l.pass,fail:l.fail,inconclusive:l.inconclusive,notApplicable:l.notApplicable,notEvaluated:l.notEvaluated,levelAchieved:u,meetsTarget:d}}}const bo={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},cs={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function U(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Se(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 vo(t,s,a,n){const{inputs:r,rows:i,summary:o,generatedAt:l}=t,c=o.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,u=new Map;for(const p of i){const h=p.criterion.id.split(".").slice(0,2).join("."),x=u.get(h)??[];x.push(p),u.set(h,x)}const d=Array.from(u.entries()).sort(([p],[h])=>p.localeCompare(h,void 0,{numeric:!0})).map(([p,h])=>`
|
|
249
|
+
<h3 class="guideline-h">Guideline ${U(p)}</h3>
|
|
250
250
|
<table class="criteria-table">
|
|
251
251
|
<thead>
|
|
252
252
|
<tr>
|
|
@@ -255,12 +255,12 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
255
255
|
</thead>
|
|
256
256
|
<tbody>
|
|
257
257
|
${h.map(x=>`
|
|
258
|
-
<tr class="${
|
|
259
|
-
<td><a href="${
|
|
260
|
-
<td>${
|
|
261
|
-
<td>${
|
|
262
|
-
<td><span class="verdict-badge ${
|
|
263
|
-
<td class="rationale">${
|
|
258
|
+
<tr class="${cs[x.verdict]}">
|
|
259
|
+
<td><a href="${U(x.understandingUrl)}" target="_blank" rel="noopener">${U(x.criterion.id)}</a></td>
|
|
260
|
+
<td>${U(x.criterion.title)}</td>
|
|
261
|
+
<td>${U(x.criterion.level)}</td>
|
|
262
|
+
<td><span class="verdict-badge ${cs[x.verdict]}">${bo[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
|
|
263
|
+
<td class="rationale">${U(x.rationale)}</td>
|
|
264
264
|
</tr>
|
|
265
265
|
${x.signals.axeFailures.length>0||x.signals.igtFailures.length>0?`
|
|
266
266
|
<tr class="evidence-row">
|
|
@@ -271,11 +271,11 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
271
271
|
<ul>
|
|
272
272
|
${[...x.signals.axeFailures,...x.signals.igtFailures].slice(0,20).map(g=>`
|
|
273
273
|
<li>
|
|
274
|
-
<code>${
|
|
275
|
-
${g.pageUrl?` on <a href="${
|
|
276
|
-
— ${
|
|
277
|
-
${g.selector?`<br><span class="ev-selector"><code>${
|
|
278
|
-
${g.notes?`<br><em>${
|
|
274
|
+
<code>${U(g.ruleOrStepId)}</code>
|
|
275
|
+
${g.pageUrl?` on <a href="${U(g.pageUrl)}" target="_blank" rel="noopener"><code>${U(g.pageUrl)}</code></a>`:""}
|
|
276
|
+
— ${U(g.description)}
|
|
277
|
+
${g.selector?`<br><span class="ev-selector"><code>${U(g.selector)}</code></span>`:""}
|
|
278
|
+
${g.notes?`<br><em>${U(g.notes)}</em>`:""}
|
|
279
279
|
</li>
|
|
280
280
|
`).join("")}
|
|
281
281
|
${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>`:""}
|
|
@@ -291,7 +291,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
291
291
|
<html lang="en">
|
|
292
292
|
<head>
|
|
293
293
|
<meta charset="utf-8" />
|
|
294
|
-
<title>WCAG ${
|
|
294
|
+
<title>WCAG ${U(r.targetVersion)} Level ${U(r.targetLevel)} Conformance Report — ${U(r.siteName)}</title>
|
|
295
295
|
<style>
|
|
296
296
|
*, *::before, *::after { box-sizing: border-box; }
|
|
297
297
|
body {
|
|
@@ -390,24 +390,24 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
390
390
|
</head>
|
|
391
391
|
<body>
|
|
392
392
|
<section class="cover">
|
|
393
|
-
<p class="eyebrow">WCAG ${
|
|
394
|
-
<h1>${
|
|
395
|
-
<p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${
|
|
393
|
+
<p class="eyebrow">WCAG ${U(r.targetVersion)} Conformance Evaluation Report</p>
|
|
394
|
+
<h1>${U(r.siteName)}</h1>
|
|
395
|
+
<p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${U(r.siteUrl)}</code></p>
|
|
396
396
|
<div class="conformance-banner ${o.meetsTarget?"met":"not-met"}">
|
|
397
|
-
${
|
|
397
|
+
${U(c)}
|
|
398
398
|
</div>
|
|
399
399
|
<dl class="meta">
|
|
400
400
|
<dt>Highest level fully satisfied</dt>
|
|
401
|
-
<dd>${o.levelAchieved?`WCAG ${
|
|
401
|
+
<dd>${o.levelAchieved?`WCAG ${U(r.targetVersion)} Level ${U(o.levelAchieved)}`:"None (target level not met)"}</dd>
|
|
402
402
|
<dt>Target conformance level</dt>
|
|
403
|
-
<dd>WCAG ${
|
|
403
|
+
<dd>WCAG ${U(r.targetVersion)} Level ${U(r.targetLevel)}</dd>
|
|
404
404
|
<dt>Report generated</dt>
|
|
405
|
-
<dd>${
|
|
405
|
+
<dd>${U(Se(l))}</dd>
|
|
406
406
|
<dt>Evaluator</dt>
|
|
407
407
|
<dd>
|
|
408
|
-
${
|
|
409
|
-
${r.evaluator.organization?`, ${
|
|
410
|
-
${r.evaluator.qualifications?`<br><span style="color: #64748b">${
|
|
408
|
+
${U(r.evaluator.name)}
|
|
409
|
+
${r.evaluator.organization?`, ${U(r.evaluator.organization)}`:""}
|
|
410
|
+
${r.evaluator.qualifications?`<br><span style="color: #64748b">${U(r.evaluator.qualifications)}</span>`:""}
|
|
411
411
|
</dd>
|
|
412
412
|
</dl>
|
|
413
413
|
</section>
|
|
@@ -423,13 +423,13 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
423
423
|
|
|
424
424
|
<h2>1 — Evaluation scope</h2>
|
|
425
425
|
<dl class="meta">
|
|
426
|
-
<dt>Website / application</dt><dd><strong>${
|
|
427
|
-
<dt>Conformance target</dt><dd>WCAG ${
|
|
426
|
+
<dt>Website / application</dt><dd><strong>${U(r.siteName)}</strong> — <code>${U(r.siteUrl)}</code></dd>
|
|
427
|
+
<dt>Conformance target</dt><dd>WCAG ${U(r.targetVersion)} Level ${U(r.targetLevel)}</dd>
|
|
428
428
|
<dt>Accessibility-support baseline</dt>
|
|
429
|
-
<dd>${
|
|
429
|
+
<dd>${U(r.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
|
|
430
430
|
${r.additionalStandards&&r.additionalStandards.length>0?`
|
|
431
431
|
<dt>Additional standards evaluated against</dt>
|
|
432
|
-
<dd>${r.additionalStandards.map(
|
|
432
|
+
<dd>${r.additionalStandards.map(U).join(", ")}</dd>
|
|
433
433
|
`:""}
|
|
434
434
|
</dl>
|
|
435
435
|
|
|
@@ -440,9 +440,9 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
440
440
|
<tbody>
|
|
441
441
|
${r.pageSample.map(p=>`
|
|
442
442
|
<tr>
|
|
443
|
-
<td><a href="${
|
|
444
|
-
<td>${
|
|
445
|
-
<td>${
|
|
443
|
+
<td><a href="${U(p.url)}" target="_blank" rel="noopener"><code>${U(p.url)}</code></a></td>
|
|
444
|
+
<td>${U(p.pageType)}</td>
|
|
445
|
+
<td>${U(p.selectionType)}</td>
|
|
446
446
|
<td>${p.hasAuditData?"✓":'<em style="color:#94a3b8">no audit data</em>'}</td>
|
|
447
447
|
</tr>
|
|
448
448
|
`).join("")}
|
|
@@ -485,7 +485,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
485
485
|
|
|
486
486
|
<section class="attestation">
|
|
487
487
|
<h3>Conformance claim</h3>
|
|
488
|
-
<p>${o.meetsTarget?`Based on the evidence collected, <strong>${
|
|
488
|
+
<p>${o.meetsTarget?`Based on the evidence collected, <strong>${U(r.siteName)}</strong> meets the success criteria required for <strong>WCAG ${U(r.targetVersion)} Level ${U(r.targetLevel)}</strong> conformance, with respect to the accessibility-support baseline declared above and within the page sample evaluated.`:`Based on the evidence collected, <strong>${U(r.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${U(r.targetVersion)} Level ${U(r.targetLevel)} conformance. ${o.fail>0?`${o.fail} criterion failure${o.fail===1?"":"s"}`:"Unresolved manual checks"} prevent the claim. See the detailed findings table above.`}</p>
|
|
489
489
|
<p style="font-size: 9.5pt; color: #475569;">This conformance claim is the responsibility of the named evaluator. The wcagcheckr tooling assembled the per-criterion evidence; the evaluator's signature attests that the methodology was followed and the verdicts reflect the site under evaluation.</p>
|
|
490
490
|
</section>
|
|
491
491
|
|
|
@@ -494,11 +494,11 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
494
494
|
<h3>Forensic anchor — report integrity proof</h3>
|
|
495
495
|
<p style="font-size: 10pt;">The content of this report was hashed and the hash was anchored to a public RFC 3161 Time Stamping Authority, then counter-signed by the wcagcheckr server's ed25519 key. Any alteration to the conformance-bearing content above invalidates the hash; the receipt below is verifiable offline by anyone with the wcagcheckr-ci CLI.</p>
|
|
496
496
|
<table class="anchor-table">
|
|
497
|
-
<tr><th>Report content hash (SHA-256)</th><td><code class="hash">${
|
|
498
|
-
<tr><th>Anchored at</th><td>${
|
|
499
|
-
<tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${
|
|
500
|
-
<tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${
|
|
501
|
-
${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${
|
|
497
|
+
<tr><th>Report content hash (SHA-256)</th><td><code class="hash">${U(s.reportHash)}</code></td></tr>
|
|
498
|
+
<tr><th>Anchored at</th><td>${U(Se(s.receipt.anchoredAt))}</td></tr>
|
|
499
|
+
<tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${U(s.receipt.tsaName)}</td></tr>
|
|
500
|
+
<tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${U(s.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
501
|
+
${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${U(s.receipt.prevAuditHash)}</code></td></tr>`:""}
|
|
502
502
|
</table>
|
|
503
503
|
<p style="font-size: 9pt; color: #64748b; margin-top: 8pt;">
|
|
504
504
|
To verify: download the verification bundle JSON from the wcagcheckr Compliance tab,
|
|
@@ -509,7 +509,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
509
509
|
<!-- Machine-readable receipt — verifier can extract from the printed PDF
|
|
510
510
|
if the JSON bundle was lost. Inert in browsers; serves only as
|
|
511
511
|
structured-data preservation. -->
|
|
512
|
-
<script type="application/json" id="wcagcheckr-anchor-receipt">${
|
|
512
|
+
<script type="application/json" id="wcagcheckr-anchor-receipt">${U(JSON.stringify(s))}<\/script>
|
|
513
513
|
</section>
|
|
514
514
|
`:`
|
|
515
515
|
<section class="anchor-block anchor-missing">
|
|
@@ -521,35 +521,35 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
521
521
|
${a?`
|
|
522
522
|
<section class="declaration declaration-signed">
|
|
523
523
|
<h3>Evaluator declaration — signed and sealed</h3>
|
|
524
|
-
<p>I, <strong>${
|
|
525
|
-
<p style="margin-top: 10pt; white-space: pre-wrap;">${
|
|
524
|
+
<p>I, <strong>${U(a.signerName)}</strong>${a.signerOrganization?` of <strong>${U(a.signerOrganization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${a.signerQualifications?`My qualifications: ${U(a.signerQualifications)}.`:""}</p>
|
|
525
|
+
<p style="margin-top: 10pt; white-space: pre-wrap;">${U(a.claim)}</p>
|
|
526
526
|
<table class="anchor-table" style="margin-top: 14pt;">
|
|
527
|
-
<tr><th>Signed by</th><td><strong>${
|
|
528
|
-
${a.signerQualifications?`<tr><th>Qualifications</th><td>${
|
|
529
|
-
<tr><th>Signed at</th><td>${
|
|
530
|
-
<tr><th>Audit captured at</th><td>${
|
|
531
|
-
<tr><th>Scope of attestation</th><td>${
|
|
532
|
-
${a.signatureReceipt?`<tr><th>Signature anchor</th><td>${
|
|
527
|
+
<tr><th>Signed by</th><td><strong>${U(a.signerName)}</strong>${a.signerOrganization?` · ${U(a.signerOrganization)}`:""} · <code>${U(a.signerEmail)}</code></td></tr>
|
|
528
|
+
${a.signerQualifications?`<tr><th>Qualifications</th><td>${U(a.signerQualifications)}</td></tr>`:""}
|
|
529
|
+
<tr><th>Signed at</th><td>${U(Se(a.signedAt))}</td></tr>
|
|
530
|
+
<tr><th>Audit captured at</th><td>${U(Se(a.auditCapturedAt))}</td></tr>
|
|
531
|
+
<tr><th>Scope of attestation</th><td>${U(a.scope)}</td></tr>
|
|
532
|
+
${a.signatureReceipt?`<tr><th>Signature anchor</th><td>${U(a.signatureReceipt.tsaName)} · <code class="hash">${U(a.signatureReceipt.timestampHex.slice(0,24))}…</code></td></tr>`:""}
|
|
533
533
|
</table>
|
|
534
534
|
<p style="font-size: 9pt; color: #475569; margin-top: 8pt;">This is a digitally-recorded attestation captured in the wcagcheckr extension at the time of signing. The signer takes responsibility for the conclusions presented.</p>
|
|
535
535
|
</section>
|
|
536
536
|
`:`
|
|
537
537
|
<section class="declaration">
|
|
538
538
|
<h3>Evaluator declaration — unsigned</h3>
|
|
539
|
-
<p>I, <strong>${
|
|
539
|
+
<p>I, <strong>${U(r.evaluator.name)}</strong>${r.evaluator.organization?` of <strong>${U(r.evaluator.organization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${r.evaluator.qualifications?`My qualifications: ${U(r.evaluator.qualifications)}.`:""} ${r.evaluator.contact?`I may be contacted at <code>${U(r.evaluator.contact)}</code>.`:""}</p>
|
|
540
540
|
<p style="font-size: 9.5pt; color: #92400e; background: #fef3c7; border-left: 3px solid #f59e0b; padding: 6pt 10pt; margin-top: 10pt;">This report has not been signed inside the wcagcheckr extension. Use the <em>Sign and seal</em> step on the Compliance tab to attach a digital attestation, or sign the line below by hand.</p>
|
|
541
541
|
<p style="margin-top: 14pt;">Signature: <span style="display:inline-block; min-width:200pt; border-bottom:1px solid #94a3b8;"> </span> Date: <span style="display:inline-block; min-width:90pt; border-bottom:1px solid #94a3b8;"> </span></p>
|
|
542
542
|
</section>
|
|
543
543
|
`}
|
|
544
544
|
|
|
545
545
|
<footer class="report-footer">
|
|
546
|
-
<span>Generated ${
|
|
546
|
+
<span>Generated ${U(Se(l))} by wcagcheckr</span>
|
|
547
547
|
<span>${o.totalCriteria} criteria · ${o.pass} pass · ${o.fail} fail · ${o.inconclusive} inconclusive</span>
|
|
548
548
|
</footer>
|
|
549
549
|
</body>
|
|
550
|
-
</html>`}async function vo(t,s,a,n){const r=bo(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(i);await chrome.tabs.create({url:o})}const tt=ys("wcag-em-anchor"),yo="https://api.wcagcheckr.com",wo="wcagcheckr",jo=15e3;function Hs(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 No(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 ko(t){return No(Ia(Hs(t)))}function So(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 Ao(t,s){const a=await ko(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${yo}/v1/products/${wo}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(jo)});if(!i.ok)return tt.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return So(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(tt.warn("anchor returned malformed receipt",o),null)}catch(i){return tt.warn("anchor request failed",i),null}}function Co(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Hs(t)}}const ct="auditAttestations",dt="auditAttestation:defaultSigner";function wt(t,s){return`${t}::${s}`}async function jt(){try{const s=(await chrome.storage.local.get(ct))[ct];return s&&typeof s=="object"?s:{}}catch{return{}}}async function zs(t){await chrome.storage.local.set({[ct]:t})}async function Io(t){const s=await jt();s[wt(t.componentId,t.auditCapturedAt)]=t,await zs(s)}async function Ks(t,s){return(await jt())[wt(t,s)]??null}async function Eo(t,s){const a=await jt();delete a[wt(t,s)],await zs(a)}async function Ro(){try{const s=(await chrome.storage.local.get(dt))[dt];return s&&typeof s=="object"?s:null}catch{return null}}async function To(t){await chrome.storage.local.set({[dt]:t})}function $o(t,s){return t.auditCapturedAt!==s}function Uo(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 Lo(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,o]=m.useState(!1),[l,c]=m.useState(""),[u,d]=m.useState(""),[p,h]=m.useState(""),[x,g]=m.useState(""),[j,A]=m.useState("");m.useEffect(()=>{let S=!1;return Promise.all([Ks(t.componentId,t.auditCapturedAt),Ro()]).then(([N,I])=>{S||(a(N),N?(c(N.signerName),d(N.signerEmail),h(N.signerOrganization??""),g(N.signerQualifications??""),A(N.claim)):I&&(c(I.signerName),d(I.signerEmail),h(I.signerOrganization??""),g(I.signerQualifications??"")),A(U=>U||Uo({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{S=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function T(){if(!l.trim()||!u.trim())return;const S={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:l.trim(),signerEmail:u.trim(),signerOrganization:p.trim()||void 0,signerQualifications:x.trim()||void 0,claim:j.trim(),scope:t.scope};await Io(S),await To({signerName:S.signerName,signerEmail:S.signerEmail,signerOrganization:S.signerOrganization,signerQualifications:S.signerQualifications}),a(S),o(!1)}async function k(){await Eo(t.componentId,t.auditCapturedAt),a(null),o(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const w=s&&$o(s,t.auditCapturedAt);if(s&&!w&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>o(!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 k(),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&&w&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>o(!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=l.trim().length>0&&u.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:l,onChange:S=>c(S.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:u,onChange:S=>d(S.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:p,onChange:S=>h(S.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:S=>g(S.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:j,onChange:S=>A(S.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>o(!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 T(),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 ut="spotAuditReviews";function qs(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function Nt(){try{const s=(await chrome.storage.local.get(ut))[ut];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Qs(t){await chrome.storage.local.set({[ut]:t})}async function _o(t){const s=await Nt();s[t.key]=t,await Qs(s)}async function Do(t){const s=await Nt();delete s[t],await Qs(s)}async function Ys(){const t=await Nt();return Object.values(t)}function Js(t,s){const a=new Map(s.map(o=>[o.key,o]));let n=0,r=0,i=0;for(const o of t){const l=a.get(o);l&&(n++,l.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function Oo(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),i=a[n];a[n]=a[r],a[r]=i}return a.slice(0,Math.min(s,a.length))}function Mo(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const o=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,l=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${o}::${i.selector}`):void 0;n.push({key:qs({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:l})}return n}const Fo={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"},Po={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 Go({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>Mo(t,s),[t,s]),[n,r]=m.useState([]),[i,o]=m.useState(!0),[l,c]=m.useState(null),[u,d]=m.useState(5),[p,h]=m.useState(!1);m.useEffect(()=>{let f=!1;return Ys().then(S=>{f||(r(S),o(!1))}),()=>{f=!0}},[]);const x=m.useMemo(()=>a.map(f=>f.key),[a]),g=m.useMemo(()=>Js(x,n),[x,n]),A=(p?x:l||n.filter(f=>x.includes(f.key)).map(f=>f.key)).map(f=>a.find(S=>S.key===f)).filter(f=>!!f);async function T(f,S,N){const I={key:f.key,criterionId:f.criterionId,ruleOrStepId:f.ruleOrStepId,pageUrl:f.pageUrl,selector:f.selector,verdict:S,correction:(N==null?void 0:N.trim())||void 0,reviewedAt:new Date().toISOString()};await _o(I),r(U=>[I,...U.filter(y=>y.key!==I.key)])}async function k(f){await Do(f.key),r(S=>S.filter(N=>N.key!==f.key))}function w(){c(Oo(x,u)),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(Le,{label:"AI determinations",value:g.total}),e.jsx(Le,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Le,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Le,{label:"Disagreed",value:g.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:u,onChange:f=>d(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:w,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),c(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:p?"Hide list":`Show all (${a.length})`}),l&&e.jsx("button",{type:"button",onClick:()=>c(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):A.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:A.map(f=>e.jsx(Vo,{row:f,review:n.find(S=>S.key===f.key)??null,onAgree:()=>void T(f,"agreed"),onDisagree:S=>void T(f,"disagreed",S),onClear:()=>void k(f)},f.key))})]})}function Le({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 Vo(t){const{row:s,review:a}=t,[n,r]=m.useState(!1),[i,o]=m.useState((a==null?void 0:a.correction)??""),l=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${l==="agreed"?"border-emerald-300 bg-emerald-50/50":l==="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 ${Fo[s.outcome]}`,children:Po[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 ${l==="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 ${l==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),l&&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)&&l==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:c=>o(c.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),o((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 Ae(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,o]=m.useState(!1),[l,c]=m.useState(null);m.useEffect(()=>{let p=!1;return Ea(t.componentId,t.criterionId).then(h=>{p||(a(h),r(!1))}),()=>{p=!0}},[t.componentId,t.criterionId]);async function u(){o(!0),c(null);try{const h=await re({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});h.ok?h.result&&a(h.result):c(h.error??"Audit failed.")}catch(p){c(p instanceof Error?p.message:String(p))}finally{o(!1)}}async function d(){await Ra(t.componentId,t.criterionId),a(null)}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&&!l&&e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),l&&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:l}),e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:i?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${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:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("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:["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",children:s.reasoning}),(()=>{const p=(s.steps??[]).filter(h=>h.action!=="initial").length;return p===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 (",p," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(h=>h.action!=="initial").map(h=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",h.focused.role||h.focused.tag,"]"]})," ",h.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:h.focused.selector})]},h.ordinal))})]})})(),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void d(),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 Wo(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return ae().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(Ae,{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(Ae,{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(Ae,{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(Ae,{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(Ae,{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.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 cs="igtRuns",Bo={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"},Ho={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function zo(){var Y,V,B;const t=v(R=>R.results),s=v(R=>R.acknowledgedKeys),[a,n]=m.useState(""),[r,i]=m.useState(""),o=$a,l=Ta,[c,u]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,p]=m.useState(""),[h,x]=m.useState(""),[g,j]=m.useState(""),[A,T]=m.useState(""),[k,w]=m.useState(""),[f,S]=m.useState(""),[N,I]=m.useState({}),[U,y]=m.useState(!1),[L,H]=m.useState([]),[C,M]=m.useState([]),[D,X]=m.useState(null),[F,Z]=m.useState(!1),[se,E]=m.useState(null);m.useEffect(()=>{let R=!1;return chrome.storage.local.get(cs).then(K=>{if(R)return;const _=K[cs]??{};I(_),y(!0)}).catch(()=>{R||y(!0)}),()=>{R=!0}},[]),m.useEffect(()=>{var J;const R=(J=t[0])==null?void 0:J.componentId;if(!R)return;let K=!1;const _=()=>{gs(R).then(te=>{K||M(te.map(ce=>({criterionId:ce.criterionId,ruleId:`ai-interactive::${ce.criterionId}`,pageUrl:ce.pageUrl,verdict:ce.verdict,reasoning:ce.reasoning})))})};_();const W=te=>{te.interactiveAuditResults&&_()};return chrome.storage.local.onChanged.addListener(W),()=>{K=!0,chrome.storage.local.onChanged.removeListener(W)}},[t]),m.useEffect(()=>{var R;if(!a&&((R=t[0])!=null&&R.pageUrl))try{const K=new URL(t[0].pageUrl);n(K.hostname),i(K.origin)}catch{}},[t,a]),m.useEffect(()=>{const R=new Set;for(const _ of t)R.add(_.pageUrl??_.scope);if(R.size===0){H([]);return}let K=!1;return Promise.all(Array.from(R).map(_=>De(_))).then(_=>{K||H(_.flat())}).catch(()=>{}),()=>{K=!0}},[t]);const q=m.useMemo(()=>{const R=new Map,K=new Map;for(const W of t){const J=W.pageUrl??W.scope,te=R.get(J)??[];te.push(W),R.set(J,te)}const _=new Map;for(const W of t){const J=W.pageUrl??W.scope;_.set(W.componentId,J)}for(const[W,J]of Object.entries(N)){const te=_.get(W);if(!te)continue;const ce=K.get(te)??{};Object.assign(ce,J),K.set(te,ce)}return{auditsByUrl:R,igtRunsByUrl:K,workflows:ie,acknowledgedMatchKeys:s,incompleteResolutions:L,interactiveAuditResults:C}},[t,N,s,L,C]),oe=m.useMemo(()=>{const R=[],K=new Set;for(const _ of q.auditsByUrl.keys())K.has(_)||(K.add(_),R.push({url:_,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const _ of f.split(`
|
|
551
|
-
`).map(W=>W.trim()).filter(Boolean))K.has(
|
|
552
|
-
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:R=>x(R.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:g,onChange:R=>j(R.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:A,onChange:R=>T(R.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:k,onChange:R=>w(R.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),b&&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 (",b.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:b.rows.map(R=>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:[R.criterion.id," · ",R.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:R.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Bo[R.verdict]}`,children:Ho[R.verdict]})]},R.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"}),D?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:[D.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",D.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.`}),se&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:se}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!b||!a||!h||F,onClick:()=>void G(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:F?"Anchoring…":D?"Re-anchor":"Anchor this report"}),D&&e.jsx("button",{type:"button",onClick:z,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"})]})]}),b&&((Y=t[0])==null?void 0:Y.componentId)&&e.jsx(Wo,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),b&&e.jsx(Go,{verdicts:O,incompleteResolutions:L}),b&&((V=t[0])==null?void 0:V.componentId)&&((B=t[0])==null?void 0:B.startedAt)&&e.jsx(Lo,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:b.summary.pass+b.summary.fail+b.summary.inconclusive+b.summary.notApplicable,totalCount:b.summary.totalCriteria,canClaimConformance:b.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:!b||!a||!h,onClick:()=>void P(),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 Ko({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:c,targetLevel:u,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${c} Level ${u}`:`Does not currently meet WCAG ${c} Level ${u}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",d," audited URL",d===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const qo={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function Qo(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 Yo(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+Da[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 Jo(){return crypto.randomUUID()}function Xo(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,i]=m.useState(""),[o,l]=m.useState("daily"),[c,u]=m.useState(null),[d,p]=m.useState(!1),[h,x]=m.useState(Ua),[g,j]=m.useState("idle"),[A,T]=m.useState(!1),[k,w]=m.useState(null);async function f(){n(!0);try{const y=await vs();y.sort((L,H)=>L.enabled!==H.enabled?L.enabled?-1:1:H.createdAt.localeCompare(L.createdAt)),s(y)}finally{n(!1)}}m.useEffect(()=>{f(),(async()=>{const y=await La();x(y)})()},[]);async function S(y){if(w(null),y.webhookEnabled&&y.webhookUrl.trim().length>0)try{if(new URL(y.webhookUrl).protocol!=="https:"){w("Webhook URL must use https://");return}}catch{w("Webhook URL is not a valid https:// URL.");return}j("saving"),await _a(y),x(y),j("saved"),setTimeout(()=>j("idle"),1500)}async function N(){u(null);const y=r.trim();if(!y){u("URL is required.");return}try{new URL(y)}catch{u("Must be a valid URL (e.g. https://example.com/).");return}p(!0);try{const L={id:Jo(),url:y,cadence:o,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await It(L),await Et(L),i(""),l("daily"),await f(),await qe()}finally{p(!1)}}async function I(y){const L={...y,enabled:!y.enabled};await It(L),L.enabled?await Et(L):await Rt(y.id),await f(),await qe()}async function U(y){window.confirm(`Remove the scheduled audit for ${y.url}? Run history for this schedule will also be deleted.`)&&(await Rt(y.id),await Oa(y.id),await Ma(y.id),await f(),await qe())}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:()=>T(y=>!y),"aria-expanded":A,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:A?"▾":"▸"})]}),A&&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:y=>void S({...h,emailEnabled:y.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:y=>void S({...h,webhookEnabled:y.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:y=>x({...h,webhookUrl:y.target.value}),onBlur:()=>void S(h),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),k&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:k})]}),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:y=>void S({...h,minImpact:y.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"})]})]}),g==="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:y=>i(y.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:o,onChange:y=>l(y.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"})]})]}),c&&e.jsx("div",{className:"text-rose-700",role:"alert",children:c}),e.jsx("button",{type:"button",onClick:()=>void N(),disabled:d||!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:d?"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(y=>e.jsx("li",{className:`border rounded p-2.5 ${y.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:y.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[qo[y.cadence]," · last run ",Qo(y.lastRunAt)," ·"," ","next ",Yo(y)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[y.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",y.lastTotalViolations??0," violation",(y.lastTotalViolations??0)===1?"":"s"]}),y.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:y.lastError??"",children:"✗ failed"}),y.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),y.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"}),(y.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:["⚠ ",y.lastNewViolationCount," new vs baseline"]}),!y.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 I(y),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:y.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void U(y),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},y.id))})]})}const ds={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function Xs(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function Zo(t){let s=0,a=0,n=0,r=0,i=0,o=0,l=0,c=0;for(const u of t){if(!u.enabled){a++;continue}s++;const d=Xs(u);d==="clean"?n++:d==="new-violations"?r++:d==="failed"?i++:d==="pending"&&o++,l+=u.lastNewViolationCount??0,c+=u.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:o,totalNewViolations:l,totalViolationsAcrossSchedules:c}}function el(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,i=n.lastNewViolationCount??0;if(r!==i)return i-r;const o=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-o}).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:Xs(a)}))}function tl(t,s,a=10){const n=new Map;for(const r of t)n.set(r.id,r.url);return[...s].sort((r,i)=>i.ranAt.localeCompare(r.ranAt)).slice(0,a).map(r=>({scheduleId:r.scheduleId,scheduleUrl:n.get(r.scheduleId)??"(deleted schedule)",ranAt:r.ranAt,totalViolations:r.totalViolations,newVsBaselineViolations:r.newVsBaselineViolations,durationMs:r.durationMs,error:r.error}))}function Zs(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),i=[];for(let l=s-1;l>=0;l--){const c=new Date(r.getTime()-l*864e5);i.push({date:c.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const o=new Map(i.map(l=>[l.date,l]));for(const l of t){const c=l.ranAt.slice(0,10),u=o.get(c);u&&(u.runs++,u.totalViolations+=l.totalViolations,u.newViolations+=l.newVsBaselineViolations)}return i}function sl(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return Zs(r,a,n)}function al(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=ds[n.cadence]*6e4;if(n.lastRunAt){const i=s.getTime()-new Date(n.lastRunAt).getTime();if(i>r*2){const o=Math.round(i/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${o}h (expected every ${ds[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 us(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 ea(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function ps({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(l=>l.totalViolations)),r=a/Math.max(1,t.length-1),i=t.map((l,c)=>{const u=c*r,d=s-l.totalViolations/n*(s-4)-2;return`${u.toFixed(1)},${d.toFixed(1)}`}),o=t.map((l,c)=>{const u=c*r,d=s-l.newViolations/n*(s-4)-2;return`${u.toFixed(1)},${d.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:o.join(" ")})]})}function _e({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 nl({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:ea(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function rl(){const[t,s]=m.useState([]),[a,n]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{(async()=>{i(!0);try{const[p,h]=await Promise.all([vs(),Fa()]);s(p),n(h)}finally{i(!1)}})()},[]);const o=Zo(t),l=el(t,5),c=tl(t,a,10),u=Zs(a,30),d=al(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 · ",o.enabledSchedules," enabled",o.pausedSchedules>0?` · ${o.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(_e,{state:"clean",count:o.cleanCount}),e.jsx(_e,{state:"new-violations",count:o.newViolationsCount}),e.jsx(_e,{state:"failed",count:o.failedCount}),e.jsx(_e,{state:"pending",count:o.pendingCount})]}),o.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[o.totalNewViolations," new WCAG violation",o.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(ps,{buckets:u}),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 ",o.enabledSchedules," schedule",o.enabledSchedules===1?"":"s"]})]})]})]}),d.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 · ",d.length]}),e.jsx("ul",{className:"space-y-1.5",children:d.map((p,h)=>e.jsx(nl,{item:p},`${p.kind}-${p.scheduleId}-${h}`))})]}),l.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:l.map(p=>{const h=sl(p.scheduleId,a,14),x=h.some(g=>g.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:p.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[p.lastTotalViolations," total · ",p.cadence," ·"," ","last run ",p.lastRunAt?us(p.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(ps,{buckets:h,height:20,width:56})}),p.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",p.lastNewViolationCount," new"]})]},p.scheduleId)})})]}),c.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:c.map((p,h)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:us(p.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:ea(p.scheduleUrl)}),p.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:p.error,children:"failed"}):p.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",p.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${p.scheduleId}-${p.ranAt}-${h}`))})]})]})}const il="https://api.anthropic.com/v1/messages",ol="2023-06-01",ll="claude-sonnet-4-6",cl={input:3/1e6,output:15/1e6},dl={input:1/1e6,output:5/1e6},ul=`You are wcagcheckr's accessibility-audit co-pilot.
|
|
550
|
+
</html>`}async function yo(t,s,a,n){const r=vo(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(i);await chrome.tabs.create({url:o})}const st=ws("wcag-em-anchor"),wo="https://api.wcagcheckr.com",jo="wcagcheckr",No=15e3;function zs(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 ko(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 So(t){return ko(Ea(zs(t)))}function Ao(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 Co(t,s){const a=await So(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${wo}/v1/products/${jo}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(No)});if(!i.ok)return st.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return Ao(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(st.warn("anchor returned malformed receipt",o),null)}catch(i){return st.warn("anchor request failed",i),null}}function Io(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:zs(t)}}const dt="auditAttestations",ut="auditAttestation:defaultSigner";function jt(t,s){return`${t}::${s}`}async function Nt(){try{const s=(await chrome.storage.local.get(dt))[dt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ks(t){await chrome.storage.local.set({[dt]:t})}async function Eo(t){const s=await Nt();s[jt(t.componentId,t.auditCapturedAt)]=t,await Ks(s)}async function qs(t,s){return(await Nt())[jt(t,s)]??null}async function Ro(t,s){const a=await Nt();delete a[jt(t,s)],await Ks(a)}async function To(){try{const s=(await chrome.storage.local.get(ut))[ut];return s&&typeof s=="object"?s:null}catch{return null}}async function $o(t){await chrome.storage.local.set({[ut]:t})}function Uo(t,s){return t.auditCapturedAt!==s}function Lo(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 _o(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,o]=m.useState(!1),[l,c]=m.useState(""),[u,d]=m.useState(""),[p,h]=m.useState(""),[x,g]=m.useState(""),[j,S]=m.useState("");m.useEffect(()=>{let N=!1;return Promise.all([qs(t.componentId,t.auditCapturedAt),To()]).then(([I,k])=>{N||(a(I),I?(c(I.signerName),d(I.signerEmail),h(I.signerOrganization??""),g(I.signerQualifications??""),S(I.claim)):k&&(c(k.signerName),d(k.signerEmail),h(k.signerOrganization??""),g(k.signerQualifications??"")),S(L=>L||Lo({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{N=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function T(){if(!l.trim()||!u.trim())return;const N={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:l.trim(),signerEmail:u.trim(),signerOrganization:p.trim()||void 0,signerQualifications:x.trim()||void 0,claim:j.trim(),scope:t.scope};await Eo(N),await $o({signerName:N.signerName,signerEmail:N.signerEmail,signerOrganization:N.signerOrganization,signerQualifications:N.signerQualifications}),a(N),o(!1)}async function w(){await Ro(t.componentId,t.auditCapturedAt),a(null),o(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const C=s&&Uo(s,t.auditCapturedAt);if(s&&!C&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>o(!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 w(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&C&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>o(!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=l.trim().length>0&&u.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:l,onChange:N=>c(N.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:u,onChange:N=>d(N.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:p,onChange:N=>h(N.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:N=>g(N.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:j,onChange:N=>S(N.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>o(!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 T(),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 pt="spotAuditReviews";function Qs(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function kt(){try{const s=(await chrome.storage.local.get(pt))[pt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ys(t){await chrome.storage.local.set({[pt]:t})}async function Do(t){const s=await kt();s[t.key]=t,await Ys(s)}async function Oo(t){const s=await kt();delete s[t],await Ys(s)}async function Js(){const t=await kt();return Object.values(t)}function Xs(t,s){const a=new Map(s.map(o=>[o.key,o]));let n=0,r=0,i=0;for(const o of t){const l=a.get(o);l&&(n++,l.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function Mo(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),i=a[n];a[n]=a[r],a[r]=i}return a.slice(0,Math.min(s,a.length))}function Fo(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const o=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,l=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${o}::${i.selector}`):void 0;n.push({key:Qs({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:l})}return n}const Po={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"},Go={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 Vo({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>Fo(t,s),[t,s]),[n,r]=m.useState([]),[i,o]=m.useState(!0),[l,c]=m.useState(null),[u,d]=m.useState(5),[p,h]=m.useState(!1);m.useEffect(()=>{let f=!1;return Js().then(N=>{f||(r(N),o(!1))}),()=>{f=!0}},[]);const x=m.useMemo(()=>a.map(f=>f.key),[a]),g=m.useMemo(()=>Xs(x,n),[x,n]),S=(p?x:l||n.filter(f=>x.includes(f.key)).map(f=>f.key)).map(f=>a.find(N=>N.key===f)).filter(f=>!!f);async function T(f,N,I){const k={key:f.key,criterionId:f.criterionId,ruleOrStepId:f.ruleOrStepId,pageUrl:f.pageUrl,selector:f.selector,verdict:N,correction:(I==null?void 0:I.trim())||void 0,reviewedAt:new Date().toISOString()};await Do(k),r(L=>[k,...L.filter(b=>b.key!==k.key)])}async function w(f){await Oo(f.key),r(N=>N.filter(I=>I.key!==f.key))}function C(){c(Mo(x,u)),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(Le,{label:"AI determinations",value:g.total}),e.jsx(Le,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Le,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Le,{label:"Disagreed",value:g.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:u,onChange:f=>d(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),c(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:p?"Hide list":`Show all (${a.length})`}),l&&e.jsx("button",{type:"button",onClick:()=>c(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):S.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:S.map(f=>e.jsx(Wo,{row:f,review:n.find(N=>N.key===f.key)??null,onAgree:()=>void T(f,"agreed"),onDisagree:N=>void T(f,"disagreed",N),onClear:()=>void w(f)},f.key))})]})}function Le({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 Wo(t){const{row:s,review:a}=t,[n,r]=m.useState(!1),[i,o]=m.useState((a==null?void 0:a.correction)??""),l=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${l==="agreed"?"border-emerald-300 bg-emerald-50/50":l==="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 ${Po[s.outcome]}`,children:Go[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 ${l==="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 ${l==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),l&&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)&&l==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:c=>o(c.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),o((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 Ae(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,o]=m.useState(!1),[l,c]=m.useState(null);m.useEffect(()=>{let p=!1;return Ra(t.componentId,t.criterionId).then(h=>{p||(a(h),r(!1))}),()=>{p=!0}},[t.componentId,t.criterionId]);async function u(){o(!0),c(null);try{const h=await re({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});h.ok?h.result&&a(h.result):c(h.error??"Audit failed.")}catch(p){c(p instanceof Error?p.message:String(p))}finally{o(!1)}}async function d(){await Ta(t.componentId,t.criterionId),a(null)}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&&!l&&e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),l&&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:l}),e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:i?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${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:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("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:["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",children:s.reasoning}),(()=>{const p=(s.steps??[]).filter(h=>h.action!=="initial").length;return p===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 (",p," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(h=>h.action!=="initial").map(h=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",h.focused.role||h.focused.tag,"]"]})," ",h.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:h.focused.selector})]},h.ordinal))})]})})(),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void d(),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 Bo(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return ae().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(Ae,{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(Ae,{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(Ae,{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(Ae,{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(Ae,{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.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 ds="igtRuns",Ho={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"},zo={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Ko(){var X,V,B;const t=y(R=>R.results),s=y(R=>R.acknowledgedKeys),[a,n]=m.useState(""),[r,i]=m.useState(""),o=Ua,l=$a,[c,u]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,p]=m.useState(""),[h,x]=m.useState(""),[g,j]=m.useState(""),[S,T]=m.useState(""),[w,C]=m.useState(""),[f,N]=m.useState(""),[I,k]=m.useState({}),[L,b]=m.useState(!1),[$,H]=m.useState([]),[A,M]=m.useState([]),[_,q]=m.useState(null),[F,Q]=m.useState(!1),[se,E]=m.useState(null);m.useEffect(()=>{let R=!1;return chrome.storage.local.get(ds).then(K=>{if(R)return;const D=K[ds]??{};k(D),b(!0)}).catch(()=>{R||b(!0)}),()=>{R=!0}},[]),m.useEffect(()=>{var Z;const R=(Z=t[0])==null?void 0:Z.componentId;if(!R)return;let K=!1;const D=()=>{fs(R).then(te=>{K||M(te.map(ce=>({criterionId:ce.criterionId,ruleId:`ai-interactive::${ce.criterionId}`,pageUrl:ce.pageUrl,verdict:ce.verdict,reasoning:ce.reasoning})))})};D();const W=te=>{te.interactiveAuditResults&&D()};return chrome.storage.local.onChanged.addListener(W),()=>{K=!0,chrome.storage.local.onChanged.removeListener(W)}},[t]),m.useEffect(()=>{var R;if(!a&&((R=t[0])!=null&&R.pageUrl))try{const K=new URL(t[0].pageUrl);n(K.hostname),i(K.origin)}catch{}},[t,a]),m.useEffect(()=>{const R=new Set;for(const D of t)R.add(D.pageUrl??D.scope);if(R.size===0){H([]);return}let K=!1;return Promise.all(Array.from(R).map(D=>Oe(D))).then(D=>{K||H(D.flat())}).catch(()=>{}),()=>{K=!0}},[t]);const Y=m.useMemo(()=>{const R=new Map,K=new Map;for(const W of t){const Z=W.pageUrl??W.scope,te=R.get(Z)??[];te.push(W),R.set(Z,te)}const D=new Map;for(const W of t){const Z=W.pageUrl??W.scope;D.set(W.componentId,Z)}for(const[W,Z]of Object.entries(I)){const te=D.get(W);if(!te)continue;const ce=K.get(te)??{};Object.assign(ce,Z),K.set(te,ce)}return{auditsByUrl:R,igtRunsByUrl:K,workflows:ie,acknowledgedMatchKeys:s,incompleteResolutions:$,interactiveAuditResults:A}},[t,I,s,$,A]),oe=m.useMemo(()=>{const R=[],K=new Set;for(const D of Y.auditsByUrl.keys())K.has(D)||(K.add(D),R.push({url:D,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const D of f.split(`
|
|
551
|
+
`).map(W=>W.trim()).filter(Boolean))K.has(D)||(K.add(D),R.push({url:D,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return R},[Y,f]),ne=m.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:c,additionalStandards:d.split(",").map(R=>R.trim()).filter(Boolean),pageSample:oe,evaluator:{name:h||"(evaluator name pending)",organization:g||void 0,qualifications:S||void 0,contact:w||void 0}}),[a,r,o,l,c,d,oe,h,g,S,w]),v=m.useMemo(()=>L?fo(ne,Y):null,[ne,Y,L]),O=m.useMemo(()=>{const R=Array.from(Y.auditsByUrl.values()).flat(),K=Object.values(I).flatMap(D=>Object.values(D));return ft({audits:R,igtRuns:K,workflows:ie,acknowledgedMatchKeys:s,incompleteResolutions:$,interactiveAuditResults:A})},[Y,I,s,$,A]);async function P(){if(!v)return;const R=t[0],K=R!=null&&R.componentId&&(R!=null&&R.startedAt)?await qs(R.componentId,R.startedAt):null,D=await Js(),W=[];for(const te of O.values())for(const ce of te.evidence)ce.source==="ai"&&W.push(Qs({criterionId:te.criterionId,ruleOrStepId:ce.ruleOrStepId,pageUrl:ce.pageUrl,selector:ce.selector}));const Z=Xs(W,D);await yo(v,_,K,Z)}async function G(){if(v){Q(!0),E(null);try{const R=await Co(v);if(!R){E("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(R)}finally{Q(!1)}}}function z(){var ce,St,At;if(!v||!_)return;const R=((At=(St=(ce=chrome.runtime).getManifest)==null?void 0:St.call(ce))==null?void 0:At.version)??"0.0.0",K=Io(v,_,R),D=new Blob([JSON.stringify(K,null,2)],{type:"application/json"}),W=URL.createObjectURL(D),Z=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,te=document.createElement("a");te.href=W,te.download=Z,te.click(),setTimeout(()=>URL.revokeObjectURL(W),1e3)}return m.useEffect(()=>{q(null),E(null)},[a,r,c,d,h,g,S,w,f]),L?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."})]}),v&&v.summary.totalCriteria>0&&e.jsx(qo,{totalCriteria:v.summary.totalCriteria,pass:v.summary.pass,fail:v.summary.fail,inconclusive:v.summary.inconclusive,notEvaluated:v.summary.notEvaluated,notApplicable:v.summary.notApplicable,levelAchieved:v.summary.levelAchieved,meetsTarget:v.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:Y.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:R=>n(R.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:R=>i(R.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 ",o," Level ",l]}),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:c,onChange:R=>u(R.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:d,onChange:R=>p(R.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.",Y.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:Y.auditsByUrl.size})," URL",Y.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:R=>N(R.target.value),rows:3,placeholder:`https://app.example.com/checkout
|
|
552
|
+
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:R=>x(R.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:g,onChange:R=>j(R.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:S,onChange:R=>T(R.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:w,onChange:R=>C(R.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),v&&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 (",v.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:v.rows.map(R=>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:[R.criterion.id," · ",R.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:R.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Ho[R.verdict]}`,children:zo[R.verdict]})]},R.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"}),_?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:[_.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",_.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.`}),se&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:se}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!v||!a||!h||F,onClick:()=>void G(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:F?"Anchoring…":_?"Re-anchor":"Anchor this report"}),_&&e.jsx("button",{type:"button",onClick:z,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"})]})]}),v&&((X=t[0])==null?void 0:X.componentId)&&e.jsx(Bo,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),v&&e.jsx(Vo,{verdicts:O,incompleteResolutions:$}),v&&((V=t[0])==null?void 0:V.componentId)&&((B=t[0])==null?void 0:B.startedAt)&&e.jsx(_o,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:v.summary.pass+v.summary.fail+v.summary.inconclusive+v.summary.notApplicable,totalCount:v.summary.totalCriteria,canClaimConformance:v.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:!v||!a||!h,onClick:()=>void P(),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 qo({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:c,targetLevel:u,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${c} Level ${u}`:`Does not currently meet WCAG ${c} Level ${u}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",d," audited URL",d===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const Qo={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function Yo(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 Jo(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+Oa[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 Xo(){return crypto.randomUUID()}function Zo(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,i]=m.useState(""),[o,l]=m.useState("daily"),[c,u]=m.useState(null),[d,p]=m.useState(!1),[h,x]=m.useState(La),[g,j]=m.useState("idle"),[S,T]=m.useState(!1),[w,C]=m.useState(null);async function f(){n(!0);try{const b=await ys();b.sort(($,H)=>$.enabled!==H.enabled?$.enabled?-1:1:H.createdAt.localeCompare($.createdAt)),s(b)}finally{n(!1)}}m.useEffect(()=>{f(),(async()=>{const b=await _a();x(b)})()},[]);async function N(b){if(C(null),b.webhookEnabled&&b.webhookUrl.trim().length>0)try{if(new URL(b.webhookUrl).protocol!=="https:"){C("Webhook URL must use https://");return}}catch{C("Webhook URL is not a valid https:// URL.");return}j("saving"),await Da(b),x(b),j("saved"),setTimeout(()=>j("idle"),1500)}async function I(){u(null);const b=r.trim();if(!b){u("URL is required.");return}try{new URL(b)}catch{u("Must be a valid URL (e.g. https://example.com/).");return}p(!0);try{const $={id:Xo(),url:b,cadence:o,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await Et($),await Rt($),i(""),l("daily"),await f(),await Qe()}finally{p(!1)}}async function k(b){const $={...b,enabled:!b.enabled};await Et($),$.enabled?await Rt($):await Tt(b.id),await f(),await Qe()}async function L(b){window.confirm(`Remove the scheduled audit for ${b.url}? Run history for this schedule will also be deleted.`)&&(await Tt(b.id),await Ma(b.id),await Fa(b.id),await f(),await Qe())}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:()=>T(b=>!b),"aria-expanded":S,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:S?"▾":"▸"})]}),S&&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:b=>void N({...h,emailEnabled:b.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:b=>void N({...h,webhookEnabled:b.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:b=>x({...h,webhookUrl:b.target.value}),onBlur:()=>void N(h),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),w&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:w})]}),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:b=>void N({...h,minImpact:b.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"})]})]}),g==="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:b=>i(b.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:o,onChange:b=>l(b.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"})]})]}),c&&e.jsx("div",{className:"text-rose-700",role:"alert",children:c}),e.jsx("button",{type:"button",onClick:()=>void I(),disabled:d||!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:d?"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(b=>e.jsx("li",{className:`border rounded p-2.5 ${b.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:b.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[Qo[b.cadence]," · last run ",Yo(b.lastRunAt)," ·"," ","next ",Jo(b)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[b.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",b.lastTotalViolations??0," violation",(b.lastTotalViolations??0)===1?"":"s"]}),b.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:b.lastError??"",children:"✗ failed"}),b.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),b.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"}),(b.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:["⚠ ",b.lastNewViolationCount," new vs baseline"]}),!b.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 k(b),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:b.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void L(b),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},b.id))})]})}const us={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function Zs(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function el(t){let s=0,a=0,n=0,r=0,i=0,o=0,l=0,c=0;for(const u of t){if(!u.enabled){a++;continue}s++;const d=Zs(u);d==="clean"?n++:d==="new-violations"?r++:d==="failed"?i++:d==="pending"&&o++,l+=u.lastNewViolationCount??0,c+=u.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:o,totalNewViolations:l,totalViolationsAcrossSchedules:c}}function tl(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,i=n.lastNewViolationCount??0;if(r!==i)return i-r;const o=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-o}).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:Zs(a)}))}function sl(t,s,a=10){const n=new Map;for(const r of t)n.set(r.id,r.url);return[...s].sort((r,i)=>i.ranAt.localeCompare(r.ranAt)).slice(0,a).map(r=>({scheduleId:r.scheduleId,scheduleUrl:n.get(r.scheduleId)??"(deleted schedule)",ranAt:r.ranAt,totalViolations:r.totalViolations,newVsBaselineViolations:r.newVsBaselineViolations,durationMs:r.durationMs,error:r.error}))}function ea(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),i=[];for(let l=s-1;l>=0;l--){const c=new Date(r.getTime()-l*864e5);i.push({date:c.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const o=new Map(i.map(l=>[l.date,l]));for(const l of t){const c=l.ranAt.slice(0,10),u=o.get(c);u&&(u.runs++,u.totalViolations+=l.totalViolations,u.newViolations+=l.newVsBaselineViolations)}return i}function al(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return ea(r,a,n)}function nl(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=us[n.cadence]*6e4;if(n.lastRunAt){const i=s.getTime()-new Date(n.lastRunAt).getTime();if(i>r*2){const o=Math.round(i/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${o}h (expected every ${us[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 ps(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 ta(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function hs({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(l=>l.totalViolations)),r=a/Math.max(1,t.length-1),i=t.map((l,c)=>{const u=c*r,d=s-l.totalViolations/n*(s-4)-2;return`${u.toFixed(1)},${d.toFixed(1)}`}),o=t.map((l,c)=>{const u=c*r,d=s-l.newViolations/n*(s-4)-2;return`${u.toFixed(1)},${d.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:o.join(" ")})]})}function _e({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 rl({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:ta(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function il(){const[t,s]=m.useState([]),[a,n]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{(async()=>{i(!0);try{const[p,h]=await Promise.all([ys(),Pa()]);s(p),n(h)}finally{i(!1)}})()},[]);const o=el(t),l=tl(t,5),c=sl(t,a,10),u=ea(a,30),d=nl(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 · ",o.enabledSchedules," enabled",o.pausedSchedules>0?` · ${o.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(_e,{state:"clean",count:o.cleanCount}),e.jsx(_e,{state:"new-violations",count:o.newViolationsCount}),e.jsx(_e,{state:"failed",count:o.failedCount}),e.jsx(_e,{state:"pending",count:o.pendingCount})]}),o.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[o.totalNewViolations," new WCAG violation",o.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(hs,{buckets:u}),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 ",o.enabledSchedules," schedule",o.enabledSchedules===1?"":"s"]})]})]})]}),d.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 · ",d.length]}),e.jsx("ul",{className:"space-y-1.5",children:d.map((p,h)=>e.jsx(rl,{item:p},`${p.kind}-${p.scheduleId}-${h}`))})]}),l.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:l.map(p=>{const h=al(p.scheduleId,a,14),x=h.some(g=>g.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:p.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[p.lastTotalViolations," total · ",p.cadence," ·"," ","last run ",p.lastRunAt?ps(p.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(hs,{buckets:h,height:20,width:56})}),p.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",p.lastNewViolationCount," new"]})]},p.scheduleId)})})]}),c.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:c.map((p,h)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:ps(p.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:ta(p.scheduleUrl)}),p.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:p.error,children:"failed"}):p.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",p.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${p.scheduleId}-${p.ranAt}-${h}`))})]})]})}const ol="https://api.anthropic.com/v1/messages",ll="2023-06-01",cl="claude-sonnet-4-6",dl={input:3/1e6,output:15/1e6},ul={input:1/1e6,output:5/1e6},pl=`You are wcagcheckr's accessibility-audit co-pilot.
|
|
553
553
|
|
|
554
554
|
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.
|
|
555
555
|
|
|
@@ -560,10 +560,10 @@ Rules:
|
|
|
560
560
|
- When you cite a WCAG criterion, use the dotted SC number (e.g. 1.4.3).
|
|
561
561
|
- Don't be cheerful or evangelical. Be factual.
|
|
562
562
|
- If the user asks for the impact-priority order, sort: critical > serious > moderate > minor.
|
|
563
|
-
- The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function
|
|
563
|
+
- The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function hl(t,s,a){const n=a.includes("haiku")?ul:dl;return t*n.input+s*n.output}async function ml(t){const s=t.model||cl,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??pl;!t.system&&t.auditContext&&(n+=`
|
|
564
564
|
|
|
565
565
|
<audit-context>
|
|
566
566
|
${t.auditContext}
|
|
567
|
-
</audit-context>`);const r=await fetch(
|
|
568
|
-
`).trim(),l=i.usage.input_tokens,c=i.usage.output_tokens,u=
|
|
569
|
-
`)}const hs="aiConfig";function xl(){var w;const t=v(f=>f.results),s=v(f=>f.componentId),[a,n]=m.useState([]),[r,i]=m.useState(""),[o,l]=m.useState(!1),[c,u]=m.useState(!1),[d,p]=m.useState("claude-sonnet-4-6"),h=m.useRef(""),x=m.useRef(null);m.useEffect(()=>{(async()=>{const S=(await chrome.storage.local.get(hs))[hs];h.current=(S==null?void 0:S.apiKey)??"",u(!!(S!=null&&S.apiKey)),S!=null&&S.model&&p(S.model)})()},[]),m.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[a.length]);const g=t.flatMap(f=>f.violations),j=ml({componentId:s??void 0,pageUrl:(w=t[0])==null?void 0:w.pageUrl,violations:g.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}}))}),A=a.reduce((f,S)=>f+(S.costUsd??0),0);async function T(){const f=r.trim();if(!f||o||!h.current)return;i("");const S={role:"user",content:f},N=[...a,S];n(N),l(!0);try{const I=N.map(y=>({role:y.role,content:y.content})),U=await hl({apiKey:h.current,model:d,messages:I,auditContext:j});n([...N,{role:"assistant",content:U.text,costUsd:U.costUsd,inputTokens:U.inputTokens,outputTokens:U.outputTokens}])}catch(I){n([...N,{role:"assistant",content:"",error:I instanceof Error?I.message:String(I)}])}finally{l(!1)}}function k(){n([])}return c?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: $",A.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:k,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 (",g.length," violation",g.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,S)=>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"]})]},S)),o&&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(),T()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:f=>i(f.target.value),placeholder:"Ask about this audit…",disabled:o,"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:o||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:o?"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 gl(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState(""),[c,u]=m.useState(new Set);async function d(){i(null),n(!0);try{const x=await ae();if(!x){i("No audited tab. Open a page to audit, then return here.");return}const g=await ee({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:x});if(!g.ok||!g.nodes){i(g.error??"Snapshot failed for an unknown reason.");return}s(g.nodes)}finally{n(!1)}}function p(x){u(g=>{const j=new Set(g);return j.has(x)?j.delete(x):j.add(x),j})}const h=t&&o?t.filter(x=>x.role.toLowerCase().includes(o.toLowerCase())||x.name.toLowerCase().includes(o.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 d(),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:o,onChange:x=>l(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(fl,{nodes:t,filtered:h,collapsed:c,onToggle:p})]})]})}function fl({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(o=>e.jsx("li",{role:"treeitem",children:e.jsx(sa,{node:o,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},o.nodeId))});const r=new Map;for(const o of t){const l=o.parentId,c=r.get(l)??[];c.push(o),r.set(l,c)}const i=r.get(void 0)??t.filter(o=>!o.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:i.map(o=>e.jsx(ta,{node:o,depth:0,byParent:r,collapsed:a,onToggle:n},o.nodeId))})}function ta({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const i=a.get(t.nodeId)??[],o=i.length>0,l=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":o?!l:void 0,children:[e.jsx(sa,{node:t,depth:s,collapsed:l,onToggle:()=>r(t.nodeId),hasChildren:o}),!l&&o&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:i.map(c=>e.jsx(ta,{node:c,depth:s+1,byParent:a,collapsed:n,onToggle:r},c.nodeId))})]})}function sa({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const i=t.properties.filter(o=>o.value!==!1&&o.value!==""&&o.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),i.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:i.map(o=>`${o.name}=${String(o.value)}`).join(" · ")})]})}const bl="2024-07-25",vl="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.",aa=[{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(aa.flatMap(t=>t.wcag2Criteria));function yl(t,s){return aa.map(a=>{const n=a.wcag2Criteria.filter(o=>t.has(o)),r=a.wcag2Criteria.some(o=>s.has(o));let i;return n.length>0?i="has-violations":r?i="clean":i="not-evaluated",{outcome:a,violatedCriteria:n,status:i}})}const wl={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function jl(){const t=v(c=>c.results);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 s=new Set,a=new Set;for(const c of t){for(const d of c.violations)s.add(d.wcagCriterion);const u=c.axeRulesEvaluated;if(u){for(const d of u.passed)a.add(d.wcagCriterion);for(const d of u.inapplicable)a.add(d.wcagCriterion);for(const d of u.incomplete)a.add(d.wcagCriterion)}for(const d of c.violations)a.add(d.wcagCriterion)}const n=yl(s,a),r=new Map;for(const c of n){const u=r.get(c.outcome.category)??[];u.push(c),r.set(c.outcome.category,u)}const i=n.filter(c=>c.status==="clean").length,o=n.filter(c=>c.status==="has-violations").length,l=n.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:bl}),"."," ",vl]})]}),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:[o," with violations"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-slate-100 text-slate-700",children:[l," not evaluated"]})]}),["perceive","operate","understand","robust"].map(c=>{const u=r.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:[wl[c]," · ",u.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:u.map(d=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(Nl,{status:d.status}),e.jsx("strong",{className:"text-xs",children:d.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:d.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",d.outcome.wcag2Criteria.join(", ")]}),d.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:d.violatedCriteria.join(", ")})]})]},d.outcome.id))})]},c)})]})}function Nl({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}function kl(){const t=v(u=>u.results),[s,a]=m.useState(!1),[n,r]=m.useState(null),[i,o]=m.useState(null);async function l(){r(null),a(!0);try{const u=await ae();if(!u){r("No audited tab. Open a page first.");return}const d=await me(u,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:u});if(!d.ok||!d.tokens||!d.references){r(d.error??"Snapshot failed.");return}const p=new Map;for(const g of t)for(const j of g.violations)p.has(j.target.selector)||p.set(j.target.selector,j.matchKey);const h=d.references.map(g=>({violationMatchKey:p.get(g.selector)??null,referencedTokens:g.referencedTokens})),x=d.tokens;o(Ba(x,h))}finally{a(!1)}}const c=i?Wa(i):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":i?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),c&&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(Ce,{label:"Total tokens",value:c.totalTokens}),e.jsx(Ce,{label:"Color tokens",value:c.colorTokens}),e.jsx(Ce,{label:"Used",value:c.usedTokens}),e.jsx(Ce,{label:"Unused",value:c.unusedTokens,tint:c.unusedTokens>0?"amber":"slate"}),e.jsx(Ce,{label:"In violations",value:c.violatingTokens,tint:c.violatingTokens>0?"rose":"slate"})]}),i&&i.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:i.map(u=>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:[u.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:u.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:u.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",u.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:u.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[u.usageCount," usage",u.usageCount===1?"":"s"]}),u.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:[u.violationMatchKeys.length," violation",u.violationMatchKeys.length===1?"":"s"]})]})]})]},u.token.name))})]}):i?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function Ce({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 st="onboarding:dismissed",at="onboarding:exportTried";function Sl(){const t=v(w=>w.tier),s=v(w=>w.results),a=v(w=>w.baselineList),[n,r]=m.useState(!1),[i,o]=m.useState(!1),[l,c]=m.useState(!1),[u,d]=m.useState(!1);m.useEffect(()=>{(async()=>{const w=await chrome.storage.local.get([st,at]);r(w[st]===!0),c(w[at]===!0);const f=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],S=await Promise.all(f.map(N=>ee({type:"SETTINGS_GET",key:N})));d(S.some(N=>typeof N.data=="string"&&N.data.length>0)),o(!0)})()},[]);const p=[{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:l?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:u?"done":"pending",optional:!0}],h=p.filter(w=>!w.optional),x=p.filter(w=>w.state==="done").length,g=h.filter(w=>w.state==="done").length,j=x===p.length,A=g===h.length;if(!i||n||A)return null;async function T(){r(!0),await chrome.storage.local.set({[st]:!0})}async function k(){const w=!l;c(w),await chrome.storage.local.set({[at]:w})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded p-2.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",x," of ",p.length," done"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Quick checklist to get you started. ",j?"All steps complete — nice!":"Auto-checks as you go."]})]}),e.jsx("button",{type:"button",onClick:()=>void T(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none -mt-1",children:"✕"})]}),e.jsx("ul",{className:"space-y-1",children:p.map(w=>e.jsx("li",{className:"flex items-start gap-1.5",children:w.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:w.state==="done",onChange:()=>void k(),className:"mt-0.5","aria-label":w.label}),e.jsx("span",{className:w.state==="done"?"line-through text-amber-700":"text-amber-900",children:w.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:w.state==="done"?"✓":"○"}),e.jsxs("span",{className:w.state==="done"?"line-through text-amber-700":"text-amber-900",children:[w.label,w.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},w.id))})]})}function Al(){const[t,s]=m.useState(""),[a,n]=m.useState(!1),[r,i]=m.useState(null);async function o(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const l=await re({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(l!=null&&l.validated)){const c=l!=null&&l.seatClaim&&"reason"in l.seatClaim?l.seatClaim.reason:null,u=l!=null&&l.seatClaim&&"hint"in l.seatClaim?l.seatClaim.hint:void 0;i(c==="cap-reached"?`License is at seat capacity. ${u??"Release a seat from another device or contact support."}`:c==="not-found"?"License not found. Check the token and try again.":c==="network"?`Network error: ${l!=null&&l.seatClaim&&"message"in l.seatClaim?l.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(l){i(l instanceof Error?l.message:String(l))}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:l=>s(l.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 o(),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 _l(){const t=v(o=>o.view),s=v(o=>o.userMode),a=v(o=>o.tier),[n,r]=m.useState(!1);m.useEffect(()=>{const o=setTimeout(()=>r(!0),600);return()=>clearTimeout(o)},[]);const i=n&&Va(a);return m.useEffect(()=>{const o=en(),c=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),u=Qa();ks({forceRefresh:!0}).catch(()=>{}),Pe().catch(()=>{}),Za().catch(()=>{}),tn().catch(()=>{}),Ja().catch(()=>{}),Pa().then(p=>{v.getState().setAcknowledgedKeys(new Set(p.map(h=>h.matchKey)))}).catch(()=>{}),Ga().then(p=>{p&&v.setState({siteCrawlReport:p})}).catch(()=>{});const d=p=>{if(p.key!=="Escape")return;const{pinnedMatchKey:h,setPinned:x,results:g}=v.getState();h&&(x(null),ae().then(j=>{var A;j&&de(j,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:j},(A=g[0])==null?void 0:A.frameId).catch(()=>{})}))};return window.addEventListener("keydown",d),()=>{u(),o.disconnect(),c==null||c.disconnect(),window.removeEventListener("keydown",d)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(Al,{}),e.jsx(Te,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Ei,{}),e.jsx(Te,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Xi,{}),e.jsx(as,{}),e.jsx(Te,{})]}):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(Bs,{}),e.jsx(Ts,{}),e.jsx(gn,{}),e.jsx(Sl,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(yn,{}),e.jsx(An,{}),e.jsx(Si,{}),e.jsx(ki,{}),e.jsx(In,{}),e.jsx(ji,{}),e.jsx(Ni,{}),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(vr,{}),t==="delta"&&e.jsx(_r,{}),t==="activity"&&e.jsx(Qr,{}),t==="guided"&&e.jsx(oi,{}),t==="flows"&&e.jsx(ui,{}),t==="scorecard"&&e.jsx(mi,{}),t==="crawl"&&e.jsx(Gs,{}),t==="forensic"&&e.jsx(Ws,{}),t==="compliance"&&e.jsx(zo,{}),t==="schedules"&&e.jsx(Xo,{}),t==="risk"&&e.jsx(rl,{}),t==="copilot"&&e.jsx(xl,{}),t==="ax-tree"&&e.jsx(gl,{}),t==="wcag3"&&e.jsx(jl,{}),t==="tokens"&&e.jsx(kl,{})]})]}),e.jsx(Ii,{}),e.jsx(Ai,{}),e.jsx(wi,{}),e.jsx(as,{}),e.jsx(Te,{})]})}class Dl extends Ie.Component{constructor(){super(...arguments);At(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{_l as A,Dl as E,Ll as d};
|
|
567
|
+
</audit-context>`);const r=await fetch(ol,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":ll,"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 d=await r.text().catch(()=>"");throw new Error(`Anthropic API ${r.status}: ${d.slice(0,300)}`)}const i=await r.json(),o=i.content.filter(d=>d.type==="text").map(d=>d.text).join(`
|
|
568
|
+
`).trim(),l=i.usage.input_tokens,c=i.usage.output_tokens,u=hl(l,c,s);if(t.maxCostUsd!==void 0&&u>t.maxCostUsd)throw new Error(`chat turn cost $${u.toFixed(4)} exceeded maxCostUsd $${t.maxCostUsd.toFixed(4)}`);return{text:o,inputTokens:l,outputTokens:c,costUsd:u,model:i.model}}function xl(t){const s=[];t.pageUrl&&s.push(`page: ${t.pageUrl}`),t.componentId&&s.push(`component: ${t.componentId}`),s.push(`violations: ${t.violations.length}`),s.push("");const a=new Set;for(const n of t.violations){const r=`${n.ruleId}::${n.target.selector}`;if(a.has(r))continue;a.add(r);const i=n.target.outerHTML.length>200?n.target.outerHTML.slice(0,197)+"...":n.target.outerHTML;s.push(`- [${n.impact}] ${n.ruleId} (WCAG ${n.wcagCriterion} ${n.wcagLevel})`),s.push(` selector: ${n.target.selector}`),s.push(` html: ${i}`),s.push(` axe says: ${n.description}`),s.push("")}return s.join(`
|
|
569
|
+
`)}const ms="aiConfig";function gl(){var C;const t=y(f=>f.results),s=y(f=>f.componentId),[a,n]=m.useState([]),[r,i]=m.useState(""),[o,l]=m.useState(!1),[c,u]=m.useState(!1),[d,p]=m.useState("claude-sonnet-4-6"),h=m.useRef(""),x=m.useRef(null);m.useEffect(()=>{(async()=>{const N=(await chrome.storage.local.get(ms))[ms];h.current=(N==null?void 0:N.apiKey)??"",u(!!(N!=null&&N.apiKey)),N!=null&&N.model&&p(N.model)})()},[]),m.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[a.length]);const g=t.flatMap(f=>f.violations),j=xl({componentId:s??void 0,pageUrl:(C=t[0])==null?void 0:C.pageUrl,violations:g.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}}))}),S=a.reduce((f,N)=>f+(N.costUsd??0),0);async function T(){const f=r.trim();if(!f||o||!h.current)return;i("");const N={role:"user",content:f},I=[...a,N];n(I),l(!0);try{const k=I.map(b=>({role:b.role,content:b.content})),L=await ml({apiKey:h.current,model:d,messages:k,auditContext:j});n([...I,{role:"assistant",content:L.text,costUsd:L.costUsd,inputTokens:L.inputTokens,outputTokens:L.outputTokens}])}catch(k){n([...I,{role:"assistant",content:"",error:k instanceof Error?k.message:String(k)}])}finally{l(!1)}}function w(){n([])}return c?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: $",S.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:w,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 (",g.length," violation",g.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,N)=>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"]})]},N)),o&&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(),T()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:f=>i(f.target.value),placeholder:"Ask about this audit…",disabled:o,"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:o||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:o?"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 fl(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState(""),[c,u]=m.useState(new Set);async function d(){i(null),n(!0);try{const x=await ae();if(!x){i("No audited tab. Open a page to audit, then return here.");return}const g=await ee({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:x});if(!g.ok||!g.nodes){i(g.error??"Snapshot failed for an unknown reason.");return}s(g.nodes)}finally{n(!1)}}function p(x){u(g=>{const j=new Set(g);return j.has(x)?j.delete(x):j.add(x),j})}const h=t&&o?t.filter(x=>x.role.toLowerCase().includes(o.toLowerCase())||x.name.toLowerCase().includes(o.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 d(),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:o,onChange:x=>l(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(bl,{nodes:t,filtered:h,collapsed:c,onToggle:p})]})]})}function bl({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(o=>e.jsx("li",{role:"treeitem",children:e.jsx(aa,{node:o,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},o.nodeId))});const r=new Map;for(const o of t){const l=o.parentId,c=r.get(l)??[];c.push(o),r.set(l,c)}const i=r.get(void 0)??t.filter(o=>!o.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:i.map(o=>e.jsx(sa,{node:o,depth:0,byParent:r,collapsed:a,onToggle:n},o.nodeId))})}function sa({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const i=a.get(t.nodeId)??[],o=i.length>0,l=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":o?!l:void 0,children:[e.jsx(aa,{node:t,depth:s,collapsed:l,onToggle:()=>r(t.nodeId),hasChildren:o}),!l&&o&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:i.map(c=>e.jsx(sa,{node:c,depth:s+1,byParent:a,collapsed:n,onToggle:r},c.nodeId))})]})}function aa({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const i=t.properties.filter(o=>o.value!==!1&&o.value!==""&&o.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),i.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:i.map(o=>`${o.name}=${String(o.value)}`).join(" · ")})]})}const vl="2024-07-25",yl="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.",na=[{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(na.flatMap(t=>t.wcag2Criteria));function wl(t,s){return na.map(a=>{const n=a.wcag2Criteria.filter(o=>t.has(o)),r=a.wcag2Criteria.some(o=>s.has(o));let i;return n.length>0?i="has-violations":r?i="clean":i="not-evaluated",{outcome:a,violatedCriteria:n,status:i}})}const jl={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Nl(){const t=y(c=>c.results);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 s=new Set,a=new Set;for(const c of t){for(const d of c.violations)s.add(d.wcagCriterion);const u=c.axeRulesEvaluated;if(u){for(const d of u.passed)a.add(d.wcagCriterion);for(const d of u.inapplicable)a.add(d.wcagCriterion);for(const d of u.incomplete)a.add(d.wcagCriterion)}for(const d of c.violations)a.add(d.wcagCriterion)}const n=wl(s,a),r=new Map;for(const c of n){const u=r.get(c.outcome.category)??[];u.push(c),r.set(c.outcome.category,u)}const i=n.filter(c=>c.status==="clean").length,o=n.filter(c=>c.status==="has-violations").length,l=n.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:vl}),"."," ",yl]})]}),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:[o," with violations"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-slate-100 text-slate-700",children:[l," not evaluated"]})]}),["perceive","operate","understand","robust"].map(c=>{const u=r.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:[jl[c]," · ",u.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:u.map(d=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(kl,{status:d.status}),e.jsx("strong",{className:"text-xs",children:d.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:d.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",d.outcome.wcag2Criteria.join(", ")]}),d.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:d.violatedCriteria.join(", ")})]})]},d.outcome.id))})]},c)})]})}function kl({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}function Sl(){const t=y(u=>u.results),[s,a]=m.useState(!1),[n,r]=m.useState(null),[i,o]=m.useState(null);async function l(){r(null),a(!0);try{const u=await ae();if(!u){r("No audited tab. Open a page first.");return}const d=await me(u,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:u});if(!d.ok||!d.tokens||!d.references){r(d.error??"Snapshot failed.");return}const p=new Map;for(const g of t)for(const j of g.violations)p.has(j.target.selector)||p.set(j.target.selector,j.matchKey);const h=d.references.map(g=>({violationMatchKey:p.get(g.selector)??null,referencedTokens:g.referencedTokens})),x=d.tokens;o(Ha(x,h))}finally{a(!1)}}const c=i?Ba(i):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":i?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),c&&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(Ce,{label:"Total tokens",value:c.totalTokens}),e.jsx(Ce,{label:"Color tokens",value:c.colorTokens}),e.jsx(Ce,{label:"Used",value:c.usedTokens}),e.jsx(Ce,{label:"Unused",value:c.unusedTokens,tint:c.unusedTokens>0?"amber":"slate"}),e.jsx(Ce,{label:"In violations",value:c.violatingTokens,tint:c.violatingTokens>0?"rose":"slate"})]}),i&&i.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:i.map(u=>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:[u.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:u.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:u.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",u.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:u.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[u.usageCount," usage",u.usageCount===1?"":"s"]}),u.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:[u.violationMatchKeys.length," violation",u.violationMatchKeys.length===1?"":"s"]})]})]})]},u.token.name))})]}):i?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function Ce({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 at="onboarding:dismissed",nt="onboarding:exportTried",De="onboarding:collapsed";function Al(){const t=y(k=>k.tier),s=y(k=>k.results),a=y(k=>k.baselineList),[n,r]=m.useState(!1),[i,o]=m.useState(!1),[l,c]=m.useState(!1),[u,d]=m.useState(!1),[p,h]=m.useState(null);m.useEffect(()=>{(async()=>{const k=await chrome.storage.local.get([at,nt,De]);r(k[at]===!0),c(k[nt]===!0),typeof k[De]=="boolean"&&h(k[De]);const L=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],b=await Promise.all(L.map($=>ee({type:"SETTINGS_GET",key:$})));d(b.some($=>typeof $.data=="string"&&$.data.length>0)),o(!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:l?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:u?"done":"pending",optional:!0}],g=x.filter(k=>!k.optional),j=x.filter(k=>k.state==="done").length,S=g.filter(k=>k.state==="done").length,T=j===x.length,w=S===g.length;if(!i||n||w)return null;async function C(){r(!0),await chrome.storage.local.set({[at]:!0})}async function f(){const k=!l;c(k),await chrome.storage.local.set({[nt]:k})}const N=p??j>0;async function I(){const k=!N;h(k),await chrome.storage.local.set({[De]:k})}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 I(),"aria-expanded":!N,"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:N?"▸":"▾"}),e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",j," 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:"✕"})]}),!N&&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. ",T?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:x.map(k=>e.jsx("li",{className:"flex items-start gap-1.5",children:k.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:k.state==="done",onChange:()=>void f(),className:"mt-0.5","aria-label":k.label}),e.jsx("span",{className:k.state==="done"?"line-through text-amber-700":"text-amber-900",children:k.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:k.state==="done"?"✓":"○"}),e.jsxs("span",{className:k.state==="done"?"line-through text-amber-700":"text-amber-900",children:[k.label,k.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},k.id))})]})]})}function Cl(){const[t,s]=m.useState(""),[a,n]=m.useState(!1),[r,i]=m.useState(null);async function o(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const l=await re({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(l!=null&&l.validated)){const c=l!=null&&l.seatClaim&&"reason"in l.seatClaim?l.seatClaim.reason:null,u=l!=null&&l.seatClaim&&"hint"in l.seatClaim?l.seatClaim.hint:void 0;i(c==="cap-reached"?`License is at seat capacity. ${u??"Release a seat from another device or contact support."}`:c==="not-found"?"License not found. Check the token and try again.":c==="network"?`Network error: ${l!=null&&l.seatClaim&&"message"in l.seatClaim?l.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(l){i(l instanceof Error?l.message:String(l))}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:l=>s(l.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 o(),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 Dl(){const t=y(o=>o.view),s=y(o=>o.userMode),a=y(o=>o.tier),[n,r]=m.useState(!1);m.useEffect(()=>{const o=setTimeout(()=>r(!0),600);return()=>clearTimeout(o)},[]);const i=n&&Wa(a);return m.useEffect(()=>{const o=tn(),c=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),u=Ya();Ss({forceRefresh:!0}).catch(()=>{}),Ge().catch(()=>{}),en().catch(()=>{}),sn().catch(()=>{}),Xa().catch(()=>{}),Ga().then(p=>{y.getState().setAcknowledgedKeys(new Set(p.map(h=>h.matchKey)))}).catch(()=>{}),Va().then(p=>{p&&y.setState({siteCrawlReport:p})}).catch(()=>{});const d=p=>{if(p.key!=="Escape")return;const{pinnedMatchKey:h,setPinned:x,results:g}=y.getState();h&&(x(null),ae().then(j=>{var S;j&&de(j,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:j},(S=g[0])==null?void 0:S.frameId).catch(()=>{})}))};return window.addEventListener("keydown",d),()=>{u(),o.disconnect(),c==null||c.disconnect(),window.removeEventListener("keydown",d)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(Cl,{}),e.jsx(Te,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Ri,{}),e.jsx(Te,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Zi,{}),e.jsx(ns,{}),e.jsx(Te,{})]}):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(Hs,{}),e.jsx($s,{}),e.jsx(fn,{}),e.jsx(Al,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(wn,{}),e.jsx(Cn,{}),e.jsx(Ai,{}),e.jsx(Si,{}),e.jsx(En,{}),e.jsx(Ni,{}),e.jsx(ki,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(ar,{}),t==="report"&&e.jsx(yr,{}),t==="delta"&&e.jsx(Dr,{}),t==="activity"&&e.jsx(Yr,{}),t==="guided"&&e.jsx(li,{}),t==="flows"&&e.jsx(pi,{}),t==="scorecard"&&e.jsx(xi,{}),t==="crawl"&&e.jsx(Vs,{}),t==="forensic"&&e.jsx(Bs,{}),t==="compliance"&&e.jsx(Ko,{}),t==="schedules"&&e.jsx(Zo,{}),t==="risk"&&e.jsx(il,{}),t==="copilot"&&e.jsx(gl,{}),t==="ax-tree"&&e.jsx(fl,{}),t==="wcag3"&&e.jsx(Nl,{}),t==="tokens"&&e.jsx(Sl,{})]})]}),e.jsx(Ei,{}),e.jsx(Ci,{}),e.jsx(ji,{}),e.jsx(ns,{}),e.jsx(Te,{})]})}class Ol extends Ie.Component{constructor(){super(...arguments);Ct(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{Dl as A,Ol as E,_l as d};
|