@wcag-checkr/ci 1.0.0-rc.131 → 1.0.0-rc.133
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-6fekJUUp.js → ErrorBoundary-DVe_75ve.js} +47 -47
- package/dist/assets/{copy-ai-fixer-prompt-CH4gMq6S.js → copy-ai-fixer-prompt-B8cjAbqP.js} +2 -2
- package/dist/assets/{devtools-panel-KapiAcmC.js → devtools-panel-BgxcN3RP.js} +1 -1
- package/dist/assets/{options-BNX5zWaI.js → options-CHJIfX1c.js} +1 -1
- package/dist/assets/{parallel-tab-flow-mOvA88F_.js → parallel-tab-flow-DE4wbeMj.js} +1 -1
- package/dist/assets/{scheduled-audit-runner-ttLLjR9p.js → scheduled-audit-runner-SsZF0LGq.js} +32 -32
- package/dist/assets/service-worker.ts-Y3OxkpZv.js +909 -0
- package/dist/assets/{side-panel-DKAPcCcU.js → side-panel-BSFGuRQJ.js} +1 -1
- package/dist/assets/{site-report-renderer-ImlCBsok.js → site-report-renderer-ErZrhshM.js} +1 -1
- package/dist/assets/styles-BfvBWXAr.css +1 -0
- package/dist/devtools/panel.html +5 -5
- package/dist/manifest.json +2 -2
- package/dist/options/options.html +3 -3
- package/dist/service-worker-loader.js +1 -1
- package/dist/side-panel/App.tsx +2 -0
- package/dist/side-panel/side-panel.html +5 -5
- package/dist/side-panel/store.ts +1 -1
- package/package.json +1 -1
- package/dist/assets/service-worker.ts-B0UmIHMv.js +0 -822
- package/dist/assets/styles-4ARdTbO6.css +0 -1
- /package/dist/assets/{styles-DKRHxn1G.js → styles-D87cK8TZ.js} +0 -0
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-
|
|
2
|
-
var $s=Object.defineProperty;var Us=(t,s,a)=>s in t?$s(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var jt=(t,s,a)=>Us(t,typeof s!="symbol"?s+"":s,a);import{R as Ae,i as ce,r as h,j as e,M as be,C as Ze,l as Ls,o as lt,t as ot,m as Yt,s as Jt,k as Ee}from"./styles-DKRHxn1G.js";import{s as Ds,g as Os,a as le,b as _s,u as Fs,c as Ms,d as Ps,e as Gs,f as ct,h as Xt,A as ee,l as dt,i as Ws,j as Le,k as Zt,m as Vs,n as ut,o as Bs,p as Hs,N as zs,q as Ks,O as qs,r as Qs,t as Ys,v as Js,w as wt,x as Xs,y as es,z as Zs,B as ea,C as ta,D as sa,E as aa,F as na,T as ra,G as ia,H as la,I as oa,J as ca,K as da,L as Nt,M as kt,P as ze,Q as ua,R as St,S as pa,U as ma,V as ha,W as xa,X as ga}from"./scheduled-audit-runner-ttLLjR9p.js";import{_ as pt}from"./diff-DA41zYPc.js";import{o as oe,r as te,s as J,c as ts,b as pe,d as Ie}from"./crash-reporter-Dc5lvxvY.js";import{B as Ke,i as ss,f as as,T as ns}from"./ai-usage-log-DBBVxutJ.js";const At=t=>{let s;const a=new Set,n=(p,d)=>{const m=typeof p=="function"?p(s):p;if(!Object.is(m,s)){const u=s;s=d??(typeof m!="object"||m===null)?m:Object.assign({},s,m),a.forEach(x=>x(s,u))}},r=()=>s,o={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,o);return o},fa=t=>t?At(t):At,ba=t=>t;function va(t,s=ba){const a=Ae.useSyncExternalStore(t.subscribe,Ae.useCallback(()=>s(t.getState()),[t,s]),Ae.useCallback(()=>s(t.getInitialState()),[t,s]));return Ae.useDebugValue(a),a}const Ct=t=>{const s=fa(t),a=n=>va(s,n);return Object.assign(a,s),a},ya=t=>t?Ct(t):Ct,f=ya(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Ds(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(o=>o.id!==s?o:a==="seen"?{...o,seen:!0}:a==="dismissed"?{...o,dismissed:!0}:a==="acknowledged"?{...o,acknowledged:!0}:a==="clicked"?{...o,clicked:!0}:o).filter(o=>o.severity==="critical"?!o.acknowledged:!o.dismissed),i=r.filter(o=>!o.seen).length,l=r.some(o=>o.severity==="critical"&&!o.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:l}})})),_e="sidePanel:lastAudit";function ja(){const t=[];return t.push(oe("AUDIT_PROGRESS_EVENT",s=>{const a=f.getState().status==="running";f.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),f.getState().setStatus("running"),a||ce.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(oe("AUDIT_COMPLETE_EVENT",s=>{var i;f.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((l,o)=>l+o.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;ce.polite(r),wa({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(oe("AUDIT_FAILED_EVENT",s=>{f.getState().setError(s.error.message)})),t.push(oe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=f.getState().aiProgress;f.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ce.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(oe("AI_AUGMENTATION_FAILED_EVENT",s=>{f.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(oe("SCORECARD_UPDATED_EVENT",()=>{Fe()})),t.push(oe("LICENSE_CHANGED_EVENT",()=>{rs()})),t.push(oe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ce.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(oe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=f.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(oe("SITE_CRAWL_FAILED_EVENT",s=>{const a=f.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 wa(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[_e]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Na(){const s=(await chrome.storage.local.get(_e))[_e];s&&f.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function ka(){await chrome.storage.local.remove(_e)}async function Ve(){f.getState().clearResults(),await ka()}async function Fe(){const t=await te({type:"BASELINE_LIST"});f.getState().setBaselineList(t.items)}async function rs(t){const s=await te({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});f.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),is()}async function is(){const{fetchMessages:t}=await pt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ua);return{fetchMessages:n}},void 0),s=f.getState().userMode,a=await t(s);a&&f.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Sa(){const s=(await te({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;f.getState().setUserMode(a)}function Aa(){return chrome.runtime.connect({name:"audit-keepalive"})}let Me=null;async function Ca(){if(Me===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Me=t.id)}catch{}}function ls(){if(Me===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Me}).catch(()=>{})}function ue(t){ls(),J(t)}function Ia({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,l]=h.useState(!0),[o,c]=h.useState(""),[p,d]=h.useState(!1),[m,u]=h.useState(null);async function x(g){var y;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),u(null);try{const S=await te({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:o.trim()||void 0});S.success?(u({ok:!0,msg:`Sent (ref: ${S.ticketRef??"n/a"})`}),setTimeout(t,1200)):u({ok:!1,msg:((y=S.error)==null?void 0:y.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:x,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:g=>a(g.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:n,onChange:g=>r(g.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:o,onChange:g=>c(g.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:g=>l(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)."})]}),m&&e.jsx("p",{id:"support-form-result",role:m.ok?"status":"alert",className:`text-xs ${m.ok?"text-green-700":"text-red-700"}`,children:m.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function It({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 Pe=ts("messages-client"),Ra="https://api.wcagcheckr.com",os="wcagcheckr",Ea=1e4;function Ta(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function cs(t,s){const a=await Os();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Ta()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Ra}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Ea)})}async function $a(t){try{const s=await cs(`/v1/products/${os}/messages`,{userMode:t??null});return s.ok?await s.json():(Pe.warn("fetchMessages http",s.status),null)}catch(s){return Pe.warn("fetchMessages failed",s),null}}async function xe(t,s){try{const a=await cs(`/v1/products/${os}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Pe.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Pe.warn("ackMessage failed",a),!1}}const Ua=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:xe,fetchMessages:$a},Symbol.toStringTag,{value:"Module"})),La=["http:","https:"];function Da(t){try{const s=new URL(t);return La.includes(s.protocol)}catch{return!1}}function Rt(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const l=t.indexOf(")",i+2);if(l!==-1){const o=t.slice(a+1,i),c=t.slice(i+2,l);Da(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:o},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:o},`l-${n++}`)),a=l+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function ds({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function l(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Rt(c)},`p-${i++}`)),r=[]}function o(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,p)=>e.jsx("li",{children:Rt(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){l(),o();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){l(),n.push(d[1]);continue}o(),r.push(p)}return l(),o(),e.jsx("div",{className:"space-y-1.5",children:a})}const Oa={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},_a={critical:"bg-rose-50 border-rose-200"};function us(){const t=f(u=>u.unreadMessageCount),s=f(u=>u.messages),a=f(u=>u.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[l,o]=h.useState(!1);h.useEffect(()=>{const u=s.filter(g=>!g.seen);if(u.length===0)return;const x=Math.max(...u.map(g=>g.id));if(x>i.current){i.current=x,o(!0);const g=setTimeout(()=>o(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const u=s.filter(x=>!x.seen);if(u.length!==0)for(const x of u)a(x.id,"seen"),xe(x.id,"seen")}function p(){const u=!n;r(u),u&&c()}async function d(u){a(u.id,"dismissed"),await xe(u.id,"dismissed")}async function m(u){u.ctaUrl&&(a(u.id,"clicked"),xe(u.id,"clicked"),chrome.tabs.create({url:u.ctaUrl}).catch(()=>{window.open(u.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Fa,{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(Ma,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:m})]})}function Fa({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 Ma({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=h.useRef(null);return h.useEffect(()=>{const i=o=>{r.current&&(r.current.contains(o.target)||s())},l=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{is()},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 ${Oa[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(ds,{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 ps(){const t=f(i=>i.messages),s=f(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await xe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),xe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${_a.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(ds,{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 ve=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","forensic","compliance"];function Pa(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Ga(){var m,u;const t=f(x=>x.view),s=f(x=>x.setView),a=f(x=>x.setUserMode),n=f(x=>x.results),r=f(x=>x.status),[i,l]=h.useState(!1),o=((m=n[0])==null?void 0:m.pageUrl)??((u=n[0])==null?void 0:u.scope),c=Pa(o),p=n.length>0&&r!=="running";function d(){a("owner"),J({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:d,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(us,{}),e.jsx(It,{onClick:()=>void J({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(It,{onClick:()=>l(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:o??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void Ve(),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(Wa,{view:t,setView:s}),e.jsx(be,{open:i,onClose:()=>l(!1),title:"Send support message",children:e.jsx(Ia,{onClose:()=>l(!1)})})]})}function Wa({view:t,setView:s}){const a=h.useRef([]);function n(i){var c;const l=(i+ve.length)%ve.length,o=ve[l];o&&(s(o),(c=a.current[l])==null||c.focus())}function r(i,l){switch(i.key){case"ArrowRight":i.preventDefault(),n(l+1);break;case"ArrowLeft":i.preventDefault(),n(l-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ve.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ve.map((i,l)=>{const o=t===i;return e.jsx("button",{ref:c=>{a.current[l]=c},role:"tab","aria-selected":o,tabIndex:o?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,l),className:o?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Va({feature:t,upgradeUrl:s}){const[a,n]=h.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(Ze,{open:a,onClose:()=>n(!1)})]})}const Ba="https://wcagcheckr.com/upgrade";function Ha(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState(null),[c,p]=h.useState(Ke),[d,m]=h.useState(Ke[0].id),u=f(w=>w.status),x=f(w=>w.tier),g=f(w=>w.results.length>0),y=u==="running";h.useEffect(()=>{Promise.all([te({type:"SETTINGS_GET",key:"matrixPresets"}),te({type:"SETTINGS_GET",key:"activePresetId"})]).then(([w,j])=>{const D=Array.isArray(w.data)?w.data:null;p(D&&D.length>0?D:Ke),typeof j.data=="string"&&m(j.data)})},[]);function S(w){const j=c.find(D=>D.id===w);j&&(m(w),J({type:"SETTINGS_SET",key:"activePresetId",value:w}),J({type:"SETTINGS_SET",key:"stateMatrix",value:j.matrix}))}const $=ss(x,"storybookAutoIterate");h.useEffect(()=>{const w=oe("ELEMENT_PICKED_EVENT",(D,_)=>{n(!1);const G=_.frameId;L(G),i({selector:D.selector,frameId:G})}),j=oe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{w(),j()}},[]);async function k(){const w=await le();w&&(n(!0),await pe(w,{type:"PICKER_ACTIVATE_REQUEST",tabId:w}))}function T(){r&&(L(r.frameId),ue({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),f.getState().startNewScan())}function b(){if(!$){o("storybook:auto-iterate");return}L(),ue({type:"START_AUDIT",mode:"storybook-all"}),f.getState().startNewScan()}function A(){L(),ue({type:"START_AUDIT",mode:"all-frames"}),f.getState().startNewScan()}function N(){L(),ue({type:"START_AUDIT",mode:"full-page"}),f.getState().startNewScan()}function I(){L(),ue({type:"START_AUDIT",mode:"quick-scan"}),f.getState().startNewScan()}function O(){L(),ue({type:"START_AUDIT",mode:"parallel-scan"}),f.getState().startNewScan()}function v(){J({type:"CANCEL_AUDIT"})}async function L(w){f.getState().setPinned(null);const j=await le();if(j)try{await pe(j,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:j},w)}catch{}}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:w=>s(w.target.value),disabled:y||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)",$?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:w=>S(w.target.value),disabled:y||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:c.map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))}),t==="single-element"?e.jsx(za,{picking:a,picked:r,isRunning:y,onPick:k,onRun:T,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:N,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:I,disabled:y,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:y?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:O,disabled:y,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:y?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:A,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:b,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Audit all stories"}),y&&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"}),!y&&g&&e.jsx("button",{type:"button",onClick:()=>void Ve(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!a&&!y&&e.jsx(Ka,{selector:r.selector,onRepick:k,onClear:()=>i(null)})]}),e.jsx(be,{open:l!==null,onClose:()=>o(null),title:"Upgrade to continue",children:e.jsx(Va,{feature:l??"",upgradeUrl:Ba})})]})}function za({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.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("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Ka({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 qa={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Qa={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Ya(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState("off"),p=f(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await le();g&&(o(x),x==="off"?await pe(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await pe(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function m(x){const g=await le();if(g){if(t&&await pe(g,{type:qa[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await pe(g,{type:Qa[x],tabId:g}).catch(()=>{}),s(x)}}async function u(){const x=await le();if(x){if(a){await pe(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const g=await Ie(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:p});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(ye,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>m("outline")}),e.jsx(ye,{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:()=>m("tab-order")}),e.jsx(ye,{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:()=>m("reading-order")}),e.jsx(ye,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>m("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ye,{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:u}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:l,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${l==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ye({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 Ja(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 Xa(){const t=f(c=>c.status),s=f(c=>c.progress),a=f(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":Ja(s.currentState),l=n?100:s.current/s.total*100,o=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(Et,{label:r,detail:i,pct:l,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),o&&e.jsx(Et,{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 Et({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:l,fillClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${l}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${o}`,style:{width:`${a}%`}})})]})}const je={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Za(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const en={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 Ge({violation:t,alreadyAcknowledged:s}){const a=f(k=>k.pinnedMatchKey),n=f(k=>k.pinnedFound),r=f(k=>k.setPinned),i=f(k=>{var T;return(T=k.results[0])==null?void 0:T.frameId}),l=f(k=>{var T;return(T=k.results[0])==null?void 0:T.scope}),o=f(k=>k.results),c=f(k=>k.acknowledgedKeys.has(t.matchKey)),p=f(k=>k.markAcknowledged),d=f(k=>k.markUnacknowledged),m=s||c,u=a===t.matchKey,x=u&&!n;async function g(k){try{return(await Ie(k,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:k,selector:t.target.selector},i)).found}catch{return!0}}async function y(){const k=await le();if(!k)return;if(u){r(null);try{await pe(k,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:k},i)}catch{}return}const T=await g(k);r(t.matchKey,T)}function S(k){k.stopPropagation(),t.currentState.breakpoint.width<=640&&ls(),(async()=>{const T=await le();if(!T)return;try{await te({type:"STATE_DRIVE_REQUEST",tabId:T,state:t.currentState,scope:l,frameId:i})}catch{}const b=await g(T);r(t.matchKey,b)})()}async function $(k){k.stopPropagation();const T=await le();if(!T)return;try{await te({type:"STATE_DRIVE_REQUEST",tabId:T,state:nn(),scope:l,frameId:i})}catch{J({type:"STATE_RESET_REQUEST",tabId:T})}const b=await g(T);r(t.matchKey,b)}return e.jsxs("button",{type:"button",onClick:y,"aria-pressed":u,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
3
|
-
${u?"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 ${en[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(rn,{violation:t}),e.jsx(cn,{violation:t}),e.jsx(on,{violation:t}),e.jsx(ln,{text:t.target.failureSummary}),e.jsx(dn,{ruleId:t.ruleId}),u&&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: ",tn(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),S(k))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:$,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),$(k))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),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:m?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:k=>{k.stopPropagation(),d(t.matchKey),an(t,o)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:k=>{k.stopPropagation(),p(t.matchKey),sn(t,o)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:k=>k.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function tn(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 sn(t,s){await Ms({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await ms(t.componentId,s)}async function an(t,s){await Fs(t.componentId,t.matchKey),await ms(t.componentId,s)}async function ms(t,s){const a=s.flatMap(n=>n.violations);try{const n=await te({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});f.getState().setDelta(n.delta)}catch{}}function nn(){const t=as.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function hs(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 rn({violation:t}){const s=hs(t);if(!s)return null;const a=s.ratio>=s.required;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px]",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"]})]})}function ln({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 on({violation:t}){const s=Za(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 cn({violation:t}){const s=hs(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return _s(t.matchKey).then(l=>{l&&!i&&n({kind:"ready",suggestion:l})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await te({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),o=l.results.find(c=>c.matchKey===t.matchKey);o?(await Ps(o),n({kind:"ready",suggestion:o})):n({kind:"empty",reason:l.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function dn({ruleId:t}){const s=Gs(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}const et=[{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 mt(t){const s=et.map(r=>pn(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(l=>l==="A").length,a=t.filter(l=>l==="C").length,n=t.filter(l=>l==="D").length,r=t.filter(l=>l==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function pn(t,s){const a=new Set(t.axeRules),n=s.violations.filter(j=>a.has(j.ruleId)),r=s.manualRuns.filter(j=>t.igtWorkflowIds.includes(j.workflowId)),i=t.igtWorkflowIds.map(j=>s.workflows.find(D=>D.id===j)).filter(j=>j!=null);let l=i.length>0;for(const j of i){const D=r.find(G=>G.workflowId===j.id);if((D?Object.keys(D.steps).length:0)!==j.steps.length){l=!1;break}}const o=r.some(j=>Object.keys(j.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(j=>c.includes(j.workflowId)),d=c.map(j=>s.workflows.find(D=>D.id===j)).filter(j=>j!=null);let m=c.length>0&&d.length===c.length;for(const j of d){const D=p.find(G=>G.workflowId===j.id);if((D?Object.keys(D.steps).length:0)!==j.steps.length){m=!1;break}}let u=null;if(m)for(const j of p)j.completedAt&&(u===null||j.completedAt>u)&&(u=j.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,y=s.interactiveAuditVerdicts,S=[];y&&(t.id==="tab-order"&&y.focusOrder&&S.push({verdict:y.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(y.keyboardTrap&&S.push({verdict:y.keyboardTrap,criterionId:"2.1.2"}),y.focusVisible&&S.push({verdict:y.focusVisible,criterionId:"2.4.7"})));const $=S.some(j=>j.verdict==="fail");if(S.length>0&&S.every(j=>j.verdict==="pass")&&c.length>0&&!m)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(j=>j.criterionId)};if(m&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:u,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const T=t.axeRules.length>0||t.heuristic!=null,b=t.igtWorkflowIds.length>0;if(T?!s.auditRan:!o)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:b||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const N={critical:0,serious:0,moderate:0,minor:0};for(const j of ct(n))N[j.impact]++;S.length>0&&S.every(j=>j.verdict==="pass")||(N.serious+=x),$&&(N.serious+=S.filter(j=>j.verdict==="fail").length);for(const j of r){const D=i.find(_=>_.id===j.workflowId);if(D)for(const _ of D.steps){const G=j.steps[_.id];(G==null?void 0:G.status)==="fail"&&(_.severity==="required"?N.serious++:N.moderate++)}}const O=N.critical>0,v=N.serious>0;let L;N.critical>=5?L="F":N.critical>=1?L="D":N.serious>=1?L="C":N.moderate>=1?L="B":L="A";const w=L!=="A"&&(b&&!l||c.length>0&&!m);return{id:t.id,label:t.label,letter:L,untested:!1,needsIgt:w,igtCompleted:l,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:N,caps:{cappedAtC:O,cappedAtB:v}}}const tt="dismissedFindings";function Be(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ge(t){return`reading-order::${t}`}function fe(t){return`tab-order::${t}`}async function He(){try{const t=await chrome.storage.local.get(tt),s=t==null?void 0:t[tt];if(s&&typeof s=="object")return s}catch{}return{}}async function ht(t){await chrome.storage.local.set({[tt]:t})}async function We(t){return(await He())[Be(t)]??{}}async function xs(t,s,a,n){const r=await He(),i=Be(t),l=r[i]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=l,await ht(r)}async function Re(t,s){if(s.length===0)return;const a=await He(),n=Be(t),r=a[n]??{},i=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:i,snippet:l.snippet};a[n]=r,await ht(a)}async function gs(t,s){const a=await He(),n=Be(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await ht(a))}const ml=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:xs,addDismissals:Re,dismissalKeyForReadingOrder:ge,dismissalKeyForTabOrder:fe,getDismissalsForUrl:We,removeDismissal:gs},Symbol.toStringTag,{value:"Module"}));function fs(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function bs(t){return`${dt(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function mn(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=bs(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 Tt={critical:0,serious:1,moderate:2,minor:3};function hn(){var k,T,b,A;const t=f(N=>N.results),s=f(N=>N.componentId),a=f(N=>N.setView),n=((k=t[0])==null?void 0:k.pageUrl)??((T=t[0])==null?void 0:T.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(new Set),[c,p]=h.useState({});if(h.useEffect(()=>{if(!s){p({});return}let N=!1;const I=async()=>{const v=await Xt(s);if(N)return;const L={};for(const w of v)w.criterionId==="2.4.3"?L.focusOrder=w.verdict:w.criterionId==="2.1.2"?L.keyboardTrap=w.verdict:w.criterionId==="2.4.7"?L.focusVisible=w.verdict:w.criterionId==="1.3.2"&&(L.readingOrder=w.verdict);p(L)};I();const O=v=>{v.interactiveAuditResults&&I()};return chrome.storage.local.onChanged.addListener(O),()=>{N=!0,chrome.storage.local.onChanged.removeListener(O)}},[s]),h.useEffect(()=>{if(!n)return;We(n).then(i);const N=()=>{document.visibilityState==="visible"&&n&&We(n).then(i)};return document.addEventListener("visibilitychange",N),()=>document.removeEventListener("visibilitychange",N)},[n]),h.useEffect(()=>{if(!s){o(new Set);return}let N=!1;const I=async()=>{const v=await chrome.storage.local.get("igtRuns");if(N)return;const w=((v==null?void 0:v.igtRuns)??{})[s]??{},j=new Set;for(const D of ee){const _=w[D.id];_&&Object.keys(_.steps).length===D.steps.length&&j.add(D.id)}o(j)};I();const O=()=>{document.visibilityState==="visible"&&I()};return document.addEventListener("visibilitychange",O),()=>{N=!0,document.removeEventListener("visibilitychange",O)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((N,I)=>N+I.durationMs,0),m=t.reduce((N,I)=>N+I.violations.length,0),u=mn(t);u.sort((N,I)=>{const O=Tt[N.representative.impact]??99,v=Tt[I.representative.impact]??99;return O!==v?O-v:I.states.length-N.states.length});const x=t.map(N=>fs(N.state)).join(`
|
|
4
|
-
`),g=c.focusOrder!==void 0||c.keyboardTrap==="pass",y=l.has("keyboard")||g?0:(((b=t[0])==null?void 0:b.tabOrderIssues)??[]).filter(N=>!(fe(N.selector)in r)).length,S=c.readingOrder!==void 0,$=l.has("page-structure")||S?0:(((A=t[0])==null?void 0:A.readingOrderIssues)??[]).filter(N=>!(ge(N.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(
|
|
5
|
-
`);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 yn={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},jn={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}){var ae,ne,re,R,H,X,V;const[a,n]=h.useState([]),[r,i]=h.useState([]),[l,o]=h.useState(new Set),[c,p]=h.useState(null),[d,m]=h.useState({}),[u,x]=h.useState(new Set),g=f(C=>C.status),y=f(C=>C.progress),S=f(C=>C.freshThisSession),$=f(C=>C.results),k=(ae=$[0])==null?void 0:ae.startedAt,T=((ne=$[0])==null?void 0:ne.pageUrl)??((re=$[0])==null?void 0:re.scope)??null;if(h.useEffect(()=>{if(!s){n([]);return}let C=!1;return chrome.storage.local.get("igtRuns").then(M=>{if(C)return;const Q=((M==null?void 0:M.igtRuns)??{})[s]??{};n(Object.values(Q))}),()=>{C=!0}},[s]),h.useEffect(()=>{if(!T){i([]);return}let C=!1;return Le(T).then(M=>{C||i(M)}),()=>{C=!0}},[T]),g==="running")return e.jsx(Rn,{current:y==null?void 0:y.current,total:y==null?void 0:y.total});const b=mt({violations:t,auditRan:$.length>0,manualRuns:a,workflows:ee,heuristicCounts:{tabOrder:((H=(R=$[0])==null?void 0:R.tabOrderIssues)==null?void 0:H.length)??0,readingOrder:((V=(X=$[0])==null?void 0:X.readingOrderIssues)==null?void 0:V.length)??0}}),A=f(C=>C.acknowledgedKeys),N=$.length>0?Zt($,{runs:a,workflows:ee},"2.1","AA",A,r):void 0,I=$.length>0?Vs(ut({audits:$,igtRuns:a,workflows:ee,acknowledgedMatchKeys:A,incompleteResolutions:r}),ee):void 0,O=N?N.failingCriteria.length>0||N.inconclusiveCriteria.length>0:!1,v=O&&b.overallLetter==="A"?"B":b.overallLetter;async function L(C){var me;if(!T||!((me=N==null?void 0:N.inconclusiveReasons)!=null&&me[C]))return;const Z=N.inconclusiveReasons[C].filter(se=>se.source==="axe-incomplete"&&se.elements&&se.elements.length>0);if(Z.length===0)return;o(se=>new Set(se).add(C)),p(null);const Q=[];let q=0;try{for(const Y of Z){const E=await J({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:Y.ruleOrStepId,pageUrl:Y.pageUrl??T,wcagCriterion:C,elements:Y.elements??[],targetLevel:"AA"});if(E!=null&&E.unavailableReason){p(E.unavailableReason);break}E!=null&&E.resolutions&&(Q.push(...E.resolutions),q+=E.totalCostUsd??0)}if(T){const Y=await Le(T);i(Y)}const se={total:Q.length,pass:Q.filter(Y=>Y.verdict==="pass").length,fail:Q.filter(Y=>Y.verdict==="fail").length,uncertain:Q.filter(Y=>Y.verdict==="uncertain").length,costUsd:q,resolutions:Q};m(Y=>({...Y,[C]:se}))}finally{o(se=>{const Y=new Set(se);return Y.delete(C),Y})}}function w(C){x(M=>{const Z=new Set(M);return Z.has(C)?Z.delete(C):Z.add(C),Z})}async function j(C){var E,B;if(!T)return;const M=((E=N==null?void 0:N.inconclusiveReasons)==null?void 0:E[C])??[],Z=((B=N==null?void 0:N.failingReasons)==null?void 0:B[C])??[],Q=[],q=new Set;for(const F of M){if(F.source!=="axe-incomplete"||!F.elements)continue;const P=F.pageUrl??T;for(const z of F.elements){const K=`${P}::${F.ruleOrStepId}::${z.selector}`;q.has(K)||(q.add(K),Q.push({ruleId:F.ruleOrStepId,pageUrl:P,selector:z.selector}))}}for(const F of Z){if(F.source!=="ai"||!F.selector)continue;const P=F.ruleOrStepId.startsWith("ai-resolved::")?F.ruleOrStepId.slice(13):F.ruleOrStepId,z=F.pageUrl??T,K=`${z}::${P}::${F.selector}`;q.has(K)||(q.add(K),Q.push({ruleId:P,pageUrl:z,selector:F.selector}))}if(Q.length===0)return;const me=new Date().toISOString(),se=[];for(const F of Q){const P=r.find(z=>z.pageUrl===F.pageUrl&&z.ruleId===F.ruleId&&z.selector===F.selector);P&&P.verdict==="pass"&&P.reasoning.startsWith("Marked as visually verified")||se.push({pageUrl:F.pageUrl,ruleId:F.ruleId,selector:F.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${me.slice(0,10)}.`,resolvedAt:me,costUsd:0,wcagCriterion:C})}if(se.length===0)return;await Bs(se);const Y=await Le(T);i(Y),m(F=>({...F,[C]:{total:se.length,pass:se.length,fail:0,uncertain:0,costUsd:0,resolutions:se}}))}const D=(()=>{if(!O||b.overallLetter!=="A"||!N)return null;const C=N.inconclusiveCriteria.length,M=N.failingCriteria.length,Z=[];M>0&&Z.push(`${M} WCAG ${N.targetLevel} ${M===1?"criterion":"criteria"} failing`),C>0&&Z.push(`${C} WCAG ${N.targetLevel} ${C===1?"criterion":"criteria"} inconclusive`);const Q=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 — ${Z.join(" + ")}. ${Q}`})();let _=0;for(const C of ee){const M=a.find(Q=>Q.workflowId===C.id);if(!M)continue;C.steps.every(Q=>{const q=M.steps[Q.id];return(q==null?void 0:q.status)==="pass"||(q==null?void 0:q.status)==="fail"||(q==null?void 0:q.status)==="skip"||(q==null?void 0:q.status)==="not-applicable"})&&_++}const G=ct(t.filter(C=>!A.has(C.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!S&&k&&e.jsx(En,{scannedAt:k}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${yn[v]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:v})}),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 ",b.subGrades.length," verification areas below. Untested areas count as F until verified."]}),D&&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:D})]})]}),b.isLawsuitRisk&&e.jsx(Sn,{areas:b.warningAreas}),e.jsx(An,{grades:b.subGrades}),N&&e.jsx(Nn,{coverage:N,onResolveWithAi:L,onMarkVisuallyVerified:j,resolving:l,resolveError:c,lastResolveResult:d,expandedResultFor:u,onToggleResultDetail:w}),I&&e.jsx(kn,{layers:I}),e.jsx(In,{violationsRemaining:G,manualCompleted:_,manualTotal:ee.length}),_>0||$.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:_})," of ",e.jsx("strong",{children:ee.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:`${_/ee.length*100}%`}})})]}):null]})}function Nn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:l,onToggleResultDetail:o}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,d]=h.useState(c>0&&c<=3),m=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),u=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 ${u?"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 ${u?"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 (",m,"%)"]}),u&&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)."]}),!u&&(()=>{const g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const y=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 ",y,"."]})})(),!u&&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."]}),!u&&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."]})]}),!u&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),className:"text-[11px] underline shrink-0 self-start",children:p?"hide":"show list"})]}),p&&!u&&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(y=>{var I,O;const S=g.kind==="inconclusive"?(I=t.inconclusiveReasons)==null?void 0:I[y]:void 0,$=g.kind==="failing"?(O=t.failingReasons)==null?void 0:O[y]:void 0,k=S==null?void 0:S.some(v=>v.source==="axe-incomplete"&&v.elements&&v.elements.length>0),T=$==null?void 0:$.some(v=>v.source==="ai"),b=(n==null?void 0:n.has(y))??!1,A=i==null?void 0:i[y],N=(l==null?void 0:l.has(y))??!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:["· ",y]}),(g.kind==="inconclusive"&&k||g.kind==="failing"&&T)&&(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:b,onClick:()=>s(y),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:b?"Resolving…":A?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:b,onClick:()=>a(y),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"})]})]}),A&&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 ",A.total," ",A.total===1?"verdict":"verdicts",":",A.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",A.pass," pass"]}),A.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",A.fail," fail"]}),A.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",A.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",A.costUsd.toFixed(4)]}),o&&e.jsx("button",{type:"button",onClick:()=>o(y),className:"ml-auto text-[10px] underline text-brand-700",children:N?"hide reasoning":"show reasoning"})]}),A.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",A.uncertain," ",A.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),A.pass===A.total&&A.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),N&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:A.resolutions.map((v,L)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:v.verdict==="pass"?"text-emerald-700 font-semibold":v.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:v.verdict==="pass"?"✓":v.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:v.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:v.reasoning})]},L))})]}),$&&$.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:$.map((v,L)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[v.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),v.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," fail — "]}),v.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," fail — "]}),v.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:v.selector}),v.notes&&e.jsx("span",{className:"text-rose-700",children:v.notes})]},L))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((v,L)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[v.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," — "]}),v.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," skipped — "]}),v.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," — "]}),v.resolutionHint,v.elements&&v.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",v.elements.length===1?"element":`${v.elements.length} elements`,":"," ",v.elements.slice(0,3).map((w,j,D)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:w.selector}),j<D.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},j)),v.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",v.elements.length-3," more"]})]})]},L))}):g.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},y)})})]},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 kn({layers:t}){const s=f(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,l=r.blocked.length,o=r.unevaluated.length,c=r.cleared,p=i>0&&l===0&&o===0,d=p?"text-emerald-700":l>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 ${p?"bg-emerald-500 text-white":l>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":l>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] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),l>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",l," blocked"]}),o>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",o," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:Ut[n].hint}),n==="human"&&o>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 Sn({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 An({grades:t}){const s=f(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 ${jn[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(Cn,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Cn({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=ee.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?vs(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 In({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=f(l=>l.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(l=>!l.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((l,o)=>{const c=o===i,p=l.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${o+1}.`}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[l.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label})]},o)})})]})}function Rn({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 En({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 (",vs(s)," old). Re-scan to grade the current page state."]})]})}function vs(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 Tn(){const t=f(a=>a.results),s=f(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(wn,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx($n,{})]})}function $n(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(we,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(we,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(we,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(we,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(we,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function we({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const Un={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 Ln({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,l=r.description,o=s.length;return o===1?e.jsx(Ge,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Un[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",o]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,p)=>e.jsx(Ge,{violation:c},p))})]})}function Dn(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 On={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function ys({open:t,onClose:s,format:a,content:n,filename:r}){const i=Ls(new Blob([n]).size);function l(){ot(n,r),s()}function o(){lt(n),s()}return e.jsxs(be,{open:t,onClose:s,title:On[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Lt=7800;function _n(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const m=`${d.ruleId}::${d.target.selector}`,u=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===m);if(x){x._states.includes(u)||x._states.push(u);continue}r.push({...d,_states:[u]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`### \`${d.ruleId}\` — ${d.impact}`),l.push(""),l.push(d.description),l.push(""),l.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),l.push(`- **Selector:** \`${d.target.selector}\``),l.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&l.push(`- **More info:** ${d.helpUrl}`),l.push(""),l.push("```html"),l.push(d.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
|
|
6
|
-
`),c=new URLSearchParams({title:i,body:o});let p=`${n}/issues/new?${c.toString()}`;return p.length>
|
|
7
|
-
`),c=new URLSearchParams({summary:i,description:o});let p=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>Dt&&(p=p.slice(0,Dt)),{url:p,summary:i,description:o}}const Ot=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Mn=["wcag-component-auditor","wcag-forensic-log"];async function Pn(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Ot);s=Object.keys(n).length,await chrome.storage.local.remove(Ot)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Mn)try{await Gn(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 Gn(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 st="accessibilityStatementInputs:v1";async function Wn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(st))[st];return s&&typeof s=="object"?s:null}async function Vn(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[st]:t})}function Bn({open:t,onClose:s,results:a}){const[n,r]=h.useState("eaa"),[i,l]=h.useState(""),[o,c]=h.useState(""),[p,d]=h.useState("partial"),[m,u]=h.useState(""),[x,g]=h.useState(""),[y,S]=h.useState(""),[$,k]=h.useState(""),[T,b]=h.useState("English"),[A,N]=h.useState("wcagcheckr (self-evaluation)"),[I,O]=h.useState("2.1"),[v,L]=h.useState("AA"),[w,j]=h.useState(!1),[D,_]=h.useState(null),G=h.useRef(null);if(h.useEffect(()=>{t&&(async()=>{var H,X,V,C;const R=await Wn();if(R&&(R.framing&&r(R.framing),R.organizationName&&l(R.organizationName),R.siteUrl&&c(R.siteUrl),R.conformanceStatus&&d(R.conformanceStatus),(H=R.contact)!=null&&H.email&&u(R.contact.email),(X=R.contact)!=null&&X.phone&&g(R.contact.phone),(V=R.contact)!=null&&V.formUrl&&S(R.contact.formUrl),R.countryCode&&k(R.countryCode),R.language&&b(R.language),R.auditedBy&&N(R.auditedBy),R.wcagVersion&&O(R.wcagVersion),R.wcagLevel&&L(R.wcagLevel)),!(R!=null&&R.siteUrl)&&((C=a[0])!=null&&C.pageUrl))try{const M=new URL(a[0].pageUrl);c(`${M.protocol}//${M.host}/`)}catch{}R!=null&&R.conformanceStatus||d(Hs(a)),setTimeout(()=>{var M;return(M=G.current)==null?void 0:M.focus()},50)})()},[t,a]),!t)return null;function ae(){var V;const R=new Date().toISOString().slice(0,10),H=(V=a[0])!=null&&V.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):R,X={};return m.trim()&&(X.email=m.trim()),x.trim()&&(X.phone=x.trim()),y.trim()&&(X.formUrl=y.trim()),{framing:n,organizationName:i.trim(),siteUrl:o.trim(),conformanceStatus:p,preparedAt:R,evaluatedAt:H,contact:X,countryCode:$||null,language:T.trim()||"English",auditedBy:A.trim()||"wcagcheckr (self-evaluation)",wcagVersion:I,wcagLevel:v}}function ne(R){if(!R.organizationName)return"Organization name is required.";if(!R.siteUrl)return"Site URL is required.";try{new URL(R.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!R.contact.email&&!R.contact.phone&&!R.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function re(R){_(null);const H=ae(),X=ne(H);if(X){_(X);return}j(!0);try{await Vn(H);const V=await te({type:"EXPORT_REQUEST",format:R==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:H}),C=(V==null?void 0:V.content)??"";if(!C||C.startsWith("# Accessibility statement — error")){_(C||"Export failed — no response.");return}try{await navigator.clipboard.writeText(C)}catch{}const M=new Blob([C],{type:R==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),Z=URL.createObjectURL(M);window.open(Z,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(Z),6e4),s()}catch(V){_(V instanceof Error?V.message:String(V))}finally{j(!1)}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40",role:"dialog","aria-modal":"true","aria-labelledby":"statement-dialog-title",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto m-4",onClick:R=>R.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked: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:G,type:"text",value:i,onChange:R=>l(R.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:o,onChange:R=>c(R.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:p,onChange:R=>d(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:I,onChange:R=>O(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:v,onChange:R=>L(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:m,onChange:R=>u(R.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:R=>g(R.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:y,onChange:R=>S(R.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:$,onChange:R=>k(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(zs).map(([R,H])=>e.jsxs("option",{value:R,children:[R," — ",H.name.replace(/^[A-Z]+\s*—\s*/,"")]},R))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:T,onChange:R=>b(R.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:A,onChange:R=>N(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),D&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:D})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void re("markdown"),disabled:w,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:w?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void re("html"),disabled:w,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:w?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:w,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 Hn(){const t=f(w=>w.delta),s=f(w=>w.componentId),a=f(w=>w.results),n=f(w=>w.tier),r=f(w=>w.baselineList),i=f(w=>w.siteCrawlReport),[l,o]=h.useState(""),[c,p]=h.useState(""),[d,m]=h.useState(!1),[u,x]=h.useState(!1),[g,y]=h.useState(null),[S,$]=h.useState(null),[k,T]=h.useState(!1);h.useEffect(()=>{Promise.all([te({type:"SETTINGS_GET",key:"githubRepoUrl"}),te({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([w,j])=>{o(typeof w.data=="string"?w.data:""),p(typeof j.data=="string"?j.data:"")})},[]);const b=ss(n,"exportJson"),A=ns[n].maxBaselines,N=r.some(w=>w.componentId===s),I=N||r.length<A;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 O(){if(!s||a.length===0)return;const w=a.flatMap(re=>re.violations),j=a.flatMap(re=>re.announcements??[]),D=a.flatMap(re=>re.focusEvents??[]),_=a[0],ae=(await te({type:"SETTINGS_GET",key:"stateMatrix"})).data??as;await J({type:"BASELINE_SET",componentId:s,violations:w,announcements:j,focusEvents:D,snapshotMeta:{url:window.location.href,axeVersion:_.axeVersion,matrixConfig:ae,capturedAt:new Date().toISOString()}});const ne=await te({type:"BASELINE_COMPARE",componentId:s,currentViolations:w,announcements:j,focusEvents:D,currentMatrix:ae});f.getState().setDelta(ne.delta),ce.polite(`Baseline saved for ${s}.`)}async function v(){if(!s||!N||!window.confirm(`Remove the saved baseline for "${s}"?
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-B8cjAbqP.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-ErZrhshM.js","assets/scheduled-audit-runner-SsZF0LGq.js","assets/ai-usage-log-DBBVxutJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Fs=Object.defineProperty;var Ms=(t,s,a)=>s in t?Fs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var jt=(t,s,a)=>Ms(t,typeof s!="symbol"?s+"":s,a);import{R as Ae,i as de,r as h,j as e,M as be,C as et,l as Ps,o as ot,t as ct,m as Zt,s as es,k as Ee}from"./styles-D87cK8TZ.js";import{s as Vs,g as Gs,a as le,b as Ws,u as Bs,c as Hs,d as zs,e as Ks,f as dt,h as ts,A as ee,l as ut,i as qs,j as De,k as ss,m as Qs,n as pt,o as Ys,p as Js,N as Xs,q as Zs,O as ea,r as ta,t as sa,v as aa,w as Nt,x as na,y as as,z as ra,B as ia,C as la,D as oa,E as ca,F as da,T as ua,G as pa,H as ma,I as ha,J as ns,K as xa,L as kt,M as St,P as Ke,Q as ga,R as At,S as fa,U as ba,V as va,W as ya,X as wa,Y as ja}from"./scheduled-audit-runner-SsZF0LGq.js";import{_ as mt}from"./diff-DA41zYPc.js";import{o as oe,r as te,s as J,c as rs,b as pe,d as Ie}from"./crash-reporter-Dc5lvxvY.js";import{B as qe,i as is,f as ls,T as os}from"./ai-usage-log-DBBVxutJ.js";const Ct=t=>{let s;const a=new Set,n=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const m=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(x=>x(s,m))}},r=()=>s,o={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,o);return o},Na=t=>t?Ct(t):Ct,ka=t=>t;function Sa(t,s=ka){const a=Ae.useSyncExternalStore(t.subscribe,Ae.useCallback(()=>s(t.getState()),[t,s]),Ae.useCallback(()=>s(t.getInitialState()),[t,s]));return Ae.useDebugValue(a),a}const It=t=>{const s=Na(t),a=n=>Sa(s,n);return Object.assign(a,s),a},Aa=t=>t?It(t):It,f=Aa(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Vs(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(o=>o.id!==s?o:a==="seen"?{...o,seen:!0}:a==="dismissed"?{...o,dismissed:!0}:a==="acknowledged"?{...o,acknowledged:!0}:a==="clicked"?{...o,clicked:!0}:o).filter(o=>o.severity==="critical"?!o.acknowledged:!o.dismissed),i=r.filter(o=>!o.seen).length,l=r.some(o=>o.severity==="critical"&&!o.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:l}})})),Fe="sidePanel:lastAudit";function Ca(){const t=[];return t.push(oe("AUDIT_PROGRESS_EVENT",s=>{const a=f.getState().status==="running";f.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),f.getState().setStatus("running"),a||de.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(oe("AUDIT_COMPLETE_EVENT",s=>{var i;f.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((l,o)=>l+o.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;de.polite(r),Ia({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(oe("AUDIT_FAILED_EVENT",s=>{f.getState().setError(s.error.message)})),t.push(oe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=f.getState().aiProgress;f.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||de.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(oe("AI_AUGMENTATION_FAILED_EVENT",s=>{f.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(oe("SCORECARD_UPDATED_EVENT",()=>{Me()})),t.push(oe("LICENSE_CHANGED_EVENT",()=>{cs()})),t.push(oe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&de.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(oe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),de.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(oe("SITE_CRAWL_FAILED_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),de.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Ia(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 Ra(){const s=(await chrome.storage.local.get(Fe))[Fe];s&&f.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Ea(){await chrome.storage.local.remove(Fe)}async function Be(){f.getState().clearResults(),await Ea()}async function Me(){const t=await te({type:"BASELINE_LIST"});f.getState().setBaselineList(t.items)}async function cs(t){const s=await te({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});f.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ds()}async function ds(){const{fetchMessages:t}=await mt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ma);return{fetchMessages:n}},void 0),s=f.getState().userMode,a=await t(s);a&&f.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Ta(){const s=(await te({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;f.getState().setUserMode(a)}function $a(){return chrome.runtime.connect({name:"audit-keepalive"})}let Pe=null;async function Ua(){if(Pe===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Pe=t.id)}catch{}}function us(){if(Pe===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Pe}).catch(()=>{})}function ue(t){us(),J(t)}function La({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,l]=h.useState(!0),[o,c]=h.useState(""),[p,d]=h.useState(!1),[u,m]=h.useState(null);async function x(g){var y;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),m(null);try{const S=await te({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:o.trim()||void 0});S.success?(m({ok:!0,msg:`Sent (ref: ${S.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((y=S.error)==null?void 0:y.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:x,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:g=>a(g.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:n,onChange:g=>r(g.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:o,onChange:g=>c(g.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:g=>l(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)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function Rt({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=rs("messages-client"),Da="https://api.wcagcheckr.com",ps="wcagcheckr",Oa=1e4;function _a(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ms(t,s){const a=await Gs();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":_a()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Da}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Oa)})}async function Fa(t){try{const s=await ms(`/v1/products/${ps}/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 xe(t,s){try{const a=await ms(`/v1/products/${ps}/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 Ma=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:xe,fetchMessages:Fa},Symbol.toStringTag,{value:"Module"})),Pa=["http:","https:"];function Va(t){try{const s=new URL(t);return Pa.includes(s.protocol)}catch{return!1}}function Et(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const l=t.indexOf(")",i+2);if(l!==-1){const o=t.slice(a+1,i),c=t.slice(i+2,l);Va(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:o},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:o},`l-${n++}`)),a=l+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function hs({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function l(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Et(c)},`p-${i++}`)),r=[]}function o(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,p)=>e.jsx("li",{children:Et(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){l(),o();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){l(),n.push(d[1]);continue}o(),r.push(p)}return l(),o(),e.jsx("div",{className:"space-y-1.5",children:a})}const Ga={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Wa={critical:"bg-rose-50 border-rose-200"};function xs(){const t=f(m=>m.unreadMessageCount),s=f(m=>m.messages),a=f(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[l,o]=h.useState(!1);h.useEffect(()=>{const m=s.filter(g=>!g.seen);if(m.length===0)return;const x=Math.max(...m.map(g=>g.id));if(x>i.current){i.current=x,o(!0);const g=setTimeout(()=>o(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),xe(x.id,"seen")}function p(){const m=!n;r(m),m&&c()}async function d(m){a(m.id,"dismissed"),await xe(m.id,"dismissed")}async function u(m){m.ctaUrl&&(a(m.id,"clicked"),xe(m.id,"clicked"),chrome.tabs.create({url:m.ctaUrl}).catch(()=>{window.open(m.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Ba,{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(Ha,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}function Ba({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 Ha({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=h.useRef(null);return h.useEffect(()=>{const i=o=>{r.current&&(r.current.contains(o.target)||s())},l=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{ds()},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 ${Ga[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(hs,{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 gs(){const t=f(i=>i.messages),s=f(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await xe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),xe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Wa.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(hs,{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 ve=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","risk","forensic","compliance"];function za(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Ka(){var u,m;const t=f(x=>x.view),s=f(x=>x.setView),a=f(x=>x.setUserMode),n=f(x=>x.results),r=f(x=>x.status),[i,l]=h.useState(!1),o=((u=n[0])==null?void 0:u.pageUrl)??((m=n[0])==null?void 0:m.scope),c=za(o),p=n.length>0&&r!=="running";function d(){a("owner"),J({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:d,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(xs,{}),e.jsx(Rt,{onClick:()=>void J({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Rt,{onClick:()=>l(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:o??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void Be(),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(qa,{view:t,setView:s}),e.jsx(be,{open:i,onClose:()=>l(!1),title:"Send support message",children:e.jsx(La,{onClose:()=>l(!1)})})]})}function qa({view:t,setView:s}){const a=h.useRef([]);function n(i){var c;const l=(i+ve.length)%ve.length,o=ve[l];o&&(s(o),(c=a.current[l])==null||c.focus())}function r(i,l){switch(i.key){case"ArrowRight":i.preventDefault(),n(l+1);break;case"ArrowLeft":i.preventDefault(),n(l-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ve.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ve.map((i,l)=>{const o=t===i;return e.jsx("button",{ref:c=>{a.current[l]=c},role:"tab","aria-selected":o,tabIndex:o?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,l),className:o?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Qa({feature:t,upgradeUrl:s}){const[a,n]=h.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(et,{open:a,onClose:()=>n(!1)})]})}const Ya="https://wcagcheckr.com/upgrade";function Ja(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState(null),[c,p]=h.useState(qe),[d,u]=h.useState(qe[0].id),m=f(j=>j.status),x=f(j=>j.tier),g=f(j=>j.results.length>0),y=m==="running";h.useEffect(()=>{Promise.all([te({type:"SETTINGS_GET",key:"matrixPresets"}),te({type:"SETTINGS_GET",key:"activePresetId"})]).then(([j,w])=>{const D=Array.isArray(j.data)?j.data:null;p(D&&D.length>0?D:qe),typeof w.data=="string"&&u(w.data)})},[]);function S(j){const w=c.find(D=>D.id===j);w&&(u(j),J({type:"SETTINGS_SET",key:"activePresetId",value:j}),J({type:"SETTINGS_SET",key:"stateMatrix",value:w.matrix}))}const $=is(x,"storybookAutoIterate");h.useEffect(()=>{const j=oe("ELEMENT_PICKED_EVENT",(D,_)=>{n(!1);const V=_.frameId;L(V),i({selector:D.selector,frameId:V})}),w=oe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{j(),w()}},[]);async function k(){const j=await le();j&&(n(!0),await pe(j,{type:"PICKER_ACTIVATE_REQUEST",tabId:j}))}function T(){r&&(L(r.frameId),ue({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),f.getState().startNewScan())}function b(){if(!$){o("storybook:auto-iterate");return}L(),ue({type:"START_AUDIT",mode:"storybook-all"}),f.getState().startNewScan()}function A(){L(),ue({type:"START_AUDIT",mode:"all-frames"}),f.getState().startNewScan()}function N(){L(),ue({type:"START_AUDIT",mode:"full-page"}),f.getState().startNewScan()}function I(){L(),ue({type:"START_AUDIT",mode:"quick-scan"}),f.getState().startNewScan()}function O(){L(),ue({type:"START_AUDIT",mode:"parallel-scan"}),f.getState().startNewScan()}function v(){J({type:"CANCEL_AUDIT"})}async function L(j){f.getState().setPinned(null);const w=await le();if(w)try{await pe(w,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:w},j)}catch{}}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:j=>s(j.target.value),disabled:y||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)",$?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:j=>S(j.target.value),disabled:y||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:c.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))}),t==="single-element"?e.jsx(Xa,{picking:a,picked:r,isRunning:y,onPick:k,onRun:T,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:N,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:I,disabled:y,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:y?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:O,disabled:y,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:y?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:A,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:b,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Audit all stories"}),y&&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"}),!y&&g&&e.jsx("button",{type:"button",onClick:()=>void Be(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!a&&!y&&e.jsx(Za,{selector:r.selector,onRepick:k,onClear:()=>i(null)})]}),e.jsx(be,{open:l!==null,onClose:()=>o(null),title:"Upgrade to continue",children:e.jsx(Qa,{feature:l??"",upgradeUrl:Ya})})]})}function Xa({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.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("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Za({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"},tn={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function sn(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState("off"),p=f(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await le();g&&(o(x),x==="off"?await pe(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await pe(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function u(x){const g=await le();if(g){if(t&&await pe(g,{type:en[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await pe(g,{type:tn[x],tabId:g}).catch(()=>{}),s(x)}}async function m(){const x=await le();if(x){if(a){await pe(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const g=await Ie(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:p});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(ye,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(ye,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(ye,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(ye,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ye,{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:m}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:l,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${l==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ye({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 an(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 nn(){const t=f(c=>c.status),s=f(c=>c.progress),a=f(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":an(s.currentState),l=n?100:s.current/s.total*100,o=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(Tt,{label:r,detail:i,pct:l,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),o&&e.jsx(Tt,{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 Tt({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:l,fillClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${l}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${o}`,style:{width:`${a}%`}})})]})}const we={"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 rn(t){return/^wcag\d/.test(t.wcagCriterion)?[we["ada-iii"],we[508],we.eaa,we["en-301-549"],we.aoda]:[]}const ln={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 Ge({violation:t,alreadyAcknowledged:s}){const a=f(k=>k.pinnedMatchKey),n=f(k=>k.pinnedFound),r=f(k=>k.setPinned),i=f(k=>{var T;return(T=k.results[0])==null?void 0:T.frameId}),l=f(k=>{var T;return(T=k.results[0])==null?void 0:T.scope}),o=f(k=>k.results),c=f(k=>k.acknowledgedKeys.has(t.matchKey)),p=f(k=>k.markAcknowledged),d=f(k=>k.markUnacknowledged),u=s||c,m=a===t.matchKey,x=m&&!n;async function g(k){try{return(await Ie(k,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:k,selector:t.target.selector},i)).found}catch{return!0}}async function y(){const k=await le();if(!k)return;if(m){r(null);try{await pe(k,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:k},i)}catch{}return}const T=await g(k);r(t.matchKey,T)}function S(k){k.stopPropagation(),t.currentState.breakpoint.width<=640&&us(),(async()=>{const T=await le();if(!T)return;try{await te({type:"STATE_DRIVE_REQUEST",tabId:T,state:t.currentState,scope:l,frameId:i})}catch{}const b=await g(T);r(t.matchKey,b)})()}async function $(k){k.stopPropagation();const T=await le();if(!T)return;try{await te({type:"STATE_DRIVE_REQUEST",tabId:T,state:un(),scope:l,frameId:i})}catch{J({type:"STATE_RESET_REQUEST",tabId:T})}const b=await g(T);r(t.matchKey,b)}return e.jsxs("button",{type:"button",onClick:y,"aria-pressed":m,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
3
|
+
${m?"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 ${ln[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(pn,{violation:t}),e.jsx(xn,{violation:t}),e.jsx(hn,{violation:t}),e.jsx(mn,{text:t.target.failureSummary}),e.jsx(gn,{ruleId:t.ruleId}),m&&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: ",on(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),S(k))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:$,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),$(k))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),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:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:k=>{k.stopPropagation(),d(t.matchKey),dn(t,o)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:k=>{k.stopPropagation(),p(t.matchKey),cn(t,o)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:k=>k.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function on(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 cn(t,s){await Hs({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await fs(t.componentId,s)}async function dn(t,s){await Bs(t.componentId,t.matchKey),await fs(t.componentId,s)}async function fs(t,s){const a=s.flatMap(n=>n.violations);try{const n=await te({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});f.getState().setDelta(n.delta)}catch{}}function un(){const t=ls.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function bs(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 pn({violation:t}){const s=bs(t);if(!s)return null;const a=s.ratio>=s.required;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px]",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"]})]})}function mn({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 hn({violation:t}){const s=rn(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function xn({violation:t}){const s=bs(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return Ws(t.matchKey).then(l=>{l&&!i&&n({kind:"ready",suggestion:l})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await te({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),o=l.results.find(c=>c.matchKey===t.matchKey);o?(await zs(o),n({kind:"ready",suggestion:o})):n({kind:"empty",reason:l.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function gn({ruleId:t}){const s=Ks(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}const tt=[{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 ht(t){const s=tt.map(r=>bn(r,t)),a=fn(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 fn(t){const s=t.filter(l=>l==="A").length,a=t.filter(l=>l==="C").length,n=t.filter(l=>l==="D").length,r=t.filter(l=>l==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function bn(t,s){const a=new Set(t.axeRules),n=s.violations.filter(w=>a.has(w.ruleId)),r=s.manualRuns.filter(w=>t.igtWorkflowIds.includes(w.workflowId)),i=t.igtWorkflowIds.map(w=>s.workflows.find(D=>D.id===w)).filter(w=>w!=null);let l=i.length>0;for(const w of i){const D=r.find(V=>V.workflowId===w.id);if((D?Object.keys(D.steps).length:0)!==w.steps.length){l=!1;break}}const o=r.some(w=>Object.keys(w.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(w=>c.includes(w.workflowId)),d=c.map(w=>s.workflows.find(D=>D.id===w)).filter(w=>w!=null);let u=c.length>0&&d.length===c.length;for(const w of d){const D=p.find(V=>V.workflowId===w.id);if((D?Object.keys(D.steps).length:0)!==w.steps.length){u=!1;break}}let m=null;if(u)for(const w of p)w.completedAt&&(m===null||w.completedAt>m)&&(m=w.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,y=s.interactiveAuditVerdicts,S=[];y&&(t.id==="tab-order"&&y.focusOrder&&S.push({verdict:y.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(y.keyboardTrap&&S.push({verdict:y.keyboardTrap,criterionId:"2.1.2"}),y.focusVisible&&S.push({verdict:y.focusVisible,criterionId:"2.4.7"})));const $=S.some(w=>w.verdict==="fail");if(S.length>0&&S.every(w=>w.verdict==="pass")&&c.length>0&&!u)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(w=>w.criterionId)};if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:m,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const T=t.axeRules.length>0||t.heuristic!=null,b=t.igtWorkflowIds.length>0;if(T?!s.auditRan:!o)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:b||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const N={critical:0,serious:0,moderate:0,minor:0};for(const w of dt(n))N[w.impact]++;S.length>0&&S.every(w=>w.verdict==="pass")||(N.serious+=x),$&&(N.serious+=S.filter(w=>w.verdict==="fail").length);for(const w of r){const D=i.find(_=>_.id===w.workflowId);if(D)for(const _ of D.steps){const V=w.steps[_.id];(V==null?void 0:V.status)==="fail"&&(_.severity==="required"?N.serious++:N.moderate++)}}const O=N.critical>0,v=N.serious>0;let L;N.critical>=5?L="F":N.critical>=1?L="D":N.serious>=1?L="C":N.moderate>=1?L="B":L="A";const j=L!=="A"&&(b&&!l||c.length>0&&!u);return{id:t.id,label:t.label,letter:L,untested:!1,needsIgt:j,igtCompleted:l,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:N,caps:{cappedAtC:O,cappedAtB:v}}}const st="dismissedFindings";function He(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ge(t){return`reading-order::${t}`}function fe(t){return`tab-order::${t}`}async function ze(){try{const t=await chrome.storage.local.get(st),s=t==null?void 0:t[st];if(s&&typeof s=="object")return s}catch{}return{}}async function xt(t){await chrome.storage.local.set({[st]:t})}async function We(t){return(await ze())[He(t)]??{}}async function vs(t,s,a,n){const r=await ze(),i=He(t),l=r[i]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=l,await xt(r)}async function Re(t,s){if(s.length===0)return;const a=await ze(),n=He(t),r=a[n]??{},i=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:i,snippet:l.snippet};a[n]=r,await xt(a)}async function ys(t,s){const a=await ze(),n=He(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await xt(a))}const Cl=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:vs,addDismissals:Re,dismissalKeyForReadingOrder:ge,dismissalKeyForTabOrder:fe,getDismissalsForUrl:We,removeDismissal:ys},Symbol.toStringTag,{value:"Module"}));function ws(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function js(t){return`${ut(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function vn(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=js(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 $t={critical:0,serious:1,moderate:2,minor:3};function yn(){var k,T,b,A;const t=f(N=>N.results),s=f(N=>N.componentId),a=f(N=>N.setView),n=((k=t[0])==null?void 0:k.pageUrl)??((T=t[0])==null?void 0:T.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(new Set),[c,p]=h.useState({});if(h.useEffect(()=>{if(!s){p({});return}let N=!1;const I=async()=>{const v=await ts(s);if(N)return;const L={};for(const j of v)j.criterionId==="2.4.3"?L.focusOrder=j.verdict:j.criterionId==="2.1.2"?L.keyboardTrap=j.verdict:j.criterionId==="2.4.7"?L.focusVisible=j.verdict:j.criterionId==="1.3.2"&&(L.readingOrder=j.verdict);p(L)};I();const O=v=>{v.interactiveAuditResults&&I()};return chrome.storage.local.onChanged.addListener(O),()=>{N=!0,chrome.storage.local.onChanged.removeListener(O)}},[s]),h.useEffect(()=>{if(!n)return;We(n).then(i);const N=()=>{document.visibilityState==="visible"&&n&&We(n).then(i)};return document.addEventListener("visibilitychange",N),()=>document.removeEventListener("visibilitychange",N)},[n]),h.useEffect(()=>{if(!s){o(new Set);return}let N=!1;const I=async()=>{const v=await chrome.storage.local.get("igtRuns");if(N)return;const j=((v==null?void 0:v.igtRuns)??{})[s]??{},w=new Set;for(const D of ee){const _=j[D.id];_&&Object.keys(_.steps).length===D.steps.length&&w.add(D.id)}o(w)};I();const O=()=>{document.visibilityState==="visible"&&I()};return document.addEventListener("visibilitychange",O),()=>{N=!0,document.removeEventListener("visibilitychange",O)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((N,I)=>N+I.durationMs,0),u=t.reduce((N,I)=>N+I.violations.length,0),m=vn(t);m.sort((N,I)=>{const O=$t[N.representative.impact]??99,v=$t[I.representative.impact]??99;return O!==v?O-v:I.states.length-N.states.length});const x=t.map(N=>ws(N.state)).join(`
|
|
4
|
+
`),g=c.focusOrder!==void 0||c.keyboardTrap==="pass",y=l.has("keyboard")||g?0:(((b=t[0])==null?void 0:b.tabOrderIssues)??[]).filter(N=>!(fe(N.selector)in r)).length,S=c.readingOrder!==void 0,$=l.has("page-structure")||S?0:(((A=t[0])==null?void 0:A.readingOrderIssues)??[]).filter(N=>!(ge(N.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(kn,{violations:t.flatMap(N=>N.violations),componentId:s,manualRuns:[],interactiveVerdicts:c}),(y>0||$>0)&&e.jsxs("button",{type:"button",onClick:()=>a("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[y>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:y})," tab-order issue",y===1?"":"s"," (WCAG 2.4.3)"]}),y>0&&$>0&&" · ",$>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:$})," reading-order issue",$===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:x,"aria-label":`${t.length} states tested: ${x.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",m.length," unique ",m.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",u," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(jn,{groups:m,totalStates:t.length,violations:t.flatMap(N=>N.violations),interactiveVerdicts:c})]})}const wn={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 jn({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=ht({violations:a,auditRan:!0,manualRuns:[],workflows:ee,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,l=new Set;for(const c of tt){for(const p of c.axeRules)l.add(p);i.set(c.id,[])}const o=[];for(const c of t){let p=!1;for(const d of tt)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),p=!0;break}p||o.push(c)}return e.jsxs("div",{className:"space-y-1.5",children:[r.subGrades.map(c=>{const p=i.get(c.id)??[];return e.jsx(Ut,{subGrade:c,groups:p,totalStates:s},c.id)}),o.length>0&&e.jsx(Ut,{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:o,totalStates:s})]})}function Ut({subGrade:t,groups:s,totalStates:a}){const[n,r]=h.useState(!1),[i,l]=h.useState("idle"),[o,c]=h.useState(null),[p,d]=h.useState(0),u=s.length>0,m=wn[t.letter],x=s.filter(S=>S.representative.ruleId==="color-contrast"||S.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function y(S){S.stopPropagation(),l("loading"),c(null);try{const $=x.map(T=>{const b=T.representative.target.outerHTML,A=T.representative.target.failureSummary,N=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(A),I=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(A);if(!N||!I)return null;const O=T.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:T.representative.matchKey,foreground:N[1],background:I[1],fontSize:16,fontWeight:400,targetLevel:O,_html:b}}).filter(T=>T!==null);if($.length===0){l("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const k=await te({type:"AI_COLOR_SUGGEST_REQUEST",inputs:$.map(({_html:T,...b})=>b)});if(k.unavailableReason&&k.results.length===0){l("error"),c(k.unavailableReason);return}await qs(k.results),l("done"),d(T=>T+1),n||r(!0)}catch($){l("error"),c($ instanceof Error?$.message:String($))}}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:!u,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 ${m}`,"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:u?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),g&&e.jsx("span",{role:"button",tabIndex:0,onClick:S=>void y(S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),y(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}`}),u&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),i==="error"&&o&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:o}),n&&u&&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(Ge,{violation:S.representative}),e.jsx(Sn,{states:S.states,totalStates:a})]},`${js(S.representative)}::${p}`))})]})}const Nn={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 kn({violations:t,componentId:s,manualRuns:a,interactiveVerdicts:n}){const r=f(p=>p.setView),l=ht({violations:t,auditRan:!0,manualRuns:a,workflows:ee,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=dt(t).length;return e.jsx("div",{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-20 shrink-0 ${Nn[l]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:l})}),e.jsxs("div",{className:"flex-1 p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:c===0?"No issues found by automation":`${c} issue${c===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Grade is the mean of 9 verification areas."," ","See the Report tab for the full breakdown."]})]}),e.jsx("button",{type:"button",onClick:()=>r("report"),className:"shrink-0 text-[11px] font-medium px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"View Full Report →"})]})]})})}function Sn({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(ws))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
|
|
5
|
+
`);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 An={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Cn={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 In({violations:t,componentId:s}){var ae,ne,re,R,H,X,W;const[a,n]=h.useState([]),[r,i]=h.useState([]),[l,o]=h.useState(new Set),[c,p]=h.useState(null),[d,u]=h.useState({}),[m,x]=h.useState(new Set),g=f(C=>C.status),y=f(C=>C.progress),S=f(C=>C.freshThisSession),$=f(C=>C.results),k=(ae=$[0])==null?void 0:ae.startedAt,T=((ne=$[0])==null?void 0:ne.pageUrl)??((re=$[0])==null?void 0:re.scope)??null;if(h.useEffect(()=>{if(!s){n([]);return}let C=!1;return chrome.storage.local.get("igtRuns").then(M=>{if(C)return;const Q=((M==null?void 0:M.igtRuns)??{})[s]??{};n(Object.values(Q))}),()=>{C=!0}},[s]),h.useEffect(()=>{if(!T){i([]);return}let C=!1;return De(T).then(M=>{C||i(M)}),()=>{C=!0}},[T]),g==="running")return e.jsx(Dn,{current:y==null?void 0:y.current,total:y==null?void 0:y.total});const b=ht({violations:t,auditRan:$.length>0,manualRuns:a,workflows:ee,heuristicCounts:{tabOrder:((H=(R=$[0])==null?void 0:R.tabOrderIssues)==null?void 0:H.length)??0,readingOrder:((W=(X=$[0])==null?void 0:X.readingOrderIssues)==null?void 0:W.length)??0}}),A=f(C=>C.acknowledgedKeys),N=$.length>0?ss($,{runs:a,workflows:ee},"2.1","AA",A,r):void 0,I=$.length>0?Qs(pt({audits:$,igtRuns:a,workflows:ee,acknowledgedMatchKeys:A,incompleteResolutions:r}),ee):void 0,O=N?N.failingCriteria.length>0||N.inconclusiveCriteria.length>0:!1,v=O&&b.overallLetter==="A"?"B":b.overallLetter;async function L(C){var me;if(!T||!((me=N==null?void 0:N.inconclusiveReasons)!=null&&me[C]))return;const Z=N.inconclusiveReasons[C].filter(se=>se.source==="axe-incomplete"&&se.elements&&se.elements.length>0);if(Z.length===0)return;o(se=>new Set(se).add(C)),p(null);const Q=[];let q=0;try{for(const Y of Z){const E=await J({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:Y.ruleOrStepId,pageUrl:Y.pageUrl??T,wcagCriterion:C,elements:Y.elements??[],targetLevel:"AA"});if(E!=null&&E.unavailableReason){p(E.unavailableReason);break}E!=null&&E.resolutions&&(Q.push(...E.resolutions),q+=E.totalCostUsd??0)}if(T){const Y=await De(T);i(Y)}const se={total:Q.length,pass:Q.filter(Y=>Y.verdict==="pass").length,fail:Q.filter(Y=>Y.verdict==="fail").length,uncertain:Q.filter(Y=>Y.verdict==="uncertain").length,costUsd:q,resolutions:Q};u(Y=>({...Y,[C]:se}))}finally{o(se=>{const Y=new Set(se);return Y.delete(C),Y})}}function j(C){x(M=>{const Z=new Set(M);return Z.has(C)?Z.delete(C):Z.add(C),Z})}async function w(C){var E,B;if(!T)return;const M=((E=N==null?void 0:N.inconclusiveReasons)==null?void 0:E[C])??[],Z=((B=N==null?void 0:N.failingReasons)==null?void 0:B[C])??[],Q=[],q=new Set;for(const F of M){if(F.source!=="axe-incomplete"||!F.elements)continue;const P=F.pageUrl??T;for(const z of F.elements){const K=`${P}::${F.ruleOrStepId}::${z.selector}`;q.has(K)||(q.add(K),Q.push({ruleId:F.ruleOrStepId,pageUrl:P,selector:z.selector}))}}for(const F of Z){if(F.source!=="ai"||!F.selector)continue;const P=F.ruleOrStepId.startsWith("ai-resolved::")?F.ruleOrStepId.slice(13):F.ruleOrStepId,z=F.pageUrl??T,K=`${z}::${P}::${F.selector}`;q.has(K)||(q.add(K),Q.push({ruleId:P,pageUrl:z,selector:F.selector}))}if(Q.length===0)return;const me=new Date().toISOString(),se=[];for(const F of Q){const P=r.find(z=>z.pageUrl===F.pageUrl&&z.ruleId===F.ruleId&&z.selector===F.selector);P&&P.verdict==="pass"&&P.reasoning.startsWith("Marked as visually verified")||se.push({pageUrl:F.pageUrl,ruleId:F.ruleId,selector:F.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${me.slice(0,10)}.`,resolvedAt:me,costUsd:0,wcagCriterion:C})}if(se.length===0)return;await Ys(se);const Y=await De(T);i(Y),u(F=>({...F,[C]:{total:se.length,pass:se.length,fail:0,uncertain:0,costUsd:0,resolutions:se}}))}const D=(()=>{if(!O||b.overallLetter!=="A"||!N)return null;const C=N.inconclusiveCriteria.length,M=N.failingCriteria.length,Z=[];M>0&&Z.push(`${M} WCAG ${N.targetLevel} ${M===1?"criterion":"criteria"} failing`),C>0&&Z.push(`${C} WCAG ${N.targetLevel} ${C===1?"criterion":"criteria"} inconclusive`);const Q=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 — ${Z.join(" + ")}. ${Q}`})();let _=0;for(const C of ee){const M=a.find(Q=>Q.workflowId===C.id);if(!M)continue;C.steps.every(Q=>{const q=M.steps[Q.id];return(q==null?void 0:q.status)==="pass"||(q==null?void 0:q.status)==="fail"||(q==null?void 0:q.status)==="skip"||(q==null?void 0:q.status)==="not-applicable"})&&_++}const V=dt(t.filter(C=>!A.has(C.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!S&&k&&e.jsx(On,{scannedAt:k}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${An[v]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:v})}),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 ",b.subGrades.length," verification areas below. Untested areas count as F until verified."]}),D&&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:D})]})]}),b.isLawsuitRisk&&e.jsx(Tn,{areas:b.warningAreas}),e.jsx($n,{grades:b.subGrades}),N&&e.jsx(Rn,{coverage:N,onResolveWithAi:L,onMarkVisuallyVerified:w,resolving:l,resolveError:c,lastResolveResult:d,expandedResultFor:m,onToggleResultDetail:j}),I&&e.jsx(En,{layers:I}),e.jsx(Ln,{violationsRemaining:V,manualCompleted:_,manualTotal:ee.length}),_>0||$.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:_})," of ",e.jsx("strong",{children:ee.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:`${_/ee.length*100}%`}})})]}):null]})}function Rn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:l,onToggleResultDetail:o}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,d]=h.useState(c>0&&c<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),m=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 ${m?"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 ${m?"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 (",u,"%)"]}),m&&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)."]}),!m&&(()=>{const g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const y=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 ",y,"."]})})(),!m&&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."]}),!m&&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."]})]}),!m&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),className:"text-[11px] underline shrink-0 self-start",children:p?"hide":"show list"})]}),p&&!m&&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(y=>{var I,O;const S=g.kind==="inconclusive"?(I=t.inconclusiveReasons)==null?void 0:I[y]:void 0,$=g.kind==="failing"?(O=t.failingReasons)==null?void 0:O[y]:void 0,k=S==null?void 0:S.some(v=>v.source==="axe-incomplete"&&v.elements&&v.elements.length>0),T=$==null?void 0:$.some(v=>v.source==="ai"),b=(n==null?void 0:n.has(y))??!1,A=i==null?void 0:i[y],N=(l==null?void 0:l.has(y))??!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:["· ",y]}),(g.kind==="inconclusive"&&k||g.kind==="failing"&&T)&&(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:b,onClick:()=>s(y),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:b?"Resolving…":A?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:b,onClick:()=>a(y),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"})]})]}),A&&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 ",A.total," ",A.total===1?"verdict":"verdicts",":",A.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",A.pass," pass"]}),A.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",A.fail," fail"]}),A.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",A.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",A.costUsd.toFixed(4)]}),o&&e.jsx("button",{type:"button",onClick:()=>o(y),className:"ml-auto text-[10px] underline text-brand-700",children:N?"hide reasoning":"show reasoning"})]}),A.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",A.uncertain," ",A.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),A.pass===A.total&&A.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),N&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:A.resolutions.map((v,L)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:v.verdict==="pass"?"text-emerald-700 font-semibold":v.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:v.verdict==="pass"?"✓":v.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:v.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:v.reasoning})]},L))})]}),$&&$.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:$.map((v,L)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[v.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),v.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," fail — "]}),v.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," fail — "]}),v.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:v.selector}),v.notes&&e.jsx("span",{className:"text-rose-700",children:v.notes})]},L))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((v,L)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[v.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," — "]}),v.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," skipped — "]}),v.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," — "]}),v.resolutionHint,v.elements&&v.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",v.elements.length===1?"element":`${v.elements.length} elements`,":"," ",v.elements.slice(0,3).map((j,w,D)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:j.selector}),w<D.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},w)),v.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",v.elements.length-3," more"]})]})]},L))}):g.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},y)})})]},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 Lt={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 En({layers:t}){const s=f(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,l=r.blocked.length,o=r.unevaluated.length,c=r.cleared,p=i>0&&l===0&&o===0,d=p?"text-emerald-700":l>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 ${p?"bg-emerald-500 text-white":l>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":l>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:Lt[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),l>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",l," blocked"]}),o>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",o," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:Lt[n].hint}),n==="human"&&o>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 Tn({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 $n({grades:t}){const s=f(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 ${Cn[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(Un,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Un({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=ee.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?Ns(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 Ln({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=f(l=>l.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(l=>!l.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((l,o)=>{const c=o===i,p=l.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${o+1}.`}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[l.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label})]},o)})})]})}function Dn({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 On({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 (",Ns(s)," old). Re-scan to grade the current page state."]})]})}function Ns(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 _n(){const t=f(a=>a.results),s=f(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(In,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(Fn,{})]})}function Fn(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(je,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(je,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(je,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(je,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(je,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function je({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const Mn={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 Pn({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,l=r.description,o=s.length;return o===1?e.jsx(Ge,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Mn[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",o]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,p)=>e.jsx(Ge,{violation:c},p))})]})}function Vn(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 Gn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function ks({open:t,onClose:s,format:a,content:n,filename:r}){const i=Ps(new Blob([n]).size);function l(){ct(n,r),s()}function o(){ot(n),s()}return e.jsxs(be,{open:t,onClose:s,title:Gn[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Dt=7800;function Wn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`### \`${d.ruleId}\` — ${d.impact}`),l.push(""),l.push(d.description),l.push(""),l.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),l.push(`- **Selector:** \`${d.target.selector}\``),l.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&l.push(`- **More info:** ${d.helpUrl}`),l.push(""),l.push("```html"),l.push(d.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
|
|
6
|
+
`),c=new URLSearchParams({title:i,body:o});let p=`${n}/issues/new?${c.toString()}`;return p.length>Dt&&(p=p.slice(0,Dt)),{url:p,title:i,body:o}}const Ot=7800;function Bn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`Component: ${s??"unknown"}`),l.push(""),l.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`Rule: ${d.ruleId} (${d.impact})`),l.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),l.push(`Description: ${d.description}`),l.push(`Selector: ${d.target.selector}`),l.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&l.push(`More info: ${d.helpUrl}`),l.push(""),l.push(`HTML: ${d.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const o=l.join(`
|
|
7
|
+
`),c=new URLSearchParams({summary:i,description:o});let p=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>Ot&&(p=p.slice(0,Ot)),{url:p,summary:i,description:o}}const _t=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Hn=["wcag-component-auditor","wcag-forensic-log"];async function zn(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(_t);s=Object.keys(n).length,await chrome.storage.local.remove(_t)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Hn)try{await Kn(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 Kn(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 at="accessibilityStatementInputs:v1";async function qn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(at))[at];return s&&typeof s=="object"?s:null}async function Qn(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[at]:t})}function Yn({open:t,onClose:s,results:a}){const[n,r]=h.useState("eaa"),[i,l]=h.useState(""),[o,c]=h.useState(""),[p,d]=h.useState("partial"),[u,m]=h.useState(""),[x,g]=h.useState(""),[y,S]=h.useState(""),[$,k]=h.useState(""),[T,b]=h.useState("English"),[A,N]=h.useState("wcagcheckr (self-evaluation)"),[I,O]=h.useState("2.1"),[v,L]=h.useState("AA"),[j,w]=h.useState(!1),[D,_]=h.useState(null),V=h.useRef(null);if(h.useEffect(()=>{t&&(async()=>{var H,X,W,C;const R=await qn();if(R&&(R.framing&&r(R.framing),R.organizationName&&l(R.organizationName),R.siteUrl&&c(R.siteUrl),R.conformanceStatus&&d(R.conformanceStatus),(H=R.contact)!=null&&H.email&&m(R.contact.email),(X=R.contact)!=null&&X.phone&&g(R.contact.phone),(W=R.contact)!=null&&W.formUrl&&S(R.contact.formUrl),R.countryCode&&k(R.countryCode),R.language&&b(R.language),R.auditedBy&&N(R.auditedBy),R.wcagVersion&&O(R.wcagVersion),R.wcagLevel&&L(R.wcagLevel)),!(R!=null&&R.siteUrl)&&((C=a[0])!=null&&C.pageUrl))try{const M=new URL(a[0].pageUrl);c(`${M.protocol}//${M.host}/`)}catch{}R!=null&&R.conformanceStatus||d(Js(a)),setTimeout(()=>{var M;return(M=V.current)==null?void 0:M.focus()},50)})()},[t,a]),!t)return null;function ae(){var W;const R=new Date().toISOString().slice(0,10),H=(W=a[0])!=null&&W.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):R,X={};return u.trim()&&(X.email=u.trim()),x.trim()&&(X.phone=x.trim()),y.trim()&&(X.formUrl=y.trim()),{framing:n,organizationName:i.trim(),siteUrl:o.trim(),conformanceStatus:p,preparedAt:R,evaluatedAt:H,contact:X,countryCode:$||null,language:T.trim()||"English",auditedBy:A.trim()||"wcagcheckr (self-evaluation)",wcagVersion:I,wcagLevel:v}}function ne(R){if(!R.organizationName)return"Organization name is required.";if(!R.siteUrl)return"Site URL is required.";try{new URL(R.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!R.contact.email&&!R.contact.phone&&!R.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function re(R){_(null);const H=ae(),X=ne(H);if(X){_(X);return}w(!0);try{await Qn(H);const W=await te({type:"EXPORT_REQUEST",format:R==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:H}),C=(W==null?void 0:W.content)??"";if(!C||C.startsWith("# Accessibility statement — error")){_(C||"Export failed — no response.");return}try{await navigator.clipboard.writeText(C)}catch{}const M=new Blob([C],{type:R==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),Z=URL.createObjectURL(M);window.open(Z,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(Z),6e4),s()}catch(W){_(W instanceof Error?W.message:String(W))}finally{w(!1)}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40",role:"dialog","aria-modal":"true","aria-labelledby":"statement-dialog-title",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto m-4",onClick:R=>R.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked: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:V,type:"text",value:i,onChange:R=>l(R.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:o,onChange:R=>c(R.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:p,onChange:R=>d(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:I,onChange:R=>O(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:v,onChange:R=>L(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:u,onChange:R=>m(R.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:R=>g(R.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:y,onChange:R=>S(R.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:$,onChange:R=>k(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(Xs).map(([R,H])=>e.jsxs("option",{value:R,children:[R," — ",H.name.replace(/^[A-Z]+\s*—\s*/,"")]},R))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:T,onChange:R=>b(R.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:A,onChange:R=>N(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),D&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:D})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void re("markdown"),disabled:j,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:j?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void re("html"),disabled:j,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:j?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:j,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 Jn(){const t=f(j=>j.delta),s=f(j=>j.componentId),a=f(j=>j.results),n=f(j=>j.tier),r=f(j=>j.baselineList),i=f(j=>j.siteCrawlReport),[l,o]=h.useState(""),[c,p]=h.useState(""),[d,u]=h.useState(!1),[m,x]=h.useState(!1),[g,y]=h.useState(null),[S,$]=h.useState(null),[k,T]=h.useState(!1);h.useEffect(()=>{Promise.all([te({type:"SETTINGS_GET",key:"githubRepoUrl"}),te({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([j,w])=>{o(typeof j.data=="string"?j.data:""),p(typeof w.data=="string"?w.data:"")})},[]);const b=is(n,"exportJson"),A=os[n].maxBaselines,N=r.some(j=>j.componentId===s),I=N||r.length<A;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 O(){if(!s||a.length===0)return;const j=a.flatMap(re=>re.violations),w=a.flatMap(re=>re.announcements??[]),D=a.flatMap(re=>re.focusEvents??[]),_=a[0],ae=(await te({type:"SETTINGS_GET",key:"stateMatrix"})).data??ls;await J({type:"BASELINE_SET",componentId:s,violations:j,announcements:w,focusEvents:D,snapshotMeta:{url:window.location.href,axeVersion:_.axeVersion,matrixConfig:ae,capturedAt:new Date().toISOString()}});const ne=await te({type:"BASELINE_COMPARE",componentId:s,currentViolations:j,announcements:w,focusEvents:D,currentMatrix:ae});f.getState().setDelta(ne.delta),de.polite(`Baseline saved for ${s}.`)}async function v(){if(!s||!N||!window.confirm(`Remove the saved baseline for "${s}"?
|
|
8
8
|
|
|
9
|
-
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await J({type:"BASELINE_DELETE",componentId:s});const j=a.flatMap(ne=>ne.violations),D=a.flatMap(ne=>ne.announcements??[]),_=a.flatMap(ne=>ne.focusEvents??[]),G=await te({type:"BASELINE_COMPARE",componentId:s,currentViolations:j,announcements:D,focusEvents:_});f.getState().setDelta(G.delta);const ae=await te({type:"BASELINE_LIST"});f.getState().setBaselineList(ae.items),ce.polite(`Baseline cleared for ${s}.`)}async function L(w,j=!1){if(a.length===0)return;if(w==="ai-prompt"){const{copyAiFixerPrompt:V}=await pt(async()=>{const{copyAiFixerPrompt:C}=await import("./copy-ai-fixer-prompt-CH4gMq6S.js");return{copyAiFixerPrompt:C}},__vite__mapDeps([0,1,2]));await V({results:a,componentId:s,delta:j?void 0:t,siteCrawlReport:i});return}let D;if((w==="defense-bundle"||w==="evidence-bundle"||w==="deposition-packet")&&s){const V=await chrome.storage.local.get("igtRuns"),M=((V==null?void 0:V.igtRuns)??{})[s]??{};D=Object.values(M)}const ae=await te({type:"EXPORT_REQUEST",format:w,results:a,delta:j?void 0:t??void 0,manualRuns:D,dismissedKeys:void 0,incompleteResolutions:void 0});if(w==="defense-bundle"||w==="evidence-bundle"||w==="deposition-packet"){const V=Yt(w,s);await Jt()?ot(ae.content,V):$({open:!0,format:w,content:ae.content,filename:V});return}if(w==="html-print"||w==="vpat"||w==="methodology-doc"){lt(ae.content);return}const ne=w==="json"?"application/json":w==="sarif"?"application/sarif+json":"application/xml",re=w==="junit"?"xml":w,R=new Blob([ae.content],{type:ne}),H=URL.createObjectURL(R),X=document.createElement("a");X.href=H,X.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${re}`,X.click(),URL.revokeObjectURL(H)}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:O,disabled:!I,title:I?void 0:`Free tier limits you to ${A} 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"}),N&&e.jsx("button",{onClick:v,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:()=>m(!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(Qn,{disabled:!b,onExport:L,onAccessibilityStatement:()=>T(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!I&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const w=qe(t.new),j=qe(t.persistent),D=qe(t.fixed),_=[...w.review,...j.review];return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{title:"New",violations:w.findings,count:w.findings.length,accent:"red",actions:[...l&&w.findings.length>0?[{label:"File GitHub issue",onClick:()=>Kn(l,s,w.findings)}]:[],...c&&w.findings.length>0?[{label:"File Jira issue",onClick:()=>qn(c,s,w.findings)}]:[]]}),e.jsx(Ne,{title:"Persistent",violations:j.findings,count:j.findings.length,accent:"slate"}),e.jsx(Ne,{title:"Fixed",violations:D.findings,count:t.fixedCount,accent:"green"}),_.length>0&&e.jsx(Ne,{title:"Needs review (does not affect grade)",violations:_,count:_.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(Ne,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),S&&e.jsx(ys,{open:S.open,onClose:()=>$(null),format:S.format,content:S.content,filename:S.filename}),e.jsx(Bn,{open:k,onClose:()=>T(!1),results:a}),d&&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"})]})]}),g&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",g.chromeStorageKeysCleared," chrome.storage key",g.chromeStorageKeysCleared===1?"":"s"," + ",g.indexedDbsCleared.length," database",g.indexedDbsCleared.length===1?"":"s",".",g.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",g.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:g?e.jsx("button",{type:"button",onClick:()=>{m(!1),y(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:()=>m(!1),disabled:u,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()=>{x(!0);try{const w=await Pn();y(w),await Ve(),ce.polite("Audit data reset. Ready for a fresh scan.")}catch(w){y({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[w instanceof Error?w.message:String(w)]})}finally{x(!1)}},disabled:u,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:u?"Resetting…":"Reset everything"})]})})]})})]})}const zn={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function qe(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 Ne({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[l,o]=h.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 ${zn[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>o(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:l?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),l?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,p)=>e.jsx(Ge,{violation:c,alreadyAcknowledged:!0},p)):Dn(s).map(c=>e.jsx(Ln,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Kn(t,s,a){if(a.length===0)return;const{url:n}=_n(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function qn(t,s,a){if(a.length===0)return;const{url:n}=Fn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Qn({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=h.useState(!1),[l,o]=h.useState(!1);function c(p){i(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(p=>!p),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>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:l,onChange:p=>o(p.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(de,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(de,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(de,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(de,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(de,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(de,{onClick:()=>c("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(de,{onClick:()=>c("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx(de,{onClick:()=>c("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(de,{onClick:()=>c("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(de,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(de,{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 de({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 _t="igtRuns";async function Yn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(_t))[_t];return s&&typeof s=="object"?s:{}}async function Jn(t,s){var l,o;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Yn())[t];if(i)for(const c of ee){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((o=(l=p.steps)==null?void 0:l[d.id])==null?void 0:o.status)!=="pass")continue;const u=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:u,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:ge(g.selector),reason:u,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const Xn=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"]),Zn=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 er(t){return Xn.has(t.ruleId)}function tr(t){return Zn.has(t.ruleId)}function sr(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function ar(){var O,v,L,w;const t=f(j=>j.results),s=f(j=>j.delta),a=f(j=>j.componentId),n=((O=t[0])==null?void 0:O.pageUrl)??((v=t[0])==null?void 0:v.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(0);h.useEffect(()=>{if(!n)return;let j=!1;return(async()=>{if(a&&t.length>0)try{await Jn(a,t)}catch{}if(j)return;const D=await We(n);j||i(D)})(),()=>{j=!0}},[n,l,a,t]);async function c(j,D){if(!n)return;const _=window.prompt(`Why is this finding a false positive?
|
|
9
|
+
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await J({type:"BASELINE_DELETE",componentId:s});const w=a.flatMap(ne=>ne.violations),D=a.flatMap(ne=>ne.announcements??[]),_=a.flatMap(ne=>ne.focusEvents??[]),V=await te({type:"BASELINE_COMPARE",componentId:s,currentViolations:w,announcements:D,focusEvents:_});f.getState().setDelta(V.delta);const ae=await te({type:"BASELINE_LIST"});f.getState().setBaselineList(ae.items),de.polite(`Baseline cleared for ${s}.`)}async function L(j,w=!1){if(a.length===0)return;if(j==="ai-prompt"){const{copyAiFixerPrompt:W}=await mt(async()=>{const{copyAiFixerPrompt:C}=await import("./copy-ai-fixer-prompt-B8cjAbqP.js");return{copyAiFixerPrompt:C}},__vite__mapDeps([0,1,2]));await W({results:a,componentId:s,delta:w?void 0:t,siteCrawlReport:i});return}let D;if((j==="defense-bundle"||j==="evidence-bundle"||j==="deposition-packet")&&s){const W=await chrome.storage.local.get("igtRuns"),M=((W==null?void 0:W.igtRuns)??{})[s]??{};D=Object.values(M)}const ae=await te({type:"EXPORT_REQUEST",format:j,results:a,delta:w?void 0:t??void 0,manualRuns:D,dismissedKeys:void 0,incompleteResolutions:void 0});if(j==="defense-bundle"||j==="evidence-bundle"||j==="deposition-packet"){const W=Zt(j,s);await es()?ct(ae.content,W):$({open:!0,format:j,content:ae.content,filename:W});return}if(j==="html-print"||j==="vpat"||j==="methodology-doc"||j==="conformance-crosswalk"){ot(ae.content);return}const ne=j==="json"?"application/json":j==="sarif"?"application/sarif+json":"application/xml",re=j==="junit"?"xml":j,R=new Blob([ae.content],{type:ne}),H=URL.createObjectURL(R),X=document.createElement("a");X.href=H,X.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${re}`,X.click(),URL.revokeObjectURL(H)}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:O,disabled:!I,title:I?void 0:`Free tier limits you to ${A} 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"}),N&&e.jsx("button",{onClick:v,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:()=>u(!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(tr,{disabled:!b,onExport:L,onAccessibilityStatement:()=>T(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!I&&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=Qe(t.new),w=Qe(t.persistent),D=Qe(t.fixed),_=[...j.review,...w.review];return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{title:"New",violations:j.findings,count:j.findings.length,accent:"red",actions:[...l&&j.findings.length>0?[{label:"File GitHub issue",onClick:()=>Zn(l,s,j.findings)}]:[],...c&&j.findings.length>0?[{label:"File Jira issue",onClick:()=>er(c,s,j.findings)}]:[]]}),e.jsx(Ne,{title:"Persistent",violations:w.findings,count:w.findings.length,accent:"slate"}),e.jsx(Ne,{title:"Fixed",violations:D.findings,count:t.fixedCount,accent:"green"}),_.length>0&&e.jsx(Ne,{title:"Needs review (does not affect grade)",violations:_,count:_.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(Ne,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),S&&e.jsx(ks,{open:S.open,onClose:()=>$(null),format:S.format,content:S.content,filename:S.filename}),e.jsx(Yn,{open:k,onClose:()=>T(!1),results:a}),d&&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"})]})]}),g&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",g.chromeStorageKeysCleared," chrome.storage key",g.chromeStorageKeysCleared===1?"":"s"," + ",g.indexedDbsCleared.length," database",g.indexedDbsCleared.length===1?"":"s",".",g.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",g.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:g?e.jsx("button",{type:"button",onClick:()=>{u(!1),y(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:()=>u(!1),disabled:m,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()=>{x(!0);try{const j=await zn();y(j),await Be(),de.polite("Audit data reset. Ready for a fresh scan.")}catch(j){y({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[j instanceof Error?j.message:String(j)]})}finally{x(!1)}},disabled:m,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:m?"Resetting…":"Reset everything"})]})})]})})]})}const Xn={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Qe(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 Ne({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[l,o]=h.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 ${Xn[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>o(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:l?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),l?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,p)=>e.jsx(Ge,{violation:c,alreadyAcknowledged:!0},p)):Vn(s).map(c=>e.jsx(Pn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Zn(t,s,a){if(a.length===0)return;const{url:n}=Wn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function er(t,s,a){if(a.length===0)return;const{url:n}=Bn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function tr({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=h.useState(!1),[l,o]=h.useState(!1);function c(p){i(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(p=>!p),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>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:l,onChange:p=>o(p.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ce,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ce,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ce,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ce,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ce,{onClick:()=>c("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ce,{onClick:()=>c("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx(ce,{onClick:()=>c("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(ce,{onClick:()=>c("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(ce,{onClick:()=>c("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{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 ce({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 Ft="igtRuns";async function sr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Ft))[Ft];return s&&typeof s=="object"?s:{}}async function ar(t,s){var l,o;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await sr())[t];if(i)for(const c of ee){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((o=(l=p.steps)==null?void 0:l[d.id])==null?void 0:o.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:ge(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const nr=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"]),rr=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 ir(t){return nr.has(t.ruleId)}function lr(t){return rr.has(t.ruleId)}function or(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function cr(){var O,v,L,j;const t=f(w=>w.results),s=f(w=>w.delta),a=f(w=>w.componentId),n=((O=t[0])==null?void 0:O.pageUrl)??((v=t[0])==null?void 0:v.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(0);h.useEffect(()=>{if(!n)return;let w=!1;return(async()=>{if(a&&t.length>0)try{await ar(a,t)}catch{}if(w)return;const D=await We(n);w||i(D)})(),()=>{w=!0}},[n,l,a,t]);async function c(w,D){if(!n)return;const _=window.prompt(`Why is this finding a false positive?
|
|
10
10
|
|
|
11
|
-
(Recorded with the dismissal so future you remembers the reasoning.)`,"");_!==null&&(await xs(n,j,_||"(no reason given)",D),o(G=>G+1))}async function p(j){n&&(await gs(n,j),o(D=>D+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((j,D)=>{var _;return j+(((_=D.announcements)==null?void 0:_.length)??0)},0),m=t.reduce((j,D)=>{var _;return j+(((_=D.focusEvents)==null?void 0:_.length)??0)},0),u=t.reduce((j,D)=>{var _;return j+(((_=D.focusEvents)==null?void 0:_.filter(G=>G.isFocusReset).length)??0)},0),x=Ft(t,er),g=Ft(t,tr),y=x.length,S=g.length,$=((L=t[0])==null?void 0:L.readingOrderIssues)??[],k=((w=t[0])==null?void 0:w.tabOrderIssues)??[],T=$.filter(j=>!(ge(j.selector)in r)),b=$.filter(j=>ge(j.selector)in r),A=k.filter(j=>!(fe(j.selector)in r)),N=k.filter(j=>fe(j.selector)in r);if(d===0&&m===0&&y===0&&S===0&&T.length===0&&A.length===0&&b.length===0&&N.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const I=b.length+N.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[y," structural · ",S," form ·"," ",A.length," tab-order ·"," ",T.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",m," focus ",m===1?"event":"events",u>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",u," focus reset",u===1?"":"s"]}),I>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",I," dismissed"]})]}),A.length>0&&e.jsx(ir,{issues:A,onDismiss:c}),T.length>0&&e.jsx(lr,{issues:T,onDismiss:c}),I>0&&e.jsx(or,{dismissedReadingOrder:b,dismissedTabOrder:N,dismissals:r,onRestore:p}),y>0&&e.jsx(Mt,{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(Mt,{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(nr,{delta:s}),t.map((j,D)=>{const _=j.announcements??[],G=j.focusEvents??[];return _.length===0&&G.length===0?null:e.jsx(rr,{state:j.state,announcements:_,focusEvents:G},D)})]})}function nr({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 Ft(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=dt(r.ruleId,r.target.selector),l=a.get(i);l?l.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function Mt({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 rr({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:sr(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 ir({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 lr({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]=h.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(o=>{const c=`tab-order::${o.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(o=>{const c=`reading-order::${o.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const at="igtRuns";async function cr(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const l=n.tabOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:fe(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:ge(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}}const dr={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"}},ur={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"}},pr={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Pt(t,s){const a=await le();if(!a)return;const n=s?dr[t]:ur[t];try{await pe(a,n)}catch{}}async function mr(){const s=(await chrome.storage.local.get(at))[at];return s&&typeof s=="object"?s:{}}async function Gt(t){await chrome.storage.local.set({[at]:t})}function hr(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 xr(){const t=f(d=>d.componentId),s=f(d=>d.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{mr().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const l=a[t]??{};function o(d,m,u){var g;const x={...a,[t]:{...l,[d]:{...l[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=l[d])==null?void 0:g.steps)??{},[m]:u},completedAt:new Date().toISOString()}}};if(n(x),Gt(x),u.status==="pass"){const y=ee.find($=>$.id===d),S=y==null?void 0:y.steps.find($=>$.id===m);S!=null&&S.autoDismissActivity&&cr(S.autoDismissActivity,s,m)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const m={...l};delete m[d];const u={...a,[t]:m};n(u),Gt(u)}const p=ee.find(d=>d.id===r);if(p){const d=l[p.id];return e.jsx(gr,{workflow:p,run:d,results:s,onAnswer:(m,u)=>o(p.id,m,u),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."}),ee.map(d=>{const m=l[d.id],u=m?Ks(m,d):null,x=m?u!=null&&u.failed&&u.failed>0?"failed":u!=null&&u.unanswered&&u.unanswered>0?"in-progress":"done":"unstarted",g={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:d.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&u&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[u.unanswered," unanswered"]})]}),u&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[u.passed," pass"]}),u.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",u.failed," fail"]}),u.notApplicable>0&&e.jsxs("span",{children:[" · ",u.notApplicable," N/A"]}),u.skipped>0&&e.jsxs("span",{children:[" · ",u.skipped," skip"]})," / ",u.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),m&&e.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function gr({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=hr(p,a);return c},[t,a]);function l(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const o=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),o>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[o," step",o===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:l,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",o," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const m=i[c.id];return m?m.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:m.ruleId})," ran clean across ",m.statesAudited," state",m.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${m.ruleId}, ${m.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:m.ruleId})," already found ",m.violationCount," violation",m.violationCount===1?"":"s"," in"," ",m.states.length," state",m.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${m.ruleId}, ${m.violationCount} hits in: ${m.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Pt(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",pr[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Pt(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:m=>n(c.id,{status:d.status,notes:m.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const fr={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?fr[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const De="savedFlows";async function br(){const t=await chrome.storage.local.get(De);return Array.isArray(t[De])?t[De]:[]}async function Wt(t){await chrome.storage.local.set({[De]:t})}function vr(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{br().then(s)},[]);async function l(){const d=await le();if(!d){i("No audit-target tab found.");return}try{await pe(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function o(){const d=await le();if(d)try{const m=await Ie(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),m.steps.length===0){i("Recording stopped — no steps captured.");return}const u=typeof prompt=="function"?prompt(`Captured ${m.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!u.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:u.trim(),steps:m.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Wt(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(m){i(`Stop failed: ${m instanceof Error?m.message:String(m)}`)}}async function c(d){const m=await le();if(m){i(`Replaying "${d.name}"…`);try{const u=await Ie(m,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${u.played} step${u.played===1?"":"s"}`+(u.errored?`, ${u.errored} errored (selector not found)`:"")+".")}catch(u){i(`Replay failed: ${u instanceof Error?u.message:String(u)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const m=t.filter(u=>u.id!==d);s(m),await Wt(m)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function yr(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),l=n.slice(r+1);return i==="story"?{primary:l.split("--").map(c=>c.split("-").map(jr).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||i}}function jr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function wr(){const t=f(o=>o.baselineList),s=f(o=>o.tier),a=ns[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{Fe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(o=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},o))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function l(o){await J({type:"BASELINE_DELETE",componentId:o}),await Fe()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(o=>{const c=yr(o.componentId),p=o.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:o.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[o.violationCount," ",o.violationCount===1?"violation":"violations"," ·"," ",new Date(o.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[o.seenOnUrlsCount&&o.seenOnUrlsCount>1&&e.jsxs(he,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",o.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(he,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(he,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(he,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(he,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(he,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(he,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(o.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},o.componentId)})]})}const Nr={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 he({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Nr[t]}`,children:a})}const kr={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"},Sr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Ar={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 js({onBack:t}){const s=f(m=>m.siteCrawlStatus),a=f(m=>m.siteCrawlProgress),n=f(m=>m.siteCrawlReport),r=f(m=>m.siteCrawlError),[i,l]=h.useState(""),[o,c]=h.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(m=>{var x;const u=(x=m[0])==null?void 0:x.url;u&&/^https?:\/\//.test(u)&&i===""&&l(u)});function p(){i&&(o>=5&&!window.confirm(`Each of the ${o} 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 ${o*5} minutes. Proceed?`)||(f.getState().setSiteCrawlStatus("running"),f.getState().setSiteCrawlReport(null),f.getState().setSiteCrawlError(null),ue({type:"START_SITE_CRAWL",startUrl:i,maxPages:o})))}function d(){J({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:m=>l(m.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:o,onChange:m=>c(Math.min(200,Math.max(1,parseInt(m.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:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Cr,{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 Cr({report:t}){function s(){pt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-ImlCBsok.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const l=i(t),o=new Blob([l],{type:"text/html"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=h.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),l=(i==null?void 0:i.content)??"";if(!l){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(l)}catch{}const o=new Blob([l],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${kr[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Sr[t.siteRisk]}`,children:qs[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 l=Qs(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 ${Ar[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:l.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 Ir(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 Ir(t){try{const s=await Ys(),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){f.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{}}f.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const Qe="onboardingDismissed",Ye=[{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 Rr(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(Qe).then(o=>{o[Qe]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Qe]:!0}),s(!1),n(0)}const i=a===Ye.length-1,l=Ye[a];return e.jsxs(be,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Ye.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(o=>o-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(o=>o+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Er(){const t=f(n=>n.status),s=f(n=>n.errorMessage),a=f(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 Tr(){const t=f(c=>c.aiFailure),s=f(c=>c.clearAiFailure),[a,n]=h.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",l="⚠",o=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:l})," ",o]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Vt(){const[t,s]=h.useState(!1);return h.useEffect(()=>oe("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),f.getState().setStatus("idle"))}),[]),e.jsxs(be,{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 $r(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{Js().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await wt(),f.getState().startNewScan(),t.mode==="storybook-all"?ue({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ue({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await wt(),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 Je="storybook:hintDismissed";function Ur(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var o;if((await chrome.storage.local.get(Je))[Je])return;const l=await le();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var m;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(m=d.__STORYBOOK_PREVIEW__)==null?void 0:m.version}}})).find(d=>{var m;return(m=d.result)==null?void 0:m.detected});p&&(n((o=p.result)==null?void 0:o.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Je]:!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 Lr(){var i;const t=f(l=>l.results),s=f(l=>l.baselineList),a=f(l=>l.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Dr(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 Dr(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<7?`${o}d ago`:a.toLocaleDateString()}function Or(){const t=f(o=>o.results),s=f(o=>o.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let o=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(o)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{o=!0}},[s]),t.length===0)return null;const r=t.flatMap(o=>o.violations),i=Xs(r,a.length>0?{runs:a,workflows:ee}:void 0),l=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function _r(){const t=f(a=>a.setUserMode);function s(a){t(a),J({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 Fr=["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"],Mr={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 Pr(t){const s=new Set(Fr),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,p])=>({ruleId:c,instanceCount:p})).sort((c,p)=>p.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,p)=>c+p,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Mr[l]}}const ws={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Gr={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[ws]},Wr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[ws]};function xt(t){return t==="thorough"?Wr:Gr}function Bt(t){const s=xt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Oe="wcagcheckr";function W(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ce(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 Vr(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Br(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 Hr(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 zr(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 Kr(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 (${W(t.receipt.tsaName)}) — anchored ${W(Ce(t.receipt.anchoredAt))}</td></tr>
|
|
12
|
-
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${
|
|
13
|
-
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${
|
|
11
|
+
(Recorded with the dismissal so future you remembers the reasoning.)`,"");_!==null&&(await vs(n,w,_||"(no reason given)",D),o(V=>V+1))}async function p(w){n&&(await ys(n,w),o(D=>D+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((w,D)=>{var _;return w+(((_=D.announcements)==null?void 0:_.length)??0)},0),u=t.reduce((w,D)=>{var _;return w+(((_=D.focusEvents)==null?void 0:_.length)??0)},0),m=t.reduce((w,D)=>{var _;return w+(((_=D.focusEvents)==null?void 0:_.filter(V=>V.isFocusReset).length)??0)},0),x=Mt(t,ir),g=Mt(t,lr),y=x.length,S=g.length,$=((L=t[0])==null?void 0:L.readingOrderIssues)??[],k=((j=t[0])==null?void 0:j.tabOrderIssues)??[],T=$.filter(w=>!(ge(w.selector)in r)),b=$.filter(w=>ge(w.selector)in r),A=k.filter(w=>!(fe(w.selector)in r)),N=k.filter(w=>fe(w.selector)in r);if(d===0&&u===0&&y===0&&S===0&&T.length===0&&A.length===0&&b.length===0&&N.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const I=b.length+N.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[y," structural · ",S," form ·"," ",A.length," tab-order ·"," ",T.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",m>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",m," focus reset",m===1?"":"s"]}),I>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",I," dismissed"]})]}),A.length>0&&e.jsx(pr,{issues:A,onDismiss:c}),T.length>0&&e.jsx(mr,{issues:T,onDismiss:c}),I>0&&e.jsx(hr,{dismissedReadingOrder:b,dismissedTabOrder:N,dismissals:r,onRestore:p}),y>0&&e.jsx(Pt,{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(Pt,{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(dr,{delta:s}),t.map((w,D)=>{const _=w.announcements??[],V=w.focusEvents??[];return _.length===0&&V.length===0?null:e.jsx(ur,{state:w.state,announcements:_,focusEvents:V},D)})]})}function dr({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 Mt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ut(r.ruleId,r.target.selector),l=a.get(i);l?l.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function Pt({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:or(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 pr({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 mr({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 hr({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(o=>{const c=`tab-order::${o.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(o=>{const c=`reading-order::${o.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const nt="igtRuns";async function xr(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const l=n.tabOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:fe(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:ge(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}}const gr={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"}},fr={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"}},br={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Vt(t,s){const a=await le();if(!a)return;const n=s?gr[t]:fr[t];try{await pe(a,n)}catch{}}async function vr(){const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:{}}async function Gt(t){await chrome.storage.local.set({[nt]:t})}function yr(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 wr(){const t=f(d=>d.componentId),s=f(d=>d.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{vr().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const l=a[t]??{};function o(d,u,m){var g;const x={...a,[t]:{...l,[d]:{...l[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=l[d])==null?void 0:g.steps)??{},[u]:m},completedAt:new Date().toISOString()}}};if(n(x),Gt(x),m.status==="pass"){const y=ee.find($=>$.id===d),S=y==null?void 0:y.steps.find($=>$.id===u);S!=null&&S.autoDismissActivity&&xr(S.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...l};delete u[d];const m={...a,[t]:u};n(m),Gt(m)}const p=ee.find(d=>d.id===r);if(p){const d=l[p.id];return e.jsx(jr,{workflow:p,run:d,results:s,onAnswer:(u,m)=>o(p.id,u,m),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."}),ee.map(d=>{const u=l[d.id],m=u?Zs(u,d):null,x=u?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.unanswered>0?"in-progress":"done":"unstarted",g={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:d.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&m&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[m.unanswered," unanswered"]})]}),m&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[m.passed," pass"]}),m.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",m.failed," fail"]}),m.notApplicable>0&&e.jsxs("span",{children:[" · ",m.notApplicable," N/A"]}),m.skipped>0&&e.jsxs("span",{children:[" · ",m.skipped," skip"]})," / ",m.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),u&&e.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function jr({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=yr(p,a);return c},[t,a]);function l(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const o=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),o>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[o," step",o===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:l,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",o," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Vt(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",br[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Vt(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>n(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const Nr={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?Nr[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Oe="savedFlows";async function kr(){const t=await chrome.storage.local.get(Oe);return Array.isArray(t[Oe])?t[Oe]:[]}async function Wt(t){await chrome.storage.local.set({[Oe]:t})}function Sr(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{kr().then(s)},[]);async function l(){const d=await le();if(!d){i("No audit-target tab found.");return}try{await pe(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function o(){const d=await le();if(d)try{const u=await Ie(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!m.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:m.trim(),steps:u.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Wt(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await le();if(u){i(`Replaying "${d.name}"…`);try{const m=await Ie(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${m.played} step${m.played===1?"":"s"}`+(m.errored?`, ${m.errored} errored (selector not found)`:"")+".")}catch(m){i(`Replay failed: ${m instanceof Error?m.message:String(m)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(m=>m.id!==d);s(u),await Wt(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function Ar(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),l=n.slice(r+1);return i==="story"?{primary:l.split("--").map(c=>c.split("-").map(Cr).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||i}}function Cr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Ir(){const t=f(o=>o.baselineList),s=f(o=>o.tier),a=os[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{Me().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(o=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},o))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function l(o){await J({type:"BASELINE_DELETE",componentId:o}),await Me()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(o=>{const c=Ar(o.componentId),p=o.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:o.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[o.violationCount," ",o.violationCount===1?"violation":"violations"," ·"," ",new Date(o.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[o.seenOnUrlsCount&&o.seenOnUrlsCount>1&&e.jsxs(he,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",o.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(he,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(he,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(he,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(he,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(he,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(he,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(o.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},o.componentId)})]})}const Rr={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 he({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Rr[t]}`,children:a})}const Er={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"},Tr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},$r={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 Ss({onBack:t}){const s=f(u=>u.siteCrawlStatus),a=f(u=>u.siteCrawlProgress),n=f(u=>u.siteCrawlReport),r=f(u=>u.siteCrawlError),[i,l]=h.useState(""),[o,c]=h.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var x;const m=(x=u[0])==null?void 0:x.url;m&&/^https?:\/\//.test(m)&&i===""&&l(m)});function p(){i&&(o>=5&&!window.confirm(`Each of the ${o} 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 ${o*5} minutes. Proceed?`)||(f.getState().setSiteCrawlStatus("running"),f.getState().setSiteCrawlReport(null),f.getState().setSiteCrawlError(null),ue({type:"START_SITE_CRAWL",startUrl:i,maxPages:o})))}function d(){J({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:u=>l(u.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:o,onChange:u=>c(Math.min(200,Math.max(1,parseInt(u.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:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Ur,{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 Ur({report:t}){function s(){mt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-ErZrhshM.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const l=i(t),o=new Blob([l],{type:"text/html"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=h.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),l=(i==null?void 0:i.content)??"";if(!l){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(l)}catch{}const o=new Blob([l],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Er[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Tr[t.siteRisk]}`,children:ea[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 l=ta(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 ${$r[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:l.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 Lr(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 Lr(t){try{const s=await sa(),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){f.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{}}f.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const Ye="onboardingDismissed",Je=[{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 Dr(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(Ye).then(o=>{o[Ye]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ye]:!0}),s(!1),n(0)}const i=a===Je.length-1,l=Je[a];return e.jsxs(be,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Je.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(o=>o-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(o=>o+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Or(){const t=f(n=>n.status),s=f(n=>n.errorMessage),a=f(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 _r(){const t=f(c=>c.aiFailure),s=f(c=>c.clearAiFailure),[a,n]=h.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",l="⚠",o=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:l})," ",o]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Bt(){const[t,s]=h.useState(!1);return h.useEffect(()=>oe("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),f.getState().setStatus("idle"))}),[]),e.jsxs(be,{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 Fr(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{aa().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await Nt(),f.getState().startNewScan(),t.mode==="storybook-all"?ue({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ue({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Nt(),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 Xe="storybook:hintDismissed";function Mr(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var o;if((await chrome.storage.local.get(Xe))[Xe])return;const l=await le();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(n((o=p.result)==null?void 0:o.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Xe]:!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 Pr(){var i;const t=f(l=>l.results),s=f(l=>l.baselineList),a=f(l=>l.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Vr(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 Vr(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<7?`${o}d ago`:a.toLocaleDateString()}function Gr(){const t=f(o=>o.results),s=f(o=>o.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let o=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(o)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{o=!0}},[s]),t.length===0)return null;const r=t.flatMap(o=>o.violations),i=na(r,a.length>0?{runs:a,workflows:ee}:void 0),l=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Wr(){const t=f(a=>a.setUserMode);function s(a){t(a),J({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 Br=["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"],Hr={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 zr(t){const s=new Set(Br),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,p])=>({ruleId:c,instanceCount:p})).sort((c,p)=>p.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,p)=>c+p,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Hr[l]}}const As={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Kr={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[As]},qr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[As]};function gt(t){return t==="thorough"?qr:Kr}function Ht(t){const s=gt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const _e="wcagcheckr";function G(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ce(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 Qr(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Yr(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 Jr(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 Xr(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 Zr(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 (${G(t.receipt.tsaName)}) — anchored ${G(Ce(t.receipt.anchoredAt))}</td></tr>
|
|
12
|
+
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${G(t.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
13
|
+
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${G(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${G(_e)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
|
|
14
14
|
<article class="entry">
|
|
15
15
|
<header class="entry-header">
|
|
16
|
-
<span class="grade-badge ${
|
|
16
|
+
<span class="grade-badge ${Xr(t.grade)}">${G(t.grade)}</span>
|
|
17
17
|
<div class="entry-headline">
|
|
18
|
-
<div class="entry-time">${
|
|
18
|
+
<div class="entry-time">${G(Ce(t.capturedAt))}</div>
|
|
19
19
|
<div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
|
|
20
20
|
</div>
|
|
21
21
|
</header>
|
|
22
22
|
<table class="entry-fields">
|
|
23
|
-
<tr><th>Audit identity hash</th><td><code class="hash">${
|
|
24
|
-
<tr><th>Page URL</th><td><code>${
|
|
25
|
-
<tr><th>Scope</th><td><code>${
|
|
26
|
-
<tr><th>axe-core version</th><td>${
|
|
23
|
+
<tr><th>Audit identity hash</th><td><code class="hash">${G(t.hash)}</code></td></tr>
|
|
24
|
+
<tr><th>Page URL</th><td><code>${G(t.pageUrl)}</code></td></tr>
|
|
25
|
+
<tr><th>Scope</th><td><code>${G(t.scope)}</code></td></tr>
|
|
26
|
+
<tr><th>axe-core version</th><td>${G(t.axeVersion)}</td></tr>
|
|
27
27
|
<tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
|
|
28
28
|
${n}
|
|
29
29
|
</table>
|
|
30
|
-
</article>`}function
|
|
30
|
+
</article>`}function ei(t){return`
|
|
31
31
|
<section class="component-section">
|
|
32
32
|
<h2>
|
|
33
|
-
<span class="component-id">${
|
|
33
|
+
<span class="component-id">${G(t.componentId)}</span>
|
|
34
34
|
<span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
|
|
35
35
|
</h2>
|
|
36
|
-
<p class="component-url"><strong>Page audited:</strong> <code>${
|
|
37
|
-
${t.entries.map(
|
|
38
|
-
</section>`}function
|
|
36
|
+
<p class="component-url"><strong>Page audited:</strong> <code>${G(t.pageUrl)}</code></p>
|
|
37
|
+
${t.entries.map(Zr).join("")}
|
|
38
|
+
</section>`}function ti(t){const{entries:s,extensionVersion:a}=t,n=Jr(s),r=Yr(s),i=(t.axeVersions??Qr(s)).join(", "),l=s.length,o=s.filter(d=>d.receipt).length,c=l-o,p=Ce(new Date().toISOString());return`<!doctype html>
|
|
39
39
|
<html lang="en">
|
|
40
40
|
<head>
|
|
41
41
|
<meta charset="utf-8" />
|
|
42
|
-
<title>Pre-litigation accessibility audit report — ${
|
|
42
|
+
<title>Pre-litigation accessibility audit report — ${G(t.matterReference??p)}</title>
|
|
43
43
|
<style>
|
|
44
44
|
*, *::before, *::after { box-sizing: border-box; }
|
|
45
45
|
:root {
|
|
@@ -180,17 +180,17 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
180
180
|
<p class="eyebrow">Accessibility audit — pre-litigation report</p>
|
|
181
181
|
<h1>Audit history & chain-of-custody</h1>
|
|
182
182
|
<dl class="cover-meta">
|
|
183
|
-
${t.matterReference?`<dt>Matter reference</dt><dd>${
|
|
184
|
-
${t.preparedBy?`<dt>Prepared by</dt><dd>${
|
|
185
|
-
${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${
|
|
186
|
-
<dt>Report generated</dt><dd>${
|
|
187
|
-
<dt>Audit period</dt><dd>${r?`${
|
|
183
|
+
${t.matterReference?`<dt>Matter reference</dt><dd>${G(t.matterReference)}</dd>`:""}
|
|
184
|
+
${t.preparedBy?`<dt>Prepared by</dt><dd>${G(t.preparedBy)}</dd>`:""}
|
|
185
|
+
${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${G(t.jurisdiction)}</dd>`:""}
|
|
186
|
+
<dt>Report generated</dt><dd>${G(p)}</dd>
|
|
187
|
+
<dt>Audit period</dt><dd>${r?`${G(Ce(r.earliest))} — ${G(Ce(r.latest))}`:"No audits recorded"}</dd>
|
|
188
188
|
</dl>
|
|
189
189
|
</section>
|
|
190
190
|
|
|
191
191
|
<aside class="attestation">
|
|
192
192
|
<h3>Attestation</h3>
|
|
193
|
-
<p>The audit records summarized below were captured by the <strong>${
|
|
193
|
+
<p>The audit records summarized below were captured by the <strong>${G(_e)}</strong> Chrome extension, version <strong>${G(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${G(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
|
|
194
194
|
<p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
|
|
195
195
|
<p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
|
|
196
196
|
</aside>
|
|
@@ -200,11 +200,11 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
200
200
|
<tr><th>RFC 3161-anchored audits</th><td>${o}</td></tr>
|
|
201
201
|
<tr><th>Local-only audits</th><td>${c}</td></tr>
|
|
202
202
|
<tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
|
|
203
|
-
<tr><th>axe-core version(s) observed</th><td>${
|
|
204
|
-
<tr><th>Tool</th><td>${
|
|
203
|
+
<tr><th>axe-core version(s) observed</th><td>${G(i||"n/a")}</td></tr>
|
|
204
|
+
<tr><th>Tool</th><td>${G(_e)} ${G(a)}</td></tr>
|
|
205
205
|
</table>
|
|
206
206
|
|
|
207
|
-
${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(
|
|
207
|
+
${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(ei).join("")}
|
|
208
208
|
|
|
209
209
|
<section class="methodology">
|
|
210
210
|
<h2>Methodology</h2>
|
|
@@ -228,17 +228,17 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
228
228
|
</section>
|
|
229
229
|
|
|
230
230
|
<footer>
|
|
231
|
-
<span>Generated ${
|
|
231
|
+
<span>Generated ${G(p)} by ${G(_e)} ${G(a)}</span>
|
|
232
232
|
<span>${l} audit${l===1?"":"s"} · ${o} anchored · ${n.length} component${n.length===1?"":"s"}</span>
|
|
233
233
|
</footer>
|
|
234
234
|
</body>
|
|
235
|
-
</html>`}async function Yr(t){const s=Qr(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Ns(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[r,i]=h.useState(0),[l,o]=h.useState(!1),[c,p]=h.useState(""),[d,m]=h.useState(""),[u,x]=h.useState(""),[g,y]=h.useState(!1);if(h.useEffect(()=>{let b=!1;return s(null),n(null),es().then(A=>{b||s(A)}).catch(A=>{b||n(A instanceof Error?A.message:String(A))}),()=>{b=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const S=t.length,$=t.filter(b=>b.receipt).length;async function k(){if(!(!t||t.length===0)){y(!0);try{await Yr({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:u.trim()||void 0}),o(!1)}finally{y(!1)}}}async function T(){if(!t||t.length===0)return;const b={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},A=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),N=URL.createObjectURL(A),I=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,O=document.createElement("a");O.href=N,O.download=I,O.click(),setTimeout(()=>URL.revokeObjectURL(N),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",$>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[$," RFC 3161-anchored"]})]}),$===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:()=>o(b=>!b),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void T(),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(b=>b+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:c,onChange:b=>p(b.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:d,onChange:b=>m(b.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:u,onChange:b=>x(b.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||S===0,onClick:k,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:g?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(b=>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 ${b.grade==="A"?"bg-emerald-100 text-emerald-700":b.grade==="B"?"bg-lime-100 text-lime-700":b.grade==="C"?"bg-yellow-100 text-yellow-700":b.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:b.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:b.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${b.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:b.receipt?`Anchored to ${b.receipt.tsaName} at ${b.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:b.receipt?`RFC 3161 (${b.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:b.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:b.capturedAt}),(b.totals.critical>0||b.totals.serious>0)&&e.jsxs("span",{children:[b.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[b.totals.critical," crit"]}),b.totals.critical>0&&b.totals.serious>0&&" · ",b.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[b.totals.serious," sev"]})]}),e.jsxs("span",{children:[b.statesAudited," ",b.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:b.hash,children:[b.hash.slice(0,12),"…"]})]})]},`${b.componentId}::${b.capturedAt}`))})]})}function Jr(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let c=!1;return es().then(p=>{c||s(p)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],l=t.slice(0,3),o=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),o>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[o," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(c=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(be,{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(Ns,{})})})]})}function Xr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Zr={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."},ei={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."},ti={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},si={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function ks(){const t=f(m=>m.tier),s=f(m=>m.trialDaysRemaining),a=f(m=>m.seatsUsed),n=f(m=>m.seatsTotal),r=f(m=>m.planCode),i=f(m=>m.licenseDaysRemaining),l=f(m=>m.pastDue),[o,c]=h.useState(!1);if(t==="solo"&&r==="solo-single-month"){const m=i,u=m!==null&&m<=7,x=m===null?"":m===0?"expires today":m===1?"1 day left":`${m} days left`;return e.jsxs("aside",{"aria-label":"License status",className:u?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:u?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),x&&e.jsxs("span",{className:u?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",x]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:u?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:u?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:u?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ze,{open:o,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const m=t==="team"?si:ti,u=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:m.perks,x=t==="team"&&a!==null&&n!==null&&a>n,g=t==="team"&&a!==null&&n!==null&&a===n,y=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}: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 ${y.bg} border-b ${y.border} px-3 py-2 space-y-1 text-[11px] ${y.shadow}`,children:[e.jsxs("div",{className:y.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",m.label]}),e.jsxs("span",{className:y.subtitle,children:[" · ",u]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),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 J({type:"OPEN_SETTINGS"}),className:y.link,children:"Manage license →"})})]})}const p=t==="trial"?Zr:ei,d=t==="trial"?Xr(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:p.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:d})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void J({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(Ze,{open:o,onClose:()=>c(!1)})]})}const ai={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"},ni={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Ht={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},ri={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"},zt={critical:0,serious:1,moderate:2,minor:3};function ii(){const t=f(m=>m.setUserMode),s=f(m=>m.status),a=f(m=>m.setStatus),n=f(m=>m.errorMessage),r=f(m=>m.setError),[i,l]=h.useState(!1),[o,c]=h.useState(!1),p=h.useRef(s);h.useEffect(()=>{if(p.current==="running"&&s==="complete"){c(!0);const m=setTimeout(()=>c(!1),3500);return p.current=s,()=>clearTimeout(m)}p.current=s},[s]),h.useEffect(()=>{if(s!=="running")return;const m=setTimeout(()=>{f.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(m)},[s,a,r]);function d(){t("dev"),J({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(ks,{}),e.jsx(ps,{}),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(us,{}),e.jsx("button",{type:"button",onClick:d,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(li,{}),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:()=>{f.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(js,{onBack:()=>l(!1)}):e.jsx(ci,{onPickCrawl:()=>l(!0)}),o&&e.jsx(oi,{})]}),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 li(){const t=f(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 J({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 oi(){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 ci({onPickCrawl:t}){const s=f(m=>m.status),a=f(m=>m.results),[n,r]=h.useState("quick"),[i,l]=h.useState("all"),o=s==="running",c=a.flatMap(m=>m.violations),p=a.length>0;function d(){ue({type:"START_AUDIT",mode:"full-page",matrixOverride:xt(n)}),f.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:d,disabled:o,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:o?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:o,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(ui,{depth:n,onChange:r,disabled:o})]}),!p&&!o&&e.jsx(di,{}),p&&e.jsx(pi,{violations:c,severityFilter:i,onSeverityFilterChange:l,scanDepth:n})]})}function di(){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 ui({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(Kt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Bt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Kt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Bt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Kt({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 pi({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var N;const r=f(I=>I.status),i=f(I=>I.results),l=f(I=>I.freshThisSession),o=f(I=>I.componentId),c=(N=i[0])==null?void 0:N.startedAt,p=Pr(t),d=r==="running",[m,u]=h.useState([]);h.useEffect(()=>{if(!o){u([]);return}let I=!1;return chrome.storage.local.get("igtRuns").then(O=>{if(I)return;const L=((O==null?void 0:O.igtRuns)??{})[o]??{};u(Object.values(L))}),()=>{I=!0}},[o]);const x=f(I=>I.acknowledgedKeys),g=i.length>0?Zt(i,{runs:m,workflows:ee},"2.1","AA",x):void 0;function y(){ue({type:"START_AUDIT",mode:"full-page",matrixOverride:xt(n)}),f.getState().startNewScan(),ce.polite("Re-scanning this page now.")}const S=s==="lawsuit-risk"?t.filter(I=>I.impact==="critical"||I.impact==="serious"):t,$=new Map;for(const I of S){const O=dt(I.ruleId,I.target.selector);$.has(O)||$.set(O,I)}const k=Array.from($.values()),T=new Map;for(const I of k){const O=T.get(I.ruleId)??[];O.push(I),T.set(I.ruleId,O)}const b=Array.from(T.entries()).sort((I,O)=>(zt[I[1][0].impact]??99)-(zt[O[1][0].impact]??99)),A=t.filter(I=>I.impact==="critical"||I.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[c&&e.jsxs("span",{children:["Last scanned: ",e.jsx(bi,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Ve(),disabled:d,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:y,disabled:d,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:d?"Scanning…":"↻ Scan again"})]})]}),d?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${ai[p.tier]}`,children:[!l&&c&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ni[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${Ht[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Ht[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged",p.flaggedInstanceCount>p.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:p.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!d&&g&&!g.canClaimConformance&&e.jsx(mi,{coverage:g}),!d&&g&&g.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",g.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(fi,{}),e.jsx(Jr,{}),t.length>0&&e.jsx(hi,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:A}),e.jsxs("div",{className:"space-y-2",children:[b.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."]}),b.map(([I,O])=>e.jsx(xi,{ruleId:I,violations:O},I))]})]})}function mi({coverage:t}){const s=f(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"),J({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 hi({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 xi({ruleId:t,violations:s}){var m;const[a,n]=h.useState(!1),r=(m=s.find(u=>u.target.opacityContext))==null?void 0:m.target.opacityContext,i=Zs(t,r),l=s[0].impact,o=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&o.description?o.description:i.whatsWrong,d=o.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${ri[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((u,x)=>e.jsx(gi,{violation:u},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:u=>u.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function gi({violation:t}){const s=f(i=>{var l;return(l=i.results[0])==null?void 0:l.frameId}),[a,n]=h.useState(null);async function r(i){i.stopPropagation();const l=await le();if(l)try{const o=await Ie(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(o.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const $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 fi(){const t=f(d=>d.results),s=f(d=>d.componentId),[a,n]=h.useState(null),[r,i]=h.useState(!1),[l,o]=h.useState(null);async function c(d,m){if(t.length!==0){n(d);try{const u=await te({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=Yt(d,s);await Jt()?ot(u.content,x):o({open:!0,format:d,content:u.content,filename:x})}else if(m)lt(u.content);else{try{await navigator.clipboard.writeText(u.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>
|
|
235
|
+
</html>`}async function si(t){const s=ti(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Cs(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[r,i]=h.useState(0),[l,o]=h.useState(!1),[c,p]=h.useState(""),[d,u]=h.useState(""),[m,x]=h.useState(""),[g,y]=h.useState(!1);if(h.useEffect(()=>{let b=!1;return s(null),n(null),as().then(A=>{b||s(A)}).catch(A=>{b||n(A instanceof Error?A.message:String(A))}),()=>{b=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const S=t.length,$=t.filter(b=>b.receipt).length;async function k(){if(!(!t||t.length===0)){y(!0);try{await si({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:m.trim()||void 0}),o(!1)}finally{y(!1)}}}async function T(){if(!t||t.length===0)return;const b={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},A=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),N=URL.createObjectURL(A),I=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,O=document.createElement("a");O.href=N,O.download=I,O.click(),setTimeout(()=>URL.revokeObjectURL(N),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",$>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[$," RFC 3161-anchored"]})]}),$===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:()=>o(b=>!b),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void T(),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(b=>b+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:c,onChange:b=>p(b.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:d,onChange:b=>u(b.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:m,onChange:b=>x(b.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||S===0,onClick:k,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:g?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(b=>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 ${b.grade==="A"?"bg-emerald-100 text-emerald-700":b.grade==="B"?"bg-lime-100 text-lime-700":b.grade==="C"?"bg-yellow-100 text-yellow-700":b.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:b.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:b.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${b.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:b.receipt?`Anchored to ${b.receipt.tsaName} at ${b.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:b.receipt?`RFC 3161 (${b.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:b.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:b.capturedAt}),(b.totals.critical>0||b.totals.serious>0)&&e.jsxs("span",{children:[b.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[b.totals.critical," crit"]}),b.totals.critical>0&&b.totals.serious>0&&" · ",b.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[b.totals.serious," sev"]})]}),e.jsxs("span",{children:[b.statesAudited," ",b.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:b.hash,children:[b.hash.slice(0,12),"…"]})]})]},`${b.componentId}::${b.capturedAt}`))})]})}function ai(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let c=!1;return as().then(p=>{c||s(p)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],l=t.slice(0,3),o=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),o>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[o," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(c=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(be,{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(Cs,{})})})]})}function ni(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const ri={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."},ii={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."},li={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},oi={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Is(){const t=f(u=>u.tier),s=f(u=>u.trialDaysRemaining),a=f(u=>u.seatsUsed),n=f(u=>u.seatsTotal),r=f(u=>u.planCode),i=f(u=>u.licenseDaysRemaining),l=f(u=>u.pastDue),[o,c]=h.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,m=u!==null&&u<=7,x=u===null?"":u===0?"expires today":u===1?"1 day left":`${u} days left`;return e.jsxs("aside",{"aria-label":"License status",className:m?"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:m?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),x&&e.jsxs("span",{className:m?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",x]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:m?"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:m?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:m?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(et,{open:o,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?oi:li,m=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,x=t==="team"&&a!==null&&n!==null&&a>n,g=t==="team"&&a!==null&&n!==null&&a===n,y=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}: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 ${y.bg} border-b ${y.border} px-3 py-2 space-y-1 text-[11px] ${y.shadow}`,children:[e.jsxs("div",{className:y.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:y.subtitle,children:[" · ",m]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),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 J({type:"OPEN_SETTINGS"}),className:y.link,children:"Manage license →"})})]})}const p=t==="trial"?ri:ii,d=t==="trial"?ni(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:p.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:d})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void J({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(et,{open:o,onClose:()=>c(!1)})]})}const ci={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"},di={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},zt={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"},Kt={critical:0,serious:1,moderate:2,minor:3};function pi(){const t=f(u=>u.setUserMode),s=f(u=>u.status),a=f(u=>u.setStatus),n=f(u=>u.errorMessage),r=f(u=>u.setError),[i,l]=h.useState(!1),[o,c]=h.useState(!1),p=h.useRef(s);h.useEffect(()=>{if(p.current==="running"&&s==="complete"){c(!0);const u=setTimeout(()=>c(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),h.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{f.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(u)},[s,a,r]);function d(){t("dev"),J({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(Is,{}),e.jsx(gs,{}),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(xs,{}),e.jsx("button",{type:"button",onClick:d,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(mi,{}),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:()=>{f.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(Ss,{onBack:()=>l(!1)}):e.jsx(xi,{onPickCrawl:()=>l(!0)}),o&&e.jsx(hi,{})]}),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 mi(){const t=f(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 J({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 hi(){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 xi({onPickCrawl:t}){const s=f(u=>u.status),a=f(u=>u.results),[n,r]=h.useState("quick"),[i,l]=h.useState("all"),o=s==="running",c=a.flatMap(u=>u.violations),p=a.length>0;function d(){ue({type:"START_AUDIT",mode:"full-page",matrixOverride:gt(n)}),f.getState().startNewScan(),de.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:d,disabled:o,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:o?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:o,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(fi,{depth:n,onChange:r,disabled:o})]}),!p&&!o&&e.jsx(gi,{}),p&&e.jsx(bi,{violations:c,severityFilter:i,onSeverityFilterChange:l,scanDepth:n})]})}function gi(){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 fi({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(qt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Ht("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(qt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Ht("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function qt({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 bi({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var N;const r=f(I=>I.status),i=f(I=>I.results),l=f(I=>I.freshThisSession),o=f(I=>I.componentId),c=(N=i[0])==null?void 0:N.startedAt,p=zr(t),d=r==="running",[u,m]=h.useState([]);h.useEffect(()=>{if(!o){m([]);return}let I=!1;return chrome.storage.local.get("igtRuns").then(O=>{if(I)return;const L=((O==null?void 0:O.igtRuns)??{})[o]??{};m(Object.values(L))}),()=>{I=!0}},[o]);const x=f(I=>I.acknowledgedKeys),g=i.length>0?ss(i,{runs:u,workflows:ee},"2.1","AA",x):void 0;function y(){ue({type:"START_AUDIT",mode:"full-page",matrixOverride:gt(n)}),f.getState().startNewScan(),de.polite("Re-scanning this page now.")}const S=s==="lawsuit-risk"?t.filter(I=>I.impact==="critical"||I.impact==="serious"):t,$=new Map;for(const I of S){const O=ut(I.ruleId,I.target.selector);$.has(O)||$.set(O,I)}const k=Array.from($.values()),T=new Map;for(const I of k){const O=T.get(I.ruleId)??[];O.push(I),T.set(I.ruleId,O)}const b=Array.from(T.entries()).sort((I,O)=>(Kt[I[1][0].impact]??99)-(Kt[O[1][0].impact]??99)),A=t.filter(I=>I.impact==="critical"||I.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[c&&e.jsxs("span",{children:["Last scanned: ",e.jsx(ki,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Be(),disabled:d,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:y,disabled:d,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:d?"Scanning…":"↻ Scan again"})]})]}),d?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${ci[p.tier]}`,children:[!l&&c&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${di[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${zt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${zt[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged",p.flaggedInstanceCount>p.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:p.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!d&&g&&!g.canClaimConformance&&e.jsx(vi,{coverage:g}),!d&&g&&g.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",g.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(Ni,{}),e.jsx(ai,{}),t.length>0&&e.jsx(yi,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:A}),e.jsxs("div",{className:"space-y-2",children:[b.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."]}),b.map(([I,O])=>e.jsx(wi,{ruleId:I,violations:O},I))]})]})}function vi({coverage:t}){const s=f(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"),J({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 yi({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 wi({ruleId:t,violations:s}){var u;const[a,n]=h.useState(!1),r=(u=s.find(m=>m.target.opacityContext))==null?void 0:u.target.opacityContext,i=ra(t,r),l=s[0].impact,o=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&o.description?o.description:i.whatsWrong,d=o.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${ui[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((m,x)=>e.jsx(ji,{violation:m},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function ji({violation:t}){const s=f(i=>{var l;return(l=i.results[0])==null?void 0:l.frameId}),[a,n]=h.useState(null);async function r(i){i.stopPropagation();const l=await le();if(l)try{const o=await Ie(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(o.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const $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 Ni(){const t=f(d=>d.results),s=f(d=>d.componentId),[a,n]=h.useState(null),[r,i]=h.useState(!1),[l,o]=h.useState(null);async function c(d,u){if(t.length!==0){n(d);try{const m=await te({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=Zt(d,s);await es()?ct(m.content,x):o({open:!0,format:d,content:m.content,filename:x})}else if(u)ot(m.content);else{try{await navigator.clipboard.writeText(m.content),de.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
|
|
236
236
|
<style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
|
|
237
237
|
.banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
|
|
238
238
|
pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
|
|
239
239
|
<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>
|
|
240
|
-
<pre>${
|
|
241
|
-
<h3 class="guideline-h">Guideline ${U(
|
|
240
|
+
<pre>${m.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`,y=new Blob([g],{type:"text/html"}),S=URL.createObjectURL(y);window.open(S,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(S),6e4)}}finally{n(null)}}}const p=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:p.map(d=>e.jsx("button",{type:"button",onClick:()=>void c(d.id,d.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:d.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:d.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:d.desc})]}),a===d.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},d.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",$e.length-2," more report option",$e.length-2===1?"":"s"," ↓"]}),l&&e.jsx(ks,{open:l.open,onClose:()=>o(null),format:l.format,content:l.content,filename:l.filename})]})}function ki({iso:t}){const[,s]=h.useState(0);h.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 Si(t,s,a){const n=new Set,r=[];let i=!1;for(const[l,o]of s)for(const c of o){for(const d of c.violations)if(d.wcagCriterion===t){if(a!=null&&a.has(d.matchKey)){n.add(d.ruleId);continue}if(d.needsReview){n.add(d.ruleId),i=!0;continue}n.add(d.ruleId),r.push({source:"axe",ruleOrStepId:d.ruleId,description:d.description||d.ruleId,pageUrl:l,selector:d.target.selector})}const p=c.axeRulesEvaluated;if(p){for(const d of p.passed)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of p.inapplicable)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of p.incomplete)d.wcagCriterion===t&&(n.add(d.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function Ai(t,s,a){const n=[];let r=0,i=0,l=0,o=0;for(const p of a){const d=p.steps.filter(u=>u.wcag===t);if(d.length!==0){r+=d.length;for(const[u,m]of s){const x=m[p.id];if(!x){i+=d.length;continue}for(const g of d){const y=x.steps[g.id];if(!y){i++;continue}y.status==="fail"?(l++,n.push({source:"igt",ruleOrStepId:`${p.id}.${g.id}`,description:g.question,pageUrl:u,notes:y.notes})):y.status==="skip"?i++:y.status==="not-applicable"?(l++,o++):l++}}}}const c=l>0&&o===l;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:c}}function Ci(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 Ii(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 Ri(t,s){var u;const a=[];for(const m of s.auditsByUrl.values())a.push(...m);const n=[];for(const m of s.igtRunsByUrl.values())n.push(...Object.values(m));const r=pt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=ia(t.targetVersion,t.targetLevel),l=[];for(const m of i){const x=Si(m.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=Ai(m.id,s.igtRunsByUrl,s.workflows),y=x.rulesFiring.size===0&&g.stepsCovering===0,S={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:y},$=(u=t.overrides)==null?void 0:u[m.id];let k,T,b=!1;if($)k=$.verdict,T=$.rationale,b=!0;else{const A=r.get(m.id);A?k=A.state:k=Ci(S,g.unanswered,x.hasIncomplete,g.allNotApplicable),T=Ii(m,k,S)}l.push({criterion:m,understandingUrl:la(m,t.targetVersion),verdict:k,signals:S,overridden:b,rationale:T})}const o={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const m of l)m.verdict==="pass"?o.pass++:m.verdict==="fail"?o.fail++:m.verdict==="inconclusive"?o.inconclusive++:m.verdict==="not-applicable"?o.notApplicable++:m.verdict==="not-evaluated"&&o.notEvaluated++;function c(m){const x={A:1,AA:2,AAA:3},g=x[m];return l.every(y=>x[y.criterion.level]>g?!0:y.verdict==="pass"||y.verdict==="not-applicable")}let p=null;c("AAA")?p="AAA":c("AA")?p="AA":c("A")&&(p="A");const d=p===t.targetLevel||p==="AAA"&&t.targetLevel==="AA"||p==="AAA"&&t.targetLevel==="A"||p==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:l,summary:{totalCriteria:l.length,pass:o.pass,fail:o.fail,inconclusive:o.inconclusive,notApplicable:o.notApplicable,notEvaluated:o.notEvaluated,levelAchieved:p,meetsTarget:d}}}const Ei={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Qt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function U(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ke(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 Ti(t,s,a,n){const{inputs:r,rows:i,summary:l,generatedAt:o}=t,c=l.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,p=new Map;for(const u of i){const m=u.criterion.id.split(".").slice(0,2).join("."),x=p.get(m)??[];x.push(u),p.set(m,x)}const d=Array.from(p.entries()).sort(([u],[m])=>u.localeCompare(m,void 0,{numeric:!0})).map(([u,m])=>`
|
|
241
|
+
<h3 class="guideline-h">Guideline ${U(u)}</h3>
|
|
242
242
|
<table class="criteria-table">
|
|
243
243
|
<thead>
|
|
244
244
|
<tr>
|
|
@@ -246,12 +246,12 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
246
246
|
</tr>
|
|
247
247
|
</thead>
|
|
248
248
|
<tbody>
|
|
249
|
-
${
|
|
250
|
-
<tr class="${
|
|
249
|
+
${m.map(x=>`
|
|
250
|
+
<tr class="${Qt[x.verdict]}">
|
|
251
251
|
<td><a href="${U(x.understandingUrl)}" target="_blank" rel="noopener">${U(x.criterion.id)}</a></td>
|
|
252
252
|
<td>${U(x.criterion.title)}</td>
|
|
253
253
|
<td>${U(x.criterion.level)}</td>
|
|
254
|
-
<td><span class="verdict-badge ${
|
|
254
|
+
<td><span class="verdict-badge ${Qt[x.verdict]}">${Ei[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
|
|
255
255
|
<td class="rationale">${U(x.rationale)}</td>
|
|
256
256
|
</tr>
|
|
257
257
|
${x.signals.axeFailures.length>0||x.signals.igtFailures.length>0?`
|
|
@@ -430,12 +430,12 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
430
430
|
<table class="sample-table">
|
|
431
431
|
<thead><tr><th>URL</th><th>Page type</th><th>Selection</th><th>Data?</th></tr></thead>
|
|
432
432
|
<tbody>
|
|
433
|
-
${r.pageSample.map(
|
|
433
|
+
${r.pageSample.map(u=>`
|
|
434
434
|
<tr>
|
|
435
|
-
<td><a href="${U(
|
|
436
|
-
<td>${U(
|
|
437
|
-
<td>${U(
|
|
438
|
-
<td>${
|
|
435
|
+
<td><a href="${U(u.url)}" target="_blank" rel="noopener"><code>${U(u.url)}</code></a></td>
|
|
436
|
+
<td>${U(u.pageType)}</td>
|
|
437
|
+
<td>${U(u.selectionType)}</td>
|
|
438
|
+
<td>${u.hasAuditData?"✓":'<em style="color:#94a3b8">no audit data</em>'}</td>
|
|
439
439
|
</tr>
|
|
440
440
|
`).join("")}
|
|
441
441
|
</tbody>
|
|
@@ -539,6 +539,6 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
539
539
|
<span>${l.totalCriteria} criteria · ${l.pass} pass · ${l.fail} fail · ${l.inconclusive} inconclusive</span>
|
|
540
540
|
</footer>
|
|
541
541
|
</body>
|
|
542
|
-
</html>`}async function Ai(t,s,a,n){const r=Si(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),l=URL.createObjectURL(i);await chrome.tabs.create({url:l})}const Xe=ts("wcag-em-anchor"),Ci="https://api.wcagcheckr.com",Ii="wcagcheckr",Ri=15e3;function Ss(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 Ei(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 Ti(t){return Ei(sa(Ss(t)))}function $i(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 Ui(t,s){const a=await Ti(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Ci}/v1/products/${Ii}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Ri)});if(!i.ok)return Xe.warn(`anchor HTTP ${i.status}`),null;const l=await i.json();return $i(l)?{reportHash:a,capturedAt:t.generatedAt,receipt:l}:(Xe.warn("anchor returned malformed receipt",l),null)}catch(i){return Xe.warn("anchor request failed",i),null}}function Li(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Ss(t)}}const nt="auditAttestations",rt="auditAttestation:defaultSigner";function gt(t,s){return`${t}::${s}`}async function ft(){try{const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function As(t){await chrome.storage.local.set({[nt]:t})}async function Di(t){const s=await ft();s[gt(t.componentId,t.auditCapturedAt)]=t,await As(s)}async function Cs(t,s){return(await ft())[gt(t,s)]??null}async function Oi(t,s){const a=await ft();delete a[gt(t,s)],await As(a)}async function _i(){try{const s=(await chrome.storage.local.get(rt))[rt];return s&&typeof s=="object"?s:null}catch{return null}}async function Fi(t){await chrome.storage.local.set({[rt]:t})}function Mi(t,s){return t.auditCapturedAt!==s}function Pi(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 Gi(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,l]=h.useState(!1),[o,c]=h.useState(""),[p,d]=h.useState(""),[m,u]=h.useState(""),[x,g]=h.useState(""),[y,S]=h.useState("");h.useEffect(()=>{let A=!1;return Promise.all([Cs(t.componentId,t.auditCapturedAt),_i()]).then(([N,I])=>{A||(a(N),N?(c(N.signerName),d(N.signerEmail),u(N.signerOrganization??""),g(N.signerQualifications??""),S(N.claim)):I&&(c(I.signerName),d(I.signerEmail),u(I.signerOrganization??""),g(I.signerQualifications??"")),S(O=>O||Pi({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{A=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function $(){if(!o.trim()||!p.trim())return;const A={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:o.trim(),signerEmail:p.trim(),signerOrganization:m.trim()||void 0,signerQualifications:x.trim()||void 0,claim:y.trim(),scope:t.scope};await Di(A),await Fi({signerName:A.signerName,signerEmail:A.signerEmail,signerOrganization:A.signerOrganization,signerQualifications:A.signerQualifications}),a(A),l(!1)}async function k(){await Oi(t.componentId,t.auditCapturedAt),a(null),l(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const T=s&&Mi(s,t.auditCapturedAt);if(s&&!T&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void k(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&T&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const b=o.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:o,onChange:A=>c(A.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:p,onChange:A=>d(A.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:m,onChange:A=>u(A.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:A=>g(A.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:y,onChange:A=>S(A.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!b,onClick:()=>void $(),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 it="spotAuditReviews";function Is(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function bt(){try{const s=(await chrome.storage.local.get(it))[it];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Rs(t){await chrome.storage.local.set({[it]:t})}async function Wi(t){const s=await bt();s[t.key]=t,await Rs(s)}async function Vi(t){const s=await bt();delete s[t],await Rs(s)}async function Es(){const t=await bt();return Object.values(t)}function Ts(t,s){const a=new Map(s.map(l=>[l.key,l]));let n=0,r=0,i=0;for(const l of t){const o=a.get(l);o&&(n++,o.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function Bi(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 Hi(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const l=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,o=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${l}::${i.selector}`):void 0;n.push({key:Is({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:o})}return n}const zi={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"},Ki={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 qi({verdicts:t,incompleteResolutions:s}){const a=h.useMemo(()=>Hi(t,s),[t,s]),[n,r]=h.useState([]),[i,l]=h.useState(!0),[o,c]=h.useState(null),[p,d]=h.useState(5),[m,u]=h.useState(!1);h.useEffect(()=>{let b=!1;return Es().then(A=>{b||(r(A),l(!1))}),()=>{b=!0}},[]);const x=h.useMemo(()=>a.map(b=>b.key),[a]),g=h.useMemo(()=>Ts(x,n),[x,n]),S=(m?x:o||n.filter(b=>x.includes(b.key)).map(b=>b.key)).map(b=>a.find(A=>A.key===b)).filter(b=>!!b);async function $(b,A,N){const I={key:b.key,criterionId:b.criterionId,ruleOrStepId:b.ruleOrStepId,pageUrl:b.pageUrl,selector:b.selector,verdict:A,correction:(N==null?void 0:N.trim())||void 0,reviewedAt:new Date().toISOString()};await Wi(I),r(O=>[I,...O.filter(v=>v.key!==I.key)])}async function k(b){await Vi(b.key),r(A=>A.filter(N=>N.key!==b.key))}function T(){c(Bi(x,p)),u(!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(Ue,{label:"AI determinations",value:g.total}),e.jsx(Ue,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Ue,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Ue,{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:p,onChange:b=>d(Math.max(1,Math.min(a.length,Number(b.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:T,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:()=>{u(b=>!b),c(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:m?"Hide list":`Show all (${a.length})`}),o&&e.jsx("button",{type:"button",onClick:()=>c(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):S.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:S.map(b=>e.jsx(Qi,{row:b,review:n.find(A=>A.key===b.key)??null,onAgree:()=>void $(b,"agreed"),onDisagree:A=>void $(b,"disagreed",A),onClear:()=>void k(b)},b.key))})]})}function Ue({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 Qi(t){const{row:s,review:a}=t,[n,r]=h.useState(!1),[i,l]=h.useState((a==null?void 0:a.correction)??""),o=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${o==="agreed"?"border-emerald-300 bg-emerald-50/50":o==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${zi[s.outcome]}`,children:Ki[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),o&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&o==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:c=>l(c.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),l((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Se(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,l]=h.useState(!1),[o,c]=h.useState(null);h.useEffect(()=>{let m=!1;return aa(t.componentId,t.criterionId).then(u=>{m||(a(u),r(!1))}),()=>{m=!0}},[t.componentId,t.criterionId]);async function p(){l(!0),c(null);try{const u=await J({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});u.ok?u.result&&a(u.result):c(u.error??"Audit failed.")}catch(m){c(m instanceof Error?m.message:String(m))}finally{l(!1)}}async function d(){await na(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&&!o&&e.jsx("button",{type:"button",onClick:()=>void p(),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"}),o&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:o}),e.jsx("button",{type:"button",onClick:()=>void p(),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 m=(s.steps??[]).filter(u=>u.action!=="initial").length;return m===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 (",m," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(u=>u.action!=="initial").map(u=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",u.focused.role||u.focused.tag,"]"]})," ",u.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:u.focused.selector})]},u.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 p(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void d(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function Yi(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let n=!1;return le().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(Se,{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(Se,{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(Se,{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(Se,{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(Se,{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 Qt="igtRuns",Ji={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"},Xi={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Zi(){var me,se,Y;const t=f(E=>E.results),s=f(E=>E.acknowledgedKeys),[a,n]=h.useState(""),[r,i]=h.useState(""),l=ia,o=ra,[c,p]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,m]=h.useState(""),[u,x]=h.useState(""),[g,y]=h.useState(""),[S,$]=h.useState(""),[k,T]=h.useState(""),[b,A]=h.useState(""),[N,I]=h.useState({}),[O,v]=h.useState(!1),[L,w]=h.useState([]),[j,D]=h.useState([]),[_,G]=h.useState(null),[ae,ne]=h.useState(!1),[re,R]=h.useState(null);h.useEffect(()=>{let E=!1;return chrome.storage.local.get(Qt).then(B=>{if(E)return;const F=B[Qt]??{};I(F),v(!0)}).catch(()=>{E||v(!0)}),()=>{E=!0}},[]),h.useEffect(()=>{var z;const E=(z=t[0])==null?void 0:z.componentId;if(!E)return;let B=!1;const F=()=>{Xt(E).then(K=>{B||D(K.map(ie=>({criterionId:ie.criterionId,ruleId:`ai-interactive::${ie.criterionId}`,pageUrl:ie.pageUrl,verdict:ie.verdict,reasoning:ie.reasoning})))})};F();const P=K=>{K.interactiveAuditResults&&F()};return chrome.storage.local.onChanged.addListener(P),()=>{B=!0,chrome.storage.local.onChanged.removeListener(P)}},[t]),h.useEffect(()=>{var E;if(!a&&((E=t[0])!=null&&E.pageUrl))try{const B=new URL(t[0].pageUrl);n(B.hostname),i(B.origin)}catch{}},[t,a]),h.useEffect(()=>{const E=new Set;for(const F of t)E.add(F.pageUrl??F.scope);if(E.size===0){w([]);return}let B=!1;return Promise.all(Array.from(E).map(F=>Le(F))).then(F=>{B||w(F.flat())}).catch(()=>{}),()=>{B=!0}},[t]);const H=h.useMemo(()=>{const E=new Map,B=new Map;for(const P of t){const z=P.pageUrl??P.scope,K=E.get(z)??[];K.push(P),E.set(z,K)}const F=new Map;for(const P of t){const z=P.pageUrl??P.scope;F.set(P.componentId,z)}for(const[P,z]of Object.entries(N)){const K=F.get(P);if(!K)continue;const ie=B.get(K)??{};Object.assign(ie,z),B.set(K,ie)}return{auditsByUrl:E,igtRunsByUrl:B,workflows:ee,acknowledgedMatchKeys:s,incompleteResolutions:L,interactiveAuditResults:j}},[t,N,s,L,j]),X=h.useMemo(()=>{const E=[],B=new Set;for(const F of H.auditsByUrl.keys())B.has(F)||(B.add(F),E.push({url:F,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const F of b.split(`
|
|
543
|
-
`).map(P=>P.trim()).filter(Boolean))B.has(F)||(B.add(F),E.push({url:F,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return E},[H,b]),
|
|
544
|
-
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:u,onChange:E=>x(E.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:E=>y(E.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:E=>$(E.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:k,onChange:E=>T(E.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),C&&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 (",C.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:C.rows.map(E=>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:[E.criterion.id," · ",E.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:E.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Ji[E.verdict]}`,children:Xi[E.verdict]})]},E.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),_?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[_.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",_.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),re&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:re}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!C||!a||!u||ae,onClick:()=>void Q(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:ae?"Anchoring…":_?"Re-anchor":"Anchor this report"}),_&&e.jsx("button",{type:"button",onClick:q,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"})]})]}),C&&((me=t[0])==null?void 0:me.componentId)&&e.jsx(Yi,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),C&&e.jsx(qi,{verdicts:M,incompleteResolutions:L}),C&&((se=t[0])==null?void 0:se.componentId)&&((Y=t[0])==null?void 0:Y.startedAt)&&e.jsx(Gi,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:l,targetLevel:o,evaluatedCount:C.summary.pass+C.summary.fail+C.summary.inconclusive+C.summary.notApplicable,totalCount:C.summary.totalCriteria,canClaimConformance:C.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:!C||!a||!u,onClick:()=>void Z(),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:"Generate WCAG-EM report →"})})]}):e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading IGT runs…"})}function el({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:l,meetsTarget:o,targetVersion:c,targetLevel:p,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${o?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${o?"text-emerald-900":"text-amber-900"}`,children:o?`Currently meeting WCAG ${c} Level ${p}`:`Does not currently meet WCAG ${c} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:l??"none"})," · ",t," applicable criteria across ",d," audited URL",d===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const tl={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function sl(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 al(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+ua[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 nl(){return crypto.randomUUID()}function rl(){const[t,s]=h.useState([]),[a,n]=h.useState(!0),[r,i]=h.useState(""),[l,o]=h.useState("daily"),[c,p]=h.useState(null),[d,m]=h.useState(!1),[u,x]=h.useState(la),[g,y]=h.useState("idle"),[S,$]=h.useState(!1),[k,T]=h.useState(null);async function b(){n(!0);try{const v=await ca();v.sort((L,w)=>L.enabled!==w.enabled?L.enabled?-1:1:w.createdAt.localeCompare(L.createdAt)),s(v)}finally{n(!1)}}h.useEffect(()=>{b(),(async()=>{const v=await oa();x(v)})()},[]);async function A(v){if(T(null),v.webhookEnabled&&v.webhookUrl.trim().length>0)try{if(new URL(v.webhookUrl).protocol!=="https:"){T("Webhook URL must use https://");return}}catch{T("Webhook URL is not a valid https:// URL.");return}y("saving"),await da(v),x(v),y("saved"),setTimeout(()=>y("idle"),1500)}async function N(){p(null);const v=r.trim();if(!v){p("URL is required.");return}try{new URL(v)}catch{p("Must be a valid URL (e.g. https://example.com/).");return}m(!0);try{const L={id:nl(),url:v,cadence:l,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await Nt(L),await kt(L),i(""),o("daily"),await b(),await ze()}finally{m(!1)}}async function I(v){const L={...v,enabled:!v.enabled};await Nt(L),L.enabled?await kt(L):await St(v.id),await b(),await ze()}async function O(v){window.confirm(`Remove the scheduled audit for ${v.url}? Run history for this schedule will also be deleted.`)&&(await St(v.id),await pa(v.id),await ma(v.id),await b(),await ze())}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:()=>$(v=>!v),"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",u.emailEnabled||u.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:u.emailEnabled,onChange:v=>void A({...u,emailEnabled:v.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:u.webhookEnabled,onChange:v=>void A({...u,webhookEnabled:v.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."})]})]}),u.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:u.webhookUrl,onChange:v=>x({...u,webhookUrl:v.target.value}),onBlur:()=>void A(u),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),k&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:k})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"alert-min-impact",className:"block text-[11px] font-medium mb-1",children:"Minimum impact to alert on"}),e.jsxs("select",{id:"alert-min-impact",value:u.minImpact,onChange:v=>void A({...u,minImpact:v.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:v=>i(v.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:l,onChange:v=>o(v.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),c&&e.jsx("div",{className:"text-rose-700",role:"alert",children:c}),e.jsx("button",{type:"button",onClick:()=>void N(),disabled:d||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:d?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(v=>e.jsx("li",{className:`border rounded p-2.5 ${v.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:v.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[tl[v.cadence]," · last run ",sl(v.lastRunAt)," ·"," ","next ",al(v)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[v.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",v.lastTotalViolations??0," violation",(v.lastTotalViolations??0)===1?"":"s"]}),v.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:v.lastError??"",children:"✗ failed"}),v.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),v.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"}),(v.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:["⚠ ",v.lastNewViolationCount," new vs baseline"]}),!v.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void I(v),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:v.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void O(v),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},v.id))})]})}function il(){const[t,s]=h.useState(""),[a,n]=h.useState(!1),[r,i]=h.useState(null);async function l(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const o=await J({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(o!=null&&o.validated)){const c=o!=null&&o.seatClaim&&"reason"in o.seatClaim?o.seatClaim.reason:null,p=o!=null&&o.seatClaim&&"hint"in o.seatClaim?o.seatClaim.hint:void 0;i(c==="cap-reached"?`License is at seat capacity. ${p??"Release a seat from another device or contact support."}`:c==="not-found"?"License not found. Check the token and try again.":c==="network"?`Network error: ${o!=null&&o.seatClaim&&"message"in o.seatClaim?o.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(o){i(o instanceof Error?o.message:String(o))}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:o=>s(o.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function hl(){const t=f(l=>l.view),s=f(l=>l.userMode),a=f(l=>l.tier),[n,r]=h.useState(!1);h.useEffect(()=>{const l=setTimeout(()=>r(!0),600);return()=>clearTimeout(l)},[]);const i=n&&ga(a);return h.useEffect(()=>{const l=Aa(),c=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),p=ja();rs({forceRefresh:!0}).catch(()=>{}),Fe().catch(()=>{}),Sa().catch(()=>{}),Ca().catch(()=>{}),Na().catch(()=>{}),ha().then(m=>{f.getState().setAcknowledgedKeys(new Set(m.map(u=>u.matchKey)))}).catch(()=>{}),xa().then(m=>{m&&f.setState({siteCrawlReport:m})}).catch(()=>{});const d=m=>{if(m.key!=="Escape")return;const{pinnedMatchKey:u,setPinned:x,results:g}=f.getState();u&&(x(null),le().then(y=>{var S;y&&pe(y,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:y},(S=g[0])==null?void 0:S.frameId).catch(()=>{})}))};return window.addEventListener("keydown",d),()=>{p(),l.disconnect(),c==null||c.disconnect(),window.removeEventListener("keydown",d)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(il,{}),e.jsx(Ee,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(_r,{}),e.jsx(Ee,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(ii,{}),e.jsx(Vt,{}),e.jsx(Ee,{})]}):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(ks,{}),e.jsx(ps,{}),e.jsx(Ga,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Ha,{}),e.jsx(Ya,{}),e.jsx(Ur,{}),e.jsx($r,{}),e.jsx(Xa,{}),e.jsx(Er,{}),e.jsx(Tr,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(hn,{}),t==="report"&&e.jsx(Tn,{}),t==="delta"&&e.jsx(Hn,{}),t==="activity"&&e.jsx(ar,{}),t==="guided"&&e.jsx(xr,{}),t==="flows"&&e.jsx(vr,{}),t==="scorecard"&&e.jsx(wr,{}),t==="crawl"&&e.jsx(js,{}),t==="forensic"&&e.jsx(Ns,{}),t==="compliance"&&e.jsx(Zi,{}),t==="schedules"&&e.jsx(rl,{})]})]}),e.jsx(Or,{}),e.jsx(Lr,{}),e.jsx(Rr,{}),e.jsx(Vt,{}),e.jsx(Ee,{})]})}class xl extends Ae.Component{constructor(){super(...arguments);jt(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,xl as E,ml as d};
|
|
542
|
+
</html>`}async function $i(t,s,a,n){const r=Ti(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),l=URL.createObjectURL(i);await chrome.tabs.create({url:l})}const Ze=rs("wcag-em-anchor"),Ui="https://api.wcagcheckr.com",Li="wcagcheckr",Di=15e3;function Rs(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 Oi(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 _i(t){return Oi(oa(Rs(t)))}function Fi(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 Mi(t,s){const a=await _i(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Ui}/v1/products/${Li}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Di)});if(!i.ok)return Ze.warn(`anchor HTTP ${i.status}`),null;const l=await i.json();return Fi(l)?{reportHash:a,capturedAt:t.generatedAt,receipt:l}:(Ze.warn("anchor returned malformed receipt",l),null)}catch(i){return Ze.warn("anchor request failed",i),null}}function Pi(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Rs(t)}}const rt="auditAttestations",it="auditAttestation:defaultSigner";function ft(t,s){return`${t}::${s}`}async function bt(){try{const s=(await chrome.storage.local.get(rt))[rt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Es(t){await chrome.storage.local.set({[rt]:t})}async function Vi(t){const s=await bt();s[ft(t.componentId,t.auditCapturedAt)]=t,await Es(s)}async function Ts(t,s){return(await bt())[ft(t,s)]??null}async function Gi(t,s){const a=await bt();delete a[ft(t,s)],await Es(a)}async function Wi(){try{const s=(await chrome.storage.local.get(it))[it];return s&&typeof s=="object"?s:null}catch{return null}}async function Bi(t){await chrome.storage.local.set({[it]:t})}function Hi(t,s){return t.auditCapturedAt!==s}function zi(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 Ki(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,l]=h.useState(!1),[o,c]=h.useState(""),[p,d]=h.useState(""),[u,m]=h.useState(""),[x,g]=h.useState(""),[y,S]=h.useState("");h.useEffect(()=>{let A=!1;return Promise.all([Ts(t.componentId,t.auditCapturedAt),Wi()]).then(([N,I])=>{A||(a(N),N?(c(N.signerName),d(N.signerEmail),m(N.signerOrganization??""),g(N.signerQualifications??""),S(N.claim)):I&&(c(I.signerName),d(I.signerEmail),m(I.signerOrganization??""),g(I.signerQualifications??"")),S(O=>O||zi({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{A=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function $(){if(!o.trim()||!p.trim())return;const A={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:o.trim(),signerEmail:p.trim(),signerOrganization:u.trim()||void 0,signerQualifications:x.trim()||void 0,claim:y.trim(),scope:t.scope};await Vi(A),await Bi({signerName:A.signerName,signerEmail:A.signerEmail,signerOrganization:A.signerOrganization,signerQualifications:A.signerQualifications}),a(A),l(!1)}async function k(){await Gi(t.componentId,t.auditCapturedAt),a(null),l(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const T=s&&Hi(s,t.auditCapturedAt);if(s&&!T&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void k(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&T&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const b=o.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:o,onChange:A=>c(A.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:p,onChange:A=>d(A.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:u,onChange:A=>m(A.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:A=>g(A.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:y,onChange:A=>S(A.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!b,onClick:()=>void $(),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 lt="spotAuditReviews";function $s(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function vt(){try{const s=(await chrome.storage.local.get(lt))[lt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Us(t){await chrome.storage.local.set({[lt]:t})}async function qi(t){const s=await vt();s[t.key]=t,await Us(s)}async function Qi(t){const s=await vt();delete s[t],await Us(s)}async function Ls(){const t=await vt();return Object.values(t)}function Ds(t,s){const a=new Map(s.map(l=>[l.key,l]));let n=0,r=0,i=0;for(const l of t){const o=a.get(l);o&&(n++,o.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function Yi(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 Ji(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const l=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,o=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${l}::${i.selector}`):void 0;n.push({key:$s({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:o})}return n}const Xi={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"},Zi={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 el({verdicts:t,incompleteResolutions:s}){const a=h.useMemo(()=>Ji(t,s),[t,s]),[n,r]=h.useState([]),[i,l]=h.useState(!0),[o,c]=h.useState(null),[p,d]=h.useState(5),[u,m]=h.useState(!1);h.useEffect(()=>{let b=!1;return Ls().then(A=>{b||(r(A),l(!1))}),()=>{b=!0}},[]);const x=h.useMemo(()=>a.map(b=>b.key),[a]),g=h.useMemo(()=>Ds(x,n),[x,n]),S=(u?x:o||n.filter(b=>x.includes(b.key)).map(b=>b.key)).map(b=>a.find(A=>A.key===b)).filter(b=>!!b);async function $(b,A,N){const I={key:b.key,criterionId:b.criterionId,ruleOrStepId:b.ruleOrStepId,pageUrl:b.pageUrl,selector:b.selector,verdict:A,correction:(N==null?void 0:N.trim())||void 0,reviewedAt:new Date().toISOString()};await qi(I),r(O=>[I,...O.filter(v=>v.key!==I.key)])}async function k(b){await Qi(b.key),r(A=>A.filter(N=>N.key!==b.key))}function T(){c(Yi(x,p)),m(!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(Ue,{label:"AI determinations",value:g.total}),e.jsx(Ue,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Ue,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Ue,{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:p,onChange:b=>d(Math.max(1,Math.min(a.length,Number(b.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:T,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:()=>{m(b=>!b),c(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:u?"Hide list":`Show all (${a.length})`}),o&&e.jsx("button",{type:"button",onClick:()=>c(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):S.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:S.map(b=>e.jsx(tl,{row:b,review:n.find(A=>A.key===b.key)??null,onAgree:()=>void $(b,"agreed"),onDisagree:A=>void $(b,"disagreed",A),onClear:()=>void k(b)},b.key))})]})}function Ue({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 tl(t){const{row:s,review:a}=t,[n,r]=h.useState(!1),[i,l]=h.useState((a==null?void 0:a.correction)??""),o=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${o==="agreed"?"border-emerald-300 bg-emerald-50/50":o==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${Xi[s.outcome]}`,children:Zi[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),o&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&o==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:c=>l(c.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),l((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Se(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,l]=h.useState(!1),[o,c]=h.useState(null);h.useEffect(()=>{let u=!1;return ca(t.componentId,t.criterionId).then(m=>{u||(a(m),r(!1))}),()=>{u=!0}},[t.componentId,t.criterionId]);async function p(){l(!0),c(null);try{const m=await J({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});m.ok?m.result&&a(m.result):c(m.error??"Audit failed.")}catch(u){c(u instanceof Error?u.message:String(u))}finally{l(!1)}}async function d(){await da(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&&!o&&e.jsx("button",{type:"button",onClick:()=>void p(),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"}),o&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:o}),e.jsx("button",{type:"button",onClick:()=>void p(),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 u=(s.steps??[]).filter(m=>m.action!=="initial").length;return u===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 (",u," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(m=>m.action!=="initial").map(m=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",m.focused.role||m.focused.tag,"]"]})," ",m.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:m.focused.selector})]},m.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 p(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void d(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function sl(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let n=!1;return le().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(Se,{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(Se,{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(Se,{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(Se,{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(Se,{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 Yt="igtRuns",al={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"},nl={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function rl(){var me,se,Y;const t=f(E=>E.results),s=f(E=>E.acknowledgedKeys),[a,n]=h.useState(""),[r,i]=h.useState(""),l=pa,o=ua,[c,p]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,u]=h.useState(""),[m,x]=h.useState(""),[g,y]=h.useState(""),[S,$]=h.useState(""),[k,T]=h.useState(""),[b,A]=h.useState(""),[N,I]=h.useState({}),[O,v]=h.useState(!1),[L,j]=h.useState([]),[w,D]=h.useState([]),[_,V]=h.useState(null),[ae,ne]=h.useState(!1),[re,R]=h.useState(null);h.useEffect(()=>{let E=!1;return chrome.storage.local.get(Yt).then(B=>{if(E)return;const F=B[Yt]??{};I(F),v(!0)}).catch(()=>{E||v(!0)}),()=>{E=!0}},[]),h.useEffect(()=>{var z;const E=(z=t[0])==null?void 0:z.componentId;if(!E)return;let B=!1;const F=()=>{ts(E).then(K=>{B||D(K.map(ie=>({criterionId:ie.criterionId,ruleId:`ai-interactive::${ie.criterionId}`,pageUrl:ie.pageUrl,verdict:ie.verdict,reasoning:ie.reasoning})))})};F();const P=K=>{K.interactiveAuditResults&&F()};return chrome.storage.local.onChanged.addListener(P),()=>{B=!0,chrome.storage.local.onChanged.removeListener(P)}},[t]),h.useEffect(()=>{var E;if(!a&&((E=t[0])!=null&&E.pageUrl))try{const B=new URL(t[0].pageUrl);n(B.hostname),i(B.origin)}catch{}},[t,a]),h.useEffect(()=>{const E=new Set;for(const F of t)E.add(F.pageUrl??F.scope);if(E.size===0){j([]);return}let B=!1;return Promise.all(Array.from(E).map(F=>De(F))).then(F=>{B||j(F.flat())}).catch(()=>{}),()=>{B=!0}},[t]);const H=h.useMemo(()=>{const E=new Map,B=new Map;for(const P of t){const z=P.pageUrl??P.scope,K=E.get(z)??[];K.push(P),E.set(z,K)}const F=new Map;for(const P of t){const z=P.pageUrl??P.scope;F.set(P.componentId,z)}for(const[P,z]of Object.entries(N)){const K=F.get(P);if(!K)continue;const ie=B.get(K)??{};Object.assign(ie,z),B.set(K,ie)}return{auditsByUrl:E,igtRunsByUrl:B,workflows:ee,acknowledgedMatchKeys:s,incompleteResolutions:L,interactiveAuditResults:w}},[t,N,s,L,w]),X=h.useMemo(()=>{const E=[],B=new Set;for(const F of H.auditsByUrl.keys())B.has(F)||(B.add(F),E.push({url:F,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const F of b.split(`
|
|
543
|
+
`).map(P=>P.trim()).filter(Boolean))B.has(F)||(B.add(F),E.push({url:F,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return E},[H,b]),W=h.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:l,targetLevel:o,accessibilitySupportBaseline:c,additionalStandards:d.split(",").map(E=>E.trim()).filter(Boolean),pageSample:X,evaluator:{name:m||"(evaluator name pending)",organization:g||void 0,qualifications:S||void 0,contact:k||void 0}}),[a,r,l,o,c,d,X,m,g,S,k]),C=h.useMemo(()=>O?Ri(W,H):null,[W,H,O]),M=h.useMemo(()=>{const E=Array.from(H.auditsByUrl.values()).flat(),B=Object.values(N).flatMap(F=>Object.values(F));return pt({audits:E,igtRuns:B,workflows:ee,acknowledgedMatchKeys:s,incompleteResolutions:L,interactiveAuditResults:w})},[H,N,s,L,w]);async function Z(){if(!C)return;const E=t[0],B=E!=null&&E.componentId&&(E!=null&&E.startedAt)?await Ts(E.componentId,E.startedAt):null,F=await Ls(),P=[];for(const K of M.values())for(const ie of K.evidence)ie.source==="ai"&&P.push($s({criterionId:K.criterionId,ruleOrStepId:ie.ruleOrStepId,pageUrl:ie.pageUrl,selector:ie.selector}));const z=Ds(P,F);await $i(C,_,B,z)}async function Q(){if(C){ne(!0),R(null);try{const E=await Mi(C);if(!E){R("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}V(E)}finally{ne(!1)}}}function q(){var ie,yt,wt;if(!C||!_)return;const E=((wt=(yt=(ie=chrome.runtime).getManifest)==null?void 0:yt.call(ie))==null?void 0:wt.version)??"0.0.0",B=Pi(C,_,E),F=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),P=URL.createObjectURL(F),z=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,K=document.createElement("a");K.href=P,K.download=z,K.click(),setTimeout(()=>URL.revokeObjectURL(P),1e3)}return h.useEffect(()=>{V(null),R(null)},[a,r,c,d,m,g,S,k,b]),O?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."})]}),C&&C.summary.totalCriteria>0&&e.jsx(il,{totalCriteria:C.summary.totalCriteria,pass:C.summary.pass,fail:C.summary.fail,inconclusive:C.summary.inconclusive,notEvaluated:C.summary.notEvaluated,notApplicable:C.summary.notApplicable,levelAchieved:C.summary.levelAchieved,meetsTarget:C.summary.meetsTarget,targetVersion:l,targetLevel:o,auditedUrlCount:H.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:E=>n(E.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:E=>i(E.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",l," Level ",o]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:c,onChange:E=>p(E.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:d,onChange:E=>u(E.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.",H.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:H.auditsByUrl.size})," URL",H.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:b,onChange:E=>A(E.target.value),rows:3,placeholder:`https://app.example.com/checkout
|
|
544
|
+
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:m,onChange:E=>x(E.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:E=>y(E.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:E=>$(E.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:k,onChange:E=>T(E.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),C&&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 (",C.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:C.rows.map(E=>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:[E.criterion.id," · ",E.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:E.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${al[E.verdict]}`,children:nl[E.verdict]})]},E.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),_?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[_.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",_.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),re&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:re}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!C||!a||!m||ae,onClick:()=>void Q(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:ae?"Anchoring…":_?"Re-anchor":"Anchor this report"}),_&&e.jsx("button",{type:"button",onClick:q,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"})]})]}),C&&((me=t[0])==null?void 0:me.componentId)&&e.jsx(sl,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),C&&e.jsx(el,{verdicts:M,incompleteResolutions:L}),C&&((se=t[0])==null?void 0:se.componentId)&&((Y=t[0])==null?void 0:Y.startedAt)&&e.jsx(Ki,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:l,targetLevel:o,evaluatedCount:C.summary.pass+C.summary.fail+C.summary.inconclusive+C.summary.notApplicable,totalCount:C.summary.totalCriteria,canClaimConformance:C.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:!C||!a||!m,onClick:()=>void Z(),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:"Generate WCAG-EM report →"})})]}):e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading IGT runs…"})}function il({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:l,meetsTarget:o,targetVersion:c,targetLevel:p,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${o?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${o?"text-emerald-900":"text-amber-900"}`,children:o?`Currently meeting WCAG ${c} Level ${p}`:`Does not currently meet WCAG ${c} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:l??"none"})," · ",t," applicable criteria across ",d," audited URL",d===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const ll={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function ol(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 cl(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+ga[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 dl(){return crypto.randomUUID()}function ul(){const[t,s]=h.useState([]),[a,n]=h.useState(!0),[r,i]=h.useState(""),[l,o]=h.useState("daily"),[c,p]=h.useState(null),[d,u]=h.useState(!1),[m,x]=h.useState(ma),[g,y]=h.useState("idle"),[S,$]=h.useState(!1),[k,T]=h.useState(null);async function b(){n(!0);try{const v=await ns();v.sort((L,j)=>L.enabled!==j.enabled?L.enabled?-1:1:j.createdAt.localeCompare(L.createdAt)),s(v)}finally{n(!1)}}h.useEffect(()=>{b(),(async()=>{const v=await ha();x(v)})()},[]);async function A(v){if(T(null),v.webhookEnabled&&v.webhookUrl.trim().length>0)try{if(new URL(v.webhookUrl).protocol!=="https:"){T("Webhook URL must use https://");return}}catch{T("Webhook URL is not a valid https:// URL.");return}y("saving"),await xa(v),x(v),y("saved"),setTimeout(()=>y("idle"),1500)}async function N(){p(null);const v=r.trim();if(!v){p("URL is required.");return}try{new URL(v)}catch{p("Must be a valid URL (e.g. https://example.com/).");return}u(!0);try{const L={id:dl(),url:v,cadence:l,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await kt(L),await St(L),i(""),o("daily"),await b(),await Ke()}finally{u(!1)}}async function I(v){const L={...v,enabled:!v.enabled};await kt(L),L.enabled?await St(L):await At(v.id),await b(),await Ke()}async function O(v){window.confirm(`Remove the scheduled audit for ${v.url}? Run history for this schedule will also be deleted.`)&&(await At(v.id),await fa(v.id),await ba(v.id),await b(),await Ke())}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:()=>$(v=>!v),"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",m.emailEnabled||m.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:m.emailEnabled,onChange:v=>void A({...m,emailEnabled:v.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:m.webhookEnabled,onChange:v=>void A({...m,webhookEnabled:v.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."})]})]}),m.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:m.webhookUrl,onChange:v=>x({...m,webhookUrl:v.target.value}),onBlur:()=>void A(m),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),k&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:k})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"alert-min-impact",className:"block text-[11px] font-medium mb-1",children:"Minimum impact to alert on"}),e.jsxs("select",{id:"alert-min-impact",value:m.minImpact,onChange:v=>void A({...m,minImpact:v.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:v=>i(v.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:l,onChange:v=>o(v.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),c&&e.jsx("div",{className:"text-rose-700",role:"alert",children:c}),e.jsx("button",{type:"button",onClick:()=>void N(),disabled:d||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:d?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(v=>e.jsx("li",{className:`border rounded p-2.5 ${v.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:v.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[ll[v.cadence]," · last run ",ol(v.lastRunAt)," ·"," ","next ",cl(v)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[v.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",v.lastTotalViolations??0," violation",(v.lastTotalViolations??0)===1?"":"s"]}),v.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:v.lastError??"",children:"✗ failed"}),v.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),v.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"}),(v.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:["⚠ ",v.lastNewViolationCount," new vs baseline"]}),!v.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void I(v),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:v.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void O(v),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},v.id))})]})}const Jt={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function Os(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function pl(t){let s=0,a=0,n=0,r=0,i=0,l=0,o=0,c=0;for(const p of t){if(!p.enabled){a++;continue}s++;const d=Os(p);d==="clean"?n++:d==="new-violations"?r++:d==="failed"?i++:d==="pending"&&l++,o+=p.lastNewViolationCount??0,c+=p.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:l,totalNewViolations:o,totalViolationsAcrossSchedules:c}}function ml(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,i=n.lastNewViolationCount??0;if(r!==i)return i-r;const l=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-l}).slice(0,s).map(a=>({scheduleId:a.id,url:a.url,cadence:a.cadence,lastRunAt:a.lastRunAt??null,lastTotalViolations:a.lastTotalViolations??0,lastNewViolationCount:a.lastNewViolationCount??0,state:Os(a)}))}function hl(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 xl(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),i=[];for(let o=s-1;o>=0;o--){const c=new Date(r.getTime()-o*864e5);i.push({date:c.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const l=new Map(i.map(o=>[o.date,o]));for(const o of t){const c=o.ranAt.slice(0,10),p=l.get(c);p&&(p.runs++,p.totalViolations+=o.totalViolations,p.newViolations+=o.newVsBaselineViolations)}return i}function gl(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=Jt[n.cadence]*6e4;if(n.lastRunAt){const i=s.getTime()-new Date(n.lastRunAt).getTime();if(i>r*2){const l=Math.round(i/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${l}h (expected every ${Jt[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 Xt(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 _s(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function fl({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(o=>o.totalViolations)),r=a/Math.max(1,t.length-1),i=t.map((o,c)=>{const p=c*r,d=s-o.totalViolations/n*(s-4)-2;return`${p.toFixed(1)},${d.toFixed(1)}`}),l=t.map((o,c)=>{const p=c*r,d=s-o.newViolations/n*(s-4)-2;return`${p.toFixed(1)},${d.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:l.join(" ")})]})}function Le({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 bl({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:_s(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function vl(){const[t,s]=h.useState([]),[a,n]=h.useState([]),[r,i]=h.useState(!0);h.useEffect(()=>{(async()=>{i(!0);try{const[u,m]=await Promise.all([ns(),va()]);s(u),n(m)}finally{i(!1)}})()},[]);const l=pl(t),o=ml(t,5),c=hl(t,a,10),p=xl(a,30),d=gl(t);return r?e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading dashboard…"}):t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Nothing to summarize yet. Add a scheduled audit from the Schedules tab to start collecting cross-page compliance posture here."})]}):e.jsxs("div",{className:"p-3 space-y-4 text-xs","data-testid":"risk-view-root",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Aggregate posture across every scheduled audit. Read-only — schedules themselves are managed in the Schedules tab."})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 space-y-2 bg-white",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:["Posture · ",l.enabledSchedules," enabled",l.pausedSchedules>0?` · ${l.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Le,{state:"clean",count:l.cleanCount}),e.jsx(Le,{state:"new-violations",count:l.newViolationsCount}),e.jsx(Le,{state:"failed",count:l.failedCount}),e.jsx(Le,{state:"pending",count:l.pendingCount})]}),l.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[l.totalNewViolations," new WCAG violation",l.totalNewViolations===1?"":"s"," vs baseline across all schedules."]})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-trend-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"30-day trend"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fl,{buckets:p}),e.jsxs("div",{className:"text-[10px] text-slate-500 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-slate-400 mr-1"})," total violations"]}),e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-rose-600 mr-1"})," new vs baseline"]}),e.jsxs("div",{className:"pt-1 text-slate-400",children:["Sum across ",l.enabledSchedules," schedule",l.enabledSchedules===1?"":"s"]})]})]})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",d.length]}),e.jsx("ul",{className:"space-y-1.5",children:d.map((u,m)=>e.jsx(bl,{item:u},`${u.kind}-${u.scheduleId}-${m}`))})]}),o.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-top-exposed-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Most exposed pages"}),e.jsx("ul",{className:"space-y-1.5",children:o.map(u=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-mono text-[11px] break-all",children:u.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[u.lastTotalViolations," total · ",u.cadence," ·"," ","last run ",u.lastRunAt?Xt(u.lastRunAt):"never"]})]}),u.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",u.lastNewViolationCount," new"]})]},u.scheduleId))})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:c.map((u,m)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:Xt(u.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:_s(u.scheduleUrl)}),u.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:u.error,children:"failed"}):u.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",u.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${u.scheduleId}-${u.ranAt}-${m}`))})]})]})}function yl(){const[t,s]=h.useState(""),[a,n]=h.useState(!1),[r,i]=h.useState(null);async function l(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const o=await J({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(o!=null&&o.validated)){const c=o!=null&&o.seatClaim&&"reason"in o.seatClaim?o.seatClaim.reason:null,p=o!=null&&o.seatClaim&&"hint"in o.seatClaim?o.seatClaim.hint:void 0;i(c==="cap-reached"?`License is at seat capacity. ${p??"Release a seat from another device or contact support."}`:c==="not-found"?"License not found. Check the token and try again.":c==="network"?`Network error: ${o!=null&&o.seatClaim&&"message"in o.seatClaim?o.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(o){i(o instanceof Error?o.message:String(o))}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:o=>s(o.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function Il(){const t=f(l=>l.view),s=f(l=>l.userMode),a=f(l=>l.tier),[n,r]=h.useState(!1);h.useEffect(()=>{const l=setTimeout(()=>r(!0),600);return()=>clearTimeout(l)},[]);const i=n&&ja(a);return h.useEffect(()=>{const l=$a(),c=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),p=Ca();cs({forceRefresh:!0}).catch(()=>{}),Me().catch(()=>{}),Ta().catch(()=>{}),Ua().catch(()=>{}),Ra().catch(()=>{}),ya().then(u=>{f.getState().setAcknowledgedKeys(new Set(u.map(m=>m.matchKey)))}).catch(()=>{}),wa().then(u=>{u&&f.setState({siteCrawlReport:u})}).catch(()=>{});const d=u=>{if(u.key!=="Escape")return;const{pinnedMatchKey:m,setPinned:x,results:g}=f.getState();m&&(x(null),le().then(y=>{var S;y&&pe(y,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:y},(S=g[0])==null?void 0:S.frameId).catch(()=>{})}))};return window.addEventListener("keydown",d),()=>{p(),l.disconnect(),c==null||c.disconnect(),window.removeEventListener("keydown",d)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(yl,{}),e.jsx(Ee,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Wr,{}),e.jsx(Ee,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(pi,{}),e.jsx(Bt,{}),e.jsx(Ee,{})]}):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(Is,{}),e.jsx(gs,{}),e.jsx(Ka,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Ja,{}),e.jsx(sn,{}),e.jsx(Mr,{}),e.jsx(Fr,{}),e.jsx(nn,{}),e.jsx(Or,{}),e.jsx(_r,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(yn,{}),t==="report"&&e.jsx(_n,{}),t==="delta"&&e.jsx(Jn,{}),t==="activity"&&e.jsx(cr,{}),t==="guided"&&e.jsx(wr,{}),t==="flows"&&e.jsx(Sr,{}),t==="scorecard"&&e.jsx(Ir,{}),t==="crawl"&&e.jsx(Ss,{}),t==="forensic"&&e.jsx(Cs,{}),t==="compliance"&&e.jsx(rl,{}),t==="schedules"&&e.jsx(ul,{}),t==="risk"&&e.jsx(vl,{})]})]}),e.jsx(Gr,{}),e.jsx(Pr,{}),e.jsx(Dr,{}),e.jsx(Bt,{}),e.jsx(Ee,{})]})}class Rl extends Ae.Component{constructor(){super(...arguments);jt(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{Il as A,Rl as E,Cl as d};
|