@wcag-checkr/ci 1.0.0-rc.159 → 1.0.0-rc.160
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-DpjTf7Rc.js → ErrorBoundary-Bfaj6h5L.js} +26 -26
- package/dist/assets/{copy-ai-fixer-prompt-CepjvZn4.js → copy-ai-fixer-prompt-DzNGWBbi.js} +2 -2
- package/dist/assets/{devtools-panel-XU5g7GFi.js → devtools-panel-BsTinh3K.js} +1 -1
- package/dist/assets/parallel-tab-flow-CfAperZb.js +1 -0
- package/dist/assets/{scheduled-audit-runner-AWkKN6iB.js → scheduled-audit-runner-gbTOurQL.js} +2 -2
- package/dist/assets/{service-worker.ts-BCBBIIXb.js → service-worker.ts-Y9QMcrlF.js} +3 -3
- package/dist/assets/{side-panel-CgzkvfCv.js → side-panel-9Hki6K_K.js} +1 -1
- package/dist/assets/{site-report-renderer-DYC7h4wW.js → site-report-renderer-e3dEbloz.js} +1 -1
- package/dist/devtools/panel.html +3 -3
- package/dist/manifest.json +2 -2
- package/dist/service-worker-loader.js +1 -1
- package/dist/side-panel/side-panel.html +3 -3
- package/package.json +1 -1
- package/dist/assets/parallel-tab-flow-ChmloQZl.js +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-
|
|
2
|
-
var la=Object.defineProperty;var ca=(t,s,a)=>s in t?la(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var kt=(t,s,a)=>ca(t,typeof s!="symbol"?s+"":s,a);import{R as ke,i as ce,r as m,j as e,M as fe,C as rt,l as da,o as ht,t as mt,m as xs,s as gs,k as Re}from"./styles-CqAu9vVq.js";import{s as ua,g as pa,a as ne,d as We,A as oe,b as De,c as fs,l as ha,e as xt,f as ma,h as xa,u as ga,i as fa,j as ba,k as va,m as Be,n as ya,o as wa,N as ja,p as bs,q as Na,O as ka,r as Sa,t as Aa,v as Ca,w as St,x as Ia,y as vs,z as Ea,B as Ra,C as Ta,D as $a,E as La,F as Ua,T as _a,G as Da,H as Oa,I as Ma,J as ys,K as Fa,L as At,M as Ct,P as Qe,Q as Pa,R as It,S as Ga,U as Va,V as Wa,W as Ba,X as Ha,Y as za}from"./scheduled-audit-runner-AWkKN6iB.js";import{_ as gt}from"./diff-DA41zYPc.js";import{o as pe,r as ee,s as ie,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 Ka,t as qa}from"./design-system-audit-DpxJrxnb.js";const Et=t=>{let s;const a=new Set,n=(u,c)=>{const p=typeof u=="function"?u(s):u;if(!Object.is(p,s)){const h=s;s=c??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(x=>x(s,h))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:u=>(a.add(u),()=>a.delete(u))},d=s=t(n,r,l);return l},Qa=t=>t?Et(t):Et,Ya=t=>t;function Ja(t,s=Ya){const a=ke.useSyncExternalStore(t.subscribe,ke.useCallback(()=>s(t.getState()),[t,s]),ke.useCallback(()=>s(t.getInitialState()),[t,s]));return ke.useDebugValue(a),a}const Rt=t=>{const s=Qa(t),a=n=>Ja(s,n);return Object.assign(a,s),a},Xa=t=>t?Rt(t):Rt,b=Xa(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",findingsLens:"overview",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,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}),setFindingsLens:s=>t({findingsLens:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),ua(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 Za(){const t=[];return t.push(pe("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState().status==="running";b.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),b.getState().setStatus("running"),a||ce.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(pe("AUDIT_COMPLETE_EVENT",s=>{var l;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((d,u)=>d+u.violations.length,0),n=((l=s.delta)==null?void 0:l.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"}.`;ce.polite(r);const i=b.getState().view;["compliance","guided","crawl"].includes(i)||(b.getState().setView("report"),b.getState().setFindingsLens("overview")),en({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(pe("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(pe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ce.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(pe("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(pe("SCORECARD_UPDATED_EVENT",()=>{Pe()})),t.push(pe("LICENSE_CHANGED_EVENT",()=>{Ss()})),t.push(pe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ce.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(pe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ce.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=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ce.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function en(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 tn(){const s=(await chrome.storage.local.get(Fe))[Fe];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function sn(){await chrome.storage.local.remove(Fe)}async function He(){b.getState().clearResults(),await sn()}async function Pe(){const t=await ee({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function Ss(t){const s=await ee({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.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 gt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>pn);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function an(){const s=(await ee({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;b.getState().setUserMode(a)}function nn(){return chrome.runtime.connect({name:"audit-keepalive"})}let Ge=null;async function rn(){if(Ge===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Ge=t.id)}catch{}}function Cs(){if(Ge===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ge}).catch(()=>{})}function he(t){Cs(),ie(t)}function on({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[i,o]=m.useState(!0),[l,d]=m.useState(""),[u,c]=m.useState(!1),[p,h]=m.useState(null);async function x(g){var k;if(g.preventDefault(),!(!s.trim()||!n.trim())){c(!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:((k=S.error)==null?void 0:k.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:x,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange: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=>d(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 Tt({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=ws("messages-client"),ln="https://api.wcagcheckr.com",Is="wcagcheckr",cn=1e4;function dn(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Es(t,s){const a=await pa();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":dn()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${ln}${t}`,{...s,headers:n,signal:AbortSignal.timeout(cn)})}async function un(t){try{const s=await Es(`/v1/products/${Is}/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 Es(`/v1/products/${Is}/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 pn=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ge,fetchMessages:un},Symbol.toStringTag,{value:"Module"})),hn=["http:","https:"];function mn(t){try{const s=new URL(t);return hn.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),d=t.slice(i+2,o);mn(d)?s.push(e.jsx("a",{href:d,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 d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:$t(d)},`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((d,u)=>e.jsx("li",{children:$t(d)},u))},`u-${i++}`)),n=[])}for(const d of s){const u=d.trimEnd();if(u===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(u);if(c){o(),n.push(c[1]);continue}l(),r.push(u)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const xn={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},gn={critical:"bg-rose-50 border-rose-200"};function Ts(){const t=b(h=>h.unreadMessageCount),s=b(h=>h.messages),a=b(h=>h.applyMessageAck),[n,r]=m.useState(!1),i=m.useRef(-1),[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 d(){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&&d()}async function c(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(fn,{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(bn,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:p})]})}function fn({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 bn({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 ${xn[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=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await 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 ${gn.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 vn=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function yn(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function wn(){var p,h;const t=b(x=>x.view),s=b(x=>x.setView),a=b(x=>x.setUserMode),n=b(x=>x.results),r=b(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),d=yn(l),u=n.length>0&&r!=="running";function c(){a("owner"),ie({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:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(Ts,{}),e.jsx(Tt,{onClick:()=>void ie({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Tt,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),u&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title: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 ${d}`,children:d}),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(jn,{view:t,setView:s}),e.jsx(fe,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(on,{onClose:()=>o(!1)})})]})}function jn({view:t,setView:s}){const a=m.useRef([]),n=b(l=>l.results),r=vn.filter(l=>!l.hideWhenIdle||n.length>0);function i(l){var c;const d=(l+r.length)%r.length,u=r[d];u&&(s(u.slug),(c=a.current[d])==null||c.focus())}function o(l,d){switch(l.key){case"ArrowRight":l.preventDefault(),i(d+1);break;case"ArrowLeft":l.preventDefault(),i(d-1);break;case"Home":l.preventDefault(),i(0);break;case"End":l.preventDefault(),i(r.length-1);break}}return e.jsx("nav",{className:"flex gap-1","aria-label":"Primary navigation",role:"tablist",children:r.map((l,d)=>{const u=t===l.slug;return e.jsx("button",{ref:c=>{a.current[d]=c},role:"tab","aria-selected":u,tabIndex:u?0:-1,onClick:()=>s(l.slug),onKeyDown:c=>o(c,d),className:u?"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md bg-slate-900 text-white shadow-sm":"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md text-slate-600 hover:bg-slate-100 border border-transparent hover:border-slate-200",children:l.label},l.slug)})})}function Nn({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 kn="https://wcagcheckr.com/upgrade";function Sn(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState(null),[d,u]=m.useState(Ye),[c,p]=m.useState(Ye[0].id),[h,x]=m.useState("none"),[g,k]=m.useState(null),S=b(F=>F.status),L=b(F=>F.tier),y=b(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,Z])=>{const se=Array.isArray(F.data)?F.data:null;u(se&&se.length>0?se:Ye),typeof Z.data=="string"&&p(Z.data)})},[]);function f(F){const Z=d.find(se=>se.id===F);Z&&(p(F),ie({type:"SETTINGS_SET",key:"activePresetId",value:F}),ie({type:"SETTINGS_SET",key:"stateMatrix",value:Z.matrix}))}const N=js(L,"storybookAutoIterate");m.useEffect(()=>{const F=pe("ELEMENT_PICKED_EVENT",(se,E)=>{n(!1);const q=E.frameId;O(q),i({selector:se.selector,frameId:q,speech:se.speech})}),Z=pe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{F(),Z()}},[]);async function T(){const F=await ne();F&&(n(!0),await de(F,{type:"PICKER_ACTIVATE_REQUEST",tabId:F}))}function v(){r&&(O(r.frameId),he({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function U(){if(!N){l("storybook:auto-iterate");return}O(),he({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function w(){O(),he({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function _(){O(),he({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function te(){O(),he({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function A(){O(),he({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function V(){ie({type:"CANCEL_AUDIT"})}async function O(F){b.getState().setPinned(null);const Z=await ne();if(Z)try{await de(Z,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:Z},F)}catch{}}async function K(F){k(null);const Z=await ne();if(!Z){k("No audited tab; open a page first.");return}if(F==="none"){const E=await ee({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:Z});E.ok||k(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){k(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:c,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:d.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 K(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(Cn,{picking:a,picked:r,isRunning:C,onPick:T,onRun:v,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:te,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:w,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:U,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:V,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!C&&y&&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&&!C&&e.jsx(In,{selector:r.selector,onRepick:T,onClear:()=>i(null)})]}),e.jsx(fe,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Nn,{feature:o??"",upgradeUrl:kn})})]})}function An({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 Cn({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(An,{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 In({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 En={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Rn={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Tn(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState("off"),u=b(x=>x.results).flatMap(x=>x.violations);async function c(x){const g=await ne();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 ne();if(g){if(t&&await de(g,{type:En[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await de(g,{type:Rn[x],tabId:g}).catch(()=>{}),s(x)}}async function h(){const x=await ne();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(be,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(be,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>p("tab-order")}),e.jsx(be,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>p("reading-order")}),e.jsx(be,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(be,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick: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 c(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 be({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function $n(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 Ln(){const t=b(d=>d.status),s=b(d=>d.progress),a=b(d=>d.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":$n(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(Lt,{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(Lt,{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 Lt({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}%`}})})]})}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 ze(t){const s=it.map(r=>_n(r,t)),a=Un(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 Un(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 _n(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(V=>V.id===A)).filter(A=>A!=null);let o=i.length>0;for(const A of i){const V=r.find(K=>K.workflowId===A.id);if((V?Object.keys(V.steps).length:0)!==A.steps.length){o=!1;break}}const l=r.some(A=>Object.keys(A.steps).length>0),d=t.verifiedByWorkflowIds??[],u=s.manualRuns.filter(A=>d.includes(A.workflowId)),c=d.map(A=>s.workflows.find(V=>V.id===A)).filter(A=>A!=null);let p=d.length>0&&c.length===d.length;for(const A of c){const V=u.find(K=>K.workflowId===A.id);if((V?Object.keys(V.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=d[0]??t.igtWorkflowIds[0]??null,k=s.interactiveAuditVerdicts,S=[];k&&(t.id==="tab-order"&&k.focusOrder&&S.push({verdict:k.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(k.keyboardTrap&&S.push({verdict:k.keyboardTrap,criterionId:"2.1.2"}),k.focusVisible&&S.push({verdict:k.focusVisible,criterionId:"2.4.7"})));const L=S.some(A=>A.verdict==="fail");if(S.length>0&&S.every(A=>A.verdict==="pass")&&d.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&&d.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||d.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 T={critical:0,serious:0,moderate:0,minor:0};for(const A of We(n))T[A.impact]++;S.length>0&&S.every(A=>A.verdict==="pass")||(T.serious+=x),L&&(T.serious+=S.filter(A=>A.verdict==="fail").length);for(const A of r){const V=i.find(O=>O.id===A.workflowId);if(V)for(const O of V.steps){const K=A.steps[O.id];(K==null?void 0:K.status)==="fail"&&(O.severity==="required"?T.serious++:T.moderate++)}}const U=T.critical>0,w=T.serious>0;let _;T.critical>=5?_="F":T.critical>=1?_="D":T.serious>=1?_="C":T.moderate>=1?_="B":_="A";const te=_!=="A"&&(f&&!o||d.length>0&&!p);return{id:t.id,label:t.label,letter:_,untested:!1,needsIgt:te,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:T,caps:{cappedAtC:U,cappedAtB:w}}}const Dn=[{slug:"delta",label:"Delta",blurb:"Compare against the last baseline; export the prompt",marker:"Δ"},{slug:"guided",label:"Guided",blurb:"Step through manual IGT workflows",marker:"G"},{slug:"compliance",label:"Compliance",blurb:"WCAG-EM report builder + sign-and-seal",marker:"§"},{slug:"scorecard",label:"Components",blurb:"Every tracked component baseline at a glance",marker:"◍"},{slug:"forensic",label:"Forensic",blurb:"Audit history + RFC 3161 timestamps",marker:"⧉"},{slug:"schedules",label:"Schedules",blurb:"Recurring audits + alerts",marker:"⟳"},{slug:"risk",label:"Risk",blurb:"Posture summary across scheduled audits",marker:"⌖"},{slug:"crawl",label:"Site crawl",blurb:"Audit a multi-page site",marker:"↺"},{slug:"flows",label:"Flows",blurb:"Record + replay user-action sequences",marker:"▷"},{slug:"copilot",label:"Co-pilot",blurb:"Chat with AI grounded on the current audit",marker:"✦"},{slug:"ax-tree",label:"AX tree",blurb:"Browser's accessibility-tree viewer",marker:"⌥"},{slug:"tokens",label:"Design tokens",blurb:"CSS custom-properties usage map",marker:"#"}];function On(){const t=b(n=>n.results),s=b(n=>n.status),a=b(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(Mn,{results:t,status:s,setView:a}),e.jsx(Pn,{setView:a})]})}function Mn({results:t,status:s,setView:a}){var c,p;if(s==="running")return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"audit in progress"}),e.jsxs("p",{className:"text-sm font-medium text-slate-900 mt-1",children:["The matrix is iterating. Progress is shown above; results land in ",e.jsx("strong",{children:"Findings"})," when done."]})]});if(t.length===0)return e.jsxs("section",{className:"border border-dashed border-slate-300 rounded-lg bg-slate-50 px-4 py-5 text-center",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"no audit yet"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-1",children:"Pick an audit mode above and run a scan."}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 max-w-md mx-auto",children:"Or jump into a specialized tool below — site crawl, multi-page schedules, IGT workflows, the AI co-pilot, the forensic log."})]});const n=t.flatMap(h=>h.violations),r=We(n),o=ze({violations:n,auditRan:!0,manualRuns:[],workflows:oe,heuristicCounts:{}}).overallLetter,l=r.length,d=((c=t[0])==null?void 0:c.pageUrl)??((p=t[0])==null?void 0:p.scope)??"audited page",u=t.length;return e.jsx("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-14 shrink-0 ${Fn[o]}`,children:e.jsx("span",{className:"text-2xl font-semibold font-display leading-none tracking-tight",children:o})}),e.jsxs("div",{className:"flex-1 px-3.5 py-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 truncate",children:["last audit · ",u," state",u===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate",title:d,children:l===0?"No issues found by automation":`${l} issue${l===1?"":"s"} to fix`})]}),e.jsx("button",{type:"button",onClick:()=>a("report"),className:"shrink-0 text-xs font-medium px-3.5 py-1.5 bg-slate-900 text-white rounded-md hover:bg-slate-800",children:"View findings →"})]})]})})}const Fn={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function Pn({setView:t}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Dn.map(s=>e.jsxs("button",{type:"button",onClick:()=>t(s.slug),className:"text-left rounded-lg border border-slate-200 bg-white hover:bg-slate-50 hover:border-slate-300 transition-colors px-3 py-2.5 flex flex-col gap-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1",children:[e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-slate-400",children:[e.jsx("span",{className:"text-slate-700 mr-1.5",children:s.marker}),s.slug]}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 leading-tight mt-0.5",children:s.label}),e.jsx("span",{className:"text-[11px] text-slate-500 leading-snug",children:s.blurb})]},s.slug))})]})}const Gn={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Vn={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 Wn({violations:t,componentId:s,hideOverallHeader:a=!1}){var Z,se,E,q,le,re,j;const[n,r]=m.useState([]),[i,o]=m.useState([]),[l,d]=m.useState(new Set),[u,c]=m.useState(null),[p,h]=m.useState({}),[x,g]=m.useState(new Set),k=b(R=>R.status),S=b(R=>R.progress),L=b(R=>R.freshThisSession),y=b(R=>R.results),C=(Z=y[0])==null?void 0:Z.startedAt,f=((se=y[0])==null?void 0:se.pageUrl)??((E=y[0])==null?void 0:E.scope)??null;if(m.useEffect(()=>{if(!s){r([]);return}let R=!1;return chrome.storage.local.get("igtRuns").then(M=>{if(R)return;const z=((M==null?void 0:M.igtRuns)??{})[s]??{};r(Object.values(z))}),()=>{R=!0}},[s]),m.useEffect(()=>{if(!f){o([]);return}let R=!1;return De(f).then(M=>{R||o(M)}),()=>{R=!0}},[f]),k==="running")return e.jsx(Yn,{current:S==null?void 0:S.current,total:S==null?void 0:S.total});const N=ze({violations:t,auditRan:y.length>0,manualRuns:n,workflows:oe,heuristicCounts:{tabOrder:((le=(q=y[0])==null?void 0:q.tabOrderIssues)==null?void 0:le.length)??0,readingOrder:((j=(re=y[0])==null?void 0:re.readingOrderIssues)==null?void 0:j.length)??0}}),T=b(R=>R.acknowledgedKeys),v=y.length>0?fs(y,{runs:n,workflows:oe},"2.1","AA",T,i):void 0,U=y.length>0?ha(xt({audits:y,igtRuns:n,workflows:oe,acknowledgedMatchKeys:T,incompleteResolutions:i}),oe):void 0,w=v?v.failingCriteria.length>0||v.inconclusiveCriteria.length>0:!1,_=w&&N.overallLetter==="A"?"B":N.overallLetter;async function te(R){var J;if(!f||!((J=v==null?void 0:v.inconclusiveReasons)!=null&&J[R]))return;const W=v.inconclusiveReasons[R].filter(B=>B.source==="axe-incomplete"&&B.elements&&B.elements.length>0);if(W.length===0)return;d(B=>new Set(B).add(R)),c(null);const z=[];let P=0;try{for(const I of W){const G=await ie({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:I.ruleOrStepId,pageUrl:I.pageUrl??f,wcagCriterion:R,elements:I.elements??[],targetLevel:"AA"});if(G!=null&&G.unavailableReason){c(G.unavailableReason);break}G!=null&&G.resolutions&&(z.push(...G.resolutions),P+=G.totalCostUsd??0)}if(f){const I=await De(f);o(I)}const B={total:z.length,pass:z.filter(I=>I.verdict==="pass").length,fail:z.filter(I=>I.verdict==="fail").length,uncertain:z.filter(I=>I.verdict==="uncertain").length,costUsd:P,resolutions:z};h(I=>({...I,[R]:B}))}finally{d(B=>{const I=new Set(B);return I.delete(R),I})}}function A(R){g(M=>{const W=new Set(M);return W.has(R)?W.delete(R):W.add(R),W})}async function V(R){var G,H;if(!f)return;const M=((G=v==null?void 0:v.inconclusiveReasons)==null?void 0:G[R])??[],W=((H=v==null?void 0:v.failingReasons)==null?void 0:H[R])??[],z=[],P=new Set;for(const D of M){if(D.source!=="axe-incomplete"||!D.elements)continue;const X=D.pageUrl??f;for(const Q of D.elements){const ae=`${X}::${D.ruleOrStepId}::${Q.selector}`;P.has(ae)||(P.add(ae),z.push({ruleId:D.ruleOrStepId,pageUrl:X,selector:Q.selector}))}}for(const D of W){if(D.source!=="ai"||!D.selector)continue;const X=D.ruleOrStepId.startsWith("ai-resolved::")?D.ruleOrStepId.slice(13):D.ruleOrStepId,Q=D.pageUrl??f,ae=`${Q}::${X}::${D.selector}`;P.has(ae)||(P.add(ae),z.push({ruleId:X,pageUrl:Q,selector:D.selector}))}if(z.length===0)return;const J=new Date().toISOString(),B=[];for(const D of z){const X=i.find(Q=>Q.pageUrl===D.pageUrl&&Q.ruleId===D.ruleId&&Q.selector===D.selector);X&&X.verdict==="pass"&&X.reasoning.startsWith("Marked as visually verified")||B.push({pageUrl:D.pageUrl,ruleId:D.ruleId,selector:D.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${J.slice(0,10)}.`,resolvedAt:J,costUsd:0,wcagCriterion:R})}if(B.length===0)return;await ma(B);const I=await De(f);o(I),h(D=>({...D,[R]:{total:B.length,pass:B.length,fail:0,uncertain:0,costUsd:0,resolutions:B}}))}const O=(()=>{if(!w||N.overallLetter!=="A"||!v)return null;const R=v.inconclusiveCriteria.length,M=v.failingCriteria.length,W=[];M>0&&W.push(`${M} WCAG ${v.targetLevel} ${M===1?"criterion":"criteria"} failing`),R>0&&W.push(`${R} WCAG ${v.targetLevel} ${R===1?"criterion":"criteria"} inconclusive`);const z=M>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 — ${W.join(" + ")}. ${z}`})();let K=0;for(const R of oe){const M=n.find(z=>z.workflowId===R.id);if(!M)continue;R.steps.every(z=>{const P=M.steps[z.id];return(P==null?void 0:P.status)==="pass"||(P==null?void 0:P.status)==="fail"||(P==null?void 0:P.status)==="skip"||(P==null?void 0:P.status)==="not-applicable"})&&K++}const F=We(t.filter(R=>!T.has(R.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!L&&C&&e.jsx(Jn,{scannedAt:C}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Gn[_]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:_})}),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 ",N.subGrades.length," verification areas below. Untested areas count as F until verified."]}),O&&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:O})]})]}),a&&O&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug bg-amber-50 border-b border-amber-200 px-3 py-2",children:O}),N.isLawsuitRisk&&e.jsx(zn,{areas:N.warningAreas}),e.jsx(Kn,{grades:N.subGrades}),v&&e.jsx(Bn,{coverage:v,onResolveWithAi:te,onMarkVisuallyVerified:V,resolving:l,resolveError:u,lastResolveResult:p,expandedResultFor:x,onToggleResultDetail:A}),U&&e.jsx(Hn,{layers:U}),e.jsx(Qn,{violationsRemaining:F,manualCompleted:K,manualTotal:oe.length}),K>0||y.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:K})," of ",e.jsx("strong",{children:oe.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:`${K/oe.length*100}%`}})})]}):null]})}function Bn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const d=t.untestedCriteria.length+t.inconclusiveCriteria.length,[u,c]=m.useState(d>0&&d<=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 k=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 ",k,"."]})})(),!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:()=>c(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(k=>{var v,U;const S=g.kind==="inconclusive"?(v=t.inconclusiveReasons)==null?void 0:v[k]:void 0,L=g.kind==="failing"?(U=t.failingReasons)==null?void 0:U[k]:void 0,y=S==null?void 0:S.some(w=>w.source==="axe-incomplete"&&w.elements&&w.elements.length>0),C=L==null?void 0:L.some(w=>w.source==="ai"),f=(n==null?void 0:n.has(k))??!1,N=i==null?void 0:i[k],T=(o==null?void 0:o.has(k))??!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:["· ",k]}),(g.kind==="inconclusive"&&y||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(k),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(k),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(k),className:"ml-auto text-[10px] underline text-brand-700",children:T?"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."]}),T&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:N.resolutions.map((w,_)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:w.verdict==="pass"?"text-emerald-700 font-semibold":w.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:w.verdict==="pass"?"✓":w.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:w.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:w.reasoning})]},_))})]}),L&&L.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:L.map((w,_)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[w.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),w.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," fail — "]}),w.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," fail — "]}),w.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:w.selector}),w.notes&&e.jsx("span",{className:"text-rose-700",children:w.notes})]},_))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((w,_)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[w.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," — "]}),w.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," skipped — "]}),w.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," — "]}),w.resolutionHint,w.elements&&w.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",w.elements.length===1?"element":`${w.elements.length} elements`,":"," ",w.elements.slice(0,3).map((te,A,V)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:te.selector}),A<V.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},A)),w.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",w.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.)"})]},k)})})]},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 Ut={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 Hn({layers:t}){const s=b(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,d=r.cleared,u=i>0&&o===0&&l===0,c=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:Ut[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${c}`,children:i===0?"no coverage yet":`${d}/${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:Ut[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 zn({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 Kn({grades:t}){const s=b(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 ${Vn[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(qn,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function qn({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=oe.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?Ls(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 Qn({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(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 d=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":d?"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:d?"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":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function Yn({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 Jn({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 (",Ls(s)," old). Re-scan to grade the current page state."]})]})}function Ls(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 Us(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function _t(t){if(!Us())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-DzNGWBbi.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-e3dEbloz.js","assets/scheduled-audit-runner-gbTOurQL.js","assets/ai-usage-log-DBBVxutJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var la=Object.defineProperty;var ca=(t,s,a)=>s in t?la(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var kt=(t,s,a)=>ca(t,typeof s!="symbol"?s+"":s,a);import{R as ke,i as ce,r as m,j as e,M as fe,C as nt,l as da,o as pt,t as ht,m as xs,s as gs,k as Re}from"./styles-CqAu9vVq.js";import{s as ua,g as pa,a as ne,d as We,b as De,c as fs,l as ha,e as mt,A as oe,f as ma,h as xa,u as ga,i as fa,j as ba,k as va,m as Be,n as ya,o as wa,N as ja,p as bs,q as Na,O as ka,r as Sa,t as Aa,v as Ca,w as St,x as Ia,y as vs,z as Ea,B as Ra,C as Ta,D as $a,E as La,F as Ua,T as _a,G as Da,H as Oa,I as Ma,J as ys,K as Fa,L as At,M as Ct,P as qe,Q as Pa,R as It,S as Ga,U as Va,V as Wa,W as Ba,X as Ha,Y as za}from"./scheduled-audit-runner-gbTOurQL.js";import{_ as xt}from"./diff-DA41zYPc.js";import{o as pe,r as ee,s as ie,c as ws,b as de,d as me}from"./crash-reporter-Dc5lvxvY.js";import{B as Qe,i as js,f as Ns,T as ks}from"./ai-usage-log-DBBVxutJ.js";import{s as Ka,t as qa}from"./design-system-audit-DpxJrxnb.js";const Et=t=>{let s;const a=new Set,n=(u,c)=>{const p=typeof u=="function"?u(s):u;if(!Object.is(p,s)){const h=s;s=c??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(x=>x(s,h))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:u=>(a.add(u),()=>a.delete(u))},d=s=t(n,r,l);return l},Qa=t=>t?Et(t):Et,Ya=t=>t;function Ja(t,s=Ya){const a=ke.useSyncExternalStore(t.subscribe,ke.useCallback(()=>s(t.getState()),[t,s]),ke.useCallback(()=>s(t.getInitialState()),[t,s]));return ke.useDebugValue(a),a}const Rt=t=>{const s=Qa(t),a=n=>Ja(s,n);return Object.assign(a,s),a},Xa=t=>t?Rt(t):Rt,b=Xa(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",findingsLens:"overview",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,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}),setFindingsLens:s=>t({findingsLens:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),ua(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 Za(){const t=[];return t.push(pe("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState().status==="running";b.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),b.getState().setStatus("running"),a||ce.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(pe("AUDIT_COMPLETE_EVENT",s=>{var l;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((d,u)=>d+u.violations.length,0),n=((l=s.delta)==null?void 0:l.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"}.`;ce.polite(r);const i=b.getState().view;["compliance","guided","crawl"].includes(i)||(b.getState().setView("report"),b.getState().setFindingsLens("overview")),en({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(pe("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(pe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ce.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(pe("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(pe("SCORECARD_UPDATED_EVENT",()=>{Pe()})),t.push(pe("LICENSE_CHANGED_EVENT",()=>{Ss()})),t.push(pe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ce.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(pe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ce.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=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ce.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function en(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 tn(){const s=(await chrome.storage.local.get(Fe))[Fe];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function sn(){await chrome.storage.local.remove(Fe)}async function He(){b.getState().clearResults(),await sn()}async function Pe(){const t=await ee({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function Ss(t){const s=await ee({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.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 xt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>pn);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function an(){const s=(await ee({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;b.getState().setUserMode(a)}function nn(){return chrome.runtime.connect({name:"audit-keepalive"})}let Ge=null;async function rn(){if(Ge===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Ge=t.id)}catch{}}function Cs(){if(Ge===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ge}).catch(()=>{})}function he(t){Cs(),ie(t)}function on({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[i,o]=m.useState(!0),[l,d]=m.useState(""),[u,c]=m.useState(!1),[p,h]=m.useState(null);async function x(g){var k;if(g.preventDefault(),!(!s.trim()||!n.trim())){c(!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:((k=S.error)==null?void 0:k.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:x,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange: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=>d(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 Tt({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=ws("messages-client"),ln="https://api.wcagcheckr.com",Is="wcagcheckr",cn=1e4;function dn(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Es(t,s){const a=await pa();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":dn()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${ln}${t}`,{...s,headers:n,signal:AbortSignal.timeout(cn)})}async function un(t){try{const s=await Es(`/v1/products/${Is}/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 Es(`/v1/products/${Is}/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 pn=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ge,fetchMessages:un},Symbol.toStringTag,{value:"Module"})),hn=["http:","https:"];function mn(t){try{const s=new URL(t);return hn.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),d=t.slice(i+2,o);mn(d)?s.push(e.jsx("a",{href:d,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 d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:$t(d)},`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((d,u)=>e.jsx("li",{children:$t(d)},u))},`u-${i++}`)),n=[])}for(const d of s){const u=d.trimEnd();if(u===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(u);if(c){o(),n.push(c[1]);continue}l(),r.push(u)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const xn={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},gn={critical:"bg-rose-50 border-rose-200"};function Ts(){const t=b(h=>h.unreadMessageCount),s=b(h=>h.messages),a=b(h=>h.applyMessageAck),[n,r]=m.useState(!1),i=m.useRef(-1),[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 d(){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&&d()}async function c(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(fn,{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(bn,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:p})]})}function fn({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 bn({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 ${xn[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=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await 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 ${gn.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 vn=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function yn(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function wn(){var p,h;const t=b(x=>x.view),s=b(x=>x.setView),a=b(x=>x.setUserMode),n=b(x=>x.results),r=b(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),d=yn(l),u=n.length>0&&r!=="running";function c(){a("owner"),ie({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:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(Ts,{}),e.jsx(Tt,{onClick:()=>void ie({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Tt,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),u&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title: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 ${d}`,children:d}),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(jn,{view:t,setView:s}),e.jsx(fe,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(on,{onClose:()=>o(!1)})})]})}function jn({view:t,setView:s}){const a=m.useRef([]),n=b(l=>l.results),r=vn.filter(l=>!l.hideWhenIdle||n.length>0);function i(l){var c;const d=(l+r.length)%r.length,u=r[d];u&&(s(u.slug),(c=a.current[d])==null||c.focus())}function o(l,d){switch(l.key){case"ArrowRight":l.preventDefault(),i(d+1);break;case"ArrowLeft":l.preventDefault(),i(d-1);break;case"Home":l.preventDefault(),i(0);break;case"End":l.preventDefault(),i(r.length-1);break}}return e.jsx("nav",{className:"flex gap-1","aria-label":"Primary navigation",role:"tablist",children:r.map((l,d)=>{const u=t===l.slug;return e.jsx("button",{ref:c=>{a.current[d]=c},role:"tab","aria-selected":u,tabIndex:u?0:-1,onClick:()=>s(l.slug),onKeyDown:c=>o(c,d),className:u?"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md bg-slate-900 text-white shadow-sm":"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md text-slate-600 hover:bg-slate-100 border border-transparent hover:border-slate-200",children:l.label},l.slug)})})}function Nn({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 kn="https://wcagcheckr.com/upgrade";function Sn(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState(null),[d,u]=m.useState(Qe),[c,p]=m.useState(Qe[0].id),[h,x]=m.useState("none"),[g,k]=m.useState(null),S=b(F=>F.status),L=b(F=>F.tier),y=b(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,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=d.find(se=>se.id===F);Z&&(p(F),ie({type:"SETTINGS_SET",key:"activePresetId",value:F}),ie({type:"SETTINGS_SET",key:"stateMatrix",value:Z.matrix}))}const N=js(L,"storybookAutoIterate");m.useEffect(()=>{const F=pe("ELEMENT_PICKED_EVENT",(se,E)=>{n(!1);const q=E.frameId;O(q),i({selector:se.selector,frameId:q,speech:se.speech})}),Z=pe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{F(),Z()}},[]);async function T(){const F=await ne();F&&(n(!0),await de(F,{type:"PICKER_ACTIVATE_REQUEST",tabId:F}))}function v(){r&&(O(r.frameId),he({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function U(){if(!N){l("storybook:auto-iterate");return}O(),he({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function w(){O(),he({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function _(){O(),he({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function te(){O(),he({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function A(){O(),he({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function V(){ie({type:"CANCEL_AUDIT"})}async function O(F){b.getState().setPinned(null);const Z=await ne();if(Z)try{await de(Z,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:Z},F)}catch{}}async function K(F){k(null);const Z=await ne();if(!Z){k("No audited tab; open a page first.");return}if(F==="none"){const E=await ee({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:Z});E.ok||k(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){k(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:c,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:d.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 K(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(Cn,{picking:a,picked:r,isRunning:C,onPick:T,onRun:v,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:te,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:w,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:U,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:V,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!C&&y&&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&&!C&&e.jsx(In,{selector:r.selector,onRepick:T,onClear:()=>i(null)})]}),e.jsx(fe,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Nn,{feature:o??"",upgradeUrl:kn})})]})}function An({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 Cn({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(An,{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 In({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 En={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Rn={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Tn(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState("off"),u=b(x=>x.results).flatMap(x=>x.violations);async function c(x){const g=await ne();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 ne();if(g){if(t&&await de(g,{type:En[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await de(g,{type:Rn[x],tabId:g}).catch(()=>{}),s(x)}}async function h(){const x=await ne();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(be,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(be,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>p("tab-order")}),e.jsx(be,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>p("reading-order")}),e.jsx(be,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(be,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick: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 c(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 be({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function $n(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 Ln(){const t=b(d=>d.status),s=b(d=>d.progress),a=b(d=>d.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":$n(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(Lt,{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(Lt,{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 Lt({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}%`}})})]})}const Un=[{slug:"delta",label:"Delta",blurb:"Compare against the last baseline; export the prompt",marker:"Δ"},{slug:"guided",label:"Guided",blurb:"Step through manual IGT workflows",marker:"G"},{slug:"compliance",label:"Compliance",blurb:"WCAG-EM report builder + sign-and-seal",marker:"§"},{slug:"scorecard",label:"Components",blurb:"Every tracked component baseline at a glance",marker:"◍"},{slug:"forensic",label:"Forensic",blurb:"Audit history + RFC 3161 timestamps",marker:"⧉"},{slug:"schedules",label:"Schedules",blurb:"Recurring audits + alerts",marker:"⟳"},{slug:"risk",label:"Risk",blurb:"Posture summary across scheduled audits",marker:"⌖"},{slug:"crawl",label:"Site crawl",blurb:"Audit a multi-page site",marker:"↺"},{slug:"flows",label:"Flows",blurb:"Record + replay user-action sequences",marker:"▷"},{slug:"copilot",label:"Co-pilot",blurb:"Chat with AI grounded on the current audit",marker:"✦"},{slug:"ax-tree",label:"AX tree",blurb:"Browser's accessibility-tree viewer",marker:"⌥"},{slug:"tokens",label:"Design tokens",blurb:"CSS custom-properties usage map",marker:"#"}];function _n(){const t=b(n=>n.results),s=b(n=>n.status),a=b(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(Dn,{results:t,status:s,setView:a}),e.jsx(On,{setView:a})]})}function Dn({results:t,status:s,setView:a}){var d,u;if(s==="running")return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"audit in progress"}),e.jsxs("p",{className:"text-sm font-medium text-slate-900 mt-1",children:["The matrix is iterating. Progress is shown above; results land in ",e.jsx("strong",{children:"Findings"})," when done."]})]});if(t.length===0)return e.jsxs("section",{className:"border border-dashed border-slate-300 rounded-lg bg-slate-50 px-4 py-5 text-center",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"no audit yet"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-1",children:"Pick an audit mode above and run a scan."}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 max-w-md mx-auto",children:"Or jump into a specialized tool below — site crawl, multi-page schedules, IGT workflows, the AI co-pilot, the forensic log."})]});const n=t.flatMap(c=>c.violations),i=We(n).length,o=((d=t[0])==null?void 0:d.pageUrl)??((u=t[0])==null?void 0:u.scope)??"audited page",l=t.length;return e.jsx("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:e.jsxs("div",{className:"px-3.5 py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 truncate",children:["last audit · ",l," state",l===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate mt-0.5",title:o,children:i===0?"No issues found by automation":`${i} issue${i===1?"":"s"} to fix`})]}),e.jsx("button",{type:"button",onClick:()=>a("report"),className:"shrink-0 text-xs font-medium px-3.5 py-1.5 bg-slate-900 text-white rounded-md hover:bg-slate-800",children:"View findings →"})]})})}function On({setView:t}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Un.map(s=>e.jsxs("button",{type:"button",onClick:()=>t(s.slug),className:"text-left rounded-lg border border-slate-200 bg-white hover:bg-slate-50 hover:border-slate-300 transition-colors px-3 py-2.5 flex flex-col gap-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1",children:[e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-slate-400",children:[e.jsx("span",{className:"text-slate-700 mr-1.5",children:s.marker}),s.slug]}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 leading-tight mt-0.5",children:s.label}),e.jsx("span",{className:"text-[11px] text-slate-500 leading-snug",children:s.blurb})]},s.slug))})]})}const 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 gt(t){const s=rt.map(r=>Fn(r,t)),a=Mn(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 Mn(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 Fn(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(V=>V.id===A)).filter(A=>A!=null);let o=i.length>0;for(const A of i){const V=r.find(K=>K.workflowId===A.id);if((V?Object.keys(V.steps).length:0)!==A.steps.length){o=!1;break}}const l=r.some(A=>Object.keys(A.steps).length>0),d=t.verifiedByWorkflowIds??[],u=s.manualRuns.filter(A=>d.includes(A.workflowId)),c=d.map(A=>s.workflows.find(V=>V.id===A)).filter(A=>A!=null);let p=d.length>0&&c.length===d.length;for(const A of c){const V=u.find(K=>K.workflowId===A.id);if((V?Object.keys(V.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=d[0]??t.igtWorkflowIds[0]??null,k=s.interactiveAuditVerdicts,S=[];k&&(t.id==="tab-order"&&k.focusOrder&&S.push({verdict:k.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(k.keyboardTrap&&S.push({verdict:k.keyboardTrap,criterionId:"2.1.2"}),k.focusVisible&&S.push({verdict:k.focusVisible,criterionId:"2.4.7"})));const L=S.some(A=>A.verdict==="fail");if(S.length>0&&S.every(A=>A.verdict==="pass")&&d.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&&d.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||d.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 T={critical:0,serious:0,moderate:0,minor:0};for(const A of We(n))T[A.impact]++;S.length>0&&S.every(A=>A.verdict==="pass")||(T.serious+=x),L&&(T.serious+=S.filter(A=>A.verdict==="fail").length);for(const A of r){const V=i.find(O=>O.id===A.workflowId);if(V)for(const O of V.steps){const K=A.steps[O.id];(K==null?void 0:K.status)==="fail"&&(O.severity==="required"?T.serious++:T.moderate++)}}const U=T.critical>0,w=T.serious>0;let _;T.critical>=5?_="F":T.critical>=1?_="D":T.serious>=1?_="C":T.moderate>=1?_="B":_="A";const te=_!=="A"&&(f&&!o||d.length>0&&!p);return{id:t.id,label:t.label,letter:_,untested:!1,needsIgt:te,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:T,caps:{cappedAtC:U,cappedAtB:w}}}const Pn={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Gn={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 Vn({violations:t,componentId:s,hideOverallHeader:a=!1}){var Z,se,E,q,le,re,j;const[n,r]=m.useState([]),[i,o]=m.useState([]),[l,d]=m.useState(new Set),[u,c]=m.useState(null),[p,h]=m.useState({}),[x,g]=m.useState(new Set),k=b(R=>R.status),S=b(R=>R.progress),L=b(R=>R.freshThisSession),y=b(R=>R.results),C=(Z=y[0])==null?void 0:Z.startedAt,f=((se=y[0])==null?void 0:se.pageUrl)??((E=y[0])==null?void 0:E.scope)??null;if(m.useEffect(()=>{if(!s){r([]);return}let R=!1;return chrome.storage.local.get("igtRuns").then(M=>{if(R)return;const z=((M==null?void 0:M.igtRuns)??{})[s]??{};r(Object.values(z))}),()=>{R=!0}},[s]),m.useEffect(()=>{if(!f){o([]);return}let R=!1;return De(f).then(M=>{R||o(M)}),()=>{R=!0}},[f]),k==="running")return e.jsx(Qn,{current:S==null?void 0:S.current,total:S==null?void 0:S.total});const N=gt({violations:t,auditRan:y.length>0,manualRuns:n,workflows:oe,heuristicCounts:{tabOrder:((le=(q=y[0])==null?void 0:q.tabOrderIssues)==null?void 0:le.length)??0,readingOrder:((j=(re=y[0])==null?void 0:re.readingOrderIssues)==null?void 0:j.length)??0}}),T=b(R=>R.acknowledgedKeys),v=y.length>0?fs(y,{runs:n,workflows:oe},"2.1","AA",T,i):void 0,U=y.length>0?ha(mt({audits:y,igtRuns:n,workflows:oe,acknowledgedMatchKeys:T,incompleteResolutions:i}),oe):void 0,w=v?v.failingCriteria.length>0||v.inconclusiveCriteria.length>0:!1,_=w&&N.overallLetter==="A"?"B":N.overallLetter;async function te(R){var J;if(!f||!((J=v==null?void 0:v.inconclusiveReasons)!=null&&J[R]))return;const W=v.inconclusiveReasons[R].filter(B=>B.source==="axe-incomplete"&&B.elements&&B.elements.length>0);if(W.length===0)return;d(B=>new Set(B).add(R)),c(null);const z=[];let P=0;try{for(const I of W){const G=await ie({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:I.ruleOrStepId,pageUrl:I.pageUrl??f,wcagCriterion:R,elements:I.elements??[],targetLevel:"AA"});if(G!=null&&G.unavailableReason){c(G.unavailableReason);break}G!=null&&G.resolutions&&(z.push(...G.resolutions),P+=G.totalCostUsd??0)}if(f){const I=await De(f);o(I)}const B={total:z.length,pass:z.filter(I=>I.verdict==="pass").length,fail:z.filter(I=>I.verdict==="fail").length,uncertain:z.filter(I=>I.verdict==="uncertain").length,costUsd:P,resolutions:z};h(I=>({...I,[R]:B}))}finally{d(B=>{const I=new Set(B);return I.delete(R),I})}}function A(R){g(M=>{const W=new Set(M);return W.has(R)?W.delete(R):W.add(R),W})}async function V(R){var G,H;if(!f)return;const M=((G=v==null?void 0:v.inconclusiveReasons)==null?void 0:G[R])??[],W=((H=v==null?void 0:v.failingReasons)==null?void 0:H[R])??[],z=[],P=new Set;for(const D of M){if(D.source!=="axe-incomplete"||!D.elements)continue;const X=D.pageUrl??f;for(const Q of D.elements){const ae=`${X}::${D.ruleOrStepId}::${Q.selector}`;P.has(ae)||(P.add(ae),z.push({ruleId:D.ruleOrStepId,pageUrl:X,selector:Q.selector}))}}for(const D of W){if(D.source!=="ai"||!D.selector)continue;const X=D.ruleOrStepId.startsWith("ai-resolved::")?D.ruleOrStepId.slice(13):D.ruleOrStepId,Q=D.pageUrl??f,ae=`${Q}::${X}::${D.selector}`;P.has(ae)||(P.add(ae),z.push({ruleId:X,pageUrl:Q,selector:D.selector}))}if(z.length===0)return;const J=new Date().toISOString(),B=[];for(const D of z){const X=i.find(Q=>Q.pageUrl===D.pageUrl&&Q.ruleId===D.ruleId&&Q.selector===D.selector);X&&X.verdict==="pass"&&X.reasoning.startsWith("Marked as visually verified")||B.push({pageUrl:D.pageUrl,ruleId:D.ruleId,selector:D.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${J.slice(0,10)}.`,resolvedAt:J,costUsd:0,wcagCriterion:R})}if(B.length===0)return;await ma(B);const I=await De(f);o(I),h(D=>({...D,[R]:{total:B.length,pass:B.length,fail:0,uncertain:0,costUsd:0,resolutions:B}}))}const O=(()=>{if(!w||N.overallLetter!=="A"||!v)return null;const R=v.inconclusiveCriteria.length,M=v.failingCriteria.length,W=[];M>0&&W.push(`${M} WCAG ${v.targetLevel} ${M===1?"criterion":"criteria"} failing`),R>0&&W.push(`${R} WCAG ${v.targetLevel} ${R===1?"criterion":"criteria"} inconclusive`);const z=M>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 — ${W.join(" + ")}. ${z}`})();let K=0;for(const R of oe){const M=n.find(z=>z.workflowId===R.id);if(!M)continue;R.steps.every(z=>{const P=M.steps[z.id];return(P==null?void 0:P.status)==="pass"||(P==null?void 0:P.status)==="fail"||(P==null?void 0:P.status)==="skip"||(P==null?void 0:P.status)==="not-applicable"})&&K++}const F=We(t.filter(R=>!T.has(R.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!L&&C&&e.jsx(Yn,{scannedAt:C}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Pn[_]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:_})}),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 ",N.subGrades.length," verification areas below. Untested areas count as F until verified."]}),O&&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:O})]})]}),a&&O&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug bg-amber-50 border-b border-amber-200 px-3 py-2",children:O}),N.isLawsuitRisk&&e.jsx(Hn,{areas:N.warningAreas}),e.jsx(zn,{grades:N.subGrades}),v&&e.jsx(Wn,{coverage:v,onResolveWithAi:te,onMarkVisuallyVerified:V,resolving:l,resolveError:u,lastResolveResult:p,expandedResultFor:x,onToggleResultDetail:A}),U&&e.jsx(Bn,{layers:U}),e.jsx(qn,{violationsRemaining:F,manualCompleted:K,manualTotal:oe.length}),K>0||y.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:K})," of ",e.jsx("strong",{children:oe.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:`${K/oe.length*100}%`}})})]}):null]})}function Wn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const d=t.untestedCriteria.length+t.inconclusiveCriteria.length,[u,c]=m.useState(d>0&&d<=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 k=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 ",k,"."]})})(),!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:()=>c(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(k=>{var v,U;const S=g.kind==="inconclusive"?(v=t.inconclusiveReasons)==null?void 0:v[k]:void 0,L=g.kind==="failing"?(U=t.failingReasons)==null?void 0:U[k]:void 0,y=S==null?void 0:S.some(w=>w.source==="axe-incomplete"&&w.elements&&w.elements.length>0),C=L==null?void 0:L.some(w=>w.source==="ai"),f=(n==null?void 0:n.has(k))??!1,N=i==null?void 0:i[k],T=(o==null?void 0:o.has(k))??!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:["· ",k]}),(g.kind==="inconclusive"&&y||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(k),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(k),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(k),className:"ml-auto text-[10px] underline text-brand-700",children:T?"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."]}),T&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:N.resolutions.map((w,_)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:w.verdict==="pass"?"text-emerald-700 font-semibold":w.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:w.verdict==="pass"?"✓":w.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:w.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:w.reasoning})]},_))})]}),L&&L.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:L.map((w,_)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[w.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),w.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," fail — "]}),w.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," fail — "]}),w.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:w.selector}),w.notes&&e.jsx("span",{className:"text-rose-700",children:w.notes})]},_))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((w,_)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[w.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," — "]}),w.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," skipped — "]}),w.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:w.ruleOrStepId})," — "]}),w.resolutionHint,w.elements&&w.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",w.elements.length===1?"element":`${w.elements.length} elements`,":"," ",w.elements.slice(0,3).map((te,A,V)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:te.selector}),A<V.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},A)),w.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",w.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.)"})]},k)})})]},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 Ut={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 Bn({layers:t}){const s=b(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,d=r.cleared,u=i>0&&o===0&&l===0,c=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:Ut[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${c}`,children:i===0?"no coverage yet":`${d}/${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:Ut[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 Hn({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 zn({grades:t}){const s=b(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 ${Gn[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(Kn,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Kn({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=oe.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?Ls(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 qn({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(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 d=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":d?"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:d?"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":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function Qn({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 Yn({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 (",Ls(s)," old). Re-scan to grade the current page state."]})]})}function Ls(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 Us(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function _t(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 Dt=.022,
|
|
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 ${pr[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(fr,{violation:t}),e.jsx(yr,{violation:t}),e.jsx(vr,{violation:t}),e.jsx(br,{text:t.target.failureSummary}),e.jsx(wr,{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: ",hr(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),S(y))},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:L,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),L(y))},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:y=>{y.preventDefault(),y.stopPropagation(),_t(t.target.selector)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),_t(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:y=>{y.stopPropagation(),c(t.matchKey),xr(t,l)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),y.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:y=>{y.stopPropagation(),u(t.matchKey),mr(t,l)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),y.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:y=>y.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function hr(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 mr(t,s){await fa({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await _s(t.componentId,s)}async function xr(t,s){await ga(t.componentId,t.matchKey),await _s(t.componentId,s)}async function _s(t,s){const a=s.flatMap(n=>n.violations);try{const n=await ee({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function gr(){const t=Ns.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Ds(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 fr({violation:t}){const s=Ds(t);if(!s)return null;const a=s.ratio>=s.required,n=dr(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 br({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 vr({violation:t}){const s=ur(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 yr({violation:t}){const s=Ds(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let i=!1;return xa(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(d=>d.matchKey===t.matchKey);l?(await ba(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 wr({ruleId:t}){const s=va(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}function jr(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Os(t){return`${Be(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Nr(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Os(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 Vt={critical:0,serious:1,moderate:2,minor:3},kr={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function Sr({results:t,interactiveVerdicts:s}){const a=t.length,n=t.flatMap(d=>d.violations),r=Nr(t);r.sort((d,u)=>{const c=Vt[d.representative.impact]??99,p=Vt[u.representative.impact]??99;return c!==p?c-p:u.states.length-d.states.length});const i=ze({violations:n,auditRan:!0,manualRuns:[],workflows:oe,heuristicCounts:{},interactiveAuditVerdicts:s}),o=new Map;for(const d of it)o.set(d.id,[]);const l=[];for(const d of r){let u=!1;for(const c of it)if(c.axeRules.includes(d.representative.ruleId)){o.get(c.id).push(d),u=!0;break}u||l.push(d)}return e.jsxs("div",{className:"space-y-1.5",children:[i.subGrades.map(d=>e.jsx(Wt,{subGrade:d,groups:o.get(d.id)??[],totalStates:a},d.id)),l.length>0&&e.jsx(Wt,{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:a})]})}function Wt({subGrade:t,groups:s,totalStates:a}){const[n,r]=m.useState(!1),[i,o]=m.useState("idle"),[l,d]=m.useState(null),[u,c]=m.useState(0),p=s.length>0,h=kr[t.letter],x=s.filter(S=>S.representative.ruleId==="color-contrast"||S.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function k(S){S.stopPropagation(),o("loading"),d(null);try{const L=x.map(C=>{const f=C.representative.target.outerHTML,N=C.representative.target.failureSummary,T=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(N),v=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(N);if(!T||!v)return null;const U=C.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:C.representative.matchKey,foreground:T[1],background:v[1],fontSize:16,fontWeight:400,targetLevel:U,_html:f}}).filter(C=>C!==null);if(L.length===0){o("error"),d("Could not parse fg/bg colors from the violation failure summaries.");return}const y=await ee({type:"AI_COLOR_SUGGEST_REQUEST",inputs:L.map(({_html:C,...f})=>f)});if(y.unavailableReason&&y.results.length===0){o("error"),d(y.unavailableReason);return}await ya(y.results),o("done"),c(C=>C+1),n||r(!0)}catch(L){o("error"),d(L instanceof Error?L.message:String(L))}}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 font-display ${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 k(S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),k(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 font-mono","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(Ae,{violation:S.representative}),e.jsx(Ar,{states:S.states,totalStates:a})]},`${Os(S.representative)}::${u}`))})]})}function Ar({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(jr))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
|
|
10
|
-
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const
|
|
8
|
+
})()`;s.inspectedWindow.eval(r,(i,o)=>{a(o?!1:i===!0)})})}const Dt=.022,Jn=1.414,Ye=2.4,Xn=.2126729,Zn=.7151522,er=.072175,tr=.56,sr=.57,ar=.62,nr=.65,Ot=1.14,Mt=.1,rr=.027,ir=.027,or=5e-4;function Ft(t,s,a){const n=t/255,r=s/255,i=a/255;return Xn*Math.pow(n,Ye)+Zn*Math.pow(r,Ye)+er*Math.pow(i,Ye)}function Pt(t){return t<0?0:t<Dt?t+Math.pow(Dt-t,Jn):t}function lr(t,s){const a=Pt(Ft(t[0],t[1],t[2])),n=Pt(Ft(s[0],s[1],s[2]));if(Math.abs(n-a)<or)return 0;let r=0;return n>a?(r=(Math.pow(n,tr)-Math.pow(a,sr))*Ot,r<Mt?0:(r-rr)*100):(r=(Math.pow(n,nr)-Math.pow(a,ar))*Ot,r>-Mt?0:(r+ir)*100)}function Gt(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 cr(t,s,a=75){const n=Gt(t),r=Gt(s);if(!n||!r)return null;const i=lr(n,r);return{lc:i,passes:Math.abs(i)>=a,threshold:a}}const ve={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function dr(t){return/^wcag\d/.test(t.wcagCriterion)?[ve["ada-iii"],ve[508],ve.eaa,ve["en-301-549"],ve.aoda]:[]}const ur={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 Ae({violation:t,alreadyAcknowledged:s}){const a=b(y=>y.pinnedMatchKey),n=b(y=>y.pinnedFound),r=b(y=>y.setPinned),i=b(y=>{var C;return(C=y.results[0])==null?void 0:C.frameId}),o=b(y=>{var C;return(C=y.results[0])==null?void 0:C.scope}),l=b(y=>y.results),d=b(y=>y.acknowledgedKeys.has(t.matchKey)),u=b(y=>y.markAcknowledged),c=b(y=>y.markUnacknowledged),p=s||d,h=a===t.matchKey,x=h&&!n;async function g(y){try{return(await me(y,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:y,selector:t.target.selector},i)).found}catch{return!0}}async function k(){const y=await ne();if(!y)return;if(h){r(null);try{await de(y,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:y},i)}catch{}return}const C=await g(y);r(t.matchKey,C)}function S(y){y.stopPropagation(),t.currentState.breakpoint.width<=640&&Cs(),(async()=>{const C=await ne();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 L(y){y.stopPropagation();const C=await ne();if(!C)return;try{await ee({type:"STATE_DRIVE_REQUEST",tabId:C,state:xr(),scope:o,frameId:i})}catch{ie({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:k,"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 ${ur[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(gr,{violation:t}),e.jsx(vr,{violation:t}),e.jsx(br,{violation:t}),e.jsx(fr,{text:t.target.failureSummary}),e.jsx(yr,{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: ",pr(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),S(y))},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:L,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),L(y))},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:y=>{y.preventDefault(),y.stopPropagation(),_t(t.target.selector)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),_t(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:y=>{y.stopPropagation(),c(t.matchKey),mr(t,l)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),y.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:y=>{y.stopPropagation(),u(t.matchKey),hr(t,l)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),y.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:y=>y.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function pr(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 hr(t,s){await fa({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await _s(t.componentId,s)}async function mr(t,s){await ga(t.componentId,t.matchKey),await _s(t.componentId,s)}async function _s(t,s){const a=s.flatMap(n=>n.violations);try{const n=await ee({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function xr(){const t=Ns.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Ds(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 gr({violation:t}){const s=Ds(t);if(!s)return null;const a=s.ratio>=s.required,n=cr(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 fr({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 br({violation:t}){const s=dr(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 vr({violation:t}){const s=Ds(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let i=!1;return xa(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(d=>d.matchKey===t.matchKey);l?(await ba(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 yr({ruleId:t}){const s=va(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}function wr(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Os(t){return`${Be(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function jr(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Os(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 Vt={critical:0,serious:1,moderate:2,minor:3},Nr={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function kr({results:t,interactiveVerdicts:s}){const a=t.length,n=t.flatMap(d=>d.violations),r=jr(t);r.sort((d,u)=>{const c=Vt[d.representative.impact]??99,p=Vt[u.representative.impact]??99;return c!==p?c-p:u.states.length-d.states.length});const i=gt({violations:n,auditRan:!0,manualRuns:[],workflows:oe,heuristicCounts:{},interactiveAuditVerdicts:s}),o=new Map;for(const d of rt)o.set(d.id,[]);const l=[];for(const d of r){let u=!1;for(const c of rt)if(c.axeRules.includes(d.representative.ruleId)){o.get(c.id).push(d),u=!0;break}u||l.push(d)}return e.jsxs("div",{className:"space-y-1.5",children:[i.subGrades.map(d=>e.jsx(Wt,{subGrade:d,groups:o.get(d.id)??[],totalStates:a},d.id)),l.length>0&&e.jsx(Wt,{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:a})]})}function Wt({subGrade:t,groups:s,totalStates:a}){const[n,r]=m.useState(!1),[i,o]=m.useState("idle"),[l,d]=m.useState(null),[u,c]=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 k(S){S.stopPropagation(),o("loading"),d(null);try{const L=x.map(C=>{const f=C.representative.target.outerHTML,N=C.representative.target.failureSummary,T=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(N),v=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(N);if(!T||!v)return null;const U=C.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:C.representative.matchKey,foreground:T[1],background:v[1],fontSize:16,fontWeight:400,targetLevel:U,_html:f}}).filter(C=>C!==null);if(L.length===0){o("error"),d("Could not parse fg/bg colors from the violation failure summaries.");return}const y=await ee({type:"AI_COLOR_SUGGEST_REQUEST",inputs:L.map(({_html:C,...f})=>f)});if(y.unavailableReason&&y.results.length===0){o("error"),d(y.unavailableReason);return}await ya(y.results),o("done"),c(C=>C+1),n||r(!0)}catch(L){o("error"),d(L instanceof Error?L.message:String(L))}}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 font-display ${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 k(S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),k(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 font-mono","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(Ae,{violation:S.representative}),e.jsx(Sr,{states:S.states,totalStates:a})]},`${Os(S.representative)}::${u}`))})]})}function Sr({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(wr))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
|
|
10
|
+
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const it="dismissedFindings";function ze(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function Ce(t){return`reading-order::${t}`}function Ie(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 ft(t){await chrome.storage.local.set({[it]:t})}async function Ms(t){return(await Ke())[ze(t)]??{}}async function Fs(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 ft(r)}async function Ee(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 ft(a)}async function Ps(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 ft(a))}const Wl=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Fs,addDismissals:Ee,dismissalKeyForReadingOrder:Ce,dismissalKeyForTabOrder:Ie,getDismissalsForUrl:Ms,removeDismissal:Ps},Symbol.toStringTag,{value:"Module"})),Bt="igtRuns";async function Ar(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Bt))[Bt];return s&&typeof s=="object"?s:{}}async function Cr(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Ar())[t];if(i)for(const d of oe){const u=i[d.id];if(u)for(const c of d.steps){if(!c.autoDismissActivity||((l=(o=u.steps)==null?void 0:o[c.id])==null?void 0:l.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Ee(n,x.map(g=>({key:Ie(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Ee(n,x.map(g=>({key:Ce(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const Ir=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"]),Er=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 Rr(t){return Ir.has(t.ruleId)}function Tr(t){return Er.has(t.ruleId)}function $r(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Gs(){var U,w,_,te;const t=b(A=>A.results),s=b(A=>A.delta),a=b(A=>A.componentId),n=((U=t[0])==null?void 0:U.pageUrl)??((w=t[0])==null?void 0:w.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 Cr(a,t)}catch{}if(A)return;const V=await Ms(n);A||i(V)})(),()=>{A=!0}},[n,o,a,t]);async function d(A,V){if(!n)return;const O=window.prompt(`Why is this finding a false positive?
|
|
11
11
|
|
|
12
|
-
(Recorded with the dismissal so future you remembers the reasoning.)`,"");O!==null&&(await Fs(n,A,O||"(no reason given)",V),l(K=>K+1))}async function u(A){n&&(await Ps(n,A),l(V=>V+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 c=t.reduce((A,V)=>{var O;return A+(((O=V.announcements)==null?void 0:O.length)??0)},0),p=t.reduce((A,V)=>{var O;return A+(((O=V.focusEvents)==null?void 0:O.length)??0)},0),h=t.reduce((A,V)=>{var O;return A+(((O=V.focusEvents)==null?void 0:O.filter(K=>K.isFocusReset).length)??0)},0),x=Ht(t,Tr),g=Ht(t,$r),k=x.length,S=g.length,L=((_=t[0])==null?void 0:_.readingOrderIssues)??[],y=((te=t[0])==null?void 0:te.tabOrderIssues)??[],C=L.filter(A=>!(Ce(A.selector)in r)),f=L.filter(A=>Ce(A.selector)in r),N=y.filter(A=>!(Ie(A.selector)in r)),T=y.filter(A=>Ie(A.selector)in r);if(c===0&&p===0&&k===0&&S===0&&C.length===0&&N.length===0&&f.length===0&&T.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const v=f.length+T.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[k," structural · ",S," form ·"," ",N.length," tab-order ·"," ",C.length," reading-order ·"," ",c," ",c===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"]}),v>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",v," dismissed"]})]}),N.length>0&&e.jsx(Dr,{issues:N,onDismiss:d}),C.length>0&&e.jsx(Or,{issues:C,onDismiss:d}),v>0&&e.jsx(Mr,{dismissedReadingOrder:f,dismissedTabOrder:T,dismissals:r,onRestore:u}),k>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}),S>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(Ur,{delta:s}),t.map((A,V)=>{const O=A.announcements??[],K=A.focusEvents??[];return O.length===0&&K.length===0?null:e.jsx(_r,{state:A.state,announcements:O,focusEvents:K},V)})]})}function Ur({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 Ht(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=Be(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 _r({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:Lr(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 Dr({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 Or({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 Mr({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 d=`tab-order::${l.selector}`,u=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children: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(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,u=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children: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(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Fr={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 Pr({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(Ae,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Fr[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((d,u)=>e.jsx(Ae,{violation:d},u))})]})}function Gr(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 Vr={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function Vs({open:t,onClose:s,format:a,content:n,filename:r}){const i=da(new Blob([n]).size);function o(){mt(n,r),s()}function l(){ht(n),s()}return e.jsxs(fe,{open:t,onClose:s,title:Vr[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 Wr(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.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({...c,_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 c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.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(`
|
|
13
|
-
`),d=new URLSearchParams({title:i,body:l});let u=`${n}/issues/new?${d.toString()}`;return u.length>Kt&&(u=u.slice(0,Kt)),{url:u,title:i,body:l}}const qt=7800;function
|
|
14
|
-
`),d=new URLSearchParams({summary:i,description:l});let u=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return u.length>qt&&(u=u.slice(0,qt)),{url:u,summary:i,description:l}}const Qt=7800;function
|
|
15
|
-
`),u=new URLSearchParams({"[Title]":o,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${u.toString()}`;return c.length>Qt&&(c=c.slice(0,Qt)),{url:c,title:o,description:d}}const Yt=7800;function
|
|
16
|
-
`),d=new URLSearchParams({"issue[title]":i,"issue[description]":l});let u=`${n}/-/issues/new?${d.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"],Kr=["wcag-component-auditor","wcag-forensic-log"];async function qr(){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 Kr)try{await Qr(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 Qr(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 Yr(){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 Jr(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[lt]:t})}function Xr({open:t,onClose:s,results:a}){const[n,r]=m.useState("eaa"),[i,o]=m.useState(""),[l,d]=m.useState(""),[u,c]=m.useState("partial"),[p,h]=m.useState(""),[x,g]=m.useState(""),[k,S]=m.useState(""),[L,y]=m.useState(""),[C,f]=m.useState("English"),[N,T]=m.useState("wcagcheckr (self-evaluation)"),[v,U]=m.useState("2.1"),[w,_]=m.useState("AA"),[te,A]=m.useState(!1),[V,O]=m.useState(null),K=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var q,le,re,j;const E=await Yr();if(E&&(E.framing&&r(E.framing),E.organizationName&&o(E.organizationName),E.siteUrl&&d(E.siteUrl),E.conformanceStatus&&c(E.conformanceStatus),(q=E.contact)!=null&&q.email&&h(E.contact.email),(le=E.contact)!=null&&le.phone&&g(E.contact.phone),(re=E.contact)!=null&&re.formUrl&&S(E.contact.formUrl),E.countryCode&&y(E.countryCode),E.language&&f(E.language),E.auditedBy&&T(E.auditedBy),E.wcagVersion&&U(E.wcagVersion),E.wcagLevel&&_(E.wcagLevel)),!(E!=null&&E.siteUrl)&&((j=a[0])!=null&&j.pageUrl))try{const R=new URL(a[0].pageUrl);d(`${R.protocol}//${R.host}/`)}catch{}E!=null&&E.conformanceStatus||c(wa(a)),setTimeout(()=>{var R;return(R=K.current)==null?void 0:R.focus()},50)})()},[t,a]),!t)return null;function F(){var re;const E=new Date().toISOString().slice(0,10),q=(re=a[0])!=null&&re.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):E,le={};return p.trim()&&(le.email=p.trim()),x.trim()&&(le.phone=x.trim()),k.trim()&&(le.formUrl=k.trim()),{framing:n,organizationName:i.trim(),siteUrl:l.trim(),conformanceStatus:u,preparedAt:E,evaluatedAt:q,contact:le,countryCode:L||null,language:C.trim()||"English",auditedBy:N.trim()||"wcagcheckr (self-evaluation)",wcagVersion:v,wcagLevel:w}}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){O(null);const q=F(),le=Z(q);if(le){O(le);return}A(!0);try{await Jr(q);const re=await ee({type:"EXPORT_REQUEST",format:E==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:q}),j=(re==null?void 0:re.content)??"";if(!j||j.startsWith("# Accessibility statement — error")){O(j||"Export failed — no response.");return}try{await navigator.clipboard.writeText(j)}catch{}const R=new Blob([j],{type:E==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),M=URL.createObjectURL(R);window.open(M,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(M),6e4),s()}catch(re){O(re instanceof Error?re.message:String(re))}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:K,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=>d(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=>c(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:v,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:w,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:k,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:L,onChange:E=>y(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(ja).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: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=>T(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),V&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:V})]}),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:te,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:te?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void se("html"),disabled:te,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:te?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:te,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 Ws(){const t=b(j=>j.delta),s=b(j=>j.componentId),a=b(j=>j.results),n=b(j=>j.tier),r=b(j=>j.baselineList),i=b(j=>j.siteCrawlReport),[o,l]=m.useState(""),[d,u]=m.useState(""),[c,p]=m.useState(""),[h,x]=m.useState(""),[g,k]=m.useState(!1),[S,L]=m.useState(!1),[y,C]=m.useState(null),[f,N]=m.useState(null),[T,v]=m.useState(!1),[U,w]=m.useState(!1),[_,te]=m.useState(null),[A,V]=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(([j,R,M,W])=>{l(typeof j.data=="string"?j.data:""),u(typeof R.data=="string"?R.data:""),p(typeof M.data=="string"?M.data:""),x(typeof W.data=="string"?W.data:"")})},[]),m.useEffect(()=>pe("BADGE_CLICKED_EVENT",R=>{const M=`viol-row-${R.violationId}`,W=document.getElementById(M);W&&(W.scrollIntoView({behavior:"smooth",block:"center"}),W.classList.add("ring-2","ring-rose-500"),setTimeout(()=>W.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const j=await ne();j&&(U&&await de(j,{type:"BADGES_HIDE_REQUEST",tabId:j}).catch(()=>{}),A&&await de(j,{type:"HEATMAP_HIDE_REQUEST",tabId:j}).catch(()=>{}))})()},[]);async function O(){const j=await ne();if(!j){ce.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(U){await de(j,{type:"BADGES_HIDE_REQUEST",tabId:j}).catch(()=>{}),w(!1),te(null);return}const R={critical:4,serious:3,moderate:2,minor:1},M=new Map;for(const J of a)for(const B of J.violations)M.has(B.matchKey)||M.set(B.matchKey,B);const z=Array.from(M.values()).sort((J,B)=>R[B.impact]-R[J.impact]).map((J,B)=>({id:J.matchKey,index:B+1,selector:J.target.selector,impact:J.impact,ruleId:J.ruleId,wcagCriterion:J.wcagCriterion}));if(z.length===0){ce.polite("No violations to badge.");return}const P=await me(j,{type:"BADGES_SHOW_REQUEST",tabId:j,violations:z}).catch(()=>null);P&&(w(!0),te({rendered:P.rendered,requested:P.requested,clustered:P.clustered}),ce.polite(`${P.rendered} violation badges shown on the page.`))}async function K(){const j=await ne();if(!j){ce.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(A){await de(j,{type:"HEATMAP_HIDE_REQUEST",tabId:j}).catch(()=>{}),V(!1);return}const R=new Map;for(const z of a)for(const P of z.violations)R.has(P.matchKey)||R.set(P.matchKey,P);const M=Array.from(R.values()).map(z=>({selector:z.target.selector,impact:z.impact}));if(M.length===0){ce.polite("No violations to heatmap.");return}const W=await me(j,{type:"HEATMAP_SHOW_REQUEST",tabId:j,violations:M}).catch(()=>null);W&&(V(!0),ce.polite(`Heatmap shown with ${W.rendered} violation blobs.`))}const F=js(n,"exportJson"),Z=ks[n].maxBaselines,se=r.some(j=>j.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 j=a.flatMap(B=>B.violations),R=a.flatMap(B=>B.announcements??[]),M=a.flatMap(B=>B.focusEvents??[]),W=a[0],P=(await ee({type:"SETTINGS_GET",key:"stateMatrix"})).data??Ns;await ie({type:"BASELINE_SET",componentId:s,violations:j,announcements:R,focusEvents:M,snapshotMeta:{url:window.location.href,axeVersion:W.axeVersion,matrixConfig:P,capturedAt:new Date().toISOString()}});const J=await ee({type:"BASELINE_COMPARE",componentId:s,currentViolations:j,announcements:R,focusEvents:M,currentMatrix:P});b.getState().setDelta(J.delta),ce.polite(`Baseline saved for ${s}.`)}async function le(){if(!s||!se||!window.confirm(`Remove the saved baseline for "${s}"?
|
|
12
|
+
(Recorded with the dismissal so future you remembers the reasoning.)`,"");O!==null&&(await Fs(n,A,O||"(no reason given)",V),l(K=>K+1))}async function u(A){n&&(await Ps(n,A),l(V=>V+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 c=t.reduce((A,V)=>{var O;return A+(((O=V.announcements)==null?void 0:O.length)??0)},0),p=t.reduce((A,V)=>{var O;return A+(((O=V.focusEvents)==null?void 0:O.length)??0)},0),h=t.reduce((A,V)=>{var O;return A+(((O=V.focusEvents)==null?void 0:O.filter(K=>K.isFocusReset).length)??0)},0),x=Ht(t,Rr),g=Ht(t,Tr),k=x.length,S=g.length,L=((_=t[0])==null?void 0:_.readingOrderIssues)??[],y=((te=t[0])==null?void 0:te.tabOrderIssues)??[],C=L.filter(A=>!(Ce(A.selector)in r)),f=L.filter(A=>Ce(A.selector)in r),N=y.filter(A=>!(Ie(A.selector)in r)),T=y.filter(A=>Ie(A.selector)in r);if(c===0&&p===0&&k===0&&S===0&&C.length===0&&N.length===0&&f.length===0&&T.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const v=f.length+T.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[k," structural · ",S," form ·"," ",N.length," tab-order ·"," ",C.length," reading-order ·"," ",c," ",c===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"]}),v>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",v," dismissed"]})]}),N.length>0&&e.jsx(_r,{issues:N,onDismiss:d}),C.length>0&&e.jsx(Dr,{issues:C,onDismiss:d}),v>0&&e.jsx(Or,{dismissedReadingOrder:f,dismissedTabOrder:T,dismissals:r,onRestore:u}),k>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}),S>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(Lr,{delta:s}),t.map((A,V)=>{const O=A.announcements??[],K=A.focusEvents??[];return O.length===0&&K.length===0?null:e.jsx(Ur,{state:A.state,announcements:O,focusEvents:K},V)})]})}function Lr({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 Ht(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=Be(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 Ur({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:$r(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 _r({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 Dr({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 Or({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 d=`tab-order::${l.selector}`,u=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children: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(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,u=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children: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(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Mr={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 Fr({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(Ae,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Mr[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((d,u)=>e.jsx(Ae,{violation:d},u))})]})}function Pr(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 Gr={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function Vs({open:t,onClose:s,format:a,content:n,filename:r}){const i=da(new Blob([n]).size);function o(){ht(n,r),s()}function l(){pt(n),s()}return e.jsxs(fe,{open:t,onClose:s,title:Gr[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 Vr(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.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({...c,_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 c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.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(`
|
|
13
|
+
`),d=new URLSearchParams({title:i,body:l});let u=`${n}/issues/new?${d.toString()}`;return u.length>Kt&&(u=u.slice(0,Kt)),{url:u,title:i,body:l}}const qt=7800;function Wr(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.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({...c,_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 c of r)o.push(`Rule: ${c.ruleId} (${c.impact})`),o.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),o.push(`Description: ${c.description}`),o.push(`Selector: ${c.target.selector}`),o.push(`Found in state(s): ${c._states.join(", ")}`),c.helpUrl&&o.push(`More info: ${c.helpUrl}`),o.push(""),o.push(`HTML: ${c.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(`
|
|
14
|
+
`),d=new URLSearchParams({summary:i,description:l});let u=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return u.length>qt&&(u=u.slice(0,qt)),{url:u,summary:i,description:l}}const Qt=7800;function Br(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(k=>`${k.ruleId}::${k.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 d=l.join(`
|
|
15
|
+
`),u=new URLSearchParams({"[Title]":o,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${u.toString()}`;return c.length>Qt&&(c=c.slice(0,Qt)),{url:c,title:o,description:d}}const Yt=7800;function Hr(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.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({...c,_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 c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.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(`
|
|
16
|
+
`),d=new URLSearchParams({"issue[title]":i,"issue[description]":l});let u=`${n}/-/issues/new?${d.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"],zr=["wcag-component-auditor","wcag-forensic-log"];async function Kr(){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 zr)try{await qr(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 qr(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 Qr(){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 Yr(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[ot]:t})}function Jr({open:t,onClose:s,results:a}){const[n,r]=m.useState("eaa"),[i,o]=m.useState(""),[l,d]=m.useState(""),[u,c]=m.useState("partial"),[p,h]=m.useState(""),[x,g]=m.useState(""),[k,S]=m.useState(""),[L,y]=m.useState(""),[C,f]=m.useState("English"),[N,T]=m.useState("wcagcheckr (self-evaluation)"),[v,U]=m.useState("2.1"),[w,_]=m.useState("AA"),[te,A]=m.useState(!1),[V,O]=m.useState(null),K=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var q,le,re,j;const E=await Qr();if(E&&(E.framing&&r(E.framing),E.organizationName&&o(E.organizationName),E.siteUrl&&d(E.siteUrl),E.conformanceStatus&&c(E.conformanceStatus),(q=E.contact)!=null&&q.email&&h(E.contact.email),(le=E.contact)!=null&&le.phone&&g(E.contact.phone),(re=E.contact)!=null&&re.formUrl&&S(E.contact.formUrl),E.countryCode&&y(E.countryCode),E.language&&f(E.language),E.auditedBy&&T(E.auditedBy),E.wcagVersion&&U(E.wcagVersion),E.wcagLevel&&_(E.wcagLevel)),!(E!=null&&E.siteUrl)&&((j=a[0])!=null&&j.pageUrl))try{const R=new URL(a[0].pageUrl);d(`${R.protocol}//${R.host}/`)}catch{}E!=null&&E.conformanceStatus||c(wa(a)),setTimeout(()=>{var R;return(R=K.current)==null?void 0:R.focus()},50)})()},[t,a]),!t)return null;function F(){var re;const E=new Date().toISOString().slice(0,10),q=(re=a[0])!=null&&re.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):E,le={};return p.trim()&&(le.email=p.trim()),x.trim()&&(le.phone=x.trim()),k.trim()&&(le.formUrl=k.trim()),{framing:n,organizationName:i.trim(),siteUrl:l.trim(),conformanceStatus:u,preparedAt:E,evaluatedAt:q,contact:le,countryCode:L||null,language:C.trim()||"English",auditedBy:N.trim()||"wcagcheckr (self-evaluation)",wcagVersion:v,wcagLevel:w}}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){O(null);const q=F(),le=Z(q);if(le){O(le);return}A(!0);try{await Yr(q);const re=await ee({type:"EXPORT_REQUEST",format:E==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:q}),j=(re==null?void 0:re.content)??"";if(!j||j.startsWith("# Accessibility statement — error")){O(j||"Export failed — no response.");return}try{await navigator.clipboard.writeText(j)}catch{}const R=new Blob([j],{type:E==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),M=URL.createObjectURL(R);window.open(M,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(M),6e4),s()}catch(re){O(re instanceof Error?re.message:String(re))}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:K,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=>d(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=>c(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:v,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:w,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:k,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:L,onChange:E=>y(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(ja).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: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=>T(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),V&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:V})]}),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:te,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:te?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void se("html"),disabled:te,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:te?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:te,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 Ws(){const t=b(j=>j.delta),s=b(j=>j.componentId),a=b(j=>j.results),n=b(j=>j.tier),r=b(j=>j.baselineList),i=b(j=>j.siteCrawlReport),[o,l]=m.useState(""),[d,u]=m.useState(""),[c,p]=m.useState(""),[h,x]=m.useState(""),[g,k]=m.useState(!1),[S,L]=m.useState(!1),[y,C]=m.useState(null),[f,N]=m.useState(null),[T,v]=m.useState(!1),[U,w]=m.useState(!1),[_,te]=m.useState(null),[A,V]=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(([j,R,M,W])=>{l(typeof j.data=="string"?j.data:""),u(typeof R.data=="string"?R.data:""),p(typeof M.data=="string"?M.data:""),x(typeof W.data=="string"?W.data:"")})},[]),m.useEffect(()=>pe("BADGE_CLICKED_EVENT",R=>{const M=`viol-row-${R.violationId}`,W=document.getElementById(M);W&&(W.scrollIntoView({behavior:"smooth",block:"center"}),W.classList.add("ring-2","ring-rose-500"),setTimeout(()=>W.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const j=await ne();j&&(U&&await de(j,{type:"BADGES_HIDE_REQUEST",tabId:j}).catch(()=>{}),A&&await de(j,{type:"HEATMAP_HIDE_REQUEST",tabId:j}).catch(()=>{}))})()},[]);async function O(){const j=await ne();if(!j){ce.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(U){await de(j,{type:"BADGES_HIDE_REQUEST",tabId:j}).catch(()=>{}),w(!1),te(null);return}const R={critical:4,serious:3,moderate:2,minor:1},M=new Map;for(const J of a)for(const B of J.violations)M.has(B.matchKey)||M.set(B.matchKey,B);const z=Array.from(M.values()).sort((J,B)=>R[B.impact]-R[J.impact]).map((J,B)=>({id:J.matchKey,index:B+1,selector:J.target.selector,impact:J.impact,ruleId:J.ruleId,wcagCriterion:J.wcagCriterion}));if(z.length===0){ce.polite("No violations to badge.");return}const P=await me(j,{type:"BADGES_SHOW_REQUEST",tabId:j,violations:z}).catch(()=>null);P&&(w(!0),te({rendered:P.rendered,requested:P.requested,clustered:P.clustered}),ce.polite(`${P.rendered} violation badges shown on the page.`))}async function K(){const j=await ne();if(!j){ce.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(A){await de(j,{type:"HEATMAP_HIDE_REQUEST",tabId:j}).catch(()=>{}),V(!1);return}const R=new Map;for(const z of a)for(const P of z.violations)R.has(P.matchKey)||R.set(P.matchKey,P);const M=Array.from(R.values()).map(z=>({selector:z.target.selector,impact:z.impact}));if(M.length===0){ce.polite("No violations to heatmap.");return}const W=await me(j,{type:"HEATMAP_SHOW_REQUEST",tabId:j,violations:M}).catch(()=>null);W&&(V(!0),ce.polite(`Heatmap shown with ${W.rendered} violation blobs.`))}const F=js(n,"exportJson"),Z=ks[n].maxBaselines,se=r.some(j=>j.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 j=a.flatMap(B=>B.violations),R=a.flatMap(B=>B.announcements??[]),M=a.flatMap(B=>B.focusEvents??[]),W=a[0],P=(await ee({type:"SETTINGS_GET",key:"stateMatrix"})).data??Ns;await ie({type:"BASELINE_SET",componentId:s,violations:j,announcements:R,focusEvents:M,snapshotMeta:{url:window.location.href,axeVersion:W.axeVersion,matrixConfig:P,capturedAt:new Date().toISOString()}});const J=await ee({type:"BASELINE_COMPARE",componentId:s,currentViolations:j,announcements:R,focusEvents:M,currentMatrix:P});b.getState().setDelta(J.delta),ce.polite(`Baseline saved for ${s}.`)}async function le(){if(!s||!se||!window.confirm(`Remove the saved baseline for "${s}"?
|
|
17
17
|
|
|
18
|
-
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await ie({type:"BASELINE_DELETE",componentId:s});const R=a.flatMap(J=>J.violations),M=a.flatMap(J=>J.announcements??[]),W=a.flatMap(J=>J.focusEvents??[]),z=await ee({type:"BASELINE_COMPARE",componentId:s,currentViolations:R,announcements:M,focusEvents:W});b.getState().setDelta(z.delta);const P=await ee({type:"BASELINE_LIST"});b.getState().setBaselineList(P.items),ce.polite(`Baseline cleared for ${s}.`)}async function re(j,R=!1){if(a.length===0)return;if(j==="ai-prompt"){const{copyAiFixerPrompt:D}=await gt(async()=>{const{copyAiFixerPrompt:X}=await import("./copy-ai-fixer-prompt-CepjvZn4.js");return{copyAiFixerPrompt:X}},__vite__mapDeps([0,1,2]));await D({results:a,componentId:s,delta:R?void 0:t,siteCrawlReport:i});return}let M;if((j==="defense-bundle"||j==="evidence-bundle"||j==="deposition-packet")&&s){const D=await chrome.storage.local.get("igtRuns"),Q=((D==null?void 0:D.igtRuns)??{})[s]??{};M=Object.values(Q)}const P=await ee({type:"EXPORT_REQUEST",format:j,results:a,delta:R?void 0:t??void 0,manualRuns:M,dismissedKeys:void 0,incompleteResolutions:void 0});if(j==="defense-bundle"||j==="evidence-bundle"||j==="deposition-packet"){const D=xs(j,s);await gs()?mt(P.content,D):N({open:!0,format:j,content:P.content,filename:D});return}if(j==="html-print"||j==="vpat"||j==="methodology-doc"||j==="conformance-crosswalk"||j==="executive-report"){ht(P.content);return}const J=j==="json"?"application/json":j==="sarif"?"application/sarif+json":j==="ticket-bundle"?"text/markdown":"application/xml",B=j==="junit"?"xml":j==="ticket-bundle"?"md":j,I=new Blob([P.content],{type:J}),G=URL.createObjectURL(I),H=document.createElement("a");H.href=G,H.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${B}`,H.click(),URL.revokeObjectURL(G)}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:le,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:()=>k(!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 O(),"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&&_&&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 K(),"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(ni,{disabled:!F,onExport:re,onAccessibilityStatement:()=>v(!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 j=Xe(t.new),R=Xe(t.persistent),M=Xe(t.fixed),W=[...j.review,...R.review];return e.jsxs(e.Fragment,{children:[e.jsx(ye,{title:"New",violations:j.findings,count:j.findings.length,accent:"red",actions:[...o&&j.findings.length>0?[{label:"File GitHub issue",onClick:()=>ei(o,s,j.findings)}]:[],...d&&j.findings.length>0?[{label:"File Jira issue",onClick:()=>ti(d,s,j.findings)}]:[],...c&&j.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>si(c,s,j.findings)}]:[],...h&&j.findings.length>0?[{label:"File GitLab issue",onClick:()=>ai(h,s,j.findings)}]:[]]}),e.jsx(ye,{title:"Persistent",violations:R.findings,count:R.findings.length,accent:"slate"}),e.jsx(ye,{title:"Fixed",violations:M.findings,count:t.fixedCount,accent:"green"}),W.length>0&&e.jsx(ye,{title:"Needs review (does not affect grade)",violations:W,count:W.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ye,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),f&&e.jsx(Vs,{open:f.open,onClose:()=>N(null),format:f.format,content:f.content,filename:f.filename}),e.jsx(Xr,{open:T,onClose:()=>v(!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"})]})]}),y&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",y.chromeStorageKeysCleared," chrome.storage key",y.chromeStorageKeysCleared===1?"":"s"," + ",y.indexedDbsCleared.length," database",y.indexedDbsCleared.length===1?"":"s",".",y.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",y.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:y?e.jsx("button",{type:"button",onClick:()=>{k(!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:()=>k(!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()=>{L(!0);try{const j=await qr();C(j),await He(),ce.polite("Audit data reset. Ready for a fresh scan.")}catch(j){C({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[j instanceof Error?j.message:String(j)]})}finally{L(!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 Zr={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 ye({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 ${Zr[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):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(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),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((d,u)=>e.jsx(Ae,{violation:d,alreadyAcknowledged:!0},u)):Gr(s).map(d=>e.jsx(Pr,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function ei(t,s,a){if(a.length===0)return;const{url:n}=Wr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function ti(t,s,a){if(a.length===0)return;const{url:n}=Br(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function si(t,s,a){if(a.length===0)return;const{url:n}=Hr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function ai(t,s,a){if(a.length===0)return;const{url:n}=zr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function ni({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=m.useState(!1),[o,l]=m.useState(!1);function d(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:()=>d("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ue,{onClick:()=>d("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ue,{onClick:()=>d("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>d("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ue,{onClick:()=>d("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ue,{onClick:()=>d("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ue,{onClick:()=>d("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx(ue,{onClick:()=>d("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(ue,{onClick:()=>d("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(ue,{onClick:()=>d("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>d("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ue,{onClick:()=>d("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx(ue,{onClick:()=>d("executive-report"),title:"Single-page executive HTML report: grade hero, top 3 risks, recommended next steps. Print-ready (Ctrl+P → Save as PDF). For stakeholder distribution rather than developer remediation.",children:"Executive report 📊"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(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 ri="2024-07-25",ii="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.",Bs=[{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(Bs.flatMap(t=>t.wcag2Criteria));function oi(t,s){return Bs.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 li={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Hs(){const t=b(d=>d.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 d of t){for(const c of d.violations)s.add(c.wcagCriterion);const u=d.axeRulesEvaluated;if(u){for(const c of u.passed)a.add(c.wcagCriterion);for(const c of u.inapplicable)a.add(c.wcagCriterion);for(const c of u.incomplete)a.add(c.wcagCriterion)}for(const c of d.violations)a.add(c.wcagCriterion)}const n=oi(s,a),r=new Map;for(const d of n){const u=r.get(d.outcome.category)??[];u.push(d),r.set(d.outcome.category,u)}const i=n.filter(d=>d.status==="clean").length,o=n.filter(d=>d.status==="has-violations").length,l=n.filter(d=>d.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:ri}),"."," ",ii]})]}),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(d=>{const u=r.get(d)??[];return e.jsxs("section",{className:"border border-slate-200 rounded bg-white","data-testid":`wcag3-category-${d}`,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:[li[d]," · ",u.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:u.map(c=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(ci,{status:c.status}),e.jsx("strong",{className:"text-xs",children:c.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:c.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",c.outcome.wcag2Criteria.join(", ")]}),c.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:c.violatedCriteria.join(", ")})]})]},c.outcome.id))})]},d)})]})}function ci({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}const di=[{id:"overview",label:"Overview",hint:"Verification areas + WCAG coverage + evidence layers"},{id:"per-area",label:"Per-area",hint:"Drill into the 9 verification areas"},{id:"violations",label:"Violations",hint:"Flat list of every unique finding"},{id:"activity",label:"Activity",hint:"Live regions · focus events · tab/reading order"},{id:"delta",label:"Delta",hint:"Compared to the last accepted baseline"},{id:"wcag3",label:"WCAG 3",hint:"Forward-looking projection on the WCAG 3 outcome map"}],ui={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function pi(){const t=b(c=>c.results),s=b(c=>c.componentId),a=b(c=>c.findingsLens),n=b(c=>c.setFindingsLens),r=b(c=>c.setView),i=b(c=>c.status),[o,l]=m.useState({});m.useEffect(()=>{if(!s)return;let c=!1;return(async()=>{const p=await bs(s);if(c)return;const h={};for(const x of p)x.criterionId==="2.4.3"?h.focusOrder=x.verdict:x.criterionId==="2.1.2"?h.keyboardTrap=x.verdict:x.criterionId==="2.4.7"&&(h.focusVisible=x.verdict);l(h)})(),()=>{c=!0}},[s]);const[d,u]=m.useState([]);return m.useEffect(()=>{if(!s){u([]);return}let c=!1;return chrome.storage.local.get("igtRuns").then(p=>{if(c)return;const x=((p==null?void 0:p.igtRuns)??{})[s]??{};u(Object.values(x))}),()=>{c=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(Xt,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:i==="running"?"Audit in progress. Findings appear here when the matrix completes.":i==="failed"||i==="interrupted"?"Last audit didn't complete. Re-run the scan from the controls above.":"No audit results yet. Run a scan from the controls above."})})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(Xt,{setView:r}),e.jsx(hi,{results:t,interactiveVerdicts:o,manualRuns:d}),e.jsx(mi,{lens:a,setLens:n}),e.jsx(xi,{lens:a,results:t,componentId:s,interactiveVerdicts:o})]})}function Xt({setView:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>t("matrix"),className:"text-xs text-slate-600 hover:text-slate-900 hover:underline font-mono px-0.5",children:"← Dashboard"}),e.jsx("span",{className:"text-[11px] font-mono uppercase tracking-widest text-slate-400",children:"findings"})]})}function hi({results:t,interactiveVerdicts:s,manualRuns:a}){var c,p,h,x;const n=t.flatMap(g=>g.violations),r=We(n),o=ze({violations:n,auditRan:!0,manualRuns:a,workflows:oe,heuristicCounts:{tabOrder:((p=(c=t[0])==null?void 0:c.tabOrderIssues)==null?void 0:p.length)??0,readingOrder:((x=(h=t[0])==null?void 0:h.readingOrderIssues)==null?void 0:x.length)??0},interactiveAuditVerdicts:s}).overallLetter,l=r.length,d=t.length,u=t.reduce((g,k)=>g+k.durationMs,0);return e.jsx("section",{className:"sticky top-0 z-10 border border-slate-200 rounded-lg bg-white overflow-hidden shadow-sm","aria-label":"Audit grade summary",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${ui[o]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:o})}),e.jsxs("div",{className:"flex-1 px-3.5 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"overall grade · 9 verification areas"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:l===0?"No issues found by automation":`${l} issue${l===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[d," state",d===1?"":"s"," tested · ",(u/1e3).toFixed(1),"s"]})]})]})})}function mi({lens:t,setLens:s}){return e.jsx("nav",{className:"flex flex-wrap gap-1 border-b border-slate-200 pb-1.5",role:"tablist","aria-label":"Findings lens",children:di.map(a=>{const n=t===a.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>s(a.id),title:a.hint,className:n?"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md bg-slate-900 text-white":"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md text-slate-600 hover:bg-slate-100",children:a.label},a.id)})})}function xi({lens:t,results:s,componentId:a,interactiveVerdicts:n}){return t==="overview"?e.jsx(Wn,{violations:s.flatMap(r=>r.violations),componentId:a,hideOverallHeader:!0}):t==="per-area"?e.jsx(Sr,{results:s,interactiveVerdicts:n}):t==="violations"?e.jsx(gi,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Gs,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ws,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Hs,{})}):null}const Zt={critical:0,serious:1,moderate:2,minor:3};function es(t){return`${Be(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function gi({results:t}){const s=new Set,a=[];for(const n of t)for(const r of n.violations){const i=es(r);s.has(i)||(s.add(i),a.push(r))}return a.sort((n,r)=>{const i=Zt[n.impact]??99,o=Zt[r.impact]??99;return i-o}),a.length===0?e.jsxs("div",{className:"text-center text-sm text-slate-600 py-6",children:["No automation-detectable violations found across ",t.length," state",t.length===1?"":"s",". Switch to ",e.jsx("strong",{children:"Per-area"})," or"," ",e.jsx("strong",{children:"Activity"})," for heuristic findings axe doesn't cover."]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[a.length," unique violation",a.length===1?"":"s"," · sorted by impact"]}),a.map(n=>e.jsx(Ae,{violation:n},es(n)))]})}const ct="igtRuns";async function fi(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 Ee(r,o.map(l=>({key:Ie(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 Ee(r,o.map(l=>({key:Ce(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const bi={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"}},vi={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"}},yi={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ts(t,s){const a=await ne();if(!a)return;const n=s?bi[t]:vi[t];try{await de(a,n)}catch{}}async function wi(){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 ji(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 Ni(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=m.useState({}),[r,i]=m.useState(null);if(m.useEffect(()=>{wi().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(c,p,h){var g;const x={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((g=o[c])==null?void 0:g.steps)??{},[p]:h},completedAt:new Date().toISOString()}}};if(n(x),ss(x),h.status==="pass"){const k=oe.find(L=>L.id===c),S=k==null?void 0:k.steps.find(L=>L.id===p);S!=null&&S.autoDismissActivity&&fi(S.autoDismissActivity,s,p)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[c];const h={...a,[t]:p};n(h),ss(h)}const u=oe.find(c=>c.id===r);if(u){const c=o[u.id];return e.jsx(ki,{workflow:u,run:c,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."}),oe.map(c=>{const p=o[c.id],h=p?Na(p,c):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(c.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:c.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),p&&e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function ki({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=m.useMemo(()=>{const d={};for(const u of t.steps)d[u.id]=ji(u,a);return d},[t,a]);function o(){for(const d of t.steps){const u=i[d.id];(u==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`})}}const l=t.steps.filter(d=>{var u;return((u=i[d.id])==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),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((d,u)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[u+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const p=i[d.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."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.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."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.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})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ts(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",yi[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ts(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(Te,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(Te,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(Te,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:p=>n(d.id,{status:c.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const Si={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 Te({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?Si[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Oe="savedFlows";async function Ai(){const t=await chrome.storage.local.get(Oe);return Array.isArray(t[Oe])?t[Oe]:[]}async function as(t){await chrome.storage.local.set({[Oe]:t})}function Ci(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,i]=m.useState(null);m.useEffect(()=>{Ai().then(s)},[]);async function o(){const c=await ne();if(!c){i("No audit-target tab found.");return}try{await de(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await ne();if(c)try{const p=await me(c,{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 d(c){const p=await ne();if(p){i(`Replaying "${c.name}"…`);try{const h=await me(p,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function u(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(h=>h.id!==c);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(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>u(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function Ii(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(d=>d.split("-").map(Ei).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function Ei(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Ri(){const t=b(l=>l.baselineList),s=b(l=>l.tier),a=ks[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 ie({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 d=Ii(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:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[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 Ti={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 ${Ti[t]}`,children:a})}const $i={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"},Li={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Ui={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 zs({onBack:t}){const s=b(p=>p.siteCrawlStatus),a=b(p=>p.siteCrawlProgress),n=b(p=>p.siteCrawlReport),r=b(p=>p.siteCrawlError),[i,o]=m.useState(""),[l,d]=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?`)||(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),he({type:"START_SITE_CRAWL",startUrl:i,maxPages:l})))}function c(){ie({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=>d(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:c,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(_i,{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 _i({report:t}){function s(){gt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-DYC7h4wW.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"}),d=URL.createObjectURL(l);window.open(d,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(d),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"}),d=URL.createObjectURL(l);window.open(d,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(d),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${$i[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Li[t.siteRisk]}`,children:ka[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=Sa(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 ${Ui[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 Di(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 Di(t){try{const s=await Aa(),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){b.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{}}b.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 Oi(){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(fe,{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 Mi(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Fi(){const t=b(d=>d.aiFailure),s=b(d=>d.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",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(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,u)=>e.jsx("li",{children:d},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),b.getState().setStatus("idle"))}),[]),e.jsxs(fe,{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 Pi(){var i;const[t,s]=m.useState(null);if(m.useEffect(()=>{Ca().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await St(),b.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 St(),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 Gi(){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 ne();if(o)try{const u=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(p=c.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(c=>{var p;return(p=c.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 Vi(){var i;const t=b(o=>o.results),s=b(o=>o.baselineList),a=b(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 ${Wi(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 Wi(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 Bi(){const t=b(l=>l.results),s=b(l=>l.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=Ia(r,a.length>0?{runs:a,workflows:oe}: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 Hi(){const t=b(a=>a.setUserMode);function s(a){t(a),ie({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 zi=["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"],Ki={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 qi(t){const s=new Set(zi),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,u])=>({ruleId:d,instanceCount:u})).sort((d,u)=>u.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,u)=>d+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:Ki[o]}}const Ks={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Qi={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ks]},Yi={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ks]};function bt(t){return t==="thorough"?Yi:Qi}function rs(t){const s=bt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Me="wcagcheckr";function Y(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Se(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 Ji(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Xi(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 Zi(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 eo(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 to(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 (${Y(t.receipt.tsaName)}) — anchored ${Y(Se(t.receipt.anchoredAt))}</td></tr>
|
|
18
|
+
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await ie({type:"BASELINE_DELETE",componentId:s});const R=a.flatMap(J=>J.violations),M=a.flatMap(J=>J.announcements??[]),W=a.flatMap(J=>J.focusEvents??[]),z=await ee({type:"BASELINE_COMPARE",componentId:s,currentViolations:R,announcements:M,focusEvents:W});b.getState().setDelta(z.delta);const P=await ee({type:"BASELINE_LIST"});b.getState().setBaselineList(P.items),ce.polite(`Baseline cleared for ${s}.`)}async function re(j,R=!1){if(a.length===0)return;if(j==="ai-prompt"){const{copyAiFixerPrompt:D}=await xt(async()=>{const{copyAiFixerPrompt:X}=await import("./copy-ai-fixer-prompt-DzNGWBbi.js");return{copyAiFixerPrompt:X}},__vite__mapDeps([0,1,2]));await D({results:a,componentId:s,delta:R?void 0:t,siteCrawlReport:i});return}let M;if((j==="defense-bundle"||j==="evidence-bundle"||j==="deposition-packet")&&s){const D=await chrome.storage.local.get("igtRuns"),Q=((D==null?void 0:D.igtRuns)??{})[s]??{};M=Object.values(Q)}const P=await ee({type:"EXPORT_REQUEST",format:j,results:a,delta:R?void 0:t??void 0,manualRuns:M,dismissedKeys:void 0,incompleteResolutions:void 0});if(j==="defense-bundle"||j==="evidence-bundle"||j==="deposition-packet"){const D=xs(j,s);await gs()?ht(P.content,D):N({open:!0,format:j,content:P.content,filename:D});return}if(j==="html-print"||j==="vpat"||j==="methodology-doc"||j==="conformance-crosswalk"||j==="executive-report"){pt(P.content);return}const J=j==="json"?"application/json":j==="sarif"?"application/sarif+json":j==="ticket-bundle"?"text/markdown":"application/xml",B=j==="junit"?"xml":j==="ticket-bundle"?"md":j,I=new Blob([P.content],{type:J}),G=URL.createObjectURL(I),H=document.createElement("a");H.href=G,H.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${B}`,H.click(),URL.revokeObjectURL(G)}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:le,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:()=>k(!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 O(),"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&&_&&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 K(),"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(ai,{disabled:!F,onExport:re,onAccessibilityStatement:()=>v(!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 j=Je(t.new),R=Je(t.persistent),M=Je(t.fixed),W=[...j.review,...R.review];return e.jsxs(e.Fragment,{children:[e.jsx(ye,{title:"New",violations:j.findings,count:j.findings.length,accent:"red",actions:[...o&&j.findings.length>0?[{label:"File GitHub issue",onClick:()=>Zr(o,s,j.findings)}]:[],...d&&j.findings.length>0?[{label:"File Jira issue",onClick:()=>ei(d,s,j.findings)}]:[],...c&&j.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>ti(c,s,j.findings)}]:[],...h&&j.findings.length>0?[{label:"File GitLab issue",onClick:()=>si(h,s,j.findings)}]:[]]}),e.jsx(ye,{title:"Persistent",violations:R.findings,count:R.findings.length,accent:"slate"}),e.jsx(ye,{title:"Fixed",violations:M.findings,count:t.fixedCount,accent:"green"}),W.length>0&&e.jsx(ye,{title:"Needs review (does not affect grade)",violations:W,count:W.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ye,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),f&&e.jsx(Vs,{open:f.open,onClose:()=>N(null),format:f.format,content:f.content,filename:f.filename}),e.jsx(Jr,{open:T,onClose:()=>v(!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"})]})]}),y&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",y.chromeStorageKeysCleared," chrome.storage key",y.chromeStorageKeysCleared===1?"":"s"," + ",y.indexedDbsCleared.length," database",y.indexedDbsCleared.length===1?"":"s",".",y.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",y.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:y?e.jsx("button",{type:"button",onClick:()=>{k(!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:()=>k(!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()=>{L(!0);try{const j=await Kr();C(j),await He(),ce.polite("Audit data reset. Ready for a fresh scan.")}catch(j){C({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[j instanceof Error?j.message:String(j)]})}finally{L(!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 Xr={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 ye({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 ${Xr[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):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(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),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((d,u)=>e.jsx(Ae,{violation:d,alreadyAcknowledged:!0},u)):Pr(s).map(d=>e.jsx(Fr,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Zr(t,s,a){if(a.length===0)return;const{url:n}=Vr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function ei(t,s,a){if(a.length===0)return;const{url:n}=Wr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function ti(t,s,a){if(a.length===0)return;const{url:n}=Br(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function si(t,s,a){if(a.length===0)return;const{url:n}=Hr(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function ai({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=m.useState(!1),[o,l]=m.useState(!1);function d(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:()=>d("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ue,{onClick:()=>d("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ue,{onClick:()=>d("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>d("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ue,{onClick:()=>d("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ue,{onClick:()=>d("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ue,{onClick:()=>d("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx(ue,{onClick:()=>d("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(ue,{onClick:()=>d("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(ue,{onClick:()=>d("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>d("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ue,{onClick:()=>d("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx(ue,{onClick:()=>d("executive-report"),title:"Single-page executive HTML report: grade hero, top 3 risks, recommended next steps. Print-ready (Ctrl+P → Save as PDF). For stakeholder distribution rather than developer remediation.",children:"Executive report 📊"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(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 ni="2024-07-25",ri="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.",Bs=[{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(Bs.flatMap(t=>t.wcag2Criteria));function ii(t,s){return Bs.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 oi={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Hs(){const t=b(d=>d.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 d of t){for(const c of d.violations)s.add(c.wcagCriterion);const u=d.axeRulesEvaluated;if(u){for(const c of u.passed)a.add(c.wcagCriterion);for(const c of u.inapplicable)a.add(c.wcagCriterion);for(const c of u.incomplete)a.add(c.wcagCriterion)}for(const c of d.violations)a.add(c.wcagCriterion)}const n=ii(s,a),r=new Map;for(const d of n){const u=r.get(d.outcome.category)??[];u.push(d),r.set(d.outcome.category,u)}const i=n.filter(d=>d.status==="clean").length,o=n.filter(d=>d.status==="has-violations").length,l=n.filter(d=>d.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:ni}),"."," ",ri]})]}),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(d=>{const u=r.get(d)??[];return e.jsxs("section",{className:"border border-slate-200 rounded bg-white","data-testid":`wcag3-category-${d}`,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:[oi[d]," · ",u.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:u.map(c=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(li,{status:c.status}),e.jsx("strong",{className:"text-xs",children:c.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:c.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",c.outcome.wcag2Criteria.join(", ")]}),c.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:c.violatedCriteria.join(", ")})]})]},c.outcome.id))})]},d)})]})}function li({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}const ci=[{id:"overview",label:"Overview",hint:"Verification areas + WCAG coverage + evidence layers"},{id:"per-area",label:"Per-area",hint:"Drill into the 9 verification areas"},{id:"violations",label:"Violations",hint:"Flat list of every unique finding"},{id:"activity",label:"Activity",hint:"Live regions · focus events · tab/reading order"},{id:"delta",label:"Delta",hint:"Compared to the last accepted baseline"},{id:"wcag3",label:"WCAG 3",hint:"Forward-looking projection on the WCAG 3 outcome map"}],di={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function ui(){const t=b(c=>c.results),s=b(c=>c.componentId),a=b(c=>c.findingsLens),n=b(c=>c.setFindingsLens),r=b(c=>c.setView),i=b(c=>c.status),[o,l]=m.useState({});m.useEffect(()=>{if(!s)return;let c=!1;return(async()=>{const p=await bs(s);if(c)return;const h={};for(const x of p)x.criterionId==="2.4.3"?h.focusOrder=x.verdict:x.criterionId==="2.1.2"?h.keyboardTrap=x.verdict:x.criterionId==="2.4.7"&&(h.focusVisible=x.verdict);l(h)})(),()=>{c=!0}},[s]);const[d,u]=m.useState([]);return m.useEffect(()=>{if(!s){u([]);return}let c=!1;return chrome.storage.local.get("igtRuns").then(p=>{if(c)return;const x=((p==null?void 0:p.igtRuns)??{})[s]??{};u(Object.values(x))}),()=>{c=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(Xt,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:i==="running"?"Audit in progress. Findings appear here when the matrix completes.":i==="failed"||i==="interrupted"?"Last audit didn't complete. Re-run the scan from the controls above.":"No audit results yet. Run a scan from the controls above."})})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(Xt,{setView:r}),e.jsx(pi,{results:t,interactiveVerdicts:o,manualRuns:d}),e.jsx(hi,{lens:a,setLens:n}),e.jsx(mi,{lens:a,results:t,componentId:s,interactiveVerdicts:o})]})}function Xt({setView:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>t("matrix"),className:"text-xs text-slate-600 hover:text-slate-900 hover:underline font-mono px-0.5",children:"← Dashboard"}),e.jsx("span",{className:"text-[11px] font-mono uppercase tracking-widest text-slate-400",children:"findings"})]})}function pi({results:t,interactiveVerdicts:s,manualRuns:a}){var c,p,h,x;const n=t.flatMap(g=>g.violations),r=We(n),o=gt({violations:n,auditRan:!0,manualRuns:a,workflows:oe,heuristicCounts:{tabOrder:((p=(c=t[0])==null?void 0:c.tabOrderIssues)==null?void 0:p.length)??0,readingOrder:((x=(h=t[0])==null?void 0:h.readingOrderIssues)==null?void 0:x.length)??0},interactiveAuditVerdicts:s}).overallLetter,l=r.length,d=t.length,u=t.reduce((g,k)=>g+k.durationMs,0);return e.jsx("section",{className:"sticky top-0 z-10 border border-slate-200 rounded-lg bg-white overflow-hidden shadow-sm","aria-label":"Audit grade summary",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${di[o]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:o})}),e.jsxs("div",{className:"flex-1 px-3.5 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"overall grade · 9 verification areas"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:l===0?"No issues found by automation":`${l} issue${l===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[d," state",d===1?"":"s"," tested · ",(u/1e3).toFixed(1),"s"]})]})]})})}function hi({lens:t,setLens:s}){return e.jsx("nav",{className:"flex flex-wrap gap-1 border-b border-slate-200 pb-1.5",role:"tablist","aria-label":"Findings lens",children:ci.map(a=>{const n=t===a.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>s(a.id),title:a.hint,className:n?"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md bg-slate-900 text-white":"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md text-slate-600 hover:bg-slate-100",children:a.label},a.id)})})}function mi({lens:t,results:s,componentId:a,interactiveVerdicts:n}){return t==="overview"?e.jsx(Vn,{violations:s.flatMap(r=>r.violations),componentId:a,hideOverallHeader:!0}):t==="per-area"?e.jsx(kr,{results:s,interactiveVerdicts:n}):t==="violations"?e.jsx(xi,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Gs,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ws,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Hs,{})}):null}const Zt={critical:0,serious:1,moderate:2,minor:3};function es(t){return`${Be(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function xi({results:t}){const s=new Set,a=[];for(const n of t)for(const r of n.violations){const i=es(r);s.has(i)||(s.add(i),a.push(r))}return a.sort((n,r)=>{const i=Zt[n.impact]??99,o=Zt[r.impact]??99;return i-o}),a.length===0?e.jsxs("div",{className:"text-center text-sm text-slate-600 py-6",children:["No automation-detectable violations found across ",t.length," state",t.length===1?"":"s",". Switch to ",e.jsx("strong",{children:"Per-area"})," or"," ",e.jsx("strong",{children:"Activity"})," for heuristic findings axe doesn't cover."]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[a.length," unique violation",a.length===1?"":"s"," · sorted by impact"]}),a.map(n=>e.jsx(Ae,{violation:n},es(n)))]})}const lt="igtRuns";async function gi(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 Ee(r,o.map(l=>({key:Ie(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 Ee(r,o.map(l=>({key:Ce(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const fi={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"}},bi={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"}},vi={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ts(t,s){const a=await ne();if(!a)return;const n=s?fi[t]:bi[t];try{await de(a,n)}catch{}}async function yi(){const s=(await chrome.storage.local.get(lt))[lt];return s&&typeof s=="object"?s:{}}async function ss(t){await chrome.storage.local.set({[lt]:t})}function wi(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 ji(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=m.useState({}),[r,i]=m.useState(null);if(m.useEffect(()=>{yi().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(c,p,h){var g;const x={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((g=o[c])==null?void 0:g.steps)??{},[p]:h},completedAt:new Date().toISOString()}}};if(n(x),ss(x),h.status==="pass"){const k=oe.find(L=>L.id===c),S=k==null?void 0:k.steps.find(L=>L.id===p);S!=null&&S.autoDismissActivity&&gi(S.autoDismissActivity,s,p)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[c];const h={...a,[t]:p};n(h),ss(h)}const u=oe.find(c=>c.id===r);if(u){const c=o[u.id];return e.jsx(Ni,{workflow:u,run:c,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."}),oe.map(c=>{const p=o[c.id],h=p?Na(p,c):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(c.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:c.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),p&&e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function Ni({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=m.useMemo(()=>{const d={};for(const u of t.steps)d[u.id]=wi(u,a);return d},[t,a]);function o(){for(const d of t.steps){const u=i[d.id];(u==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`})}}const l=t.steps.filter(d=>{var u;return((u=i[d.id])==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),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((d,u)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[u+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const p=i[d.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."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.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."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.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})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ts(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",vi[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ts(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(Te,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(Te,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(Te,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:p=>n(d.id,{status:c.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const ki={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 Te({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?ki[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Oe="savedFlows";async function Si(){const t=await chrome.storage.local.get(Oe);return Array.isArray(t[Oe])?t[Oe]:[]}async function as(t){await chrome.storage.local.set({[Oe]:t})}function Ai(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,i]=m.useState(null);m.useEffect(()=>{Si().then(s)},[]);async function o(){const c=await ne();if(!c){i("No audit-target tab found.");return}try{await de(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await ne();if(c)try{const p=await me(c,{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 d(c){const p=await ne();if(p){i(`Replaying "${c.name}"…`);try{const h=await me(p,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function u(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(h=>h.id!==c);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(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>u(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function Ci(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(d=>d.split("-").map(Ii).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function Ii(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Ei(){const t=b(l=>l.baselineList),s=b(l=>l.tier),a=ks[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 ie({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 d=Ci(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:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[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 Ri={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 ${Ri[t]}`,children:a})}const Ti={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"},$i={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Li={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 zs({onBack:t}){const s=b(p=>p.siteCrawlStatus),a=b(p=>p.siteCrawlProgress),n=b(p=>p.siteCrawlReport),r=b(p=>p.siteCrawlError),[i,o]=m.useState(""),[l,d]=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?`)||(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),he({type:"START_SITE_CRAWL",startUrl:i,maxPages:l})))}function c(){ie({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=>d(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:c,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Ui,{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 Ui({report:t}){function s(){xt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-e3dEbloz.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"}),d=URL.createObjectURL(l);window.open(d,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(d),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"}),d=URL.createObjectURL(l);window.open(d,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(d),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Ti[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${$i[t.siteRisk]}`,children:ka[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=Sa(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 ${Li[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 _i(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 _i(t){try{const s=await Aa(),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){b.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{}}b.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 Di(){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(fe,{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 Oi(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Mi(){const t=b(d=>d.aiFailure),s=b(d=>d.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",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(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,u)=>e.jsx("li",{children:d},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),b.getState().setStatus("idle"))}),[]),e.jsxs(fe,{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 Fi(){var i;const[t,s]=m.useState(null);if(m.useEffect(()=>{Ca().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await St(),b.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 St(),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 Pi(){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 ne();if(o)try{const u=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(p=c.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(c=>{var p;return(p=c.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 Gi(){var i;const t=b(o=>o.results),s=b(o=>o.baselineList),a=b(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 ${Vi(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 Vi(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 Wi(){const t=b(l=>l.results),s=b(l=>l.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=Ia(r,a.length>0?{runs:a,workflows:oe}: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 Bi(){const t=b(a=>a.setUserMode);function s(a){t(a),ie({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 Hi=["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"],zi={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 Ki(t){const s=new Set(Hi),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,u])=>({ruleId:d,instanceCount:u})).sort((d,u)=>u.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,u)=>d+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:zi[o]}}const Ks={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},qi={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ks]},Qi={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ks]};function bt(t){return t==="thorough"?Qi:qi}function rs(t){const s=bt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Me="wcagcheckr";function Y(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Se(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 Yi(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Ji(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 Xi(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 Zi(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 eo(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 (${Y(t.receipt.tsaName)}) — anchored ${Y(Se(t.receipt.anchoredAt))}</td></tr>
|
|
19
19
|
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${Y(t.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
20
20
|
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${Y(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${Y(Me)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
|
|
21
21
|
<article class="entry">
|
|
22
22
|
<header class="entry-header">
|
|
23
|
-
<span class="grade-badge ${
|
|
23
|
+
<span class="grade-badge ${Zi(t.grade)}">${Y(t.grade)}</span>
|
|
24
24
|
<div class="entry-headline">
|
|
25
25
|
<div class="entry-time">${Y(Se(t.capturedAt))}</div>
|
|
26
26
|
<div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
|
|
@@ -34,15 +34,15 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
34
34
|
<tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
|
|
35
35
|
${n}
|
|
36
36
|
</table>
|
|
37
|
-
</article>`}function
|
|
37
|
+
</article>`}function to(t){return`
|
|
38
38
|
<section class="component-section">
|
|
39
39
|
<h2>
|
|
40
40
|
<span class="component-id">${Y(t.componentId)}</span>
|
|
41
41
|
<span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
|
|
42
42
|
</h2>
|
|
43
43
|
<p class="component-url"><strong>Page audited:</strong> <code>${Y(t.pageUrl)}</code></p>
|
|
44
|
-
${t.entries.map(
|
|
45
|
-
</section>`}function
|
|
44
|
+
${t.entries.map(eo).join("")}
|
|
45
|
+
</section>`}function so(t){const{entries:s,extensionVersion:a}=t,n=Xi(s),r=Ji(s),i=(t.axeVersions??Yi(s)).join(", "),o=s.length,l=s.filter(c=>c.receipt).length,d=o-l,u=Se(new Date().toISOString());return`<!doctype html>
|
|
46
46
|
<html lang="en">
|
|
47
47
|
<head>
|
|
48
48
|
<meta charset="utf-8" />
|
|
@@ -211,7 +211,7 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
211
211
|
<tr><th>Tool</th><td>${Y(Me)} ${Y(a)}</td></tr>
|
|
212
212
|
</table>
|
|
213
213
|
|
|
214
|
-
${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(
|
|
214
|
+
${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(to).join("")}
|
|
215
215
|
|
|
216
216
|
<section class="methodology">
|
|
217
217
|
<h2>Methodology</h2>
|
|
@@ -239,12 +239,12 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
239
239
|
<span>${o} audit${o===1?"":"s"} · ${l} anchored · ${n.length} component${n.length===1?"":"s"}</span>
|
|
240
240
|
</footer>
|
|
241
241
|
</body>
|
|
242
|
-
</html>`}async function no(t){const s=ao(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function qs(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,i]=m.useState(0),[o,l]=m.useState(!1),[d,u]=m.useState(""),[c,p]=m.useState(""),[h,x]=m.useState(""),[g,k]=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,L=t.filter(f=>f.receipt).length;async function y(){if(!(!t||t.length===0)){k(!0);try{await no({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),l(!1)}finally{k(!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"}),T=URL.createObjectURL(N),v=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,U=document.createElement("a");U.href=T,U.download=v,U.click(),setTimeout(()=>URL.revokeObjectURL(T),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",L>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[L," RFC 3161-anchored"]})]}),L===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:d,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:c,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:y,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 ro(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let d=!1;return vs().then(u=>{d||s(u)}).catch(()=>{d||s([])}),()=>{d=!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(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),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(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(fe,{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(qs,{})})})]})}function io(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const oo={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."},lo={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."},co={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},uo={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Qs(){const t=b(p=>p.tier),s=b(p=>p.trialDaysRemaining),a=b(p=>p.seatsUsed),n=b(p=>p.seatsTotal),r=b(p=>p.planCode),i=b(p=>p.licenseDaysRemaining),o=b(p=>p.pastDue),[l,d]=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:()=>d(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void ie({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(rt,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?uo:co,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,k=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 ${k.bg} border-b ${k.border} px-3 py-2 space-y-1 text-[11px] ${k.shadow}`,children:[e.jsxs("div",{className:k.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",p.label]}),e.jsxs("span",{className:k.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 ie({type:"OPEN_SETTINGS"}),className:k.link,children:"Manage license →"})})]})}const u=t==="trial"?oo:lo,c=t==="trial"?io(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:c})]}),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:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void ie({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:()=>d(!1)})]})}const po={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"},ho={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"},mo={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"},os={critical:0,serious:1,moderate:2,minor:3};function xo(){const t=b(p=>p.setUserMode),s=b(p=>p.status),a=b(p=>p.setStatus),n=b(p=>p.errorMessage),r=b(p=>p.setError),[i,o]=m.useState(!1),[l,d]=m.useState(!1),u=m.useRef(s);m.useEffect(()=>{if(u.current==="running"&&s==="complete"){d(!0);const p=setTimeout(()=>d(!1),3500);return u.current=s,()=>clearTimeout(p)}u.current=s},[s]),m.useEffect(()=>{if(s!=="running")return;const p=setTimeout(()=>{b.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 c(){t("dev"),ie({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(Qs,{}),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:c,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(go,{}),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:()=>{b.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(zs,{onBack:()=>o(!1)}):e.jsx(bo,{onPickCrawl:()=>o(!0)}),l&&e.jsx(fo,{})]}),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 go(){const t=b(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void ie({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 fo(){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 bo({onPickCrawl:t}){const s=b(p=>p.status),a=b(p=>p.results),[n,r]=m.useState("quick"),[i,o]=m.useState("all"),l=s==="running",d=a.flatMap(p=>p.violations),u=a.length>0;function c(){he({type:"START_AUDIT",mode:"full-page",matrixOverride:bt(n)}),b.getState().startNewScan(),ce.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:c,disabled: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(yo,{depth:n,onChange:r,disabled:l})]}),!u&&!l&&e.jsx(vo,{}),u&&e.jsx(wo,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function vo(){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 yo({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 wo({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var T;const r=b(v=>v.status),i=b(v=>v.results),o=b(v=>v.freshThisSession),l=b(v=>v.componentId),d=(T=i[0])==null?void 0:T.startedAt,u=qi(t),c=r==="running",[p,h]=m.useState([]);m.useEffect(()=>{if(!l){h([]);return}let v=!1;return chrome.storage.local.get("igtRuns").then(U=>{if(v)return;const _=((U==null?void 0:U.igtRuns)??{})[l]??{};h(Object.values(_))}),()=>{v=!0}},[l]);const x=b(v=>v.acknowledgedKeys),g=i.length>0?fs(i,{runs:p,workflows:oe},"2.1","AA",x):void 0;function k(){he({type:"START_AUDIT",mode:"full-page",matrixOverride:bt(n)}),b.getState().startNewScan(),ce.polite("Re-scanning this page now.")}const S=s==="lawsuit-risk"?t.filter(v=>v.impact==="critical"||v.impact==="serious"):t,L=new Map;for(const v of S){const U=Be(v.ruleId,v.target.selector);L.has(U)||L.set(U,v)}const y=Array.from(L.values()),C=new Map;for(const v of y){const U=C.get(v.ruleId)??[];U.push(v),C.set(v.ruleId,U)}const f=Array.from(C.entries()).sort((v,U)=>(os[v[1][0].impact]??99)-(os[U[1][0].impact]??99)),N=t.filter(v=>v.impact==="critical"||v.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Co,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void He(),disabled:c,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:k,disabled:c,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:c?"Scanning…":"↻ Scan again"})]})]}),c?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${po[u.tier]}`,children:[!o&&d&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ho[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."]})]})]})]}),!c&&g&&!g.canClaimConformance&&e.jsx(jo,{coverage:g}),!c&&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(Ao,{}),e.jsx(ro,{}),t.length>0&&e.jsx(No,{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(([v,U])=>e.jsx(ko,{ruleId:v,violations:U},v))]})]})}function jo({coverage:t}){const s=b(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),ie({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 No({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 ko({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=Ea(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,c=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 ${mo[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(So,{violation:h},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function So({violation:t}){const s=b(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 ne();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 $e=[{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 Ao(){const t=b(c=>c.results),s=b(c=>c.componentId),[a,n]=m.useState(null),[r,i]=m.useState(!1),[o,l]=m.useState(null);async function d(c,p){if(t.length!==0){n(c);try{const h=await ee({type:"EXPORT_REQUEST",format:c,results:t});if(c==="defense-bundle"||c==="evidence-bundle"){const x=xs(c,s);await gs()?mt(h.content,x):l({open:!0,format:c,content:h.content,filename:x})}else if(p)ht(h.content);else{try{await navigator.clipboard.writeText(h.content),ce.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
|
|
242
|
+
</html>`}async function ao(t){const s=so(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function qs(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,i]=m.useState(0),[o,l]=m.useState(!1),[d,u]=m.useState(""),[c,p]=m.useState(""),[h,x]=m.useState(""),[g,k]=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,L=t.filter(f=>f.receipt).length;async function y(){if(!(!t||t.length===0)){k(!0);try{await ao({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),l(!1)}finally{k(!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"}),T=URL.createObjectURL(N),v=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,U=document.createElement("a");U.href=T,U.download=v,U.click(),setTimeout(()=>URL.revokeObjectURL(T),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",L>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[L," RFC 3161-anchored"]})]}),L===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:d,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:c,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:y,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 no(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let d=!1;return vs().then(u=>{d||s(u)}).catch(()=>{d||s([])}),()=>{d=!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(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),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(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(fe,{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(qs,{})})})]})}function ro(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const io={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."},oo={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."},lo={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},co={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Qs(){const t=b(p=>p.tier),s=b(p=>p.trialDaysRemaining),a=b(p=>p.seatsUsed),n=b(p=>p.seatsTotal),r=b(p=>p.planCode),i=b(p=>p.licenseDaysRemaining),o=b(p=>p.pastDue),[l,d]=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:()=>d(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void ie({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(nt,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?co:lo,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,k=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 ${k.bg} border-b ${k.border} px-3 py-2 space-y-1 text-[11px] ${k.shadow}`,children:[e.jsxs("div",{className:k.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",p.label]}),e.jsxs("span",{className:k.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 ie({type:"OPEN_SETTINGS"}),className:k.link,children:"Manage license →"})})]})}const u=t==="trial"?io:oo,c=t==="trial"?ro(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:c})]}),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:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void ie({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:()=>d(!1)})]})}const uo={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},po={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"},ho={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 mo(){const t=b(p=>p.setUserMode),s=b(p=>p.status),a=b(p=>p.setStatus),n=b(p=>p.errorMessage),r=b(p=>p.setError),[i,o]=m.useState(!1),[l,d]=m.useState(!1),u=m.useRef(s);m.useEffect(()=>{if(u.current==="running"&&s==="complete"){d(!0);const p=setTimeout(()=>d(!1),3500);return u.current=s,()=>clearTimeout(p)}u.current=s},[s]),m.useEffect(()=>{if(s!=="running")return;const p=setTimeout(()=>{b.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 c(){t("dev"),ie({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(Qs,{}),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:c,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(xo,{}),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:()=>{b.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(zs,{onBack:()=>o(!1)}):e.jsx(fo,{onPickCrawl:()=>o(!0)}),l&&e.jsx(go,{})]}),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 xo(){const t=b(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void ie({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 go(){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 fo({onPickCrawl:t}){const s=b(p=>p.status),a=b(p=>p.results),[n,r]=m.useState("quick"),[i,o]=m.useState("all"),l=s==="running",d=a.flatMap(p=>p.violations),u=a.length>0;function c(){he({type:"START_AUDIT",mode:"full-page",matrixOverride:bt(n)}),b.getState().startNewScan(),ce.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:c,disabled: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(vo,{depth:n,onChange:r,disabled:l})]}),!u&&!l&&e.jsx(bo,{}),u&&e.jsx(yo,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function bo(){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 vo({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 yo({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var T;const r=b(v=>v.status),i=b(v=>v.results),o=b(v=>v.freshThisSession),l=b(v=>v.componentId),d=(T=i[0])==null?void 0:T.startedAt,u=Ki(t),c=r==="running",[p,h]=m.useState([]);m.useEffect(()=>{if(!l){h([]);return}let v=!1;return chrome.storage.local.get("igtRuns").then(U=>{if(v)return;const _=((U==null?void 0:U.igtRuns)??{})[l]??{};h(Object.values(_))}),()=>{v=!0}},[l]);const x=b(v=>v.acknowledgedKeys),g=i.length>0?fs(i,{runs:p,workflows:oe},"2.1","AA",x):void 0;function k(){he({type:"START_AUDIT",mode:"full-page",matrixOverride:bt(n)}),b.getState().startNewScan(),ce.polite("Re-scanning this page now.")}const S=s==="lawsuit-risk"?t.filter(v=>v.impact==="critical"||v.impact==="serious"):t,L=new Map;for(const v of S){const U=Be(v.ruleId,v.target.selector);L.has(U)||L.set(U,v)}const y=Array.from(L.values()),C=new Map;for(const v of y){const U=C.get(v.ruleId)??[];U.push(v),C.set(v.ruleId,U)}const f=Array.from(C.entries()).sort((v,U)=>(os[v[1][0].impact]??99)-(os[U[1][0].impact]??99)),N=t.filter(v=>v.impact==="critical"||v.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Ao,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void He(),disabled:c,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:k,disabled:c,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:c?"Scanning…":"↻ Scan again"})]})]}),c?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${uo[u.tier]}`,children:[!o&&d&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${po[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."]})]})]})]}),!c&&g&&!g.canClaimConformance&&e.jsx(wo,{coverage:g}),!c&&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(So,{}),e.jsx(no,{}),t.length>0&&e.jsx(jo,{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(([v,U])=>e.jsx(No,{ruleId:v,violations:U},v))]})]})}function wo({coverage:t}){const s=b(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),ie({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 jo({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 No({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=Ea(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,c=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 ${ho[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(ko,{violation:h},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function ko({violation:t}){const s=b(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 ne();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 $e=[{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 So(){const t=b(c=>c.results),s=b(c=>c.componentId),[a,n]=m.useState(null),[r,i]=m.useState(!1),[o,l]=m.useState(null);async function d(c,p){if(t.length!==0){n(c);try{const h=await ee({type:"EXPORT_REQUEST",format:c,results:t});if(c==="defense-bundle"||c==="evidence-bundle"){const x=xs(c,s);await gs()?ht(h.content,x):l({open:!0,format:c,content:h.content,filename:x})}else if(p)pt(h.content);else{try{await navigator.clipboard.writeText(h.content),ce.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
243
|
<style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
|
|
244
244
|
.banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
|
|
245
245
|
pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
|
|
246
246
|
<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>
|
|
247
|
-
<pre>${h.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`,k=new Blob([g],{type:"text/html"}),S=URL.createObjectURL(k);window.open(S,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(S),6e4)}}finally{n(null)}}}const u=r?$e:$e.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(c=>e.jsx("button",{type:"button",onClick:()=>void d(c.id,c.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:c.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:c.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:c.desc})]}),a===c.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},c.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",$e.length-2," more report option",$e.length-2===1?"":"s"," ↓"]}),o&&e.jsx(Vs,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function
|
|
247
|
+
<pre>${h.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`,k=new Blob([g],{type:"text/html"}),S=URL.createObjectURL(k);window.open(S,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(S),6e4)}}finally{n(null)}}}const u=r?$e:$e.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(c=>e.jsx("button",{type:"button",onClick:()=>void d(c.id,c.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:c.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:c.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:c.desc})]}),a===c.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},c.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",$e.length-2," more report option",$e.length-2===1?"":"s"," ↓"]}),o&&e.jsx(Vs,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function Ao({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 Co(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const d of l){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),i=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:o,selector:c.target.selector})}const u=d.axeRulesEvaluated;if(u){for(const c of u.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of u.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of u.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function Io(t,s,a){const n=[];let r=0,i=0,o=0,l=0;for(const u of a){const c=u.steps.filter(p=>p.wcag===t);if(c.length!==0){r+=c.length;for(const[p,h]of s){const x=h[u.id];if(!x){i+=c.length;continue}for(const g of c){const k=x.steps[g.id];if(!k){i++;continue}k.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${u.id}.${g.id}`,description:g.question,pageUrl:p,notes:k.notes})):k.status==="skip"?i++:k.status==="not-applicable"?(o++,l++):o++}}}}const d=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function Eo(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 Ro(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 To(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=mt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=Ra(t.targetVersion,t.targetLevel),o=[];for(const h of i){const x=Co(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=Io(h.id,s.igtRunsByUrl,s.workflows),k=x.rulesFiring.size===0&&g.stepsCovering===0,S={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:k},L=(p=t.overrides)==null?void 0:p[h.id];let y,C,f=!1;if(L)y=L.verdict,C=L.rationale,f=!0;else{const N=r.get(h.id);N?y=N.state:y=Eo(S,g.unanswered,x.hasIncomplete,g.allNotApplicable),C=Ro(h,y,S)}o.push({criterion:h,understandingUrl:Ta(h,t.targetVersion),verdict:y,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 d(h){const x={A:1,AA:2,AAA:3},g=x[h];return o.every(k=>x[k.criterion.level]>g?!0:k.verdict==="pass"||k.verdict==="not-applicable")}let u=null;d("AAA")?u="AAA":d("AA")?u="AA":d("A")&&(u="A");const c=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:c}}}const $o={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 $(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function we(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 Lo(t,s,a,n){const{inputs:r,rows:i,summary:o,generatedAt:l}=t,d=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 c=Array.from(u.entries()).sort(([p],[h])=>p.localeCompare(h,void 0,{numeric:!0})).map(([p,h])=>`
|
|
248
248
|
<h3 class="guideline-h">Guideline ${$(p)}</h3>
|
|
249
249
|
<table class="criteria-table">
|
|
250
250
|
<thead>
|
|
@@ -258,7 +258,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
258
258
|
<td><a href="${$(x.understandingUrl)}" target="_blank" rel="noopener">${$(x.criterion.id)}</a></td>
|
|
259
259
|
<td>${$(x.criterion.title)}</td>
|
|
260
260
|
<td>${$(x.criterion.level)}</td>
|
|
261
|
-
<td><span class="verdict-badge ${cs[x.verdict]}">${
|
|
261
|
+
<td><span class="verdict-badge ${cs[x.verdict]}">${$o[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
|
|
262
262
|
<td class="rationale">${$(x.rationale)}</td>
|
|
263
263
|
</tr>
|
|
264
264
|
${x.signals.axeFailures.length>0||x.signals.igtFailures.length>0?`
|
|
@@ -546,9 +546,9 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
546
546
|
<span>${o.totalCriteria} criteria · ${o.pass} pass · ${o.fail} fail · ${o.inconclusive} inconclusive</span>
|
|
547
547
|
</footer>
|
|
548
548
|
</body>
|
|
549
|
-
</html>`}async function _o(t,s,a,n){const r=Uo(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"),Do="https://api.wcagcheckr.com",Oo="wcagcheckr",Mo=15e3;function Ys(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 Fo(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 Po(t){return Fo($a(Ys(t)))}function Go(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 Vo(t,s){const a=await Po(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Do}/v1/products/${Oo}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Mo)});if(!i.ok)return st.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return Go(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 Wo(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Ys(t)}}const dt="auditAttestations",ut="auditAttestation:defaultSigner";function vt(t,s){return`${t}::${s}`}async function yt(){try{const s=(await chrome.storage.local.get(dt))[dt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Js(t){await chrome.storage.local.set({[dt]:t})}async function Bo(t){const s=await yt();s[vt(t.componentId,t.auditCapturedAt)]=t,await Js(s)}async function Xs(t,s){return(await yt())[vt(t,s)]??null}async function Ho(t,s){const a=await yt();delete a[vt(t,s)],await Js(a)}async function zo(){try{const s=(await chrome.storage.local.get(ut))[ut];return s&&typeof s=="object"?s:null}catch{return null}}async function Ko(t){await chrome.storage.local.set({[ut]:t})}function qo(t,s){return t.auditCapturedAt!==s}function Qo(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 Yo(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,o]=m.useState(!1),[l,d]=m.useState(""),[u,c]=m.useState(""),[p,h]=m.useState(""),[x,g]=m.useState(""),[k,S]=m.useState("");m.useEffect(()=>{let N=!1;return Promise.all([Xs(t.componentId,t.auditCapturedAt),zo()]).then(([T,v])=>{N||(a(T),T?(d(T.signerName),c(T.signerEmail),h(T.signerOrganization??""),g(T.signerQualifications??""),S(T.claim)):v&&(d(v.signerName),c(v.signerEmail),h(v.signerOrganization??""),g(v.signerQualifications??"")),S(U=>U||Qo({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 L(){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:k.trim(),scope:t.scope};await Bo(N),await Ko({signerName:N.signerName,signerEmail:N.signerEmail,signerOrganization:N.signerOrganization,signerQualifications:N.signerQualifications}),a(N),o(!1)}async function y(){await Ho(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&&qo(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 y(),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=>d(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=>c(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:k,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 L(),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 Zs(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function wt(){try{const s=(await chrome.storage.local.get(pt))[pt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function ea(t){await chrome.storage.local.set({[pt]:t})}async function Jo(t){const s=await wt();s[t.key]=t,await ea(s)}async function Xo(t){const s=await wt();delete s[t],await ea(s)}async function ta(){const t=await wt();return Object.values(t)}function sa(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 Zo(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 el(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:Zs({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 tl={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"},sl={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 al({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>el(t,s),[t,s]),[n,r]=m.useState([]),[i,o]=m.useState(!0),[l,d]=m.useState(null),[u,c]=m.useState(5),[p,h]=m.useState(!1);m.useEffect(()=>{let f=!1;return ta().then(N=>{f||(r(N),o(!1))}),()=>{f=!0}},[]);const x=m.useMemo(()=>a.map(f=>f.key),[a]),g=m.useMemo(()=>sa(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 L(f,N,T){const v={key:f.key,criterionId:f.criterionId,ruleOrStepId:f.ruleOrStepId,pageUrl:f.pageUrl,selector:f.selector,verdict:N,correction:(T==null?void 0:T.trim())||void 0,reviewedAt:new Date().toISOString()};await Jo(v),r(U=>[v,...U.filter(w=>w.key!==v.key)])}async function y(f){await Xo(f.key),r(N=>N.filter(T=>T.key!==f.key))}function C(){d(Zo(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=>c(Math.max(1,Math.min(a.length,Number(f.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:C,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{h(f=>!f),d(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:p?"Hide list":`Show all (${a.length})`}),l&&e.jsx("button",{type:"button",onClick:()=>d(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):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(nl,{row:f,review:n.find(N=>N.key===f.key)??null,onAgree:()=>void L(f,"agreed"),onDisagree:N=>void L(f,"disagreed",N),onClear:()=>void y(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 nl(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 ${tl[s.outcome]}`,children:sl[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:d=>o(d.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),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 je(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,o]=m.useState(!1),[l,d]=m.useState(null);m.useEffect(()=>{let p=!1;return La(t.componentId,t.criterionId).then(h=>{p||(a(h),r(!1))}),()=>{p=!0}},[t.componentId,t.criterionId]);async function u(){o(!0),d(null);try{const h=await ie({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});h.ok?h.result&&a(h.result):d(h.error??"Audit failed.")}catch(p){d(p instanceof Error?p.message:String(p))}finally{o(!1)}}async function c(){await Ua(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 c(),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 rl(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return ne().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(je,{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(je,{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(je,{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(je,{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(je,{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",il={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"},ol={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function ll(){var P,J,B;const t=b(I=>I.results),s=b(I=>I.acknowledgedKeys),[a,n]=m.useState(""),[r,i]=m.useState(""),o=Da,l=_a,[d,u]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,p]=m.useState(""),[h,x]=m.useState(""),[g,k]=m.useState(""),[S,L]=m.useState(""),[y,C]=m.useState(""),[f,N]=m.useState(""),[T,v]=m.useState({}),[U,w]=m.useState(!1),[_,te]=m.useState([]),[A,V]=m.useState([]),[O,K]=m.useState(null),[F,Z]=m.useState(!1),[se,E]=m.useState(null);m.useEffect(()=>{let I=!1;return chrome.storage.local.get(ds).then(G=>{if(I)return;const H=G[ds]??{};v(H),w(!0)}).catch(()=>{I||w(!0)}),()=>{I=!0}},[]),m.useEffect(()=>{var X;const I=(X=t[0])==null?void 0:X.componentId;if(!I)return;let G=!1;const H=()=>{bs(I).then(Q=>{G||V(Q.map(ae=>({criterionId:ae.criterionId,ruleId:`ai-interactive::${ae.criterionId}`,pageUrl:ae.pageUrl,verdict:ae.verdict,reasoning:ae.reasoning})))})};H();const D=Q=>{Q.interactiveAuditResults&&H()};return chrome.storage.local.onChanged.addListener(D),()=>{G=!0,chrome.storage.local.onChanged.removeListener(D)}},[t]),m.useEffect(()=>{var I;if(!a&&((I=t[0])!=null&&I.pageUrl))try{const G=new URL(t[0].pageUrl);n(G.hostname),i(G.origin)}catch{}},[t,a]),m.useEffect(()=>{const I=new Set;for(const H of t)I.add(H.pageUrl??H.scope);if(I.size===0){te([]);return}let G=!1;return Promise.all(Array.from(I).map(H=>De(H))).then(H=>{G||te(H.flat())}).catch(()=>{}),()=>{G=!0}},[t]);const q=m.useMemo(()=>{const I=new Map,G=new Map;for(const D of t){const X=D.pageUrl??D.scope,Q=I.get(X)??[];Q.push(D),I.set(X,Q)}const H=new Map;for(const D of t){const X=D.pageUrl??D.scope;H.set(D.componentId,X)}for(const[D,X]of Object.entries(T)){const Q=H.get(D);if(!Q)continue;const ae=G.get(Q)??{};Object.assign(ae,X),G.set(Q,ae)}return{auditsByUrl:I,igtRunsByUrl:G,workflows:oe,acknowledgedMatchKeys:s,incompleteResolutions:_,interactiveAuditResults:A}},[t,T,s,_,A]),le=m.useMemo(()=>{const I=[],G=new Set;for(const H of q.auditsByUrl.keys())G.has(H)||(G.add(H),I.push({url:H,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const H of f.split(`
|
|
550
|
-
`).map(D=>D.trim()).filter(Boolean))G.has(H)||(G.add(H),I.push({url:H,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return I},[q,f]),re=m.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(I=>I.trim()).filter(Boolean),pageSample:le,evaluator:{name:h||"(evaluator name pending)",organization:g||void 0,qualifications:S||void 0,contact:y||void 0}}),[a,r,o,l,d,c,le,h,g,S,y]),j=m.useMemo(()=>U
|
|
551
|
-
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:I=>x(I.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:I=>k(I.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:I=>L(I.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:y,onChange:I=>C(I.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),j&&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 (",j.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:j.rows.map(I=>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:[I.criterion.id," · ",I.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:I.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${il[I.verdict]}`,children:ol[I.verdict]})]},I.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"}),O?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:[O.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",O.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:!j||!a||!h||F,onClick:()=>void W(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:F?"Anchoring…":O?"Re-anchor":"Anchor this report"}),O&&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"})]})]}),j&&((P=t[0])==null?void 0:P.componentId)&&e.jsx(rl,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),j&&e.jsx(al,{verdicts:R,incompleteResolutions:_}),j&&((J=t[0])==null?void 0:J.componentId)&&((B=t[0])==null?void 0:B.startedAt)&&e.jsx(Yo,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:j.summary.pass+j.summary.fail+j.summary.inconclusive+j.summary.notApplicable,totalCount:j.summary.totalCriteria,canClaimConformance:j.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:!j||!a||!h,onClick:()=>void M(),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 cl({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:d,targetLevel:u,auditedUrlCount:c}){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 ${d} Level ${u}`:`Does not currently meet WCAG ${d} 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 ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const dl={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function ul(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 pl(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+Pa[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 hl(){return crypto.randomUUID()}function ml(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,i]=m.useState(""),[o,l]=m.useState("daily"),[d,u]=m.useState(null),[c,p]=m.useState(!1),[h,x]=m.useState(Oa),[g,k]=m.useState("idle"),[S,L]=m.useState(!1),[y,C]=m.useState(null);async function f(){n(!0);try{const w=await ys();w.sort((_,te)=>_.enabled!==te.enabled?_.enabled?-1:1:te.createdAt.localeCompare(_.createdAt)),s(w)}finally{n(!1)}}m.useEffect(()=>{f(),(async()=>{const w=await Ma();x(w)})()},[]);async function N(w){if(C(null),w.webhookEnabled&&w.webhookUrl.trim().length>0)try{if(new URL(w.webhookUrl).protocol!=="https:"){C("Webhook URL must use https://");return}}catch{C("Webhook URL is not a valid https:// URL.");return}k("saving"),await Fa(w),x(w),k("saved"),setTimeout(()=>k("idle"),1500)}async function T(){u(null);const w=r.trim();if(!w){u("URL is required.");return}try{new URL(w)}catch{u("Must be a valid URL (e.g. https://example.com/).");return}p(!0);try{const _={id:hl(),url:w,cadence:o,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await At(_),await Ct(_),i(""),l("daily"),await f(),await Qe()}finally{p(!1)}}async function v(w){const _={...w,enabled:!w.enabled};await At(_),_.enabled?await Ct(_):await It(w.id),await f(),await Qe()}async function U(w){window.confirm(`Remove the scheduled audit for ${w.url}? Run history for this schedule will also be deleted.`)&&(await It(w.id),await Ga(w.id),await Va(w.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:()=>L(w=>!w),"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:w=>void N({...h,emailEnabled:w.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:w=>void N({...h,webhookEnabled:w.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:w=>x({...h,webhookUrl:w.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]"}),y&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:y})]}),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:w=>void N({...h,minImpact:w.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:w=>i(w.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:w=>l(w.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),d&&e.jsx("div",{className:"text-rose-700",role:"alert",children:d}),e.jsx("button",{type:"button",onClick:()=>void T(),disabled:c||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:c?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(w=>e.jsx("li",{className:`border rounded p-2.5 ${w.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:w.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[dl[w.cadence]," · last run ",ul(w.lastRunAt)," ·"," ","next ",pl(w)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[w.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",w.lastTotalViolations??0," violation",(w.lastTotalViolations??0)===1?"":"s"]}),w.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:w.lastError??"",children:"✗ failed"}),w.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),w.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"}),(w.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:["⚠ ",w.lastNewViolationCount," new vs baseline"]}),!w.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void v(w),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:w.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void U(w),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},w.id))})]})}const us={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function aa(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function xl(t){let s=0,a=0,n=0,r=0,i=0,o=0,l=0,d=0;for(const u of t){if(!u.enabled){a++;continue}s++;const c=aa(u);c==="clean"?n++:c==="new-violations"?r++:c==="failed"?i++:c==="pending"&&o++,l+=u.lastNewViolationCount??0,d+=u.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:o,totalNewViolations:l,totalViolationsAcrossSchedules:d}}function gl(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:aa(a)}))}function fl(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 na(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 d=new Date(r.getTime()-l*864e5);i.push({date:d.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 d=l.ranAt.slice(0,10),u=o.get(d);u&&(u.runs++,u.totalViolations+=l.totalViolations,u.newViolations+=l.newVsBaselineViolations)}return i}function bl(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return na(r,a,n)}function vl(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 ra(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,d)=>{const u=d*r,c=s-l.totalViolations/n*(s-4)-2;return`${u.toFixed(1)},${c.toFixed(1)}`}),o=t.map((l,d)=>{const u=d*r,c=s-l.newViolations/n*(s-4)-2;return`${u.toFixed(1)},${c.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:o.join(" ")})]})}function Ue({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 yl({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:ra(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function wl(){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(),Wa()]);s(p),n(h)}finally{i(!1)}})()},[]);const o=xl(t),l=gl(t,5),d=fl(t,a,10),u=na(a,30),c=vl(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(Ue,{state:"clean",count:o.cleanCount}),e.jsx(Ue,{state:"new-violations",count:o.newViolationsCount}),e.jsx(Ue,{state:"failed",count:o.failedCount}),e.jsx(Ue,{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"]})]})]})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",c.length]}),e.jsx("ul",{className:"space-y-1.5",children:c.map((p,h)=>e.jsx(yl,{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=bl(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)})})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:d.map((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:ra(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 jl="https://api.anthropic.com/v1/messages",Nl="2023-06-01",kl="claude-sonnet-4-6",Sl={input:3/1e6,output:15/1e6},Al={input:1/1e6,output:5/1e6},Cl=`You are wcagcheckr's accessibility-audit co-pilot.
|
|
549
|
+
</html>`}async function Uo(t,s,a,n){const r=Lo(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=ws("wcag-em-anchor"),_o="https://api.wcagcheckr.com",Do="wcagcheckr",Oo=15e3;function Ys(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 Mo(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 Fo(t){return Mo($a(Ys(t)))}function Po(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 Go(t,s){const a=await Fo(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${_o}/v1/products/${Do}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Oo)});if(!i.ok)return tt.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return Po(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 Vo(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Ys(t)}}const ct="auditAttestations",dt="auditAttestation:defaultSigner";function vt(t,s){return`${t}::${s}`}async function yt(){try{const s=(await chrome.storage.local.get(ct))[ct];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Js(t){await chrome.storage.local.set({[ct]:t})}async function Wo(t){const s=await yt();s[vt(t.componentId,t.auditCapturedAt)]=t,await Js(s)}async function Xs(t,s){return(await yt())[vt(t,s)]??null}async function Bo(t,s){const a=await yt();delete a[vt(t,s)],await Js(a)}async function Ho(){try{const s=(await chrome.storage.local.get(dt))[dt];return s&&typeof s=="object"?s:null}catch{return null}}async function zo(t){await chrome.storage.local.set({[dt]:t})}function Ko(t,s){return t.auditCapturedAt!==s}function qo(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 Qo(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,o]=m.useState(!1),[l,d]=m.useState(""),[u,c]=m.useState(""),[p,h]=m.useState(""),[x,g]=m.useState(""),[k,S]=m.useState("");m.useEffect(()=>{let N=!1;return Promise.all([Xs(t.componentId,t.auditCapturedAt),Ho()]).then(([T,v])=>{N||(a(T),T?(d(T.signerName),c(T.signerEmail),h(T.signerOrganization??""),g(T.signerQualifications??""),S(T.claim)):v&&(d(v.signerName),c(v.signerEmail),h(v.signerOrganization??""),g(v.signerQualifications??"")),S(U=>U||qo({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 L(){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:k.trim(),scope:t.scope};await Wo(N),await zo({signerName:N.signerName,signerEmail:N.signerEmail,signerOrganization:N.signerOrganization,signerQualifications:N.signerQualifications}),a(N),o(!1)}async function y(){await Bo(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&&Ko(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 y(),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=>d(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=>c(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:k,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 L(),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 Zs(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function wt(){try{const s=(await chrome.storage.local.get(ut))[ut];return s&&typeof s=="object"?s:{}}catch{return{}}}async function ea(t){await chrome.storage.local.set({[ut]:t})}async function Yo(t){const s=await wt();s[t.key]=t,await ea(s)}async function Jo(t){const s=await wt();delete s[t],await ea(s)}async function ta(){const t=await wt();return Object.values(t)}function sa(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 Xo(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 Zo(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:Zs({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 el={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"},tl={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 sl({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>Zo(t,s),[t,s]),[n,r]=m.useState([]),[i,o]=m.useState(!0),[l,d]=m.useState(null),[u,c]=m.useState(5),[p,h]=m.useState(!1);m.useEffect(()=>{let f=!1;return ta().then(N=>{f||(r(N),o(!1))}),()=>{f=!0}},[]);const x=m.useMemo(()=>a.map(f=>f.key),[a]),g=m.useMemo(()=>sa(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 L(f,N,T){const v={key:f.key,criterionId:f.criterionId,ruleOrStepId:f.ruleOrStepId,pageUrl:f.pageUrl,selector:f.selector,verdict:N,correction:(T==null?void 0:T.trim())||void 0,reviewedAt:new Date().toISOString()};await Yo(v),r(U=>[v,...U.filter(w=>w.key!==v.key)])}async function y(f){await Jo(f.key),r(N=>N.filter(T=>T.key!==f.key))}function C(){d(Xo(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=>c(Math.max(1,Math.min(a.length,Number(f.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:C,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{h(f=>!f),d(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:p?"Hide list":`Show all (${a.length})`}),l&&e.jsx("button",{type:"button",onClick:()=>d(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):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(al,{row:f,review:n.find(N=>N.key===f.key)??null,onAgree:()=>void L(f,"agreed"),onDisagree:N=>void L(f,"disagreed",N),onClear:()=>void y(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 al(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 ${el[s.outcome]}`,children:tl[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:d=>o(d.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),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 je(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,o]=m.useState(!1),[l,d]=m.useState(null);m.useEffect(()=>{let p=!1;return La(t.componentId,t.criterionId).then(h=>{p||(a(h),r(!1))}),()=>{p=!0}},[t.componentId,t.criterionId]);async function u(){o(!0),d(null);try{const h=await ie({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});h.ok?h.result&&a(h.result):d(h.error??"Audit failed.")}catch(p){d(p instanceof Error?p.message:String(p))}finally{o(!1)}}async function c(){await Ua(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 c(),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 nl(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return ne().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(je,{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(je,{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(je,{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(je,{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(je,{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",rl={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"},il={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function ol(){var P,J,B;const t=b(I=>I.results),s=b(I=>I.acknowledgedKeys),[a,n]=m.useState(""),[r,i]=m.useState(""),o=Da,l=_a,[d,u]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,p]=m.useState(""),[h,x]=m.useState(""),[g,k]=m.useState(""),[S,L]=m.useState(""),[y,C]=m.useState(""),[f,N]=m.useState(""),[T,v]=m.useState({}),[U,w]=m.useState(!1),[_,te]=m.useState([]),[A,V]=m.useState([]),[O,K]=m.useState(null),[F,Z]=m.useState(!1),[se,E]=m.useState(null);m.useEffect(()=>{let I=!1;return chrome.storage.local.get(ds).then(G=>{if(I)return;const H=G[ds]??{};v(H),w(!0)}).catch(()=>{I||w(!0)}),()=>{I=!0}},[]),m.useEffect(()=>{var X;const I=(X=t[0])==null?void 0:X.componentId;if(!I)return;let G=!1;const H=()=>{bs(I).then(Q=>{G||V(Q.map(ae=>({criterionId:ae.criterionId,ruleId:`ai-interactive::${ae.criterionId}`,pageUrl:ae.pageUrl,verdict:ae.verdict,reasoning:ae.reasoning})))})};H();const D=Q=>{Q.interactiveAuditResults&&H()};return chrome.storage.local.onChanged.addListener(D),()=>{G=!0,chrome.storage.local.onChanged.removeListener(D)}},[t]),m.useEffect(()=>{var I;if(!a&&((I=t[0])!=null&&I.pageUrl))try{const G=new URL(t[0].pageUrl);n(G.hostname),i(G.origin)}catch{}},[t,a]),m.useEffect(()=>{const I=new Set;for(const H of t)I.add(H.pageUrl??H.scope);if(I.size===0){te([]);return}let G=!1;return Promise.all(Array.from(I).map(H=>De(H))).then(H=>{G||te(H.flat())}).catch(()=>{}),()=>{G=!0}},[t]);const q=m.useMemo(()=>{const I=new Map,G=new Map;for(const D of t){const X=D.pageUrl??D.scope,Q=I.get(X)??[];Q.push(D),I.set(X,Q)}const H=new Map;for(const D of t){const X=D.pageUrl??D.scope;H.set(D.componentId,X)}for(const[D,X]of Object.entries(T)){const Q=H.get(D);if(!Q)continue;const ae=G.get(Q)??{};Object.assign(ae,X),G.set(Q,ae)}return{auditsByUrl:I,igtRunsByUrl:G,workflows:oe,acknowledgedMatchKeys:s,incompleteResolutions:_,interactiveAuditResults:A}},[t,T,s,_,A]),le=m.useMemo(()=>{const I=[],G=new Set;for(const H of q.auditsByUrl.keys())G.has(H)||(G.add(H),I.push({url:H,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const H of f.split(`
|
|
550
|
+
`).map(D=>D.trim()).filter(Boolean))G.has(H)||(G.add(H),I.push({url:H,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return I},[q,f]),re=m.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(I=>I.trim()).filter(Boolean),pageSample:le,evaluator:{name:h||"(evaluator name pending)",organization:g||void 0,qualifications:S||void 0,contact:y||void 0}}),[a,r,o,l,d,c,le,h,g,S,y]),j=m.useMemo(()=>U?To(re,q):null,[re,q,U]),R=m.useMemo(()=>{const I=Array.from(q.auditsByUrl.values()).flat(),G=Object.values(T).flatMap(H=>Object.values(H));return mt({audits:I,igtRuns:G,workflows:oe,acknowledgedMatchKeys:s,incompleteResolutions:_,interactiveAuditResults:A})},[q,T,s,_,A]);async function M(){if(!j)return;const I=t[0],G=I!=null&&I.componentId&&(I!=null&&I.startedAt)?await Xs(I.componentId,I.startedAt):null,H=await ta(),D=[];for(const Q of R.values())for(const ae of Q.evidence)ae.source==="ai"&&D.push(Zs({criterionId:Q.criterionId,ruleOrStepId:ae.ruleOrStepId,pageUrl:ae.pageUrl,selector:ae.selector}));const X=sa(D,H);await Uo(j,O,G,X)}async function W(){if(j){Z(!0),E(null);try{const I=await Go(j);if(!I){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}K(I)}finally{Z(!1)}}}function z(){var ae,jt,Nt;if(!j||!O)return;const I=((Nt=(jt=(ae=chrome.runtime).getManifest)==null?void 0:jt.call(ae))==null?void 0:Nt.version)??"0.0.0",G=Vo(j,O,I),H=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),D=URL.createObjectURL(H),X=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,Q=document.createElement("a");Q.href=D,Q.download=X,Q.click(),setTimeout(()=>URL.revokeObjectURL(D),1e3)}return m.useEffect(()=>{K(null),E(null)},[a,r,d,c,h,g,S,y,f]),U?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."})]}),j&&j.summary.totalCriteria>0&&e.jsx(ll,{totalCriteria:j.summary.totalCriteria,pass:j.summary.pass,fail:j.summary.fail,inconclusive:j.summary.inconclusive,notEvaluated:j.summary.notEvaluated,notApplicable:j.summary.notApplicable,levelAchieved:j.summary.levelAchieved,meetsTarget:j.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:q.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:I=>n(I.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:I=>i(I.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:d,onChange:I=>u(I.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:I=>p(I.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.",q.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:q.auditsByUrl.size})," URL",q.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:I=>N(I.target.value),rows:3,placeholder:`https://app.example.com/checkout
|
|
551
|
+
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:I=>x(I.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:I=>k(I.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:I=>L(I.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:y,onChange:I=>C(I.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),j&&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 (",j.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:j.rows.map(I=>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:[I.criterion.id," · ",I.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:I.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${rl[I.verdict]}`,children:il[I.verdict]})]},I.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"}),O?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:[O.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",O.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:!j||!a||!h||F,onClick:()=>void W(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:F?"Anchoring…":O?"Re-anchor":"Anchor this report"}),O&&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"})]})]}),j&&((P=t[0])==null?void 0:P.componentId)&&e.jsx(nl,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),j&&e.jsx(sl,{verdicts:R,incompleteResolutions:_}),j&&((J=t[0])==null?void 0:J.componentId)&&((B=t[0])==null?void 0:B.startedAt)&&e.jsx(Qo,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:j.summary.pass+j.summary.fail+j.summary.inconclusive+j.summary.notApplicable,totalCount:j.summary.totalCriteria,canClaimConformance:j.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:!j||!a||!h,onClick:()=>void M(),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 ll({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:d,targetLevel:u,auditedUrlCount:c}){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 ${d} Level ${u}`:`Does not currently meet WCAG ${d} 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 ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const cl={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function dl(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 ul(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+Pa[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 pl(){return crypto.randomUUID()}function hl(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,i]=m.useState(""),[o,l]=m.useState("daily"),[d,u]=m.useState(null),[c,p]=m.useState(!1),[h,x]=m.useState(Oa),[g,k]=m.useState("idle"),[S,L]=m.useState(!1),[y,C]=m.useState(null);async function f(){n(!0);try{const w=await ys();w.sort((_,te)=>_.enabled!==te.enabled?_.enabled?-1:1:te.createdAt.localeCompare(_.createdAt)),s(w)}finally{n(!1)}}m.useEffect(()=>{f(),(async()=>{const w=await Ma();x(w)})()},[]);async function N(w){if(C(null),w.webhookEnabled&&w.webhookUrl.trim().length>0)try{if(new URL(w.webhookUrl).protocol!=="https:"){C("Webhook URL must use https://");return}}catch{C("Webhook URL is not a valid https:// URL.");return}k("saving"),await Fa(w),x(w),k("saved"),setTimeout(()=>k("idle"),1500)}async function T(){u(null);const w=r.trim();if(!w){u("URL is required.");return}try{new URL(w)}catch{u("Must be a valid URL (e.g. https://example.com/).");return}p(!0);try{const _={id:pl(),url:w,cadence:o,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await At(_),await Ct(_),i(""),l("daily"),await f(),await qe()}finally{p(!1)}}async function v(w){const _={...w,enabled:!w.enabled};await At(_),_.enabled?await Ct(_):await It(w.id),await f(),await qe()}async function U(w){window.confirm(`Remove the scheduled audit for ${w.url}? Run history for this schedule will also be deleted.`)&&(await It(w.id),await Ga(w.id),await Va(w.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:()=>L(w=>!w),"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:w=>void N({...h,emailEnabled:w.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:w=>void N({...h,webhookEnabled:w.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:w=>x({...h,webhookUrl:w.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]"}),y&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:y})]}),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:w=>void N({...h,minImpact:w.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:w=>i(w.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:w=>l(w.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),d&&e.jsx("div",{className:"text-rose-700",role:"alert",children:d}),e.jsx("button",{type:"button",onClick:()=>void T(),disabled:c||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:c?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(w=>e.jsx("li",{className:`border rounded p-2.5 ${w.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:w.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[cl[w.cadence]," · last run ",dl(w.lastRunAt)," ·"," ","next ",ul(w)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[w.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",w.lastTotalViolations??0," violation",(w.lastTotalViolations??0)===1?"":"s"]}),w.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:w.lastError??"",children:"✗ failed"}),w.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),w.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"}),(w.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:["⚠ ",w.lastNewViolationCount," new vs baseline"]}),!w.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void v(w),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:w.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void U(w),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},w.id))})]})}const us={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function aa(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function ml(t){let s=0,a=0,n=0,r=0,i=0,o=0,l=0,d=0;for(const u of t){if(!u.enabled){a++;continue}s++;const c=aa(u);c==="clean"?n++:c==="new-violations"?r++:c==="failed"?i++:c==="pending"&&o++,l+=u.lastNewViolationCount??0,d+=u.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:o,totalNewViolations:l,totalViolationsAcrossSchedules:d}}function xl(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:aa(a)}))}function gl(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 na(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 d=new Date(r.getTime()-l*864e5);i.push({date:d.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 d=l.ranAt.slice(0,10),u=o.get(d);u&&(u.runs++,u.totalViolations+=l.totalViolations,u.newViolations+=l.newVsBaselineViolations)}return i}function fl(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return na(r,a,n)}function bl(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 ra(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,d)=>{const u=d*r,c=s-l.totalViolations/n*(s-4)-2;return`${u.toFixed(1)},${c.toFixed(1)}`}),o=t.map((l,d)=>{const u=d*r,c=s-l.newViolations/n*(s-4)-2;return`${u.toFixed(1)},${c.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:o.join(" ")})]})}function Ue({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 vl({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:ra(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function yl(){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(),Wa()]);s(p),n(h)}finally{i(!1)}})()},[]);const o=ml(t),l=xl(t,5),d=gl(t,a,10),u=na(a,30),c=bl(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(Ue,{state:"clean",count:o.cleanCount}),e.jsx(Ue,{state:"new-violations",count:o.newViolationsCount}),e.jsx(Ue,{state:"failed",count:o.failedCount}),e.jsx(Ue,{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"]})]})]})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",c.length]}),e.jsx("ul",{className:"space-y-1.5",children:c.map((p,h)=>e.jsx(vl,{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=fl(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)})})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:d.map((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:ra(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 wl="https://api.anthropic.com/v1/messages",jl="2023-06-01",Nl="claude-sonnet-4-6",kl={input:3/1e6,output:15/1e6},Sl={input:1/1e6,output:5/1e6},Al=`You are wcagcheckr's accessibility-audit co-pilot.
|
|
552
552
|
|
|
553
553
|
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.
|
|
554
554
|
|
|
@@ -559,10 +559,10 @@ Rules:
|
|
|
559
559
|
- When you cite a WCAG criterion, use the dotted SC number (e.g. 1.4.3).
|
|
560
560
|
- Don't be cheerful or evangelical. Be factual.
|
|
561
561
|
- If the user asks for the impact-priority order, sort: critical > serious > moderate > minor.
|
|
562
|
-
- The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function
|
|
562
|
+
- The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function Cl(t,s,a){const n=a.includes("haiku")?Sl:kl;return t*n.input+s*n.output}async function Il(t){const s=t.model||Nl,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??Al;!t.system&&t.auditContext&&(n+=`
|
|
563
563
|
|
|
564
564
|
<audit-context>
|
|
565
565
|
${t.auditContext}
|
|
566
|
-
</audit-context>`);const r=await fetch(
|
|
567
|
-
`).trim(),l=i.usage.input_tokens,d=i.usage.output_tokens,u=
|
|
568
|
-
`)}const ms="aiConfig";function Tl(){var C;const t=b(f=>f.results),s=b(f=>f.componentId),[a,n]=m.useState([]),[r,i]=m.useState(""),[o,l]=m.useState(!1),[d,u]=m.useState(!1),[c,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),k=Rl({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 L(){const f=r.trim();if(!f||o||!h.current)return;i("");const N={role:"user",content:f},T=[...a,N];n(T),l(!0);try{const v=T.map(w=>({role:w.role,content:w.content})),U=await El({apiKey:h.current,model:c,messages:v,auditContext:k});n([...T,{role:"assistant",content:U.text,costUsd:U.costUsd,inputTokens:U.inputTokens,outputTokens:U.outputTokens}])}catch(v){n([...T,{role:"assistant",content:"",error:v instanceof Error?v.message:String(v)}])}finally{l(!1)}}function y(){n([])}return d?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",S.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:y,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(),L()},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 $l(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState(""),[d,u]=m.useState(new Set);async function c(){i(null),n(!0);try{const x=await ne();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 k=new Set(g);return k.has(x)?k.delete(x):k.add(x),k})}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 c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value: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(Ll,{nodes:t,filtered:h,collapsed:d,onToggle:p})]})]})}function Ll({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(oa,{node:o,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},o.nodeId))});const r=new Map;for(const o of t){const l=o.parentId,d=r.get(l)??[];d.push(o),r.set(l,d)}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(ia,{node:o,depth:0,byParent:r,collapsed:a,onToggle:n},o.nodeId))})}function ia({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(oa,{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(d=>e.jsx(ia,{node:d,depth:s+1,byParent:a,collapsed:n,onToggle:r},d.nodeId))})]})}function oa({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(" · ")})]})}function Ul(){const t=b(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 ne();if(!u){r("No audited tab. Open a page first.");return}const c=await me(u,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:u});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const p=new Map;for(const g of t)for(const k of g.violations)p.has(k.target.selector)||p.set(k.target.selector,k.matchKey);const h=c.references.map(g=>({violationMatchKey:p.get(g.selector)??null,referencedTokens:g.referencedTokens})),x=c.tokens;o(qa(x,h))}finally{a(!1)}}const d=i?Ka(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}),d&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(Ne,{label:"Total tokens",value:d.totalTokens}),e.jsx(Ne,{label:"Color tokens",value:d.colorTokens}),e.jsx(Ne,{label:"Used",value:d.usedTokens}),e.jsx(Ne,{label:"Unused",value:d.unusedTokens,tint:d.unusedTokens>0?"amber":"slate"}),e.jsx(Ne,{label:"In violations",value:d.violatingTokens,tint:d.violatingTokens>0?"rose":"slate"})]}),i&&i.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:i.map(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 Ne({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",_e="onboarding:collapsed";function _l(){const t=b(v=>v.tier),s=b(v=>v.results),a=b(v=>v.baselineList),[n,r]=m.useState(!1),[i,o]=m.useState(!1),[l,d]=m.useState(!1),[u,c]=m.useState(!1),[p,h]=m.useState(null);m.useEffect(()=>{(async()=>{const v=await chrome.storage.local.get([at,nt,_e]);r(v[at]===!0),d(v[nt]===!0),typeof v[_e]=="boolean"&&h(v[_e]);const U=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],w=await Promise.all(U.map(_=>ee({type:"SETTINGS_GET",key:_})));c(w.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(v=>!v.optional),k=x.filter(v=>v.state==="done").length,S=g.filter(v=>v.state==="done").length,L=k===x.length,y=S===g.length;if(!i||n||y)return null;async function C(){r(!0),await chrome.storage.local.set({[at]:!0})}async function f(){const v=!l;d(v),await chrome.storage.local.set({[nt]:v})}const N=p??k>0;async function T(){const v=!N;h(v),await chrome.storage.local.set({[_e]:v})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void T(),"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 · ",k," 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. ",L?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:x.map(v=>e.jsx("li",{className:"flex items-start gap-1.5",children:v.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:v.state==="done",onChange:()=>void f(),className:"mt-0.5","aria-label":v.label}),e.jsx("span",{className:v.state==="done"?"line-through text-amber-700":"text-amber-900",children:v.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:v.state==="done"?"✓":"○"}),e.jsxs("span",{className:v.state==="done"?"line-through text-amber-700":"text-amber-900",children:[v.label,v.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},v.id))})]})]})}function Dl(){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 ie({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(l!=null&&l.validated)){const d=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(d==="cap-reached"?`License is at seat capacity. ${u??"Release a seat from another device or contact support."}`:d==="not-found"?"License not found. Check the token and try again.":d==="network"?`Network error: ${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 Hl(){const t=b(o=>o.view),s=b(o=>o.userMode),a=b(o=>o.tier),[n,r]=m.useState(!1);m.useEffect(()=>{const o=setTimeout(()=>r(!0),600);return()=>clearTimeout(o)},[]);const i=n&&za(a);return m.useEffect(()=>{const o=nn(),d=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),u=Za();Ss({forceRefresh:!0}).catch(()=>{}),Pe().catch(()=>{}),an().catch(()=>{}),rn().catch(()=>{}),tn().catch(()=>{}),Ba().then(p=>{b.getState().setAcknowledgedKeys(new Set(p.map(h=>h.matchKey)))}).catch(()=>{}),Ha().then(p=>{p&&b.setState({siteCrawlReport:p})}).catch(()=>{});const c=p=>{if(p.key!=="Escape")return;const{pinnedMatchKey:h,setPinned:x,results:g}=b.getState();h&&(x(null),ne().then(k=>{var S;k&&de(k,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:k},(S=g[0])==null?void 0:S.frameId).catch(()=>{})}))};return window.addEventListener("keydown",c),()=>{u(),o.disconnect(),d==null||d.disconnect(),window.removeEventListener("keydown",c)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(Dl,{}),e.jsx(Re,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Hi,{}),e.jsx(Re,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(xo,{}),e.jsx(ns,{}),e.jsx(Re,{})]}):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(Qs,{}),e.jsx($s,{}),e.jsx(wn,{}),e.jsx(_l,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Sn,{}),e.jsx(Tn,{}),e.jsx(Gi,{}),e.jsx(Pi,{}),e.jsx(Ln,{}),e.jsx(Mi,{}),e.jsx(Fi,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(On,{}),t==="report"&&e.jsx(pi,{}),t==="delta"&&e.jsx(Ws,{}),t==="activity"&&e.jsx(Gs,{}),t==="guided"&&e.jsx(Ni,{}),t==="flows"&&e.jsx(Ci,{}),t==="scorecard"&&e.jsx(Ri,{}),t==="crawl"&&e.jsx(zs,{}),t==="forensic"&&e.jsx(qs,{}),t==="compliance"&&e.jsx(ll,{}),t==="schedules"&&e.jsx(ml,{}),t==="risk"&&e.jsx(wl,{}),t==="copilot"&&e.jsx(Tl,{}),t==="ax-tree"&&e.jsx($l,{}),t==="wcag3"&&e.jsx(Hs,{}),t==="tokens"&&e.jsx(Ul,{})]})]}),e.jsx(Bi,{}),e.jsx(Vi,{}),e.jsx(Oi,{}),e.jsx(ns,{}),e.jsx(Re,{})]})}class zl extends ke.Component{constructor(){super(...arguments);kt(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{Hl as A,zl as E,Bl as d};
|
|
566
|
+
</audit-context>`);const r=await fetch(wl,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":jl,"anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:s,max_tokens:a,system:n,messages:t.messages}),signal:t.signal});if(!r.ok){const c=await r.text().catch(()=>"");throw new Error(`Anthropic API ${r.status}: ${c.slice(0,300)}`)}const i=await r.json(),o=i.content.filter(c=>c.type==="text").map(c=>c.text).join(`
|
|
567
|
+
`).trim(),l=i.usage.input_tokens,d=i.usage.output_tokens,u=Cl(l,d,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:d,costUsd:u,model:i.model}}function El(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(`
|
|
568
|
+
`)}const ms="aiConfig";function Rl(){var C;const t=b(f=>f.results),s=b(f=>f.componentId),[a,n]=m.useState([]),[r,i]=m.useState(""),[o,l]=m.useState(!1),[d,u]=m.useState(!1),[c,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),k=El({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 L(){const f=r.trim();if(!f||o||!h.current)return;i("");const N={role:"user",content:f},T=[...a,N];n(T),l(!0);try{const v=T.map(w=>({role:w.role,content:w.content})),U=await Il({apiKey:h.current,model:c,messages:v,auditContext:k});n([...T,{role:"assistant",content:U.text,costUsd:U.costUsd,inputTokens:U.inputTokens,outputTokens:U.outputTokens}])}catch(v){n([...T,{role:"assistant",content:"",error:v instanceof Error?v.message:String(v)}])}finally{l(!1)}}function y(){n([])}return d?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",S.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:y,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(),L()},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 Tl(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[o,l]=m.useState(""),[d,u]=m.useState(new Set);async function c(){i(null),n(!0);try{const x=await ne();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 k=new Set(g);return k.has(x)?k.delete(x):k.add(x),k})}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 c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value: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($l,{nodes:t,filtered:h,collapsed:d,onToggle:p})]})]})}function $l({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(oa,{node:o,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},o.nodeId))});const r=new Map;for(const o of t){const l=o.parentId,d=r.get(l)??[];d.push(o),r.set(l,d)}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(ia,{node:o,depth:0,byParent:r,collapsed:a,onToggle:n},o.nodeId))})}function ia({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(oa,{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(d=>e.jsx(ia,{node:d,depth:s+1,byParent:a,collapsed:n,onToggle:r},d.nodeId))})]})}function oa({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(" · ")})]})}function Ll(){const t=b(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 ne();if(!u){r("No audited tab. Open a page first.");return}const c=await me(u,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:u});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const p=new Map;for(const g of t)for(const k of g.violations)p.has(k.target.selector)||p.set(k.target.selector,k.matchKey);const h=c.references.map(g=>({violationMatchKey:p.get(g.selector)??null,referencedTokens:g.referencedTokens})),x=c.tokens;o(qa(x,h))}finally{a(!1)}}const d=i?Ka(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}),d&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(Ne,{label:"Total tokens",value:d.totalTokens}),e.jsx(Ne,{label:"Color tokens",value:d.colorTokens}),e.jsx(Ne,{label:"Used",value:d.usedTokens}),e.jsx(Ne,{label:"Unused",value:d.unusedTokens,tint:d.unusedTokens>0?"amber":"slate"}),e.jsx(Ne,{label:"In violations",value:d.violatingTokens,tint:d.violatingTokens>0?"rose":"slate"})]}),i&&i.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:i.map(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 Ne({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",_e="onboarding:collapsed";function Ul(){const t=b(v=>v.tier),s=b(v=>v.results),a=b(v=>v.baselineList),[n,r]=m.useState(!1),[i,o]=m.useState(!1),[l,d]=m.useState(!1),[u,c]=m.useState(!1),[p,h]=m.useState(null);m.useEffect(()=>{(async()=>{const v=await chrome.storage.local.get([st,at,_e]);r(v[st]===!0),d(v[at]===!0),typeof v[_e]=="boolean"&&h(v[_e]);const U=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],w=await Promise.all(U.map(_=>ee({type:"SETTINGS_GET",key:_})));c(w.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(v=>!v.optional),k=x.filter(v=>v.state==="done").length,S=g.filter(v=>v.state==="done").length,L=k===x.length,y=S===g.length;if(!i||n||y)return null;async function C(){r(!0),await chrome.storage.local.set({[st]:!0})}async function f(){const v=!l;d(v),await chrome.storage.local.set({[at]:v})}const N=p??k>0;async function T(){const v=!N;h(v),await chrome.storage.local.set({[_e]:v})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void T(),"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 · ",k," 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. ",L?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:x.map(v=>e.jsx("li",{className:"flex items-start gap-1.5",children:v.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:v.state==="done",onChange:()=>void f(),className:"mt-0.5","aria-label":v.label}),e.jsx("span",{className:v.state==="done"?"line-through text-amber-700":"text-amber-900",children:v.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:v.state==="done"?"✓":"○"}),e.jsxs("span",{className:v.state==="done"?"line-through text-amber-700":"text-amber-900",children:[v.label,v.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},v.id))})]})]})}function _l(){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 ie({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(l!=null&&l.validated)){const d=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(d==="cap-reached"?`License is at seat capacity. ${u??"Release a seat from another device or contact support."}`:d==="not-found"?"License not found. Check the token and try again.":d==="network"?`Network error: ${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 Bl(){const t=b(o=>o.view),s=b(o=>o.userMode),a=b(o=>o.tier),[n,r]=m.useState(!1);m.useEffect(()=>{const o=setTimeout(()=>r(!0),600);return()=>clearTimeout(o)},[]);const i=n&&za(a);return m.useEffect(()=>{const o=nn(),d=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),u=Za();Ss({forceRefresh:!0}).catch(()=>{}),Pe().catch(()=>{}),an().catch(()=>{}),rn().catch(()=>{}),tn().catch(()=>{}),Ba().then(p=>{b.getState().setAcknowledgedKeys(new Set(p.map(h=>h.matchKey)))}).catch(()=>{}),Ha().then(p=>{p&&b.setState({siteCrawlReport:p})}).catch(()=>{});const c=p=>{if(p.key!=="Escape")return;const{pinnedMatchKey:h,setPinned:x,results:g}=b.getState();h&&(x(null),ne().then(k=>{var S;k&&de(k,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:k},(S=g[0])==null?void 0:S.frameId).catch(()=>{})}))};return window.addEventListener("keydown",c),()=>{u(),o.disconnect(),d==null||d.disconnect(),window.removeEventListener("keydown",c)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(_l,{}),e.jsx(Re,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Bi,{}),e.jsx(Re,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(mo,{}),e.jsx(ns,{}),e.jsx(Re,{})]}):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(Qs,{}),e.jsx($s,{}),e.jsx(wn,{}),e.jsx(Ul,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Sn,{}),e.jsx(Tn,{}),e.jsx(Pi,{}),e.jsx(Fi,{}),e.jsx(Ln,{}),e.jsx(Oi,{}),e.jsx(Mi,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(_n,{}),t==="report"&&e.jsx(ui,{}),t==="delta"&&e.jsx(Ws,{}),t==="activity"&&e.jsx(Gs,{}),t==="guided"&&e.jsx(ji,{}),t==="flows"&&e.jsx(Ai,{}),t==="scorecard"&&e.jsx(Ei,{}),t==="crawl"&&e.jsx(zs,{}),t==="forensic"&&e.jsx(qs,{}),t==="compliance"&&e.jsx(ol,{}),t==="schedules"&&e.jsx(hl,{}),t==="risk"&&e.jsx(yl,{}),t==="copilot"&&e.jsx(Rl,{}),t==="ax-tree"&&e.jsx(Tl,{}),t==="wcag3"&&e.jsx(Hs,{}),t==="tokens"&&e.jsx(Ll,{})]})]}),e.jsx(Wi,{}),e.jsx(Gi,{}),e.jsx(Di,{}),e.jsx(ns,{}),e.jsx(Re,{})]})}class Hl extends ke.Component{constructor(){super(...arguments);kt(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{Bl as A,Hl as E,Wl as d};
|