@wcag-checkr/ci 1.0.0-rc.255 → 1.0.0-rc.256

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,28 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-V0TlccxL.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/ai-usage-log-C-jq4cW3.js","assets/copy-ai-fixer-prompt-BCdNHN79.js","assets/site-report-renderer-uSajBWRd.js"])))=>i.map(i=>d[i]);
2
- var Pa=Object.defineProperty;var Ga=(t,s,a)=>s in t?Pa(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var ns=(t,s,a)=>Ga(t,typeof s!="symbol"?s+"":s,a);import{R as Be,i as he,r as h,j as e,M as De,C as Tt,A as Ze}from"./styles-UZY6vFOS.js";import{s as Ys,i as Gt,g as Va,a as ce,d as Vt,l as _e,b as He,c as Je,e as Js,f as Wa,h as Wt,A as xe,j as Ba,k as Ha,u as Ka,m as za,n as qa,o as Qa,p as Ya,q as Ja,N as Xa,r as $t,t as Xs,v as Lt,w as Za,O as en,x as Ut,y as ot,z as tn,B as sn,C as rs,D as an,E as nn,F as rn,G as on,H as ln,I as cn,J as dn,K as un,L as pn,M as mn,T as hn,P as xn,Q as gn,R as fn,S as Zs,U as bn,V as is,W as os,X as vt,Y as vn,Z as ls,_ as yn,$ as wn,a0 as jn,a1 as Nn,a2 as kn}from"./scheduled-audit-runner-V0TlccxL.js";import{_ as ke}from"./diff-DA41zYPc.js";import{o as ye,r as J,s as de,c as ea,b as be,d as Ie}from"./crash-reporter-Dc5lvxvY.js";import{g as ta,j as pt,k as mt,t as Xe,m as Sn,B as yt,i as Bt,n as An,o as $e,T as sa,p as aa,q as ht,u as Cn}from"./ai-usage-log-C-jq4cW3.js";import{s as In,t as En}from"./design-system-audit-DpxJrxnb.js";const cs=t=>{let s;const a=new Set,n=(u,c)=>{const p=typeof u=="function"?u(s):u;if(!Object.is(p,s)){const m=s;s=c??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(x=>x(s,m))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:u=>(a.add(u),()=>a.delete(u))},d=s=t(n,r,l);return l},Rn=t=>t?cs(t):cs,Tn=t=>t;function $n(t,s=Tn){const a=Be.useSyncExternalStore(t.subscribe,Be.useCallback(()=>s(t.getState()),[t,s]),Be.useCallback(()=>s(t.getInitialState()),[t,s]));return Be.useDebugValue(a),a}const ds=t=>{const s=Rn(t),a=n=>$n(s,n);return Object.assign(a,s),a},Ln=t=>t?ds(t):ds,v=Ln(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",findingsLens:"overview",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,crawlNavContext:null,resolutionsByUrl:{},pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,pendingAreaExpand:null,auditStartedAtMs:null,lastAuditWallClockMs:null,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,auditStartedAtMs:Date.now(),crawlNavContext:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t(r=>{const i=r.auditStartedAtMs?Date.now()-r.auditStartedAtMs:null;return{results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0,lastAuditWallClockMs:i,auditStartedAtMs:null}}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setFindingsLens:s=>t({findingsLens:s}),setPendingAreaExpand:s=>t({pendingAreaExpand:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setCrawlNavContext:s=>t({crawlNavContext:s}),setResolutionsForUrl:(s,a)=>t(n=>({resolutionsByUrl:{...n.resolutionsByUrl,[s]:a}})),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Ys(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),dismissedKeys:new Set,setDismissedKeys:s=>t({dismissedKeys:s}),markDismissed:s=>t(a=>({dismissedKeys:new Set(a.dismissedKeys).add(s)})),markUndismissed:s=>t(a=>{const n=new Set(a.dismissedKeys);return n.delete(s),{dismissedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),lt="sidePanel:lastAudit";function Un(){const t=[];return t.push(ye("AUDIT_PROGRESS_EVENT",s=>{const a=v.getState().status==="running";v.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),v.getState().setStatus("running"),a||he.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(ye("AUDIT_COMPLETE_EVENT",s=>{var l;v.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((d,u)=>d+u.violations.length,0),n=((l=s.delta)==null?void 0:l.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;he.polite(r);const i=v.getState().view;["compliance","guided","crawl"].includes(i)||(v.getState().setView("report"),v.getState().setFindingsLens("overview")),Dn({results:s.results,delta:s.delta,componentId:s.componentId}),_n(s.results,s.delta,s.componentId)})),t.push(ye("AUDIT_FAILED_EVENT",s=>{v.getState().setError(s.error.message)})),t.push(ye("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=v.getState().aiProgress;v.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||he.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(ye("AI_AUGMENTATION_FAILED_EVENT",s=>{v.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(ye("SCORECARD_UPDATED_EVENT",()=>{ct()})),t.push(ye("LICENSE_CHANGED_EVENT",()=>{na()})),t.push(ye("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&he.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(ye("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),he.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`),(async()=>{try{const{loadSiteCrawlPerUrlResults:n}=await ke(async()=>{const{loadSiteCrawlPerUrlResults:l}=await import("./scheduled-audit-runner-V0TlccxL.js").then(d=>d.aC);return{loadSiteCrawlPerUrlResults:l}},__vite__mapDeps([0,1,2,3])),{getResolutionsForPage:r}=await ke(async()=>{const{getResolutionsForPage:l}=await import("./scheduled-audit-runner-V0TlccxL.js").then(d=>d.aE);return{getResolutionsForPage:l}},__vite__mapDeps([0,1,2,3])),i=await n();if(!i||i.length===0)return;const o=v.getState().setResolutionsForUrl;await Promise.all(i.map(async l=>{try{const d=await r(l.url);o(l.url,d)}catch{}}))}catch(n){console.warn("[site-crawl] failed to pre-warm resolutions cache",n)}})()})),t.push(ye("SITE_CRAWL_FAILED_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),he.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function _n(t,s,a){var n,r;if(t.length!==0)try{const i=await ta();if(!i.enabled)return;const o=v.getState().tier;if(Gt(o)||!pt(o,"autoExportAuditReports"))return;const l=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",d=[],u=v.getState().lastAuditWallClockMs??void 0;for(const c of i.formats)try{const p=await J({type:"EXPORT_REQUEST",format:c,results:t,delta:s??void 0,wallClockMs:u});if(typeof p.content!="string"||p.content.length<200)continue;const m=mt(c,a??null);Xe(p.content,m),l&&await Sn({url:l,exportedAt:new Date().toISOString(),format:c,filename:m}),d.push(m)}catch(p){console.warn(`[auto-export] format ${c} failed:`,p)}d.length>0&&he.polite(`Audit auto-exported ${d.length} file${d.length===1?"":"s"}.`)}catch(i){console.warn("[auto-export] failed:",i)}}async function Dn(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[lt]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function On(){const s=(await chrome.storage.local.get(lt))[lt];s&&v.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Fn(){await chrome.storage.local.remove(lt)}async function xt(){v.getState().clearResults(),await Fn()}async function ct(){const t=await J({type:"BASELINE_LIST"});v.getState().setBaselineList(t.items)}async function na(t){const s=await J({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});v.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ra()}async function ra(){const{fetchMessages:t}=await ke(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>zn);return{fetchMessages:n}},void 0),s=v.getState().userMode,a=await t(s);a&&v.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Mn(){const s=(await J({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;v.getState().setUserMode(a)}function Pn(){return chrome.runtime.connect({name:"audit-keepalive"})}let dt=null;async function Gn(){if(dt===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(dt=t.id)}catch{}}function ia(){if(dt===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:dt}).catch(()=>{})}function Ne(t){ia(),v.getState().setSiteCrawlReport(null),Ys(null).catch(()=>{}),de(t)}const _t="dismissedFindings";function gt(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ze(t){return`reading-order::${t}`}function qe(t){return`tab-order::${t}`}function Ht(t){return`violation::${t}`}async function ft(){try{const t=await chrome.storage.local.get(_t),s=t==null?void 0:t[_t];if(s&&typeof s=="object")return s}catch{}return{}}async function Kt(t){await chrome.storage.local.set({[_t]:t})}async function zt(t){return(await ft())[gt(t)]??{}}async function qt(t,s,a,n){const r=await ft(),i=gt(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await Kt(r)}async function Qe(t,s){if(s.length===0)return;const a=await ft(),n=gt(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await Kt(a)}async function Qt(t,s){const a=await ft(),n=gt(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await Kt(a))}const _c=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:qt,addDismissals:Qe,dismissalKeyForReadingOrder:ze,dismissalKeyForTabOrder:qe,dismissalKeyForViolation:Ht,getDismissalsForUrl:zt,removeDismissal:Qt},Symbol.toStringTag,{value:"Module"}));function Vn({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,o]=h.useState(!0),[l,d]=h.useState(""),[u,c]=h.useState(!1),[p,m]=h.useState(null);async function x(f){var w;if(f.preventDefault(),!(!s.trim()||!n.trim())){c(!0),m(null);try{const A=await J({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});A.success?(m({ok:!0,msg:`Sent (ref: ${A.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((w=A.error)==null?void 0:w.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:x,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:f=>a(f.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:f=>r(f.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:f=>d(f.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:f=>o(f.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),p&&e.jsx("p",{id:"support-form-result",role:p.ok?"status":"alert",className:`text-xs ${p.ok?"text-green-700":"text-red-700"}`,children:p.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:u,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:u?"Sending…":"Send"})]})]})}function us({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 ut=ea("messages-client"),Wn="https://api.wcagcheckr.com",oa="wcagcheckr",Bn=1e4;function Hn(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function la(t,s){const a=await Va();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Hn()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Wn}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Bn)})}async function Kn(t){try{const s=await la(`/v1/products/${oa}/messages`,{userMode:t??null});return s.ok?await s.json():(ut.warn("fetchMessages http",s.status),null)}catch(s){return ut.warn("fetchMessages failed",s),null}}async function Ue(t,s){try{const a=await la(`/v1/products/${oa}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(ut.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return ut.warn("ackMessage failed",a),!1}}const zn=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Ue,fetchMessages:Kn},Symbol.toStringTag,{value:"Module"})),qn=["http:","https:"];function Qn(t){try{const s=new URL(t);return qn.includes(s.protocol)}catch{return!1}}function ps(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),d=t.slice(i+2,o);Qn(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function ca({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:ps(d)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,u)=>e.jsx("li",{children:ps(d)},u))},`u-${i++}`)),n=[])}for(const d of s){const u=d.trimEnd();if(u===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(u);if(c){o(),n.push(c[1]);continue}l(),r.push(u)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const Yn={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Jn={critical:"bg-rose-50 border-rose-200"};function da(){const t=v(m=>m.unreadMessageCount),s=v(m=>m.messages),a=v(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[o,l]=h.useState(!1);h.useEffect(()=>{const m=s.filter(f=>!f.seen);if(m.length===0)return;const x=Math.max(...m.map(f=>f.id));if(x>i.current){i.current=x,l(!0);const f=setTimeout(()=>l(!1),1500);return()=>clearTimeout(f)}},[s]);async function d(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),Ue(x.id,"seen")}function u(){const m=!n;r(m),m&&d()}async function c(m){a(m.id,"dismissed"),await Ue(m.id,"dismissed")}async function p(m){m.ctaUrl&&(a(m.id,"clicked"),Ue(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:u,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Xn,{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(Zn,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:p})]})}function Xn({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 Zn({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=h.useRef(null);return h.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{ra()},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 ${Yn[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(ca,{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 ua(){const t=v(i=>i.messages),s=v(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await Ue(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),Ue(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Jn.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(ca,{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 er=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function tr(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function sr(){var p,m;const t=v(x=>x.view),s=v(x=>x.setView),a=v(x=>x.setUserMode),n=v(x=>x.results),r=v(x=>x.status),[i,o]=h.useState(!1),l=((p=n[0])==null?void 0:p.pageUrl)??((m=n[0])==null?void 0:m.scope),d=tr(l),u=n.length>0&&r!=="running";function c(){a("owner"),de({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(da,{}),e.jsx(us,{onClick:()=>void de({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(us,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),u&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void xt(),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(ar,{view:t,setView:s}),e.jsx(De,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Vn,{onClose:()=>o(!1)})})]})}function ar({view:t,setView:s}){const a=h.useRef([]),n=v(l=>l.results),r=er.filter(l=>!l.hideWhenIdle||n.length>0);function i(l){var c;const d=(l+r.length)%r.length,u=r[d];u&&(s(u.slug),(c=a.current[d])==null||c.focus())}function o(l,d){switch(l.key){case"ArrowRight":l.preventDefault(),i(d+1);break;case"ArrowLeft":l.preventDefault(),i(d-1);break;case"Home":l.preventDefault(),i(0);break;case"End":l.preventDefault(),i(r.length-1);break}}return e.jsx("nav",{className:"flex gap-1","aria-label":"Primary navigation",role:"tablist",children:r.map((l,d)=>{const u=t===l.slug;return e.jsx("button",{ref:c=>{a.current[d]=c},role:"tab","aria-selected":u,tabIndex:u?0:-1,onClick:()=>s(l.slug),onKeyDown:c=>o(c,d),className:u?"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md bg-slate-900 text-white shadow-sm":"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md text-slate-600 hover:bg-slate-100 border border-transparent hover:border-slate-200",children:l.label},l.slug)})})}function nr({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(Tt,{open:a,onClose:()=>n(!1)})]})}const rr="https://wcagcheckr.com/upgrade";function ir(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState(null),[d,u]=h.useState(yt),[c,p]=h.useState(yt[0].id),[m,x]=h.useState("none"),[f,w]=h.useState(null),A=v(k=>k.status),$=v(k=>k.tier),T=v(k=>k.results.length>0),j=A==="running";h.useEffect(()=>{Promise.all([J({type:"SETTINGS_GET",key:"matrixPresets"}),J({type:"SETTINGS_GET",key:"activePresetId"})]).then(([k,O])=>{const M=Array.isArray(k.data)?k.data:null;u(M&&M.length>0?M:yt),typeof O.data=="string"&&p(O.data)})},[]);function b(k){const O=d.find(M=>M.id===k);O&&(p(k),de({type:"SETTINGS_SET",key:"activePresetId",value:k}),de({type:"SETTINGS_SET",key:"stateMatrix",value:O.matrix}))}const I=pt($,"storybookAutoIterate");h.useEffect(()=>{const k=ye("ELEMENT_PICKED_EVENT",(M,ee)=>{n(!1);const E=ee.frameId;L(E),i({selector:M.selector,frameId:E,speech:M.speech})}),O=ye("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{k(),O()}},[]);async function g(){const k=await ce();k&&(n(!0),await be(k,{type:"PICKER_ACTIVATE_REQUEST",tabId:k}))}function y(){r&&(L(r.frameId),Ne({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),v.getState().startNewScan())}function C(){if(!I){l("storybook:auto-iterate");return}L(),Ne({type:"START_AUDIT",mode:"storybook-all"}),v.getState().startNewScan()}function S(){L(),Ne({type:"START_AUDIT",mode:"all-frames"}),v.getState().startNewScan()}function R(){L(),Ne({type:"START_AUDIT",mode:"full-page"}),v.getState().startNewScan()}function K(){L(),Ne({type:"START_AUDIT",mode:"quick-scan"}),v.getState().startNewScan()}function V(){L(),Ne({type:"START_AUDIT",mode:"parallel-scan"}),v.getState().startNewScan()}function W(){de({type:"CANCEL_AUDIT"})}async function L(k){v.getState().setPinned(null);const O=await ce();if(O)try{await be(O,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:O},k)}catch{}}async function U(k){w(null);const O=await ce();if(!O){w("No audited tab; open a page first.");return}if(k==="none"){const ee=await J({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:O});ee.ok||w(ee.error??"Failed to clear throttle."),x("none");return}const M=await J({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:O,profile:k});if(!M.ok){w(M.error??"Failed to apply throttle.");return}x(k)}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:k=>s(k.target.value),disabled:j||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)",I?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:k=>b(k.target.value),disabled:j||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(k=>e.jsx("option",{value:k.id,children:k.name},k.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:m,onChange:k=>void U(k.target.value),disabled:j||a,title:"Apply CDP network + CPU throttling to the audited tab. Catch contrast / focus / loading-state issues that only manifest under realistic conditions.",className:`text-xs border rounded px-2 py-1 ${m==="none"?"border-slate-300":"border-amber-400 bg-amber-50"}`,children:[e.jsx("option",{value:"none",children:"⚡ Throttle: off"}),e.jsx("option",{value:"3g-slow",children:"⚡ Slow 3G + 6× CPU"}),e.jsx("option",{value:"3g-fast",children:"⚡ Fast 3G + 4× CPU"}),e.jsx("option",{value:"4g",children:"⚡ 4G LTE + 2× CPU"}),e.jsx("option",{value:"cpu-2x",children:"⚡ CPU 2× only"}),e.jsx("option",{value:"cpu-4x",children:"⚡ CPU 4× only"})]}),t==="single-element"?e.jsx(lr,{picking:a,picked:r,isRunning:j,onPick:g,onRun:y,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:R,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:K,disabled:j,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:j?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:V,disabled:j,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:j?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:S,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:C,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all stories"}),j&&e.jsx("button",{onClick:W,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!j&&T&&e.jsx("button",{type:"button",onClick:()=>void xt(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),f&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",f]}),t==="single-element"&&r&&!a&&!j&&e.jsx(cr,{selector:r.selector,onRepick:g,onClear:()=>i(null)})]}),e.jsx(De,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(nr,{feature:o??"",upgradeUrl:rr})})]})}function or({speech:t}){if(!t)return null;const s=[];if(t.name&&s.push(t.name),t.role&&!["none","presentation","generic"].includes(t.role)&&s.push(t.role),s.push(...t.states),t.group&&s.push(t.group),s.length===0)return e.jsxs("span",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-0.5",title:"A screen reader would announce nothing for this element. Either it has no accessible name + a silent role (generic/presentation), or it's hidden from AT entirely.","data-testid":"sr-speech-preview",children:["SR: ",e.jsx("em",{children:"(silent)"})]});const a=s.join(", ");return e.jsxs("span",{className:"text-[10px] text-slate-700 bg-slate-100 border border-slate-200 rounded px-2 py-0.5 max-w-[280px] truncate",title:`Predicted screen-reader announcement when this element receives focus: "${a}"`,"data-testid":"sr-speech-preview",children:["SR: ",e.jsx("strong",{children:a})]})}function lr({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}),e.jsx(or,{speech:s.speech})]}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function cr({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 dr={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},ur={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function pr(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState("off"),u=v(x=>x.results).flatMap(x=>x.violations);async function c(x){const f=await ce();f&&(l(x),x==="off"?await be(f,{type:"VISION_SIMULATOR_CLEAR",tabId:f}).catch(()=>{}):await be(f,{type:"VISION_SIMULATOR_APPLY",tabId:f,mode:x}).catch(()=>{}))}async function p(x){const f=await ce();if(f){if(t&&await be(f,{type:dr[t],tabId:f}).catch(()=>{}),t===x){s(null);return}await be(f,{type:ur[x],tabId:f}).catch(()=>{}),s(x)}}async function m(){const x=await ce();if(x){if(a){await be(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(u.length===0){i("Run an audit first.");return}try{const f=await Ie(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:u});n(!0),i(`Previewing ${f.visualFixCount} visual fix${f.visualFixCount===1?"":"es"} + ${f.annotationCount} annotation${f.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(Fe,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(Fe,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>p("tab-order")}),e.jsx(Fe,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>p("reading-order")}),e.jsx(Fe,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(Fe,{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:o,onChange:x=>void c(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function Fe({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 mr(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 hr(){const t=v(d=>d.status),s=v(d=>d.progress),a=v(d=>d.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":mr(s.currentState),o=n?100:s.current/s.total*100,l=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(ms,{label:r,detail:i,pct:o,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),l&&e.jsx(ms,{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 ms({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}const Te=[{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 xr(t,s){const a=new Set;for(const n of s)n.wcagCriterion===t&&a.add(n.ruleId);if(a.size===0)return null;for(const n of Te)for(const r of n.axeRules)if(a.has(r))return n.id;return null}function Yt(t){const s=Te.map(r=>fr(r,t)),a=gr(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 gr(t){const s=t.filter(o=>o==="A").length,a=t.filter(o=>o==="C").length,n=t.filter(o=>o==="D").length,r=t.filter(o=>o==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function fr(t,s){const a=new Set(t.axeRules),n=s.violations.filter(U=>a.has(U.ruleId)),r=s.manualRuns.filter(U=>t.igtWorkflowIds.includes(U.workflowId)),i=t.igtWorkflowIds.map(U=>s.workflows.find(k=>k.id===U)).filter(U=>U!=null);let o=i.length>0;for(const U of i){const k=r.find(M=>M.workflowId===U.id);if((k?Object.keys(k.steps).length:0)!==U.steps.length){o=!1;break}}const l=r.some(U=>Object.keys(U.steps).length>0),d=t.verifiedByWorkflowIds??[],u=s.manualRuns.filter(U=>d.includes(U.workflowId)),c=d.map(U=>s.workflows.find(k=>k.id===U)).filter(U=>U!=null);let p=d.length>0&&c.length===d.length;for(const U of c){const k=u.find(M=>M.workflowId===U.id);if((k?Object.keys(k.steps).length:0)!==U.steps.length){p=!1;break}}let m=null;if(p)for(const U of u)U.completedAt&&(m===null||U.completedAt>m)&&(m=U.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,f=d[0]??t.igtWorkflowIds[0]??null,w=s.interactiveAuditVerdicts,A=[];w&&(t.id==="tab-order"&&w.focusOrder&&A.push({verdict:w.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(w.keyboardTrap&&A.push({verdict:w.keyboardTrap,criterionId:"2.1.2"}),w.focusVisible&&A.push({verdict:w.focusVisible,criterionId:"2.4.7"})),t.id==="reading-order"&&w.readingOrder&&A.push({verdict:w.readingOrder,criterionId:"1.3.2"}),t.id==="contrast"&&w.nonTextContrast&&A.push({verdict:w.nonTextContrast,criterionId:"1.4.11"}));const $=A.some(U=>U.verdict==="fail");if(A.length>0&&A.every(U=>U.verdict==="pass")&&d.length>0&&!p)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:A.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:f,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:A.map(U=>U.criterionId)};if(p&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:m,suppressedHeuristicCount:x,primaryVerifierWorkflowId:f,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j=t.axeRules.length>0||t.heuristic!=null,b=t.igtWorkflowIds.length>0;if(j?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:b||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:f,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const g={critical:0,serious:0,moderate:0,minor:0},y=Vt(n);for(const U of y)g[U.impact]++;const C=(s.aiResolvedFails??[]).filter(U=>a.has(U.ruleId));if(C.length>0){const U=new Set(y.map(k=>`${k.ruleId}::${k.target.selector}`));for(const k of C){const O=`${k.ruleId}::${k.selector}`;U.has(O)||(U.add(O),g[k.impact]++)}}const S=A.length>0&&A.some(U=>U.verdict==="pass"||U.verdict==="fail"),R=S?x:0;S||(g.serious+=x),$&&(g.serious+=A.filter(U=>U.verdict==="fail").length);for(const U of r){const k=i.find(O=>O.id===U.workflowId);if(k)for(const O of k.steps){const M=U.steps[O.id];(M==null?void 0:M.status)==="fail"&&(O.severity==="required"?g.serious++:g.moderate++)}}const K=g.critical>0,V=g.serious>0;let W;g.critical>=5?W="F":g.critical>=1?W="D":g.serious>=1?W="C":g.moderate>=1?W="B":W="A";const L=W!=="A"&&(b&&!o||d.length>0&&!p);return{id:t.id,label:t.label,letter:W,untested:!1,needsIgt:L,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:R,primaryVerifierWorkflowId:f,counts:g,caps:{cappedAtC:K,cappedAtB:V}}}function br(){const t=new Set;for(const s of Te)for(const a of s.axeRules)t.add(a);return t}function pa(t,s,a,n){const r=new Set;for(const i of t)a.has(i.matchKey)||n.has(`violation::${i.matchKey}`)||r.add(`${i.ruleId}::${i.target.selector}`);for(const i of s)i.verdict==="fail"&&r.add(`${i.ruleId}::${i.selector}`);return r.size}function vr(t,s,a,n){const r=new Set;for(const i of t)a.has(i.matchKey)||n.has(`violation::${i.matchKey}`)||i.wcagCriterion&&r.add(i.wcagCriterion);for(const i of s)i.verdict==="fail"&&i.wcagCriterion&&r.add(i.wcagCriterion);return Array.from(r).sort()}function yr(t,s,a={}){const n=br(),i=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),o=Vt(i),l={critical:0,serious:0,moderate:0,minor:0};for(const c of o)l[c.impact]++;const d=new Set(o.map(c=>_e(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const p=_e(c.ruleId,c.selector);d.has(p)||(d.add(p),l.serious++)}return{total:l.critical+l.serious+l.moderate+l.minor,counts:l,representatives:o}}function hs(t,s){var n;const a=new Set;for(const r of s)for(const i of((n=r.axeRulesEvaluated)==null?void 0:n.incomplete)??[])for(const o of i.elements??[])a.add(`${i.ruleId}::${o.selector}`);return t.filter(r=>r.verdict==="fail"&&a.has(`${r.ruleId}::${r.selector}`))}function Jt(t){var i,o;const s=((i=t[0])==null?void 0:i.pageUrl)??((o=t[0])==null?void 0:o.scope)??"",a=v(l=>l.setResolutionsForUrl),[n,r]=h.useState(()=>{if(!s)return[];const l=v.getState().resolutionsByUrl[s];return l?hs(l,t):[]});return h.useEffect(()=>{if(!s){r([]);return}let l=!1;return He(s).then(d=>{l||(a(s,d),r(hs(d,t)))}),()=>{l=!0}},[s,t,a]),n}const wr=[{slug:"delta",label:"Delta",blurb:"Compare against the last baseline; export the prompt",marker:"Δ"},{slug:"guided",label:"Guided",blurb:"Step through manual IGT workflows",marker:"G"},{slug:"compliance",label:"Compliance",blurb:"WCAG-EM report builder + sign-and-seal",marker:"§"},{slug:"scorecard",label:"Components",blurb:"Every tracked component baseline at a glance",marker:"◍"},{slug:"forensic",label:"Forensic",blurb:"Audit history + RFC 3161 timestamps",marker:"⧉"},{slug:"schedules",label:"Schedules",blurb:"Recurring audits + alerts",marker:"⟳"},{slug:"risk",label:"Risk",blurb:"Posture summary across scheduled audits",marker:"⌖"},{slug:"crawl",label:"Site crawl",blurb:"Audit a multi-page site",marker:"↺"},{slug:"flows",label:"Flows",blurb:"Record + replay user-action sequences",marker:"▷"},{slug:"copilot",label:"Co-pilot",blurb:"Chat with AI grounded on the current audit",marker:"✦"},{slug:"ax-tree",label:"AX tree",blurb:"Browser's accessibility-tree viewer",marker:"⌥"},{slug:"tokens",label:"Design tokens",blurb:"CSS custom-properties usage map",marker:"#"}];function jr(){const t=v(n=>n.results),s=v(n=>n.status),a=v(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(Nr,{results:t,status:s,setView:a}),e.jsx(kr,{setView:a})]})}function Nr({results:t,status:s,setView:a}){var x,f;if(s==="running")return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"audit in progress"}),e.jsxs("p",{className:"text-sm font-medium text-slate-900 mt-1",children:["The matrix is iterating. Progress is shown above; results land in ",e.jsx("strong",{children:"Findings"})," when done."]})]});if(t.length===0)return e.jsxs("section",{className:"border border-dashed border-slate-300 rounded-lg bg-slate-50 px-4 py-5 text-center",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"no audit yet"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-1",children:"Pick an audit mode above and run a scan."}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 max-w-md mx-auto",children:"Or jump into a specialized tool below — site crawl, multi-page schedules, IGT workflows, the AI co-pilot, the forensic log."})]});const n=t.flatMap(w=>w.violations),r=Vt(n),i=((x=t[0])==null?void 0:x.pageUrl)??((f=t[0])==null?void 0:f.scope)??"audited page",o=t.length,l=Jt(t),d=v(w=>w.acknowledgedKeys),u=v(w=>w.dismissedKeys),c=pa(n,l,d,u),p=3,m=c>0&&c<=p?r.slice(0,p):[];return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 truncate",children:["last audit · ",o," state",o===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate mt-0.5",title:i,children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`})]}),e.jsx("button",{type:"button",onClick:()=>a("report"),className:"shrink-0 text-xs font-medium px-3.5 py-1.5 bg-slate-900 text-white rounded-md hover:bg-slate-800",children:"View findings →"})]}),m.length>0&&e.jsx("ul",{className:"border-t border-slate-200 divide-y divide-slate-100","aria-label":"Violations inline list",children:m.map(w=>{var T;const A=((T=w.target)==null?void 0:T.selector)??"(no selector)",$=A.length>50?A.slice(0,47)+"…":A;return e.jsx("li",{className:"px-3.5 py-2",children:e.jsxs("button",{type:"button",onClick:()=>a("report"),className:"w-full text-left flex items-center gap-2 hover:bg-slate-50 -mx-3.5 -my-2 px-3.5 py-2 transition-colors",title:`${w.description??w.ruleId} — ${A}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${w.impact==="critical"?"bg-rose-200 text-rose-900":w.impact==="serious"?"bg-orange-200 text-orange-900":w.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:w.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:w.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:$})]})},`${w.ruleId}::${A}`)})})]})}function kr({setView:t}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:wr.map(s=>e.jsxs("button",{type:"button",onClick:()=>t(s.slug),className:"text-left rounded-lg border border-slate-200 bg-white hover:bg-slate-50 hover:border-slate-300 transition-colors px-3 py-2.5 flex flex-col gap-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1",children:[e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-slate-400",children:[e.jsx("span",{className:"text-slate-700 mr-1.5",children:s.marker}),s.slug]}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 leading-tight mt-0.5",children:s.label}),e.jsx("span",{className:"text-[11px] text-slate-500 leading-snug",children:s.blurb})]},s.slug))})]})}const Sr={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Ar={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 Cr({violations:t,componentId:s,hideOverallHeader:a=!1}){var ue,_,Y,q,Q,pe,le,me;const[n,r]=h.useState([]),[i,o]=h.useState({}),[l,d]=h.useState([]),[u,c]=h.useState([]),[p,m]=h.useState(new Set),[x,f]=h.useState(null),[w,A]=h.useState({}),[$,T]=h.useState(new Set),[j,b]=h.useState(null),I=v(F=>F.status),g=v(F=>F.progress),y=v(F=>F.freshThisSession),C=v(F=>F.results),S=(ue=C[0])==null?void 0:ue.startedAt,R=((_=C[0])==null?void 0:_.pageUrl)??((Y=C[0])==null?void 0:Y.scope)??null;h.useEffect(()=>{if(!s){r([]),o({});return}let F=!1;return chrome.storage.local.get("igtRuns").then(X=>{if(F)return;const te=((X==null?void 0:X.igtRuns)??{})[s]??{};r(Object.values(te))}),Je(s).then(X=>{if(F)return;const ae={},te=[];for(const B of X)B.criterionId==="2.4.3"?ae.focusOrder=B.verdict:B.criterionId==="2.1.2"?ae.keyboardTrap=B.verdict:B.criterionId==="2.4.7"?ae.focusVisible=B.verdict:B.criterionId==="1.3.2"?ae.readingOrder=B.verdict:B.criterionId==="1.4.11"&&(ae.nonTextContrast=B.verdict),te.push({criterionId:B.criterionId,ruleId:`ai-walkthrough-${B.criterionId}`,pageUrl:B.pageUrl,verdict:B.verdict,reasoning:B.reasoning});o(ae),d(te)}),()=>{F=!0}},[s]),h.useEffect(()=>{if(!R){c([]);return}let F=!1;return He(R).then(X=>{F||c(X)}),()=>{F=!0}},[R,C]);const K=Jt(C);if(I==="running")return e.jsx(Ur,{current:g==null?void 0:g.current,total:g==null?void 0:g.total});const V=Yt({violations:t,auditRan:C.length>0,manualRuns:n,workflows:xe,heuristicCounts:{tabOrder:((Q=(q=C[0])==null?void 0:q.tabOrderIssues)==null?void 0:Q.length)??0,readingOrder:((le=(pe=C[0])==null?void 0:pe.readingOrderIssues)==null?void 0:le.length)??0},interactiveAuditVerdicts:i,aiResolvedFails:K.map(F=>({ruleId:F.ruleId,impact:"serious",selector:F.selector}))}),W=v(F=>F.acknowledgedKeys),U=new Set(C.map(F=>F.pageUrl??F.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",k=C.length>0?Js(C,{runs:n,workflows:xe},"2.1","AA",W,u,l,U):void 0,O=C.length>0?Wa(Wt({audits:C,igtRuns:n,workflows:xe,acknowledgedMatchKeys:W,incompleteResolutions:u,interactiveAuditResults:l,auditScope:U}),xe):void 0,M=V.overallLetter,E=(k?k.failingCriteria.length+k.inconclusiveCriteria.length+k.untestedCriteria.length:0)===0&&!!k;async function P(F){var je;if(!R||!((je=k==null?void 0:k.inconclusiveReasons)!=null&&je[F]))return;const ae=k.inconclusiveReasons[F].filter(fe=>fe.source==="axe-incomplete"&&fe.elements&&fe.elements.length>0);if(ae.length===0)return;m(fe=>new Set(fe).add(F)),f(null);const te=[];let B=0;try{for(const ge of ae){const we=await de({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:ge.ruleOrStepId,pageUrl:ge.pageUrl??R,wcagCriterion:F,elements:ge.elements??[],targetLevel:"AA"});if(we!=null&&we.unavailableReason){f(we.unavailableReason);break}we!=null&&we.resolutions&&(te.push(...we.resolutions),B+=we.totalCostUsd??0)}if(R){const ge=await He(R);c(ge)}const fe={total:te.length,pass:te.filter(ge=>ge.verdict==="pass").length,fail:te.filter(ge=>ge.verdict==="fail").length,uncertain:te.filter(ge=>ge.verdict==="uncertain").length,costUsd:B,resolutions:te};A(ge=>({...ge,[F]:fe}))}finally{m(fe=>{const ge=new Set(fe);return ge.delete(F),ge})}}function ne(F){T(X=>{const ae=new Set(X);return ae.has(F)?ae.delete(F):ae.add(F),ae})}const N=((me=C[0])==null?void 0:me.startedAt)??null,G=s&&N?`${s}::${N}`:null;h.useEffect(()=>{if(!G||!k||j===G||I!=="complete")return;const F=k.inconclusiveCriteria.filter(X=>{var te;return(((te=k.inconclusiveReasons)==null?void 0:te[X])??[]).some(B=>B.source==="axe-incomplete"&&B.elements&&B.elements.length>0)});if(F.length===0){b(G);return}b(G),(async()=>{for(const X of F)try{await P(X)}catch{}})()},[G,k,I]);async function H(F){var we,as;if(!R)return;const X=((we=k==null?void 0:k.inconclusiveReasons)==null?void 0:we[F])??[],ae=((as=k==null?void 0:k.failingReasons)==null?void 0:as[F])??[],te=[],B=new Set;for(const oe of X){if(oe.source!=="axe-incomplete"||!oe.elements)continue;const Se=oe.pageUrl??R;for(const Ae of oe.elements){const Oe=`${Se}::${oe.ruleOrStepId}::${Ae.selector}`;B.has(Oe)||(B.add(Oe),te.push({ruleId:oe.ruleOrStepId,pageUrl:Se,selector:Ae.selector}))}}for(const oe of ae){if(oe.source!=="ai"||!oe.selector)continue;const Se=oe.ruleOrStepId.startsWith("ai-resolved::")?oe.ruleOrStepId.slice(13):oe.ruleOrStepId,Ae=oe.pageUrl??R,Oe=`${Ae}::${Se}::${oe.selector}`;B.has(Oe)||(B.add(Oe),te.push({ruleId:Se,pageUrl:Ae,selector:oe.selector}))}if(te.length===0)return;const je=new Date().toISOString(),fe=[];for(const oe of te){const Se=u.find(Ae=>Ae.pageUrl===oe.pageUrl&&Ae.ruleId===oe.ruleId&&Ae.selector===oe.selector);Se&&Se.verdict==="pass"&&Se.reasoning.startsWith("Marked as visually verified")||fe.push({pageUrl:oe.pageUrl,ruleId:oe.ruleId,selector:oe.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${je.slice(0,10)}.`,resolvedAt:je,costUsd:0,wcagCriterion:F})}if(fe.length===0)return;await Ba(fe);const ge=await He(R);c(ge),A(oe=>({...oe,[F]:{total:fe.length,pass:fe.length,fail:0,uncertain:0,costUsd:0,resolutions:fe}}))}const z=(()=>{if(!k)return null;if(E)return{kind:"conformant",text:`WCAG ${k.targetLevel} Status: Conformant`,detail:"All applicable criteria pass automated + AI checks."};const F=k.inconclusiveCriteria.length,X=k.failingCriteria.length,ae=k.untestedCriteria.length,te=[];if(X>0){const je=k.failingCriteria.slice(0,4).join(", ")+(X>4?`, +${X-4}`:"");te.push(`${X} ${X===1?"criterion":"criteria"} failing (${je})`)}if(F>0){const je=k.inconclusiveCriteria.slice(0,4).join(", ")+(F>4?`, +${F-4}`:"");te.push(`${F} inconclusive (${je})`)}if(ae>0){const je=k.untestedCriteria.slice(0,4).join(", ")+(ae>4?`, +${ae-4}`:"");te.push(`${ae} untested (${je})`)}const B=X>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":ae>0?"Mark untested via Guided Tests, OR confirm the tool gap (no axe rule + no AI walkthrough + no IGT step).":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return{kind:"not-conformant",text:`WCAG ${k.targetLevel} Status: Not conformant`,detail:`${te.join(" · ")}. ${B}`}})();let re=0;for(const F of xe){const X=n.find(te=>te.workflowId===F.id);if(!X)continue;F.steps.every(te=>{const B=X.steps[te.id];return(B==null?void 0:B.status)==="pass"||(B==null?void 0:B.status)==="fail"||(B==null?void 0:B.status)==="skip"||(B==null?void 0:B.status)==="not-applicable"})&&re++}const se=new Set;for(const F of t)W.has(F.matchKey)||se.add(`${F.ruleId}::${F.target.selector}`);for(const F of K)F.verdict==="fail"&&se.add(`${F.ruleId}::${F.selector}`);const ie=se.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!y&&S&&e.jsx(_r,{scannedAt:S}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Sr[M]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:M})}),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 ",V.subGrades.length," verification areas below. Untested areas count as F until verified."]}),z&&e.jsxs("div",{className:`text-[11px] leading-snug mt-1 rounded px-2 py-1 border ${z.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[z.kind==="conformant"?"✓ ":"✗ ",z.text]}),e.jsx("p",{className:"mt-0.5",children:z.detail})]})]})]}),a&&z&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${z.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[z.kind==="conformant"?"✓ ":"✗ ",z.text]}),e.jsx("p",{className:"mt-0.5",children:z.detail})]}),V.isLawsuitRisk&&e.jsx(Rr,{areas:V.warningAreas}),e.jsx(Tr,{grades:V.subGrades,uncategorized:yr(t,u,{excludeAckedMatchKeys:W})}),k&&e.jsx(Ir,{coverage:k,onResolveWithAi:P,onMarkVisuallyVerified:H,resolving:p,resolveError:x,lastResolveResult:w,expandedResultFor:$,onToggleResultDetail:ne,violations:t}),O&&e.jsx(Er,{layers:O}),e.jsx(Lr,{violationsRemaining:ie,manualCompleted:re,manualTotal:xe.length}),re>0||C.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:re})," of ",e.jsx("strong",{children:xe.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:`${re/xe.length*100}%`}})})]}):null]})}function Ir({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l,violations:d}){const u=v(j=>j.setView),c=v(j=>j.setFindingsLens),p=v(j=>j.setPendingAreaExpand);function m(j){const b=xr(j,d);u("report"),b?(c("per-area"),p(b)):c("violations")}const x=t.untestedCriteria.length+t.inconclusiveCriteria.length,[f,w]=h.useState(x>0&&x<=3),A=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),$=t.canClaimConformance,T=[];return t.failingCriteria.length>0&&T.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&T.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&T.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${$?"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 ${$?"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 (",A,"%)"]}),$&&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)."]}),!$&&(()=>{const j=[];t.failingCriteria.length>0&&j.push("failing"),t.inconclusiveCriteria.length>0&&j.push("inconclusive"),t.untestedCriteria.length>0&&j.push("untested");const b=j.length===0?"unresolved":j.length===1?j[0]:j.length===2?`${j[0]} or ${j[1]}`:`${j.slice(0,-1).join(", ")}, or ${j[j.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",b,"."]})})(),!$&&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."]}),!$&&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."]})]}),!$&&T.length>0&&e.jsx("button",{type:"button",onClick:()=>w(j=>!j),className:"text-[11px] underline shrink-0 self-start",children:f?"hide":"show list"})]}),f&&!$&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[T.map(j=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${j.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[j.kind==="untested"?"Untested":j.kind==="inconclusive"?"Inconclusive":"Failing"," (",j.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:j.ids.map(b=>{var V,W;const I=j.kind==="inconclusive"?(V=t.inconclusiveReasons)==null?void 0:V[b]:void 0,g=j.kind==="failing"?(W=t.failingReasons)==null?void 0:W[b]:void 0,y=I==null?void 0:I.some(L=>L.source==="axe-incomplete"&&L.elements&&L.elements.length>0),C=g==null?void 0:g.some(L=>L.source==="ai"),S=(n==null?void 0:n.has(b))??!1,R=i==null?void 0:i[b],K=(o==null?void 0:o.has(b))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>m(b),className:"font-mono text-[11px] text-left underline-offset-2 hover:underline text-brand-700 hover:text-brand-800 cursor-pointer",title:`Jump to the verification area covering ${b}`,children:["· ",b]}),(j.kind==="inconclusive"&&y||j.kind==="failing"&&C)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[j.kind==="inconclusive"&&s&&b!=="1.4.3"&&b!=="1.4.6"&&e.jsx("button",{type:"button",disabled:S,onClick:()=>s(b),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:S?"Resolving…":R?"✨ Resolve again →":"✨ Resolve with AI →"}),j.kind==="inconclusive"&&(b==="1.4.3"||b==="1.4.6")&&e.jsx("span",{className:"text-[10px] text-slate-500 italic",title:"The pixel-contrast sampler runs automatically and produces the authoritative verdict for color-contrast. Mark visually verified if the AI was wrong about a specific element.",children:"Pixel sampler ran automatically — use Mark visually verified if needed"}),a&&e.jsx("button",{type:"button",disabled:S,onClick:()=>a(b),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:j.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),R&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",R.total," ",R.total===1?"verdict":"verdicts",":",R.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",R.pass," pass"]}),R.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",R.fail," fail"]}),R.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",R.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",R.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(b),className:"ml-auto text-[10px] underline text-brand-700",children:K?"hide reasoning":"show reasoning"})]}),R.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",R.uncertain," ",R.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),R.pass===R.total&&R.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),K&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:R.resolutions.map((L,U)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:L.verdict==="pass"?"text-emerald-700 font-semibold":L.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:L.verdict==="pass"?"✓":L.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:L.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:L.reasoning})]},U))})]}),g&&g.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:g.map((L,U)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[L.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),L.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," fail — "]}),L.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," fail — "]}),L.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:L.selector}),L.notes&&e.jsx("span",{className:"text-rose-700",children:L.notes})]},U))}),I&&I.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:I.map((L,U)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[L.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," — "]}),L.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," skipped — "]}),L.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," — "]}),L.resolutionHint,L.elements&&L.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",L.elements.length===1?"element":`${L.elements.length} elements`,":"," ",L.elements.slice(0,3).map((k,O,M)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:k.selector}),O<M.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},O)),L.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",L.elements.length-3," more"]})]})]},U))}):j.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.)"})]},b)})})]},j.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 xs={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 Er({layers:t}){const s=v(i=>i.setView),a=v(i=>i.setFindingsLens);function n(){s("report"),a("violations")}const r=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:r.map(i=>{const o=t[i],l=o.coveredCriteria.length,d=o.failing.length,u=o.inconclusive.length,c=o.unevaluated.length,p=o.cleared,m=d>0||u>0,x=l>0&&!m&&c===0,f=x?"text-emerald-700":d>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${x?"bg-emerald-500 text-white":d>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:x?"✓":d>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:xs[i].label}),e.jsx("span",{className:`font-mono text-[10px] ${f}`,children:l===0?"no coverage yet":`${p}/${l}`}),d>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-rose-700 hover:underline cursor-pointer",title:`Confirmed fails (action: fix the underlying issue + re-audit, OR mark visually verified): ${o.failing.join(", ")}`,children:["· ",d," failing"]}),u>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-amber-700 hover:underline cursor-pointer",title:`Inconclusive — this layer couldn't determine (action: try "Resolve with AI" below, OR mark via Guided Tests): ${o.inconclusive.join(", ")}`,children:["· ",u," inconclusive"]}),c>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",c," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:xs[i].hint}),i==="human"&&c>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},i)})})]})}function Rr({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 Tr({grades:t,uncategorized:s}){const a=v(l=>l.setView),n=v(l=>l.setFindingsLens),r=v(l=>l.setPendingAreaExpand);function i(l){a("report"),n("per-area"),r(l)}function o(l){const d=l.counts;return d.critical+d.serious+d.moderate+d.minor>0}return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsxs("ul",{className:"grid grid-cols-1 gap-1.5",children:[t.map(l=>{const d=o(l),u="flex items-center gap-2 text-[11px] w-full text-left rounded px-1 py-0.5 -mx-1",c=d?"cursor-pointer hover:bg-slate-100":"cursor-default",p=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${Ar[l.letter]}`,"aria-label":`Grade ${l.letter}`,children:l.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:l.label}),e.jsx($r,{grade:l,onOpenGuided:()=>a("guided")})]});return e.jsx("li",{children:d?e.jsx("button",{type:"button",onClick:()=>i(l.id),className:`${u} ${c}`,"aria-label":`Open ${l.label} violations`,children:p}):e.jsx("div",{className:u,children:p})},l.id)}),s&&s.total>0&&e.jsxs("li",{className:"flex items-center gap-2 text-[11px] mt-1 pt-1.5 border-t border-dashed border-slate-200",title:`These findings come from rules not mapped to any of the ${t.length} verification areas above. Listing them here so the headline count and the area cards agree. Rules: ${s.representatives.map(l=>l.ruleId).join(", ")}`,children:[e.jsx("span",{className:"w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold bg-slate-300 text-slate-700","aria-label":"Other findings",children:"?"}),e.jsxs("span",{className:"font-medium text-slate-700 flex-1 min-w-0",children:["Other findings",e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal italic",children:"rules not mapped to a category"})]}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:(()=>{const l=[];return s.counts.critical>0&&l.push(`${s.counts.critical} critical`),s.counts.serious>0&&l.push(`${s.counts.serious} serious`),s.counts.moderate>0&&l.push(`${s.counts.moderate} moderate`),s.counts.minor>0&&l.push(`${s.counts.minor} minor`),l.join(" · ")})()})]})]})]})}function $r({grade:t,onOpenGuided:s}){const a=l=>{if(!l)return"";const d=xe.find(u=>u.id===l);return(d==null?void 0:d.name)??l};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 l=t.verifiedAt?ma(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",l?` ${l} ago`:""]})}const{critical:n,serious:r,moderate:i,minor:o}=t.counts;if(n>0||r>0||i>0||o>0){const l=[];return n>0&&l.push({label:"critical",n,cls:"text-rose-700"}),r>0&&l.push({label:"serious",n:r,cls:"text-orange-700"}),i>0&&l.push({label:"moderate",n:i,cls:"text-amber-700"}),o>0&&l.push({label:"minor",n:o,cls:"text-slate-600"}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:l.map((d,u)=>e.jsxs("span",{children:[u>0&&" · ",e.jsxs("span",{className:d.cls,children:[d.n," ",d.label]})]},d.label))})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function Lr({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=v(o=>o.setView),r=v(o=>o.setFindingsLens),i=[{status:t===0?"done":"next",label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:t>0?()=>{n("report"),r("violations")}:void 0,tooltip:t>0?"Open the Violations list — each finding card has inline Acknowledge / Not a real issue / Locate / Fix recipe affordances.":void 0},{status:"optional",label:a>0?`Optional: spot-check via Guided Tests (${s}/${a} done — AI walkthroughs cover most)`:"Optional: spot-check via Guided Tests (AI walkthroughs cover most)",action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The 5 AI walkthroughs auto-run after every audit and verdict the criteria that previously required manual keyboard / vision checks. Run these workflows only for belt-and-suspenders confidence on a formal conformance claim."},{status:t===0?"next":"pending",label:"Export AI fix prompt → sign-and-seal in Compliance",action:()=>n("delta"),tooltip:'Switches to the Delta lens. Export menu → "AI fix prompt" produces markdown for ChatGPT / Claude / Copilot with code-level fix recipes for every automated finding, including false-positive guidance. Then jump to the Compliance tile from Dashboard to sign-and-seal the audit for a chain-of-custody record.'}];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:i.map((o,l)=>{const d=o.status==="done"?"text-emerald-700":o.status==="next"?"text-brand-600 font-semibold":o.status==="optional"?"text-slate-500":"text-slate-400";return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:`font-mono shrink-0 ${d}`,"aria-hidden":"true",children:[l+1,"."]}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:o.status==="next"?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:o.status==="done"?"text-slate-500 line-through leading-snug":o.status==="next"?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label}),o.status==="done"&&e.jsx("span",{className:"text-emerald-700 shrink-0 font-mono","aria-label":"step complete",children:"✓"})]},l)})})]})}function Ur({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 _r({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 (",ma(s)," old). Re-scan to grade the current page state."]})]})}function ma(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 ha(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function gs(t){if(!ha())return!1;const s=chrome.devtools;return await new Promise(a=>{const r=`(function(){
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-r1WNrwB5.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/ai-usage-log-C-jq4cW3.js","assets/copy-ai-fixer-prompt-Cpl_NnwJ.js","assets/site-report-renderer-CAdiagxw.js"])))=>i.map(i=>d[i]);
2
+ var Ga=Object.defineProperty;var Va=(t,s,a)=>s in t?Ga(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var is=(t,s,a)=>Va(t,typeof s!="symbol"?s+"":s,a);import{R as He,i as he,r as h,j as e,M as De,C as Lt,A as Ze}from"./styles-UZY6vFOS.js";import{s as Ys,i as Wt,g as Wa,a as de,d as Bt,l as _e,b as Ke,c as Oe,e as Js,f as Ba,h as Ht,A as xe,j as Ha,k as Ka,u as za,m as qa,n as Qa,o as Ya,p as Ja,q as Xa,N as Za,r as en,t as Ut,v as Xs,w as _t,x as Zs,y as tn,O as sn,z as Dt,B as lt,C as an,D as nn,E as os,F as rn,G as on,H as ln,I as cn,J as dn,K as un,L as pn,M as mn,P as hn,T as xn,Q as gn,R as fn,S as bn,U as ea,V as vn,W as ls,X as cs,Y as jt,Z as yn,_ as ds,$ as wn,a0 as jn,a1 as Nn,a2 as kn,a3 as Sn}from"./scheduled-audit-runner-r1WNrwB5.js";import{_ as ke}from"./diff-DA41zYPc.js";import{o as ye,r as J,s as le,c as ta,b as be,d as Ie}from"./crash-reporter-Dc5lvxvY.js";import{g as sa,j as xt,k as gt,t as Xe,m as An,B as Nt,i as Kt,n as Cn,o as $e,T as aa,p as na,q as ft,u as In}from"./ai-usage-log-C-jq4cW3.js";import{s as En,t as Rn}from"./design-system-audit-DpxJrxnb.js";const us=t=>{let s;const a=new Set,n=(u,c)=>{const p=typeof u=="function"?u(s):u;if(!Object.is(p,s)){const m=s;s=c??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(x=>x(s,m))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:u=>(a.add(u),()=>a.delete(u))},d=s=t(n,r,l);return l},Tn=t=>t?us(t):us,$n=t=>t;function Ln(t,s=$n){const a=He.useSyncExternalStore(t.subscribe,He.useCallback(()=>s(t.getState()),[t,s]),He.useCallback(()=>s(t.getInitialState()),[t,s]));return He.useDebugValue(a),a}const ps=t=>{const s=Tn(t),a=n=>Ln(s,n);return Object.assign(a,s),a},Un=t=>t?ps(t):ps,v=Un(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",findingsLens:"overview",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,crawlNavContext:null,resolutionsByUrl:{},pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,pendingAreaExpand:null,auditStartedAtMs:null,lastAuditWallClockMs:null,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,auditStartedAtMs:Date.now(),crawlNavContext:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t(r=>{const i=r.auditStartedAtMs?Date.now()-r.auditStartedAtMs:null;return{results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0,lastAuditWallClockMs:i,auditStartedAtMs:null}}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setFindingsLens:s=>t({findingsLens:s}),setPendingAreaExpand:s=>t({pendingAreaExpand:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setCrawlNavContext:s=>t({crawlNavContext:s}),setResolutionsForUrl:(s,a)=>t(n=>({resolutionsByUrl:{...n.resolutionsByUrl,[s]:a}})),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Ys(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),dismissedKeys:new Set,setDismissedKeys:s=>t({dismissedKeys:s}),markDismissed:s=>t(a=>({dismissedKeys:new Set(a.dismissedKeys).add(s)})),markUndismissed:s=>t(a=>{const n=new Set(a.dismissedKeys);return n.delete(s),{dismissedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),ct="sidePanel:lastAudit";function _n(){const t=[];return t.push(ye("AUDIT_PROGRESS_EVENT",s=>{const a=v.getState().status==="running";v.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),v.getState().setStatus("running"),a||he.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(ye("AUDIT_COMPLETE_EVENT",s=>{var l;v.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((d,u)=>d+u.violations.length,0),n=((l=s.delta)==null?void 0:l.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;he.polite(r);const i=v.getState().view;["compliance","guided","crawl"].includes(i)||(v.getState().setView("report"),v.getState().setFindingsLens("overview")),On({results:s.results,delta:s.delta,componentId:s.componentId}),Dn(s.results,s.delta,s.componentId)})),t.push(ye("AUDIT_FAILED_EVENT",s=>{v.getState().setError(s.error.message)})),t.push(ye("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=v.getState().aiProgress;v.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||he.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(ye("AI_AUGMENTATION_FAILED_EVENT",s=>{v.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(ye("SCORECARD_UPDATED_EVENT",()=>{dt()})),t.push(ye("LICENSE_CHANGED_EVENT",()=>{ra()})),t.push(ye("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&he.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(ye("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),he.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`),(async()=>{try{const{loadSiteCrawlPerUrlResults:n}=await ke(async()=>{const{loadSiteCrawlPerUrlResults:l}=await import("./scheduled-audit-runner-r1WNrwB5.js").then(d=>d.aD);return{loadSiteCrawlPerUrlResults:l}},__vite__mapDeps([0,1,2,3])),{getResolutionsForPage:r}=await ke(async()=>{const{getResolutionsForPage:l}=await import("./scheduled-audit-runner-r1WNrwB5.js").then(d=>d.aF);return{getResolutionsForPage:l}},__vite__mapDeps([0,1,2,3])),i=await n();if(!i||i.length===0)return;const o=v.getState().setResolutionsForUrl;await Promise.all(i.map(async l=>{try{const d=await r(l.url);o(l.url,d)}catch{}}))}catch(n){console.warn("[site-crawl] failed to pre-warm resolutions cache",n)}})()})),t.push(ye("SITE_CRAWL_FAILED_EVENT",s=>{const a=v.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),he.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Dn(t,s,a){var n,r;if(t.length!==0)try{const i=await sa();if(!i.enabled)return;const o=v.getState().tier;if(Wt(o)||!xt(o,"autoExportAuditReports"))return;const l=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",d=[],u=v.getState().lastAuditWallClockMs??void 0;for(const c of i.formats)try{const p=await J({type:"EXPORT_REQUEST",format:c,results:t,delta:s??void 0,wallClockMs:u});if(typeof p.content!="string"||p.content.length<200)continue;const m=gt(c,a??null);Xe(p.content,m),l&&await An({url:l,exportedAt:new Date().toISOString(),format:c,filename:m}),d.push(m)}catch(p){console.warn(`[auto-export] format ${c} failed:`,p)}d.length>0&&he.polite(`Audit auto-exported ${d.length} file${d.length===1?"":"s"}.`)}catch(i){console.warn("[auto-export] failed:",i)}}async function On(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[ct]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Fn(){const s=(await chrome.storage.local.get(ct))[ct];s&&v.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Mn(){await chrome.storage.local.remove(ct)}async function bt(){v.getState().clearResults(),await Mn()}async function dt(){const t=await J({type:"BASELINE_LIST"});v.getState().setBaselineList(t.items)}async function ra(t){const s=await J({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});v.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ia()}async function ia(){const{fetchMessages:t}=await ke(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>qn);return{fetchMessages:n}},void 0),s=v.getState().userMode,a=await t(s);a&&v.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Pn(){const s=(await J({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;v.getState().setUserMode(a)}function Gn(){return chrome.runtime.connect({name:"audit-keepalive"})}let ut=null;async function Vn(){if(ut===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(ut=t.id)}catch{}}function oa(){if(ut===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:ut}).catch(()=>{})}function Ne(t){oa(),v.getState().setSiteCrawlReport(null),Ys(null).catch(()=>{}),le(t)}const Ot="dismissedFindings";function vt(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function qe(t){return`reading-order::${t}`}function Qe(t){return`tab-order::${t}`}function zt(t){return`violation::${t}`}async function yt(){try{const t=await chrome.storage.local.get(Ot),s=t==null?void 0:t[Ot];if(s&&typeof s=="object")return s}catch{}return{}}async function qt(t){await chrome.storage.local.set({[Ot]:t})}async function Qt(t){return(await yt())[vt(t)]??{}}async function Yt(t,s,a,n){const r=await yt(),i=vt(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await qt(r)}async function Ye(t,s){if(s.length===0)return;const a=await yt(),n=vt(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await qt(a)}async function Jt(t,s){const a=await yt(),n=vt(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await qt(a))}const Mc=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Yt,addDismissals:Ye,dismissalKeyForReadingOrder:qe,dismissalKeyForTabOrder:Qe,dismissalKeyForViolation:zt,getDismissalsForUrl:Qt,removeDismissal:Jt},Symbol.toStringTag,{value:"Module"}));function Wn({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,o]=h.useState(!0),[l,d]=h.useState(""),[u,c]=h.useState(!1),[p,m]=h.useState(null);async function x(f){var w;if(f.preventDefault(),!(!s.trim()||!n.trim())){c(!0),m(null);try{const j=await J({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});j.success?(m({ok:!0,msg:`Sent (ref: ${j.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((w=j.error)==null?void 0:w.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:x,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:f=>a(f.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:f=>r(f.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:f=>d(f.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:f=>o(f.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),p&&e.jsx("p",{id:"support-form-result",role:p.ok?"status":"alert",className:`text-xs ${p.ok?"text-green-700":"text-red-700"}`,children:p.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:u,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:u?"Sending…":"Send"})]})]})}function ms({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 pt=ta("messages-client"),Bn="https://api.wcagcheckr.com",la="wcagcheckr",Hn=1e4;function Kn(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ca(t,s){const a=await Wa();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Kn()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Bn}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Hn)})}async function zn(t){try{const s=await ca(`/v1/products/${la}/messages`,{userMode:t??null});return s.ok?await s.json():(pt.warn("fetchMessages http",s.status),null)}catch(s){return pt.warn("fetchMessages failed",s),null}}async function Ue(t,s){try{const a=await ca(`/v1/products/${la}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(pt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return pt.warn("ackMessage failed",a),!1}}const qn=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Ue,fetchMessages:zn},Symbol.toStringTag,{value:"Module"})),Qn=["http:","https:"];function Yn(t){try{const s=new URL(t);return Qn.includes(s.protocol)}catch{return!1}}function hs(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),d=t.slice(i+2,o);Yn(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function da({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:hs(d)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,u)=>e.jsx("li",{children:hs(d)},u))},`u-${i++}`)),n=[])}for(const d of s){const u=d.trimEnd();if(u===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(u);if(c){o(),n.push(c[1]);continue}l(),r.push(u)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const Jn={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Xn={critical:"bg-rose-50 border-rose-200"};function ua(){const t=v(m=>m.unreadMessageCount),s=v(m=>m.messages),a=v(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[o,l]=h.useState(!1);h.useEffect(()=>{const m=s.filter(f=>!f.seen);if(m.length===0)return;const x=Math.max(...m.map(f=>f.id));if(x>i.current){i.current=x,l(!0);const f=setTimeout(()=>l(!1),1500);return()=>clearTimeout(f)}},[s]);async function d(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),Ue(x.id,"seen")}function u(){const m=!n;r(m),m&&d()}async function c(m){a(m.id,"dismissed"),await Ue(m.id,"dismissed")}async function p(m){m.ctaUrl&&(a(m.id,"clicked"),Ue(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:u,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Zn,{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(er,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:p})]})}function Zn({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 er({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=h.useRef(null);return h.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{ia()},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 ${Jn[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(da,{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 pa(){const t=v(i=>i.messages),s=v(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await Ue(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),Ue(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Xn.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(da,{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 tr=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function sr(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function ar(){var p,m;const t=v(x=>x.view),s=v(x=>x.setView),a=v(x=>x.setUserMode),n=v(x=>x.results),r=v(x=>x.status),[i,o]=h.useState(!1),l=((p=n[0])==null?void 0:p.pageUrl)??((m=n[0])==null?void 0:m.scope),d=sr(l),u=n.length>0&&r!=="running";function c(){a("owner"),le({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(ua,{}),e.jsx(ms,{onClick:()=>void le({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(ms,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),u&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void bt(),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(nr,{view:t,setView:s}),e.jsx(De,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Wn,{onClose:()=>o(!1)})})]})}function nr({view:t,setView:s}){const a=h.useRef([]),n=v(l=>l.results),r=tr.filter(l=>!l.hideWhenIdle||n.length>0);function i(l){var c;const d=(l+r.length)%r.length,u=r[d];u&&(s(u.slug),(c=a.current[d])==null||c.focus())}function o(l,d){switch(l.key){case"ArrowRight":l.preventDefault(),i(d+1);break;case"ArrowLeft":l.preventDefault(),i(d-1);break;case"Home":l.preventDefault(),i(0);break;case"End":l.preventDefault(),i(r.length-1);break}}return e.jsx("nav",{className:"flex gap-1","aria-label":"Primary navigation",role:"tablist",children:r.map((l,d)=>{const u=t===l.slug;return e.jsx("button",{ref:c=>{a.current[d]=c},role:"tab","aria-selected":u,tabIndex:u?0:-1,onClick:()=>s(l.slug),onKeyDown:c=>o(c,d),className:u?"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md bg-slate-900 text-white shadow-sm":"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md text-slate-600 hover:bg-slate-100 border border-transparent hover:border-slate-200",children:l.label},l.slug)})})}function rr({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(Lt,{open:a,onClose:()=>n(!1)})]})}const ir="https://wcagcheckr.com/upgrade";function or(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState(null),[d,u]=h.useState(Nt),[c,p]=h.useState(Nt[0].id),[m,x]=h.useState("none"),[f,w]=h.useState(null),j=v(A=>A.status),$=v(A=>A.tier),R=v(A=>A.results.length>0),N=j==="running";h.useEffect(()=>{Promise.all([J({type:"SETTINGS_GET",key:"matrixPresets"}),J({type:"SETTINGS_GET",key:"activePresetId"})]).then(([A,O])=>{const M=Array.isArray(A.data)?A.data:null;u(M&&M.length>0?M:Nt),typeof O.data=="string"&&p(O.data)})},[]);function b(A){const O=d.find(M=>M.id===A);O&&(p(A),le({type:"SETTINGS_SET",key:"activePresetId",value:A}),le({type:"SETTINGS_SET",key:"stateMatrix",value:O.matrix}))}const I=xt($,"storybookAutoIterate");h.useEffect(()=>{const A=ye("ELEMENT_PICKED_EVENT",(M,ee)=>{n(!1);const E=ee.frameId;L(E),i({selector:M.selector,frameId:E,speech:M.speech})}),O=ye("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{A(),O()}},[]);async function g(){const A=await de();A&&(n(!0),await be(A,{type:"PICKER_ACTIVATE_REQUEST",tabId:A}))}function y(){r&&(L(r.frameId),Ne({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),v.getState().startNewScan())}function C(){if(!I){l("storybook:auto-iterate");return}L(),Ne({type:"START_AUDIT",mode:"storybook-all"}),v.getState().startNewScan()}function S(){L(),Ne({type:"START_AUDIT",mode:"all-frames"}),v.getState().startNewScan()}function T(){L(),Ne({type:"START_AUDIT",mode:"full-page"}),v.getState().startNewScan()}function H(){L(),Ne({type:"START_AUDIT",mode:"quick-scan"}),v.getState().startNewScan()}function V(){L(),Ne({type:"START_AUDIT",mode:"parallel-scan"}),v.getState().startNewScan()}function W(){le({type:"CANCEL_AUDIT"})}async function L(A){v.getState().setPinned(null);const O=await de();if(O)try{await be(O,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:O},A)}catch{}}async function U(A){w(null);const O=await de();if(!O){w("No audited tab; open a page first.");return}if(A==="none"){const ee=await J({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:O});ee.ok||w(ee.error??"Failed to clear throttle."),x("none");return}const M=await J({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:O,profile:A});if(!M.ok){w(M.error??"Failed to apply throttle.");return}x(A)}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:A=>s(A.target.value),disabled:N||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)",I?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:A=>b(A.target.value),disabled:N||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(A=>e.jsx("option",{value:A.id,children:A.name},A.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:m,onChange:A=>void U(A.target.value),disabled:N||a,title:"Apply CDP network + CPU throttling to the audited tab. Catch contrast / focus / loading-state issues that only manifest under realistic conditions.",className:`text-xs border rounded px-2 py-1 ${m==="none"?"border-slate-300":"border-amber-400 bg-amber-50"}`,children:[e.jsx("option",{value:"none",children:"⚡ Throttle: off"}),e.jsx("option",{value:"3g-slow",children:"⚡ Slow 3G + 6× CPU"}),e.jsx("option",{value:"3g-fast",children:"⚡ Fast 3G + 4× CPU"}),e.jsx("option",{value:"4g",children:"⚡ 4G LTE + 2× CPU"}),e.jsx("option",{value:"cpu-2x",children:"⚡ CPU 2× only"}),e.jsx("option",{value:"cpu-4x",children:"⚡ CPU 4× only"})]}),t==="single-element"?e.jsx(cr,{picking:a,picked:r,isRunning:N,onPick:g,onRun:y,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:T,disabled:N,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:N?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:H,disabled:N,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:N?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:V,disabled:N,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:N?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:S,disabled:N,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:N?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:C,disabled:N,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:N?"Auditing…":"Audit all stories"}),N&&e.jsx("button",{onClick:W,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!N&&R&&e.jsx("button",{type:"button",onClick:()=>void bt(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),f&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",f]}),t==="single-element"&&r&&!a&&!N&&e.jsx(dr,{selector:r.selector,onRepick:g,onClear:()=>i(null)})]}),e.jsx(De,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(rr,{feature:o??"",upgradeUrl:ir})})]})}function lr({speech:t}){if(!t)return null;const s=[];if(t.name&&s.push(t.name),t.role&&!["none","presentation","generic"].includes(t.role)&&s.push(t.role),s.push(...t.states),t.group&&s.push(t.group),s.length===0)return e.jsxs("span",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-0.5",title:"A screen reader would announce nothing for this element. Either it has no accessible name + a silent role (generic/presentation), or it's hidden from AT entirely.","data-testid":"sr-speech-preview",children:["SR: ",e.jsx("em",{children:"(silent)"})]});const a=s.join(", ");return e.jsxs("span",{className:"text-[10px] text-slate-700 bg-slate-100 border border-slate-200 rounded px-2 py-0.5 max-w-[280px] truncate",title:`Predicted screen-reader announcement when this element receives focus: "${a}"`,"data-testid":"sr-speech-preview",children:["SR: ",e.jsx("strong",{children:a})]})}function cr({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}),e.jsx(lr,{speech:s.speech})]}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function dr({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 ur={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},pr={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function mr(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState("off"),u=v(x=>x.results).flatMap(x=>x.violations);async function c(x){const f=await de();f&&(l(x),x==="off"?await be(f,{type:"VISION_SIMULATOR_CLEAR",tabId:f}).catch(()=>{}):await be(f,{type:"VISION_SIMULATOR_APPLY",tabId:f,mode:x}).catch(()=>{}))}async function p(x){const f=await de();if(f){if(t&&await be(f,{type:ur[t],tabId:f}).catch(()=>{}),t===x){s(null);return}await be(f,{type:pr[x],tabId:f}).catch(()=>{}),s(x)}}async function m(){const x=await de();if(x){if(a){await be(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(u.length===0){i("Run an audit first.");return}try{const f=await Ie(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:u});n(!0),i(`Previewing ${f.visualFixCount} visual fix${f.visualFixCount===1?"":"es"} + ${f.annotationCount} annotation${f.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(Me,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(Me,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>p("tab-order")}),e.jsx(Me,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>p("reading-order")}),e.jsx(Me,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(Me,{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:o,onChange:x=>void c(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function Me({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 hr(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 xr(){const t=v(d=>d.status),s=v(d=>d.progress),a=v(d=>d.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":hr(s.currentState),o=n?100:s.current/s.total*100,l=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(xs,{label:r,detail:i,pct:o,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),l&&e.jsx(xs,{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 xs({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}const Te=[{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 gr(t,s){const a=new Set;for(const n of s)n.wcagCriterion===t&&a.add(n.ruleId);if(a.size===0)return null;for(const n of Te)for(const r of n.axeRules)if(a.has(r))return n.id;return null}function Xt(t){const s=Te.map(r=>br(r,t)),a=fr(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 fr(t){const s=t.filter(o=>o==="A").length,a=t.filter(o=>o==="C").length,n=t.filter(o=>o==="D").length,r=t.filter(o=>o==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function br(t,s){const a=new Set(t.axeRules),n=s.violations.filter(U=>a.has(U.ruleId)),r=s.manualRuns.filter(U=>t.igtWorkflowIds.includes(U.workflowId)),i=t.igtWorkflowIds.map(U=>s.workflows.find(A=>A.id===U)).filter(U=>U!=null);let o=i.length>0;for(const U of i){const A=r.find(M=>M.workflowId===U.id);if((A?Object.keys(A.steps).length:0)!==U.steps.length){o=!1;break}}const l=r.some(U=>Object.keys(U.steps).length>0),d=t.verifiedByWorkflowIds??[],u=s.manualRuns.filter(U=>d.includes(U.workflowId)),c=d.map(U=>s.workflows.find(A=>A.id===U)).filter(U=>U!=null);let p=d.length>0&&c.length===d.length;for(const U of c){const A=u.find(M=>M.workflowId===U.id);if((A?Object.keys(A.steps).length:0)!==U.steps.length){p=!1;break}}let m=null;if(p)for(const U of u)U.completedAt&&(m===null||U.completedAt>m)&&(m=U.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,f=d[0]??t.igtWorkflowIds[0]??null,w=s.interactiveAuditVerdicts,j=[];w&&(t.id==="tab-order"&&w.focusOrder&&j.push({verdict:w.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(w.keyboardTrap&&j.push({verdict:w.keyboardTrap,criterionId:"2.1.2"}),w.focusVisible&&j.push({verdict:w.focusVisible,criterionId:"2.4.7"})),t.id==="reading-order"&&w.readingOrder&&j.push({verdict:w.readingOrder,criterionId:"1.3.2"}),t.id==="contrast"&&w.nonTextContrast&&j.push({verdict:w.nonTextContrast,criterionId:"1.4.11"}));const $=j.some(U=>U.verdict==="fail");if(j.length>0&&j.every(U=>U.verdict==="pass")&&d.length>0&&!p)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:j.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:f,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:j.map(U=>U.criterionId)};if(p&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:m,suppressedHeuristicCount:x,primaryVerifierWorkflowId:f,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const N=t.axeRules.length>0||t.heuristic!=null,b=t.igtWorkflowIds.length>0;if(N?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:b||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:f,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const g={critical:0,serious:0,moderate:0,minor:0},y=Bt(n);for(const U of y)g[U.impact]++;const C=(s.aiResolvedFails??[]).filter(U=>a.has(U.ruleId));if(C.length>0){const U=new Set(y.map(A=>`${A.ruleId}::${A.target.selector}`));for(const A of C){const O=`${A.ruleId}::${A.selector}`;U.has(O)||(U.add(O),g[A.impact]++)}}const S=j.length>0&&j.some(U=>U.verdict==="pass"||U.verdict==="fail"),T=S?x:0;S||(g.serious+=x),$&&(g.serious+=j.filter(U=>U.verdict==="fail").length);for(const U of r){const A=i.find(O=>O.id===U.workflowId);if(A)for(const O of A.steps){const M=U.steps[O.id];(M==null?void 0:M.status)==="fail"&&(O.severity==="required"?g.serious++:g.moderate++)}}const H=g.critical>0,V=g.serious>0;let W;g.critical>=5?W="F":g.critical>=1?W="D":g.serious>=1?W="C":g.moderate>=1?W="B":W="A";const L=W!=="A"&&(b&&!o||d.length>0&&!p);return{id:t.id,label:t.label,letter:W,untested:!1,needsIgt:L,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:T,primaryVerifierWorkflowId:f,counts:g,caps:{cappedAtC:H,cappedAtB:V}}}function vr(){const t=new Set;for(const s of Te)for(const a of s.axeRules)t.add(a);return t}function ma(t,s,a,n){const r=new Set;for(const i of t)a.has(i.matchKey)||n.has(`violation::${i.matchKey}`)||r.add(`${i.ruleId}::${i.target.selector}`);for(const i of s)i.verdict==="fail"&&r.add(`${i.ruleId}::${i.selector}`);return r.size}function yr(t,s,a,n){const r=new Set;for(const i of t)a.has(i.matchKey)||n.has(`violation::${i.matchKey}`)||i.wcagCriterion&&r.add(i.wcagCriterion);for(const i of s)i.verdict==="fail"&&i.wcagCriterion&&r.add(i.wcagCriterion);return Array.from(r).sort()}function wr(t,s,a={}){const n=vr(),i=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),o=Bt(i),l={critical:0,serious:0,moderate:0,minor:0};for(const c of o)l[c.impact]++;const d=new Set(o.map(c=>_e(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const p=_e(c.ruleId,c.selector);d.has(p)||(d.add(p),l.serious++)}return{total:l.critical+l.serious+l.moderate+l.minor,counts:l,representatives:o}}function gs(t,s){var n;const a=new Set;for(const r of s)for(const i of((n=r.axeRulesEvaluated)==null?void 0:n.incomplete)??[])for(const o of i.elements??[])a.add(`${i.ruleId}::${o.selector}`);return t.filter(r=>r.verdict==="fail"&&a.has(`${r.ruleId}::${r.selector}`))}function Zt(t){var i,o;const s=((i=t[0])==null?void 0:i.pageUrl)??((o=t[0])==null?void 0:o.scope)??"",a=v(l=>l.setResolutionsForUrl),[n,r]=h.useState(()=>{if(!s)return[];const l=v.getState().resolutionsByUrl[s];return l?gs(l,t):[]});return h.useEffect(()=>{if(!s){r([]);return}let l=!1;return Ke(s).then(d=>{l||(a(s,d),r(gs(d,t)))}),()=>{l=!0}},[s,t,a]),n}const jr=[{slug:"delta",label:"Delta",blurb:"Compare against the last baseline; export the prompt",marker:"Δ"},{slug:"guided",label:"Guided",blurb:"Step through manual IGT workflows",marker:"G"},{slug:"compliance",label:"Compliance",blurb:"WCAG-EM report builder + sign-and-seal",marker:"§"},{slug:"scorecard",label:"Components",blurb:"Every tracked component baseline at a glance",marker:"◍"},{slug:"forensic",label:"Forensic",blurb:"Audit history + RFC 3161 timestamps",marker:"⧉"},{slug:"schedules",label:"Schedules",blurb:"Recurring audits + alerts",marker:"⟳"},{slug:"risk",label:"Risk",blurb:"Posture summary across scheduled audits",marker:"⌖"},{slug:"crawl",label:"Site crawl",blurb:"Audit a multi-page site",marker:"↺"},{slug:"flows",label:"Flows",blurb:"Record + replay user-action sequences",marker:"▷"},{slug:"copilot",label:"Co-pilot",blurb:"Chat with AI grounded on the current audit",marker:"✦"},{slug:"ax-tree",label:"AX tree",blurb:"Browser's accessibility-tree viewer",marker:"⌥"},{slug:"tokens",label:"Design tokens",blurb:"CSS custom-properties usage map",marker:"#"}];function Nr(){const t=v(n=>n.results),s=v(n=>n.status),a=v(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(kr,{results:t,status:s,setView:a}),e.jsx(Sr,{setView:a})]})}function kr({results:t,status:s,setView:a}){var x,f;if(s==="running")return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"audit in progress"}),e.jsxs("p",{className:"text-sm font-medium text-slate-900 mt-1",children:["The matrix is iterating. Progress is shown above; results land in ",e.jsx("strong",{children:"Findings"})," when done."]})]});if(t.length===0)return e.jsxs("section",{className:"border border-dashed border-slate-300 rounded-lg bg-slate-50 px-4 py-5 text-center",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"no audit yet"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-1",children:"Pick an audit mode above and run a scan."}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 max-w-md mx-auto",children:"Or jump into a specialized tool below — site crawl, multi-page schedules, IGT workflows, the AI co-pilot, the forensic log."})]});const n=t.flatMap(w=>w.violations),r=Bt(n),i=((x=t[0])==null?void 0:x.pageUrl)??((f=t[0])==null?void 0:f.scope)??"audited page",o=t.length,l=Zt(t),d=v(w=>w.acknowledgedKeys),u=v(w=>w.dismissedKeys),c=ma(n,l,d,u),p=3,m=c>0&&c<=p?r.slice(0,p):[];return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 truncate",children:["last audit · ",o," state",o===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate mt-0.5",title:i,children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`})]}),e.jsx("button",{type:"button",onClick:()=>a("report"),className:"shrink-0 text-xs font-medium px-3.5 py-1.5 bg-slate-900 text-white rounded-md hover:bg-slate-800",children:"View findings →"})]}),m.length>0&&e.jsx("ul",{className:"border-t border-slate-200 divide-y divide-slate-100","aria-label":"Violations inline list",children:m.map(w=>{var R;const j=((R=w.target)==null?void 0:R.selector)??"(no selector)",$=j.length>50?j.slice(0,47)+"…":j;return e.jsx("li",{className:"px-3.5 py-2",children:e.jsxs("button",{type:"button",onClick:()=>a("report"),className:"w-full text-left flex items-center gap-2 hover:bg-slate-50 -mx-3.5 -my-2 px-3.5 py-2 transition-colors",title:`${w.description??w.ruleId} — ${j}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${w.impact==="critical"?"bg-rose-200 text-rose-900":w.impact==="serious"?"bg-orange-200 text-orange-900":w.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:w.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:w.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:$})]})},`${w.ruleId}::${j}`)})})]})}function Sr({setView:t}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:jr.map(s=>e.jsxs("button",{type:"button",onClick:()=>t(s.slug),className:"text-left rounded-lg border border-slate-200 bg-white hover:bg-slate-50 hover:border-slate-300 transition-colors px-3 py-2.5 flex flex-col gap-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1",children:[e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-slate-400",children:[e.jsx("span",{className:"text-slate-700 mr-1.5",children:s.marker}),s.slug]}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 leading-tight mt-0.5",children:s.label}),e.jsx("span",{className:"text-[11px] text-slate-500 leading-snug",children:s.blurb})]},s.slug))})]})}const Ar={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Cr={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function Ir({violations:t,componentId:s,hideOverallHeader:a=!1}){var ue,_,Y,q,Q,pe,ce,me;const[n,r]=h.useState([]),[i,o]=h.useState({}),[l,d]=h.useState([]),[u,c]=h.useState([]),[p,m]=h.useState(new Set),[x,f]=h.useState(null),[w,j]=h.useState({}),[$,R]=h.useState(new Set),[N,b]=h.useState(null),I=v(F=>F.status),g=v(F=>F.progress),y=v(F=>F.freshThisSession),C=v(F=>F.results),S=(ue=C[0])==null?void 0:ue.startedAt,T=((_=C[0])==null?void 0:_.pageUrl)??((Y=C[0])==null?void 0:Y.scope)??null;h.useEffect(()=>{if(!s){r([]),o({});return}let F=!1;return chrome.storage.local.get("igtRuns").then(X=>{if(F)return;const te=((X==null?void 0:X.igtRuns)??{})[s]??{};r(Object.values(te))}),Oe(s).then(X=>{if(F)return;const ae={},te=[];for(const B of X)B.criterionId==="2.4.3"?ae.focusOrder=B.verdict:B.criterionId==="2.1.2"?ae.keyboardTrap=B.verdict:B.criterionId==="2.4.7"?ae.focusVisible=B.verdict:B.criterionId==="1.3.2"?ae.readingOrder=B.verdict:B.criterionId==="1.4.11"&&(ae.nonTextContrast=B.verdict),te.push({criterionId:B.criterionId,ruleId:`ai-walkthrough-${B.criterionId}`,pageUrl:B.pageUrl,verdict:B.verdict,reasoning:B.reasoning});o(ae),d(te)}),()=>{F=!0}},[s]),h.useEffect(()=>{if(!T){c([]);return}let F=!1;return Ke(T).then(X=>{F||c(X)}),()=>{F=!0}},[T,C]);const H=Zt(C);if(I==="running")return e.jsx(_r,{current:g==null?void 0:g.current,total:g==null?void 0:g.total});const V=Xt({violations:t,auditRan:C.length>0,manualRuns:n,workflows:xe,heuristicCounts:{tabOrder:((Q=(q=C[0])==null?void 0:q.tabOrderIssues)==null?void 0:Q.length)??0,readingOrder:((ce=(pe=C[0])==null?void 0:pe.readingOrderIssues)==null?void 0:ce.length)??0},interactiveAuditVerdicts:i,aiResolvedFails:H.map(F=>({ruleId:F.ruleId,impact:"serious",selector:F.selector}))}),W=v(F=>F.acknowledgedKeys),U=new Set(C.map(F=>F.pageUrl??F.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",A=C.length>0?Js(C,{runs:n,workflows:xe},"2.1","AA",W,u,l,U):void 0,O=C.length>0?Ba(Ht({audits:C,igtRuns:n,workflows:xe,acknowledgedMatchKeys:W,incompleteResolutions:u,interactiveAuditResults:l,auditScope:U}),xe):void 0,M=V.overallLetter,E=(A?A.failingCriteria.length+A.inconclusiveCriteria.length+A.untestedCriteria.length:0)===0&&!!A;async function P(F){var je;if(!T||!((je=A==null?void 0:A.inconclusiveReasons)!=null&&je[F]))return;const ae=A.inconclusiveReasons[F].filter(fe=>fe.source==="axe-incomplete"&&fe.elements&&fe.elements.length>0);if(ae.length===0)return;m(fe=>new Set(fe).add(F)),f(null);const te=[];let B=0;try{for(const ge of ae){const we=await le({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:ge.ruleOrStepId,pageUrl:ge.pageUrl??T,wcagCriterion:F,elements:ge.elements??[],targetLevel:"AA"});if(we!=null&&we.unavailableReason){f(we.unavailableReason);break}we!=null&&we.resolutions&&(te.push(...we.resolutions),B+=we.totalCostUsd??0)}if(T){const ge=await Ke(T);c(ge)}const fe={total:te.length,pass:te.filter(ge=>ge.verdict==="pass").length,fail:te.filter(ge=>ge.verdict==="fail").length,uncertain:te.filter(ge=>ge.verdict==="uncertain").length,costUsd:B,resolutions:te};j(ge=>({...ge,[F]:fe}))}finally{m(fe=>{const ge=new Set(fe);return ge.delete(F),ge})}}function ne(F){R(X=>{const ae=new Set(X);return ae.has(F)?ae.delete(F):ae.add(F),ae})}const k=((me=C[0])==null?void 0:me.startedAt)??null,G=s&&k?`${s}::${k}`:null;h.useEffect(()=>{if(!G||!A||N===G||I!=="complete")return;const F=A.inconclusiveCriteria.filter(X=>{var te;return(((te=A.inconclusiveReasons)==null?void 0:te[X])??[]).some(B=>B.source==="axe-incomplete"&&B.elements&&B.elements.length>0)});if(F.length===0){b(G);return}b(G),(async()=>{for(const X of F)try{await P(X)}catch{}})()},[G,A,I]);async function K(F){var we,rs;if(!T)return;const X=((we=A==null?void 0:A.inconclusiveReasons)==null?void 0:we[F])??[],ae=((rs=A==null?void 0:A.failingReasons)==null?void 0:rs[F])??[],te=[],B=new Set;for(const oe of X){if(oe.source!=="axe-incomplete"||!oe.elements)continue;const Se=oe.pageUrl??T;for(const Ae of oe.elements){const Fe=`${Se}::${oe.ruleOrStepId}::${Ae.selector}`;B.has(Fe)||(B.add(Fe),te.push({ruleId:oe.ruleOrStepId,pageUrl:Se,selector:Ae.selector}))}}for(const oe of ae){if(oe.source!=="ai"||!oe.selector)continue;const Se=oe.ruleOrStepId.startsWith("ai-resolved::")?oe.ruleOrStepId.slice(13):oe.ruleOrStepId,Ae=oe.pageUrl??T,Fe=`${Ae}::${Se}::${oe.selector}`;B.has(Fe)||(B.add(Fe),te.push({ruleId:Se,pageUrl:Ae,selector:oe.selector}))}if(te.length===0)return;const je=new Date().toISOString(),fe=[];for(const oe of te){const Se=u.find(Ae=>Ae.pageUrl===oe.pageUrl&&Ae.ruleId===oe.ruleId&&Ae.selector===oe.selector);Se&&Se.verdict==="pass"&&Se.reasoning.startsWith("Marked as visually verified")||fe.push({pageUrl:oe.pageUrl,ruleId:oe.ruleId,selector:oe.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${je.slice(0,10)}.`,resolvedAt:je,costUsd:0,wcagCriterion:F})}if(fe.length===0)return;await Ha(fe);const ge=await Ke(T);c(ge),j(oe=>({...oe,[F]:{total:fe.length,pass:fe.length,fail:0,uncertain:0,costUsd:0,resolutions:fe}}))}const z=(()=>{if(!A)return null;if(E)return{kind:"conformant",text:`WCAG ${A.targetLevel} Status: Conformant`,detail:"All applicable criteria pass automated + AI checks."};const F=A.inconclusiveCriteria.length,X=A.failingCriteria.length,ae=A.untestedCriteria.length,te=[];if(X>0){const je=A.failingCriteria.slice(0,4).join(", ")+(X>4?`, +${X-4}`:"");te.push(`${X} ${X===1?"criterion":"criteria"} failing (${je})`)}if(F>0){const je=A.inconclusiveCriteria.slice(0,4).join(", ")+(F>4?`, +${F-4}`:"");te.push(`${F} inconclusive (${je})`)}if(ae>0){const je=A.untestedCriteria.slice(0,4).join(", ")+(ae>4?`, +${ae-4}`:"");te.push(`${ae} untested (${je})`)}const B=X>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":ae>0?"Mark untested via Guided Tests, OR confirm the tool gap (no axe rule + no AI walkthrough + no IGT step).":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return{kind:"not-conformant",text:`WCAG ${A.targetLevel} Status: Not conformant`,detail:`${te.join(" · ")}. ${B}`}})();let re=0;for(const F of xe){const X=n.find(te=>te.workflowId===F.id);if(!X)continue;F.steps.every(te=>{const B=X.steps[te.id];return(B==null?void 0:B.status)==="pass"||(B==null?void 0:B.status)==="fail"||(B==null?void 0:B.status)==="skip"||(B==null?void 0:B.status)==="not-applicable"})&&re++}const se=new Set;for(const F of t)W.has(F.matchKey)||se.add(`${F.ruleId}::${F.target.selector}`);for(const F of H)F.verdict==="fail"&&se.add(`${F.ruleId}::${F.selector}`);const ie=se.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!y&&S&&e.jsx(Dr,{scannedAt:S}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Ar[M]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:M})}),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 ",V.subGrades.length," verification areas below. Untested areas count as F until verified."]}),z&&e.jsxs("div",{className:`text-[11px] leading-snug mt-1 rounded px-2 py-1 border ${z.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[z.kind==="conformant"?"✓ ":"✗ ",z.text]}),e.jsx("p",{className:"mt-0.5",children:z.detail})]})]})]}),a&&z&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${z.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[z.kind==="conformant"?"✓ ":"✗ ",z.text]}),e.jsx("p",{className:"mt-0.5",children:z.detail})]}),V.isLawsuitRisk&&e.jsx(Tr,{areas:V.warningAreas}),e.jsx($r,{grades:V.subGrades,uncategorized:wr(t,u,{excludeAckedMatchKeys:W})}),A&&e.jsx(Er,{coverage:A,onResolveWithAi:P,onMarkVisuallyVerified:K,resolving:p,resolveError:x,lastResolveResult:w,expandedResultFor:$,onToggleResultDetail:ne,violations:t}),O&&e.jsx(Rr,{layers:O}),e.jsx(Ur,{violationsRemaining:ie,manualCompleted:re,manualTotal:xe.length}),re>0||C.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:re})," of ",e.jsx("strong",{children:xe.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:`${re/xe.length*100}%`}})})]}):null]})}function Er({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l,violations:d}){const u=v(N=>N.setView),c=v(N=>N.setFindingsLens),p=v(N=>N.setPendingAreaExpand);function m(N){const b=gr(N,d);u("report"),b?(c("per-area"),p(b)):c("violations")}const x=t.untestedCriteria.length+t.inconclusiveCriteria.length,[f,w]=h.useState(x>0&&x<=3),j=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),$=t.canClaimConformance,R=[];return t.failingCriteria.length>0&&R.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&R.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&R.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${$?"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 ${$?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",j,"%)"]}),$&&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)."]}),!$&&(()=>{const N=[];t.failingCriteria.length>0&&N.push("failing"),t.inconclusiveCriteria.length>0&&N.push("inconclusive"),t.untestedCriteria.length>0&&N.push("untested");const b=N.length===0?"unresolved":N.length===1?N[0]:N.length===2?`${N[0]} or ${N[1]}`:`${N.slice(0,-1).join(", ")}, or ${N[N.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",b,"."]})})(),!$&&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."]}),!$&&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."]})]}),!$&&R.length>0&&e.jsx("button",{type:"button",onClick:()=>w(N=>!N),className:"text-[11px] underline shrink-0 self-start",children:f?"hide":"show list"})]}),f&&!$&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[R.map(N=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${N.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[N.kind==="untested"?"Untested":N.kind==="inconclusive"?"Inconclusive":"Failing"," (",N.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:N.ids.map(b=>{var V,W;const I=N.kind==="inconclusive"?(V=t.inconclusiveReasons)==null?void 0:V[b]:void 0,g=N.kind==="failing"?(W=t.failingReasons)==null?void 0:W[b]:void 0,y=I==null?void 0:I.some(L=>L.source==="axe-incomplete"&&L.elements&&L.elements.length>0),C=g==null?void 0:g.some(L=>L.source==="ai"),S=(n==null?void 0:n.has(b))??!1,T=i==null?void 0:i[b],H=(o==null?void 0:o.has(b))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>m(b),className:"font-mono text-[11px] text-left underline-offset-2 hover:underline text-brand-700 hover:text-brand-800 cursor-pointer",title:`Jump to the verification area covering ${b}`,children:["· ",b]}),(N.kind==="inconclusive"&&y||N.kind==="failing"&&C)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[N.kind==="inconclusive"&&s&&b!=="1.4.3"&&b!=="1.4.6"&&e.jsx("button",{type:"button",disabled:S,onClick:()=>s(b),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:S?"Resolving…":T?"✨ Resolve again →":"✨ Resolve with AI →"}),N.kind==="inconclusive"&&(b==="1.4.3"||b==="1.4.6")&&e.jsx("span",{className:"text-[10px] text-slate-500 italic",title:"The pixel-contrast sampler runs automatically and produces the authoritative verdict for color-contrast. Mark visually verified if the AI was wrong about a specific element.",children:"Pixel sampler ran automatically — use Mark visually verified if needed"}),a&&e.jsx("button",{type:"button",disabled:S,onClick:()=>a(b),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:N.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),T&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",T.total," ",T.total===1?"verdict":"verdicts",":",T.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",T.pass," pass"]}),T.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",T.fail," fail"]}),T.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",T.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",T.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(b),className:"ml-auto text-[10px] underline text-brand-700",children:H?"hide reasoning":"show reasoning"})]}),T.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",T.uncertain," ",T.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),T.pass===T.total&&T.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),H&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:T.resolutions.map((L,U)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:L.verdict==="pass"?"text-emerald-700 font-semibold":L.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:L.verdict==="pass"?"✓":L.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:L.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:L.reasoning})]},U))})]}),g&&g.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:g.map((L,U)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[L.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),L.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," fail — "]}),L.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," fail — "]}),L.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:L.selector}),L.notes&&e.jsx("span",{className:"text-rose-700",children:L.notes})]},U))}),I&&I.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:I.map((L,U)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[L.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," — "]}),L.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," skipped — "]}),L.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:L.ruleOrStepId})," — "]}),L.resolutionHint,L.elements&&L.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",L.elements.length===1?"element":`${L.elements.length} elements`,":"," ",L.elements.slice(0,3).map((A,O,M)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:A.selector}),O<M.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},O)),L.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",L.elements.length-3," more"]})]})]},U))}):N.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.)"})]},b)})})]},N.kind)),r&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:r})]})]})}const fs={automation:{label:"Automation",hint:"axe-core rules — runs on every scan."},ai:{label:"AI judgment",hint:"wcagcheckr AI analyzers (alt-text, contrast, vision)."},human:{label:"Human verification",hint:"Independent Guided Tests — manual checks."}};function Rr({layers:t}){const s=v(i=>i.setView),a=v(i=>i.setFindingsLens);function n(){s("report"),a("violations")}const r=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:r.map(i=>{const o=t[i],l=o.coveredCriteria.length,d=o.failing.length,u=o.inconclusive.length,c=o.unevaluated.length,p=o.cleared,m=d>0||u>0,x=l>0&&!m&&c===0,f=x?"text-emerald-700":d>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${x?"bg-emerald-500 text-white":d>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:x?"✓":d>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:fs[i].label}),e.jsx("span",{className:`font-mono text-[10px] ${f}`,children:l===0?"no coverage yet":`${p}/${l}`}),d>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-rose-700 hover:underline cursor-pointer",title:`Confirmed fails (action: fix the underlying issue + re-audit, OR mark visually verified): ${o.failing.join(", ")}`,children:["· ",d," failing"]}),u>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-amber-700 hover:underline cursor-pointer",title:`Inconclusive — this layer couldn't determine (action: try "Resolve with AI" below, OR mark via Guided Tests): ${o.inconclusive.join(", ")}`,children:["· ",u," inconclusive"]}),c>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",c," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:fs[i].hint}),i==="human"&&c>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},i)})})]})}function Tr({areas:t}){const s=t.map(a=>a.label);return e.jsxs("div",{className:"border-t border-rose-200 bg-rose-50 px-3 py-2 text-[11px] text-rose-900 leading-snug",children:[e.jsx("p",{className:"font-semibold mb-0.5",children:"⚠ Not lawsuit-safe"}),e.jsx("p",{children:s.length===1?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s[0]})," scored ",t[0].letter,". Even a high overall grade doesn't help if one area is failing — demand-letter mills target the weakest link."]}):e.jsxs(e.Fragment,{children:[s.length," areas are at lawsuit-risk:"," ",s.map((a,n)=>e.jsxs("span",{children:[e.jsx("strong",{children:a}),n<s.length-1?", ":""]},a)),". Fix these before relying on the overall grade."]})})]})}function $r({grades:t,uncategorized:s}){const a=v(l=>l.setView),n=v(l=>l.setFindingsLens),r=v(l=>l.setPendingAreaExpand);function i(l){a("report"),n("per-area"),r(l)}function o(l){const d=l.counts;return d.critical+d.serious+d.moderate+d.minor>0}return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsxs("ul",{className:"grid grid-cols-1 gap-1.5",children:[t.map(l=>{const d=o(l),u="flex items-center gap-2 text-[11px] w-full text-left rounded px-1 py-0.5 -mx-1",c=d?"cursor-pointer hover:bg-slate-100":"cursor-default",p=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${Cr[l.letter]}`,"aria-label":`Grade ${l.letter}`,children:l.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:l.label}),e.jsx(Lr,{grade:l,onOpenGuided:()=>a("guided")})]});return e.jsx("li",{children:d?e.jsx("button",{type:"button",onClick:()=>i(l.id),className:`${u} ${c}`,"aria-label":`Open ${l.label} violations`,children:p}):e.jsx("div",{className:u,children:p})},l.id)}),s&&s.total>0&&e.jsxs("li",{className:"flex items-center gap-2 text-[11px] mt-1 pt-1.5 border-t border-dashed border-slate-200",title:`These findings come from rules not mapped to any of the ${t.length} verification areas above. Listing them here so the headline count and the area cards agree. Rules: ${s.representatives.map(l=>l.ruleId).join(", ")}`,children:[e.jsx("span",{className:"w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold bg-slate-300 text-slate-700","aria-label":"Other findings",children:"?"}),e.jsxs("span",{className:"font-medium text-slate-700 flex-1 min-w-0",children:["Other findings",e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal italic",children:"rules not mapped to a category"})]}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:(()=>{const l=[];return s.counts.critical>0&&l.push(`${s.counts.critical} critical`),s.counts.serious>0&&l.push(`${s.counts.serious} serious`),s.counts.moderate>0&&l.push(`${s.counts.moderate} moderate`),s.counts.minor>0&&l.push(`${s.counts.minor} minor`),l.join(" · ")})()})]})]})]})}function Lr({grade:t,onOpenGuided:s}){const a=l=>{if(!l)return"";const d=xe.find(u=>u.id===l);return(d==null?void 0:d.name)??l};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 l=t.verifiedAt?ha(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",l?` ${l} ago`:""]})}const{critical:n,serious:r,moderate:i,minor:o}=t.counts;if(n>0||r>0||i>0||o>0){const l=[];return n>0&&l.push({label:"critical",n,cls:"text-rose-700"}),r>0&&l.push({label:"serious",n:r,cls:"text-orange-700"}),i>0&&l.push({label:"moderate",n:i,cls:"text-amber-700"}),o>0&&l.push({label:"minor",n:o,cls:"text-slate-600"}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:l.map((d,u)=>e.jsxs("span",{children:[u>0&&" · ",e.jsxs("span",{className:d.cls,children:[d.n," ",d.label]})]},d.label))})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function Ur({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=v(o=>o.setView),r=v(o=>o.setFindingsLens),i=[{status:t===0?"done":"next",label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:t>0?()=>{n("report"),r("violations")}:void 0,tooltip:t>0?"Open the Violations list — each finding card has inline Acknowledge / Not a real issue / Locate / Fix recipe affordances.":void 0},{status:"optional",label:a>0?`Optional: spot-check via Guided Tests (${s}/${a} done — AI walkthroughs cover most)`:"Optional: spot-check via Guided Tests (AI walkthroughs cover most)",action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The 5 AI walkthroughs auto-run after every audit and verdict the criteria that previously required manual keyboard / vision checks. Run these workflows only for belt-and-suspenders confidence on a formal conformance claim."},{status:t===0?"next":"pending",label:"Export AI fix prompt → sign-and-seal in Compliance",action:()=>n("delta"),tooltip:'Switches to the Delta lens. Export menu → "AI fix prompt" produces markdown for ChatGPT / Claude / Copilot with code-level fix recipes for every automated finding, including false-positive guidance. Then jump to the Compliance tile from Dashboard to sign-and-seal the audit for a chain-of-custody record.'}];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:i.map((o,l)=>{const d=o.status==="done"?"text-emerald-700":o.status==="next"?"text-brand-600 font-semibold":o.status==="optional"?"text-slate-500":"text-slate-400";return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:`font-mono shrink-0 ${d}`,"aria-hidden":"true",children:[l+1,"."]}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:o.status==="next"?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:o.status==="done"?"text-slate-500 line-through leading-snug":o.status==="next"?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label}),o.status==="done"&&e.jsx("span",{className:"text-emerald-700 shrink-0 font-mono","aria-label":"step complete",children:"✓"})]},l)})})]})}function _r({current:t,total:s}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg bg-white p-4 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:typeof t=="number"&&typeof s=="number"?`State ${t} of ${s}. Grade will appear when the scan completes.`:"Grade will appear when the scan completes."})]})]})}function Dr({scannedAt:t}){const s=Date.now()-new Date(t).getTime();return e.jsxs("div",{className:"bg-amber-50 border-b border-amber-200 px-3 py-1.5 text-[11px] text-amber-900 flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),e.jsxs("span",{children:["Showing a previous scan (",ha(s)," old). Re-scan to grade the current page state."]})]})}function ha(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 xa(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function bs(t){if(!xa())return!1;const s=chrome.devtools;return await new Promise(a=>{const r=`(function(){
3
3
  try {
4
4
  var el = document.querySelector(${JSON.stringify(t)});
5
5
  if (el) { inspect(el); return true; }
6
6
  return false;
7
7
  } catch (err) { return false; }
8
- })()`;s.inspectedWindow.eval(r,(i,o)=>{a(o?!1:i===!0)})})}const fs=.022,Dr=1.414,wt=2.4,Or=.2126729,Fr=.7151522,Mr=.072175,Pr=.56,Gr=.57,Vr=.62,Wr=.65,bs=1.14,vs=.1,Br=.027,Hr=.027,Kr=5e-4;function ys(t,s,a){const n=t/255,r=s/255,i=a/255;return Or*Math.pow(n,wt)+Fr*Math.pow(r,wt)+Mr*Math.pow(i,wt)}function ws(t){return t<0?0:t<fs?t+Math.pow(fs-t,Dr):t}function zr(t,s){const a=ws(ys(t[0],t[1],t[2])),n=ws(ys(s[0],s[1],s[2]));if(Math.abs(n-a)<Kr)return 0;let r=0;return n>a?(r=(Math.pow(n,Pr)-Math.pow(a,Gr))*bs,r<vs?0:(r-Br)*100):(r=(Math.pow(n,Wr)-Math.pow(a,Vr))*bs,r>-vs?0:(r+Hr)*100)}function js(t){const s=t.trim().replace(/^#/,"");if(s.length===3){const a=parseInt(s[0]+s[0],16),n=parseInt(s[1]+s[1],16),r=parseInt(s[2]+s[2],16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}if(s.length===6){const a=parseInt(s.slice(0,2),16),n=parseInt(s.slice(2,4),16),r=parseInt(s.slice(4,6),16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}return null}function qr(t,s,a=75){const n=js(t),r=js(s);if(!n||!r)return null;const i=zr(n,r);return{lc:i,passes:Math.abs(i)>=a,threshold:a}}const Me={"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 Qr(t){return/^wcag\d/.test(t.wcagCriterion)?[Me["ada-iii"],Me[508],Me.eaa,Me["en-301-549"],Me.aoda]:[]}const Yr={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 Ye({violation:t,alreadyAcknowledged:s}){const a=v(g=>g.pinnedMatchKey),n=v(g=>g.pinnedFound),r=v(g=>g.setPinned),i=v(g=>{var y;return(y=g.results[0])==null?void 0:y.frameId}),o=v(g=>{var y;return(y=g.results[0])==null?void 0:y.scope}),l=v(g=>g.results),d=v(g=>g.acknowledgedKeys.has(t.matchKey)),u=v(g=>g.markAcknowledged),c=v(g=>g.markUnacknowledged),p=s||d,m=Ht(t.matchKey),x=v(g=>g.dismissedKeys.has(m)),f=v(g=>g.markDismissed),w=v(g=>g.markUndismissed),A=a===t.matchKey,$=A&&!n;async function T(g){try{return(await Ie(g,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:g,selector:t.target.selector},i)).found}catch{return!0}}async function j(){const g=await ce();if(!g)return;if(A){r(null);try{await be(g,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:g},i)}catch{}return}const y=await T(g);r(t.matchKey,y)}function b(g){g.stopPropagation(),t.currentState.breakpoint.width<=640&&ia(),(async()=>{const y=await ce();if(!y)return;try{await J({type:"STATE_DRIVE_REQUEST",tabId:y,state:t.currentState,scope:o,frameId:i})}catch{}const C=await T(y);r(t.matchKey,C)})()}async function I(g){g.stopPropagation();const y=await ce();if(!y)return;try{await J({type:"STATE_DRIVE_REQUEST",tabId:y,state:si(),scope:o,frameId:i})}catch{de({type:"STATE_RESET_REQUEST",tabId:y})}const C=await T(y);r(t.matchKey,C)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:j,"aria-pressed":A,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
9
- ${A?"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 ${Yr[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(ai,{violation:t}),e.jsx(ii,{violation:t}),e.jsx(ri,{violation:t}),e.jsx(ni,{text:t.target.failureSummary}),e.jsx(oi,{ruleId:t.ruleId}),A&&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: ",Jr(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:b,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),b(g))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:I,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),I(g))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),ha()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:g=>{g.preventDefault(),g.stopPropagation(),gs(t.target.selector)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),gs(t.target.selector))},title:"Focus this element in the DevTools Elements tab",className:"text-brand-600 hover:underline cursor-pointer","data-testid":"reveal-in-elements",children:"Reveal in Elements"})]}),$&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap text-xs",children:[t.needsReview&&(p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Verified OK"}),e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),c(t.matchKey),Zr(t,l)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),u(t.matchKey),Xr(t,l)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},title:"The rule was right to flag this — I verified the content is fine. Surfaces in the AI fix prompt's 'Previously verified by human' section.",className:"px-2 py-0.5 border border-emerald-300 bg-emerald-50 text-emerald-800 rounded hover:bg-emerald-100 cursor-pointer",children:"✓ Verified OK"})),x?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700 font-semibold",children:"✗ Dismissed"}),e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),w(m),ti(t,l)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),f(m),ei(t,l,m)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},title:"The rule itself is wrong about this page — false positive. Suppresses this finding from future audits on this URL + filters it from the AI fix prompt.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"✗ Not a real issue"})]}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:g=>g.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Jr(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 Xr(t,s){await za({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await bt(t.componentId,s)}async function Zr(t,s){await Ka(t.componentId,t.matchKey),await bt(t.componentId,s)}async function ei(t,s,a){var o,l;const n=((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??"";if(!n)return;const r=(t.target.outerHTML??t.target.selector).slice(0,200),i=`Marked "not a real issue" via Findings UI (${t.ruleId} on ${t.target.selector})`;await qt(n,a,i,r),await bt(t.componentId,s)}async function ti(t,s){var n,r;const a=((n=s[0])==null?void 0:n.pageUrl)??((r=s[0])==null?void 0:r.scope)??"";a&&(await Qt(a,Ht(t.matchKey)),await bt(t.componentId,s))}async function bt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await J({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});v.getState().setDelta(n.delta)}catch{}}function si(){const t=Bt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function xa(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 ai({violation:t}){const s=xa(t);if(!s)return null;const a=s.ratio>=s.required,n=qr(s.fg,s.bg,75),r=(n==null?void 0:n.passes)??!1;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] flex-wrap",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]}),n&&e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${r?"border-emerald-300 bg-emerald-50 text-emerald-800":"border-amber-300 bg-amber-50 text-amber-800"}`,title:"APCA Lc — the contrast algorithm WCAG 3 is built around. Signed: positive = dark text on light, negative = light on dark. |Lc| ≥ 75 typically required for body text.","data-testid":"apca-lc",children:["APCA Lc ",n.lc.toFixed(1)]})]})}function ni({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 ri({violation:t}){const s=Qr(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 ii({violation:t}){const s=xa(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return Ha(t.matchKey).then(o=>{o&&!i&&n({kind:"ready",suggestion:o})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await J({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(d=>d.matchKey===t.matchKey);l?(await qa(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function oi({ruleId:t}){const s=Qa(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}function li(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function ga(t){return`${_e(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function ci(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=ga(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 Ns={critical:0,serious:1,moderate:2,minor:3},di={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function ui({results:t,interactiveVerdicts:s,aiResolvedFails:a}){const n=t.length,r=t.flatMap(p=>p.violations),i=ci(t);i.sort((p,m)=>{const x=Ns[p.representative.impact]??99,f=Ns[m.representative.impact]??99;return x!==f?x-f:m.states.length-p.states.length});const o=Yt({violations:r,auditRan:!0,manualRuns:[],workflows:xe,heuristicCounts:{},interactiveAuditVerdicts:s}),l=new Map;for(const p of Te)l.set(p.id,[]);const d=[];for(const p of i){let m=!1;for(const x of Te)if(x.axeRules.includes(p.representative.ruleId)){l.get(x.id).push(p),m=!0;break}m||d.push(p)}const u=new Map;for(const p of Te)u.set(p.id,[]);const c=[];for(const p of a??[]){let m=!1;for(const x of Te)if(x.axeRules.includes(p.ruleId)){u.get(x.id).push(p),m=!0;break}m||c.push(p)}return e.jsxs("div",{className:"space-y-1.5",children:[o.subGrades.map(p=>e.jsx(ks,{subGrade:p,groups:l.get(p.id)??[],totalStates:n,aiFails:u.get(p.id)??[]},p.id)),(d.length>0||c.length>0)&&e.jsx(ks,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:d,totalStates:n,aiFails:c})]})}function ks({subGrade:t,groups:s,totalStates:a,aiFails:n}){const[r,i]=h.useState(!1),o=v(j=>j.pendingAreaExpand),l=v(j=>j.setPendingAreaExpand);h.useEffect(()=>{o===t.id&&(i(!0),l(null),requestAnimationFrame(()=>{const j=document.querySelector(`[data-area-card="${t.id}"]`);j==null||j.scrollIntoView({behavior:"smooth",block:"start"})}))},[o,t.id,l]);const[d,u]=h.useState("idle"),[c,p]=h.useState(null),[m,x]=h.useState(0),f=s.length>0||n.length>0,w=di[t.letter],A=s.filter(j=>j.representative.ruleId==="color-contrast"||j.representative.ruleId==="color-contrast-enhanced"),$=A.length>=2;async function T(j){j.stopPropagation(),u("loading"),p(null);try{const b=A.map(g=>{const y=g.representative.target.outerHTML,C=g.representative.target.failureSummary,S=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(C),R=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(C);if(!S||!R)return null;const K=g.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:g.representative.matchKey,foreground:S[1],background:R[1],fontSize:16,fontWeight:400,targetLevel:K,_html:y}}).filter(g=>g!==null);if(b.length===0){u("error"),p("Could not parse fg/bg colors from the violation failure summaries.");return}const I=await J({type:"AI_COLOR_SUGGEST_REQUEST",inputs:b.map(({_html:g,...y})=>y)});if(I.unavailableReason&&I.results.length===0){u("error"),p(I.unavailableReason);return}await Ya(I.results),u("done"),x(g=>g+1),r||i(!0)}catch(b){u("error"),p(b instanceof Error?b.message:String(b))}}return e.jsxs("div",{"data-area-card":t.id,className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(j=>!j),"aria-expanded":r,disabled:!f,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold font-display ${w}`,"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:f?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),$&&e.jsx("span",{role:"button",tabIndex:0,onClick:j=>void T(j),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),T(j))},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 ${A.length} contrast issues at once`,children:d==="loading"?"Asking AI…":d==="done"?`✓ Suggested for all ${A.length}`:`✨ Suggest for all ${A.length}`}),f&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0 font-mono","aria-hidden":"true",children:r?"−":"+"})]}),d==="error"&&c&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:c}),r&&f&&e.jsxs("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:[s.map(j=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ye,{violation:j.representative}),e.jsx(pi,{states:j.states,totalStates:a})]},`${ga(j.representative)}::${m}`)),n.length>0&&e.jsxs(e.Fragment,{children:[s.length>0&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI-resolved fails (",n.length,")"]}),n.map(j=>e.jsx(mi,{fail:j},`${j.ruleId}::${j.selector}`))]})]})]})}function pi({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(li))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
10
- `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}function mi({fail:t}){const[s,a]=h.useState(!1),[n,r]=h.useState(!1);async function i(){a(!0);try{const{saveResolutions:o}=await ke(async()=>{const{saveResolutions:l}=await import("./scheduled-audit-runner-V0TlccxL.js").then(d=>d.aE);return{saveResolutions:l}},__vite__mapDeps([0,1,2,3]));await o([{...t,verdict:"pass",reasoning:`[Human override — visually verified by user] ${t.reasoning}`,resolvedAt:new Date().toISOString()}]),r(!0)}finally{a(!1)}}return e.jsxs("div",{className:`border rounded-md bg-white p-2 text-[11px] ${n?"border-emerald-200 bg-emerald-50":"border-rose-200"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[10px] text-rose-700",children:t.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold ${n?"bg-emerald-100 text-emerald-800":"bg-rose-100 text-rose-900"}`,children:n?"✓ Resolved":"AI verdict: FAIL"})]}),e.jsx("p",{className:"font-mono text-[10px] text-slate-700 mb-1 break-all",children:t.selector}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:t.reasoning}),!n&&e.jsx("button",{type:"button",onClick:()=>void i(),disabled:s,className:"px-2 py-1 text-[11px] font-medium bg-white border border-emerald-300 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50",title:"Override the AI's fail determination — your human visual judgment is the highest authority per WCAG-EM. Use when you've verified the contrast / labeling is actually fine.",children:"✓ Mark as resolved (override AI)"})]})}const Ss="igtRuns";async function hi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Ss))[Ss];return s&&typeof s=="object"?s:{}}async function xi(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await hi())[t];if(i)for(const d of xe){const u=i[d.id];if(u)for(const c of d.steps){if(!c.autoDismissActivity||((l=(o=u.steps)==null?void 0:o[c.id])==null?void 0:l.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Qe(n,x.map(f=>({key:qe(f.selector),reason:m,snippet:`${f.selector} — ${f.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Qe(n,x.map(f=>({key:ze(f.selector),reason:m,snippet:`${f.selector} — ${f.textSnippet||"(no text)"}`})))}}}}const gi=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"]),fi=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 bi(t){return gi.has(t.ruleId)}function vi(t){return fi.has(t.ruleId)}function yi(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function fa(){var V,W,L,U;const t=v(k=>k.results),s=v(k=>k.delta),a=v(k=>k.componentId),n=((V=t[0])==null?void 0:V.pageUrl)??((W=t[0])==null?void 0:W.scope)??"",[r,i]=h.useState({}),[o,l]=h.useState(!1),[d,u]=h.useState(!1);h.useEffect(()=>{if(!a){l(!1),u(!1);return}let k=!1;return(async()=>{const O=await Je(a);if(k)return;const M=O.some(E=>E.criterionId==="2.1.2"&&E.verdict==="pass"),ee=O.some(E=>E.criterionId==="1.3.2");l(M),u(ee)})(),()=>{k=!0}},[a]);const[c,p]=h.useState(0);h.useEffect(()=>{if(!n)return;let k=!1;return(async()=>{if(a&&t.length>0)try{await xi(a,t)}catch{}if(k)return;const O=await zt(n);k||i(O)})(),()=>{k=!0}},[n,c,a,t]);async function m(k,O){if(!n)return;const M=window.prompt(`Why is this finding a false positive?
8
+ })()`;s.inspectedWindow.eval(r,(i,o)=>{a(o?!1:i===!0)})})}const vs=.022,Or=1.414,kt=2.4,Fr=.2126729,Mr=.7151522,Pr=.072175,Gr=.56,Vr=.57,Wr=.62,Br=.65,ys=1.14,ws=.1,Hr=.027,Kr=.027,zr=5e-4;function js(t,s,a){const n=t/255,r=s/255,i=a/255;return Fr*Math.pow(n,kt)+Mr*Math.pow(r,kt)+Pr*Math.pow(i,kt)}function Ns(t){return t<0?0:t<vs?t+Math.pow(vs-t,Or):t}function qr(t,s){const a=Ns(js(t[0],t[1],t[2])),n=Ns(js(s[0],s[1],s[2]));if(Math.abs(n-a)<zr)return 0;let r=0;return n>a?(r=(Math.pow(n,Gr)-Math.pow(a,Vr))*ys,r<ws?0:(r-Hr)*100):(r=(Math.pow(n,Br)-Math.pow(a,Wr))*ys,r>-ws?0:(r+Kr)*100)}function ks(t){const s=t.trim().replace(/^#/,"");if(s.length===3){const a=parseInt(s[0]+s[0],16),n=parseInt(s[1]+s[1],16),r=parseInt(s[2]+s[2],16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}if(s.length===6){const a=parseInt(s.slice(0,2),16),n=parseInt(s.slice(2,4),16),r=parseInt(s.slice(4,6),16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}return null}function Qr(t,s,a=75){const n=ks(t),r=ks(s);if(!n||!r)return null;const i=qr(n,r);return{lc:i,passes:Math.abs(i)>=a,threshold:a}}const Pe={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Yr(t){return/^wcag\d/.test(t.wcagCriterion)?[Pe["ada-iii"],Pe[508],Pe.eaa,Pe["en-301-549"],Pe.aoda]:[]}const Jr={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Je({violation:t,alreadyAcknowledged:s}){const a=v(g=>g.pinnedMatchKey),n=v(g=>g.pinnedFound),r=v(g=>g.setPinned),i=v(g=>{var y;return(y=g.results[0])==null?void 0:y.frameId}),o=v(g=>{var y;return(y=g.results[0])==null?void 0:y.scope}),l=v(g=>g.results),d=v(g=>g.acknowledgedKeys.has(t.matchKey)),u=v(g=>g.markAcknowledged),c=v(g=>g.markUnacknowledged),p=s||d,m=zt(t.matchKey),x=v(g=>g.dismissedKeys.has(m)),f=v(g=>g.markDismissed),w=v(g=>g.markUndismissed),j=a===t.matchKey,$=j&&!n;async function R(g){try{return(await Ie(g,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:g,selector:t.target.selector},i)).found}catch{return!0}}async function N(){const g=await de();if(!g)return;if(j){r(null);try{await be(g,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:g},i)}catch{}return}const y=await R(g);r(t.matchKey,y)}function b(g){g.stopPropagation(),t.currentState.breakpoint.width<=640&&oa(),(async()=>{const y=await de();if(!y)return;try{await J({type:"STATE_DRIVE_REQUEST",tabId:y,state:t.currentState,scope:o,frameId:i})}catch{}const C=await R(y);r(t.matchKey,C)})()}async function I(g){g.stopPropagation();const y=await de();if(!y)return;try{await J({type:"STATE_DRIVE_REQUEST",tabId:y,state:ai(),scope:o,frameId:i})}catch{le({type:"STATE_RESET_REQUEST",tabId:y})}const C=await R(y);r(t.matchKey,C)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:N,"aria-pressed":j,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
9
+ ${j?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Jr[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(ni,{violation:t}),e.jsx(oi,{violation:t}),e.jsx(ii,{violation:t}),e.jsx(ri,{text:t.target.failureSummary}),e.jsx(li,{ruleId:t.ruleId}),j&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",Xr(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:b,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),b(g))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:I,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),I(g))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),xa()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:g=>{g.preventDefault(),g.stopPropagation(),bs(t.target.selector)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),bs(t.target.selector))},title:"Focus this element in the DevTools Elements tab",className:"text-brand-600 hover:underline cursor-pointer","data-testid":"reveal-in-elements",children:"Reveal in Elements"})]}),$&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap text-xs",children:[t.needsReview&&(p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Verified OK"}),e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),c(t.matchKey),ei(t,l)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),u(t.matchKey),Zr(t,l)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},title:"The rule was right to flag this — I verified the content is fine. Surfaces in the AI fix prompt's 'Previously verified by human' section.",className:"px-2 py-0.5 border border-emerald-300 bg-emerald-50 text-emerald-800 rounded hover:bg-emerald-100 cursor-pointer",children:"✓ Verified OK"})),x?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700 font-semibold",children:"✗ Dismissed"}),e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),w(m),si(t,l)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),f(m),ti(t,l,m)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},title:"The rule itself is wrong about this page — false positive. Suppresses this finding from future audits on this URL + filters it from the AI fix prompt.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"✗ Not a real issue"})]}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:g=>g.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Xr(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function Zr(t,s){await qa({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await wt(t.componentId,s)}async function ei(t,s){await za(t.componentId,t.matchKey),await wt(t.componentId,s)}async function ti(t,s,a){var o,l;const n=((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??"";if(!n)return;const r=(t.target.outerHTML??t.target.selector).slice(0,200),i=`Marked "not a real issue" via Findings UI (${t.ruleId} on ${t.target.selector})`;await Yt(n,a,i,r),await wt(t.componentId,s)}async function si(t,s){var n,r;const a=((n=s[0])==null?void 0:n.pageUrl)??((r=s[0])==null?void 0:r.scope)??"";a&&(await Jt(a,zt(t.matchKey)),await wt(t.componentId,s))}async function wt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await J({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});v.getState().setDelta(n.delta)}catch{}}function ai(){const t=Kt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function ga(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 ni({violation:t}){const s=ga(t);if(!s)return null;const a=s.ratio>=s.required,n=Qr(s.fg,s.bg,75),r=(n==null?void 0:n.passes)??!1;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] flex-wrap",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]}),n&&e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${r?"border-emerald-300 bg-emerald-50 text-emerald-800":"border-amber-300 bg-amber-50 text-amber-800"}`,title:"APCA Lc — the contrast algorithm WCAG 3 is built around. Signed: positive = dark text on light, negative = light on dark. |Lc| ≥ 75 typically required for body text.","data-testid":"apca-lc",children:["APCA Lc ",n.lc.toFixed(1)]})]})}function ri({text:t}){return t?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-slate-500 cursor-pointer hover:text-slate-700",children:"Show failure detail"}),e.jsx("pre",{className:"text-[11px] text-slate-600 whitespace-pre-wrap mt-1 bg-slate-50 p-1.5 rounded",children:t})]}):null}function ii({violation:t}){const s=Yr(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function oi({violation:t}){const s=ga(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return Ka(t.matchKey).then(o=>{o&&!i&&n({kind:"ready",suggestion:o})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await J({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(d=>d.matchKey===t.matchKey);l?(await Qa(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function li({ruleId:t}){const s=Ya(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}function ci(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function fa(t){return`${_e(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function di(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=fa(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 Ss={critical:0,serious:1,moderate:2,minor:3},ui={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function pi({results:t,interactiveVerdicts:s,aiResolvedFails:a}){const n=t.length,r=t.flatMap(p=>p.violations),i=di(t);i.sort((p,m)=>{const x=Ss[p.representative.impact]??99,f=Ss[m.representative.impact]??99;return x!==f?x-f:m.states.length-p.states.length});const o=Xt({violations:r,auditRan:!0,manualRuns:[],workflows:xe,heuristicCounts:{},interactiveAuditVerdicts:s}),l=new Map;for(const p of Te)l.set(p.id,[]);const d=[];for(const p of i){let m=!1;for(const x of Te)if(x.axeRules.includes(p.representative.ruleId)){l.get(x.id).push(p),m=!0;break}m||d.push(p)}const u=new Map;for(const p of Te)u.set(p.id,[]);const c=[];for(const p of a??[]){let m=!1;for(const x of Te)if(x.axeRules.includes(p.ruleId)){u.get(x.id).push(p),m=!0;break}m||c.push(p)}return e.jsxs("div",{className:"space-y-1.5",children:[o.subGrades.map(p=>e.jsx(As,{subGrade:p,groups:l.get(p.id)??[],totalStates:n,aiFails:u.get(p.id)??[]},p.id)),(d.length>0||c.length>0)&&e.jsx(As,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:d,totalStates:n,aiFails:c})]})}function As({subGrade:t,groups:s,totalStates:a,aiFails:n}){const[r,i]=h.useState(!1),o=v(N=>N.pendingAreaExpand),l=v(N=>N.setPendingAreaExpand);h.useEffect(()=>{o===t.id&&(i(!0),l(null),requestAnimationFrame(()=>{const N=document.querySelector(`[data-area-card="${t.id}"]`);N==null||N.scrollIntoView({behavior:"smooth",block:"start"})}))},[o,t.id,l]);const[d,u]=h.useState("idle"),[c,p]=h.useState(null),[m,x]=h.useState(0),f=s.length>0||n.length>0,w=ui[t.letter],j=s.filter(N=>N.representative.ruleId==="color-contrast"||N.representative.ruleId==="color-contrast-enhanced"),$=j.length>=2;async function R(N){N.stopPropagation(),u("loading"),p(null);try{const b=j.map(g=>{const y=g.representative.target.outerHTML,C=g.representative.target.failureSummary,S=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(C),T=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(C);if(!S||!T)return null;const H=g.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:g.representative.matchKey,foreground:S[1],background:T[1],fontSize:16,fontWeight:400,targetLevel:H,_html:y}}).filter(g=>g!==null);if(b.length===0){u("error"),p("Could not parse fg/bg colors from the violation failure summaries.");return}const I=await J({type:"AI_COLOR_SUGGEST_REQUEST",inputs:b.map(({_html:g,...y})=>y)});if(I.unavailableReason&&I.results.length===0){u("error"),p(I.unavailableReason);return}await Ja(I.results),u("done"),x(g=>g+1),r||i(!0)}catch(b){u("error"),p(b instanceof Error?b.message:String(b))}}return e.jsxs("div",{"data-area-card":t.id,className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(N=>!N),"aria-expanded":r,disabled:!f,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold font-display ${w}`,"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:f?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),$&&e.jsx("span",{role:"button",tabIndex:0,onClick:N=>void R(N),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),R(N))},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 ${j.length} contrast issues at once`,children:d==="loading"?"Asking AI…":d==="done"?`✓ Suggested for all ${j.length}`:`✨ Suggest for all ${j.length}`}),f&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0 font-mono","aria-hidden":"true",children:r?"−":"+"})]}),d==="error"&&c&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:c}),r&&f&&e.jsxs("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:[s.map(N=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Je,{violation:N.representative}),e.jsx(mi,{states:N.states,totalStates:a})]},`${fa(N.representative)}::${m}`)),n.length>0&&e.jsxs(e.Fragment,{children:[s.length>0&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI-resolved fails (",n.length,")"]}),n.map(N=>e.jsx(hi,{fail:N},`${N.ruleId}::${N.selector}`))]})]})]})}function mi({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(ci))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
10
+ `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}function hi({fail:t}){const[s,a]=h.useState(!1),[n,r]=h.useState(!1);async function i(){a(!0);try{const{saveResolutions:o}=await ke(async()=>{const{saveResolutions:l}=await import("./scheduled-audit-runner-r1WNrwB5.js").then(d=>d.aF);return{saveResolutions:l}},__vite__mapDeps([0,1,2,3]));await o([{...t,verdict:"pass",reasoning:`[Human override — visually verified by user] ${t.reasoning}`,resolvedAt:new Date().toISOString()}]),r(!0)}finally{a(!1)}}return e.jsxs("div",{className:`border rounded-md bg-white p-2 text-[11px] ${n?"border-emerald-200 bg-emerald-50":"border-rose-200"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[10px] text-rose-700",children:t.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold ${n?"bg-emerald-100 text-emerald-800":"bg-rose-100 text-rose-900"}`,children:n?"✓ Resolved":"AI verdict: FAIL"})]}),e.jsx("p",{className:"font-mono text-[10px] text-slate-700 mb-1 break-all",children:t.selector}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:t.reasoning}),!n&&e.jsx("button",{type:"button",onClick:()=>void i(),disabled:s,className:"px-2 py-1 text-[11px] font-medium bg-white border border-emerald-300 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50",title:"Override the AI's fail determination — your human visual judgment is the highest authority per WCAG-EM. Use when you've verified the contrast / labeling is actually fine.",children:"✓ Mark as resolved (override AI)"})]})}const Cs="igtRuns";async function xi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Cs))[Cs];return s&&typeof s=="object"?s:{}}async function gi(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await xi())[t];if(i)for(const d of xe){const u=i[d.id];if(u)for(const c of d.steps){if(!c.autoDismissActivity||((l=(o=u.steps)==null?void 0:o[c.id])==null?void 0:l.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Ye(n,x.map(f=>({key:Qe(f.selector),reason:m,snippet:`${f.selector} — ${f.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Ye(n,x.map(f=>({key:qe(f.selector),reason:m,snippet:`${f.selector} — ${f.textSnippet||"(no text)"}`})))}}}}const fi=new Set(["heading-order","page-has-heading-one","empty-heading","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","landmark-banner-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-complementary-is-top-level","landmark-unique","region","bypass","duplicate-id","duplicate-id-aria","duplicate-id-active"]),bi=new Set(["label","label-content-name-mismatch","label-title-only","form-field-multiple-labels","input-button-name","input-image-alt","autocomplete-valid","aria-required-attr","aria-required-children","aria-required-parent","aria-input-field-name","aria-toggle-field-name","select-name","button-name"]);function vi(t){return fi.has(t.ruleId)}function yi(t){return bi.has(t.ruleId)}function wi(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function ba(){var V,W,L,U;const t=v(A=>A.results),s=v(A=>A.delta),a=v(A=>A.componentId),n=((V=t[0])==null?void 0:V.pageUrl)??((W=t[0])==null?void 0:W.scope)??"",[r,i]=h.useState({}),[o,l]=h.useState(!1),[d,u]=h.useState(!1);h.useEffect(()=>{if(!a){l(!1),u(!1);return}let A=!1;return(async()=>{const O=await Oe(a);if(A)return;const M=O.some(E=>E.criterionId==="2.1.2"&&E.verdict==="pass"),ee=O.some(E=>E.criterionId==="1.3.2");l(M),u(ee)})(),()=>{A=!0}},[a]);const[c,p]=h.useState(0);h.useEffect(()=>{if(!n)return;let A=!1;return(async()=>{if(a&&t.length>0)try{await gi(a,t)}catch{}if(A)return;const O=await Qt(n);A||i(O)})(),()=>{A=!0}},[n,c,a,t]);async function m(A,O){if(!n)return;const M=window.prompt(`Why is this finding a false positive?
11
11
 
12
- (Recorded with the dismissal so future you remembers the reasoning.)`,"");M!==null&&(await qt(n,k,M||"(no reason given)",O),p(ee=>ee+1))}async function x(k){n&&(await Qt(n,k),p(O=>O+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 f=t.reduce((k,O)=>{var M;return k+(((M=O.announcements)==null?void 0:M.length)??0)},0),w=t.reduce((k,O)=>{var M;return k+(((M=O.focusEvents)==null?void 0:M.length)??0)},0),A=t.reduce((k,O)=>{var M;return k+(((M=O.focusEvents)==null?void 0:M.filter(ee=>ee.isFocusReset).length)??0)},0),$=As(t,bi),T=As(t,vi),j=$.length,b=T.length,I=d?[]:((L=t[0])==null?void 0:L.readingOrderIssues)??[],g=o?[]:((U=t[0])==null?void 0:U.tabOrderIssues)??[],y=I.filter(k=>!(ze(k.selector)in r)),C=I.filter(k=>ze(k.selector)in r),S=g.filter(k=>!(qe(k.selector)in r)),R=g.filter(k=>qe(k.selector)in r);if(f===0&&w===0&&j===0&&b===0&&y.length===0&&S.length===0&&C.length===0&&R.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const K=C.length+R.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[j," structural · ",b," form ·"," ",S.length," tab-order ·"," ",y.length," reading-order ·"," ",f," ",f===1?"announcement":"announcements"," ·"," ",w," focus ",w===1?"event":"events",A>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",A," focus reset",A===1?"":"s"]}),K>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",K," dismissed"]})]}),S.length>0&&e.jsx(Ni,{issues:S,onDismiss:m}),y.length>0&&e.jsx(ki,{issues:y,onDismiss:m}),K>0&&e.jsx(Si,{dismissedReadingOrder:C,dismissedTabOrder:R,dismissals:r,onRestore:x}),j>0&&e.jsx(Cs,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:$}),b>0&&e.jsx(Cs,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:T}),e.jsx(wi,{delta:s}),t.map((k,O)=>{const M=k.announcements??[],ee=k.focusEvents??[];return M.length===0&&ee.length===0?null:e.jsx(ji,{state:k.state,announcements:M,focusEvents:ee},O)})]})}function wi({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 As(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=_e(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function Cs({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 ji({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:yi(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 Ni({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 ki({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 Si({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const d=`tab-order::${l.selector}`,u=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,u=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Ai={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 Ci({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Ye,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Ai[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,u)=>e.jsx(Ye,{violation:d},u))})]})}function Ii(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 Ei={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function ba({open:t,onClose:s,format:a,content:n,filename:r}){const i=An(new Blob([n]).size);function o(){Xe(n,r),s()}function l(){$e(n),s()}return e.jsxs(De,{open:t,onClose:s,title:Ei[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Is=7800;function Ri(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,m=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,x=r.find(f=>`${f.ruleId}::${f.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...c,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
13
- `),d=new URLSearchParams({title:i,body:l});let u=`${n}/issues/new?${d.toString()}`;return u.length>Is&&(u=u.slice(0,Is)),{url:u,title:i,body:l}}const Es=7800;function Ti(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,m=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,x=r.find(f=>`${f.ruleId}::${f.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...c,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`Component: ${s??"unknown"}`),o.push(""),o.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`Rule: ${c.ruleId} (${c.impact})`),o.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),o.push(`Description: ${c.description}`),o.push(`Selector: ${c.target.selector}`),o.push(`Found in state(s): ${c._states.join(", ")}`),c.helpUrl&&o.push(`More info: ${c.helpUrl}`),o.push(""),o.push(`HTML: ${c.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const l=o.join(`
14
- `),d=new URLSearchParams({summary:i,description:l});let u=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return u.length>Es&&(u=u.slice(0,Es)),{url:u,summary:i,description:l}}const Rs=7800;function $i(t,s,a,n="Bug"){const r=t.replace(/\/$/,""),i=[];for(const p of a){const m=`${p.ruleId}::${p.target.selector}`,x=`:${p.currentState.pseudoState} · ${p.currentState.theme} · ${p.currentState.direction}`,f=i.find(w=>`${w.ruleId}::${w.target.selector}`===m);if(f){f._states.includes(x)||f._states.push(x);continue}i.push({...p,_states:[x]})}const o=`a11y: ${i.length} new violation${i.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const p of i)l.push(`### \`${p.ruleId}\` — ${p.impact}`),l.push(""),l.push(p.description),l.push(""),l.push(`- **WCAG:** ${p.wcagCriterion} (${p.wcagLevel})`),l.push(`- **Selector:** \`${p.target.selector}\``),l.push(`- **Found in state(s):** ${p._states.join(", ")}`),p.helpUrl&&l.push(`- **More info:** ${p.helpUrl}`),l.push(""),l.push("```html"),l.push(p.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const d=l.join(`
15
- `),u=new URLSearchParams({"[Title]":o,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${u.toString()}`;return c.length>Rs&&(c=c.slice(0,Rs)),{url:c,title:o,description:d}}const Ts=7800;function Li(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,m=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,x=r.find(f=>`${f.ruleId}::${f.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...c,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
16
- `),d=new URLSearchParams({"issue[title]":i,"issue[description]":l});let u=`${n}/-/issues/new?${d.toString()}`;return u.length>Ts&&(u=u.slice(0,Ts)),{url:u,title:i,description:l}}const $s=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Ui=["wcag-component-auditor","wcag-forensic-log"];async function _i(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get($s);s=Object.keys(n).length,await chrome.storage.local.remove($s)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Ui)try{await Di(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 Di(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 Dt="accessibilityStatementInputs:v1";async function Oi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(Dt))[Dt];return s&&typeof s=="object"?s:null}async function Fi(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[Dt]:t})}function va({open:t,onClose:s,results:a,siteCrawlSource:n}){const[r,i]=h.useState("eaa"),[o,l]=h.useState(""),[d,u]=h.useState(""),[c,p]=h.useState("partial"),[m,x]=h.useState(""),[f,w]=h.useState(""),[A,$]=h.useState(""),[T,j]=h.useState(""),[b,I]=h.useState("English"),[g,y]=h.useState("wcagcheckr (self-evaluation)"),[C,S]=h.useState("2.1"),[R,K]=h.useState("AA"),[V,W]=h.useState(!1),[L,U]=h.useState(null),k=h.useRef(null);if(h.useEffect(()=>{t&&(async()=>{var P,ne,N,G;const E=await Oi();if(E&&(E.framing&&i(E.framing),E.organizationName&&l(E.organizationName),E.siteUrl&&u(E.siteUrl),E.conformanceStatus&&p(E.conformanceStatus),(P=E.contact)!=null&&P.email&&x(E.contact.email),(ne=E.contact)!=null&&ne.phone&&w(E.contact.phone),(N=E.contact)!=null&&N.formUrl&&$(E.contact.formUrl),E.countryCode&&j(E.countryCode),E.language&&I(E.language),E.auditedBy&&y(E.auditedBy),E.wcagVersion&&S(E.wcagVersion),E.wcagLevel&&K(E.wcagLevel)),!(E!=null&&E.siteUrl)&&((G=a[0])!=null&&G.pageUrl))try{const H=new URL(a[0].pageUrl);u(`${H.protocol}//${H.host}/`)}catch{}E!=null&&E.conformanceStatus||p(Ja(a)),setTimeout(()=>{var H;return(H=k.current)==null?void 0:H.focus()},50)})()},[t,a]),!t)return null;function O(){var N;const E=new Date().toISOString().slice(0,10),P=(N=a[0])!=null&&N.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):E,ne={};return m.trim()&&(ne.email=m.trim()),f.trim()&&(ne.phone=f.trim()),A.trim()&&(ne.formUrl=A.trim()),{framing:r,organizationName:o.trim(),siteUrl:d.trim(),conformanceStatus:c,preparedAt:E,evaluatedAt:P,contact:ne,countryCode:T||null,language:b.trim()||"English",auditedBy:g.trim()||"wcagcheckr (self-evaluation)",wcagVersion:C,wcagLevel:R}}function M(E){if(!E.organizationName)return"Organization name is required.";if(!E.siteUrl)return"Site URL is required.";try{new URL(E.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!E.contact.email&&!E.contact.phone&&!E.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function ee(E){var N;U(null);const P=O(),ne=M(P);if(ne){U(ne);return}W(!0);try{await Fi(P);const G=await J({type:"EXPORT_REQUEST",format:E==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:n?[]:a,siteCrawlSource:n||void 0,statementInputs:P}),H=(G==null?void 0:G.content)??"";if(!H||H.startsWith("# Accessibility statement — error")){U(H||"Export failed — no response.");return}try{await navigator.clipboard.writeText(H)}catch{}const z=new Blob([H],{type:E==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),re=URL.createObjectURL(z);typeof chrome<"u"&&((N=chrome.tabs)!=null&&N.create)?await chrome.tabs.create({url:re,active:!0}).catch(()=>{window.open(re,"_blank","noopener,noreferrer")}):window.open(re,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(re),6e4),s()}catch(G){U(G instanceof Error?G.message:String(G))}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:E=>E.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked:r==="eaa",onChange:()=>i("eaa"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"EAA"})," (Directive 2019/882) — private sector. E-commerce, banking, transport, telecom, e-readers, media. Enforceable June 2025."]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"wad",checked:r==="wad",onChange:()=>i("wad"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"WAD"})," (Directive 2016/2102) — EU public sector. Government, public bodies, education."]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-org",className:"block font-medium mb-1",children:["Organization name ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-org",ref:k,type:"text",value:o,onChange:E=>l(E.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:d,onChange:E=>u(E.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:c,onChange:E=>p(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:C,onChange:E=>S(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:R,onChange:E=>K(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:m,onChange:E=>x(E.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:f,onChange:E=>w(E.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:A,onChange:E=>$(E.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:T,onChange:E=>j(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(Xa).map(([E,P])=>e.jsxs("option",{value:E,children:[E," — ",P.name.replace(/^[A-Z]+\s*—\s*/,"")]},E))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:b,onChange:E=>I(E.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:g,onChange:E=>y(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),L&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:L})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void ee("markdown"),disabled:V,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:V?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void ee("html"),disabled:V,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:V?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:V,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 ya(){const t=v(N=>N.delta),s=v(N=>N.componentId),a=v(N=>N.results),n=v(N=>N.tier),r=v(N=>N.baselineList),i=v(N=>N.siteCrawlReport),[o,l]=h.useState(""),[d,u]=h.useState(""),[c,p]=h.useState(""),[m,x]=h.useState(""),[f,w]=h.useState(!1),[A,$]=h.useState(!1),[T,j]=h.useState(null),[b,I]=h.useState(null),[g,y]=h.useState(!1),[C,S]=h.useState(!1),[R,K]=h.useState(null),[V,W]=h.useState(!1);h.useEffect(()=>{Promise.all([J({type:"SETTINGS_GET",key:"githubRepoUrl"}),J({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),J({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),J({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([N,G,H,z])=>{l(typeof N.data=="string"?N.data:""),u(typeof G.data=="string"?G.data:""),p(typeof H.data=="string"?H.data:""),x(typeof z.data=="string"?z.data:"")})},[]),h.useEffect(()=>ye("BADGE_CLICKED_EVENT",G=>{const H=`viol-row-${G.violationId}`,z=document.getElementById(H);z&&(z.scrollIntoView({behavior:"smooth",block:"center"}),z.classList.add("ring-2","ring-rose-500"),setTimeout(()=>z.classList.remove("ring-2","ring-rose-500"),1500))}),[]),h.useEffect(()=>()=>{(async()=>{const N=await ce();N&&(C&&await be(N,{type:"BADGES_HIDE_REQUEST",tabId:N}).catch(()=>{}),V&&await be(N,{type:"HEATMAP_HIDE_REQUEST",tabId:N}).catch(()=>{}))})()},[]);async function L(){const N=await ce();if(!N){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(C){await be(N,{type:"BADGES_HIDE_REQUEST",tabId:N}).catch(()=>{}),S(!1),K(null);return}const G={critical:4,serious:3,moderate:2,minor:1},H=new Map;for(const ie of a)for(const ue of ie.violations)H.has(ue.matchKey)||H.set(ue.matchKey,ue);const re=Array.from(H.values()).sort((ie,ue)=>G[ue.impact]-G[ie.impact]).map((ie,ue)=>({id:ie.matchKey,index:ue+1,selector:ie.target.selector,impact:ie.impact,ruleId:ie.ruleId,wcagCriterion:ie.wcagCriterion}));if(re.length===0){he.polite("No violations to badge.");return}const se=await Ie(N,{type:"BADGES_SHOW_REQUEST",tabId:N,violations:re}).catch(()=>null);se&&(S(!0),K({rendered:se.rendered,requested:se.requested,clustered:se.clustered}),he.polite(`${se.rendered} violation badges shown on the page.`))}async function U(){const N=await ce();if(!N){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(V){await be(N,{type:"HEATMAP_HIDE_REQUEST",tabId:N}).catch(()=>{}),W(!1);return}const G=new Map;for(const re of a)for(const se of re.violations)G.has(se.matchKey)||G.set(se.matchKey,se);const H=Array.from(G.values()).map(re=>({selector:re.target.selector,impact:re.impact}));if(H.length===0){he.polite("No violations to heatmap.");return}const z=await Ie(N,{type:"HEATMAP_SHOW_REQUEST",tabId:N,violations:H}).catch(()=>null);z&&(W(!0),he.polite(`Heatmap shown with ${z.rendered} violation blobs.`))}const k=pt(n,"exportJson"),O=sa[n].maxBaselines,M=r.some(N=>N.componentId===s),ee=M||r.length<O;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 E(){if(!s||a.length===0)return;const N=a.flatMap(ue=>ue.violations),G=a.flatMap(ue=>ue.announcements??[]),H=a.flatMap(ue=>ue.focusEvents??[]),z=a[0],se=(await J({type:"SETTINGS_GET",key:"stateMatrix"})).data??Bt;await de({type:"BASELINE_SET",componentId:s,violations:N,announcements:G,focusEvents:H,snapshotMeta:{url:window.location.href,axeVersion:z.axeVersion,matrixConfig:se,capturedAt:new Date().toISOString()}});const ie=await J({type:"BASELINE_COMPARE",componentId:s,currentViolations:N,announcements:G,focusEvents:H,currentMatrix:se});v.getState().setDelta(ie.delta),he.polite(`Baseline saved for ${s}.`)}async function P(){if(!s||!M||!window.confirm(`Remove the saved baseline for "${s}"?
12
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");M!==null&&(await Yt(n,A,M||"(no reason given)",O),p(ee=>ee+1))}async function x(A){n&&(await Jt(n,A),p(O=>O+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 f=t.reduce((A,O)=>{var M;return A+(((M=O.announcements)==null?void 0:M.length)??0)},0),w=t.reduce((A,O)=>{var M;return A+(((M=O.focusEvents)==null?void 0:M.length)??0)},0),j=t.reduce((A,O)=>{var M;return A+(((M=O.focusEvents)==null?void 0:M.filter(ee=>ee.isFocusReset).length)??0)},0),$=Is(t,vi),R=Is(t,yi),N=$.length,b=R.length,I=d?[]:((L=t[0])==null?void 0:L.readingOrderIssues)??[],g=o?[]:((U=t[0])==null?void 0:U.tabOrderIssues)??[],y=I.filter(A=>!(qe(A.selector)in r)),C=I.filter(A=>qe(A.selector)in r),S=g.filter(A=>!(Qe(A.selector)in r)),T=g.filter(A=>Qe(A.selector)in r);if(f===0&&w===0&&N===0&&b===0&&y.length===0&&S.length===0&&C.length===0&&T.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const H=C.length+T.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[N," structural · ",b," form ·"," ",S.length," tab-order ·"," ",y.length," reading-order ·"," ",f," ",f===1?"announcement":"announcements"," ·"," ",w," focus ",w===1?"event":"events",j>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",j," focus reset",j===1?"":"s"]}),H>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",H," dismissed"]})]}),S.length>0&&e.jsx(ki,{issues:S,onDismiss:m}),y.length>0&&e.jsx(Si,{issues:y,onDismiss:m}),H>0&&e.jsx(Ai,{dismissedReadingOrder:C,dismissedTabOrder:T,dismissals:r,onRestore:x}),N>0&&e.jsx(Es,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:$}),b>0&&e.jsx(Es,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:R}),e.jsx(ji,{delta:s}),t.map((A,O)=>{const M=A.announcements??[],ee=A.focusEvents??[];return M.length===0&&ee.length===0?null:e.jsx(Ni,{state:A.state,announcements:M,focusEvents:ee},O)})]})}function ji({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,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 Is(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=_e(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function Es({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function Ni({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:wi(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function ki({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,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 Si({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Ai({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const d=`tab-order::${l.selector}`,u=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,u=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Ci={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Ii({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Je,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Ci[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,u)=>e.jsx(Je,{violation:d},u))})]})}function Ei(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const Ri={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function va({open:t,onClose:s,format:a,content:n,filename:r}){const i=Cn(new Blob([n]).size);function o(){Xe(n,r),s()}function l(){$e(n),s()}return e.jsxs(De,{open:t,onClose:s,title:Ri[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Rs=7800;function Ti(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,m=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,x=r.find(f=>`${f.ruleId}::${f.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...c,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
13
+ `),d=new URLSearchParams({title:i,body:l});let u=`${n}/issues/new?${d.toString()}`;return u.length>Rs&&(u=u.slice(0,Rs)),{url:u,title:i,body:l}}const Ts=7800;function $i(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,m=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,x=r.find(f=>`${f.ruleId}::${f.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...c,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`Component: ${s??"unknown"}`),o.push(""),o.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`Rule: ${c.ruleId} (${c.impact})`),o.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),o.push(`Description: ${c.description}`),o.push(`Selector: ${c.target.selector}`),o.push(`Found in state(s): ${c._states.join(", ")}`),c.helpUrl&&o.push(`More info: ${c.helpUrl}`),o.push(""),o.push(`HTML: ${c.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const l=o.join(`
14
+ `),d=new URLSearchParams({summary:i,description:l});let u=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return u.length>Ts&&(u=u.slice(0,Ts)),{url:u,summary:i,description:l}}const $s=7800;function Li(t,s,a,n="Bug"){const r=t.replace(/\/$/,""),i=[];for(const p of a){const m=`${p.ruleId}::${p.target.selector}`,x=`:${p.currentState.pseudoState} · ${p.currentState.theme} · ${p.currentState.direction}`,f=i.find(w=>`${w.ruleId}::${w.target.selector}`===m);if(f){f._states.includes(x)||f._states.push(x);continue}i.push({...p,_states:[x]})}const o=`a11y: ${i.length} new violation${i.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const p of i)l.push(`### \`${p.ruleId}\` — ${p.impact}`),l.push(""),l.push(p.description),l.push(""),l.push(`- **WCAG:** ${p.wcagCriterion} (${p.wcagLevel})`),l.push(`- **Selector:** \`${p.target.selector}\``),l.push(`- **Found in state(s):** ${p._states.join(", ")}`),p.helpUrl&&l.push(`- **More info:** ${p.helpUrl}`),l.push(""),l.push("```html"),l.push(p.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const d=l.join(`
15
+ `),u=new URLSearchParams({"[Title]":o,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${u.toString()}`;return c.length>$s&&(c=c.slice(0,$s)),{url:c,title:o,description:d}}const Ls=7800;function Ui(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,m=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,x=r.find(f=>`${f.ruleId}::${f.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...c,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
16
+ `),d=new URLSearchParams({"issue[title]":i,"issue[description]":l});let u=`${n}/-/issues/new?${d.toString()}`;return u.length>Ls&&(u=u.slice(0,Ls)),{url:u,title:i,description:l}}const Us=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],_i=["wcag-component-auditor","wcag-forensic-log"];async function Di(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Us);s=Object.keys(n).length,await chrome.storage.local.remove(Us)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of _i)try{await Oi(n),a.push(n)}catch(r){t.push(`IndexedDB ${n}: ${r instanceof Error?r.message:String(r)}`)}return{chromeStorageKeysCleared:s,indexedDbsCleared:a,errors:t}}function Oi(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}const Ft="accessibilityStatementInputs:v1";async function Fi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(Ft))[Ft];return s&&typeof s=="object"?s:null}async function Mi(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[Ft]:t})}function ya({open:t,onClose:s,results:a,siteCrawlSource:n}){const[r,i]=h.useState("eaa"),[o,l]=h.useState(""),[d,u]=h.useState(""),[c,p]=h.useState("partial"),[m,x]=h.useState(""),[f,w]=h.useState(""),[j,$]=h.useState(""),[R,N]=h.useState(""),[b,I]=h.useState("English"),[g,y]=h.useState("wcagcheckr (self-evaluation)"),[C,S]=h.useState("2.1"),[T,H]=h.useState("AA"),[V,W]=h.useState(!1),[L,U]=h.useState(null),A=h.useRef(null);if(h.useEffect(()=>{t&&(async()=>{var P,ne,k,G;const E=await Fi();if(E&&(E.framing&&i(E.framing),E.organizationName&&l(E.organizationName),E.siteUrl&&u(E.siteUrl),E.conformanceStatus&&p(E.conformanceStatus),(P=E.contact)!=null&&P.email&&x(E.contact.email),(ne=E.contact)!=null&&ne.phone&&w(E.contact.phone),(k=E.contact)!=null&&k.formUrl&&$(E.contact.formUrl),E.countryCode&&N(E.countryCode),E.language&&I(E.language),E.auditedBy&&y(E.auditedBy),E.wcagVersion&&S(E.wcagVersion),E.wcagLevel&&H(E.wcagLevel)),!(E!=null&&E.siteUrl)&&((G=a[0])!=null&&G.pageUrl))try{const K=new URL(a[0].pageUrl);u(`${K.protocol}//${K.host}/`)}catch{}E!=null&&E.conformanceStatus||p(Xa(a)),setTimeout(()=>{var K;return(K=A.current)==null?void 0:K.focus()},50)})()},[t,a]),!t)return null;function O(){var k;const E=new Date().toISOString().slice(0,10),P=(k=a[0])!=null&&k.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):E,ne={};return m.trim()&&(ne.email=m.trim()),f.trim()&&(ne.phone=f.trim()),j.trim()&&(ne.formUrl=j.trim()),{framing:r,organizationName:o.trim(),siteUrl:d.trim(),conformanceStatus:c,preparedAt:E,evaluatedAt:P,contact:ne,countryCode:R||null,language:b.trim()||"English",auditedBy:g.trim()||"wcagcheckr (self-evaluation)",wcagVersion:C,wcagLevel:T}}function M(E){if(!E.organizationName)return"Organization name is required.";if(!E.siteUrl)return"Site URL is required.";try{new URL(E.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!E.contact.email&&!E.contact.phone&&!E.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function ee(E){var k;U(null);const P=O(),ne=M(P);if(ne){U(ne);return}W(!0);try{await Mi(P);const G=await J({type:"EXPORT_REQUEST",format:E==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:n?[]:a,siteCrawlSource:n||void 0,statementInputs:P}),K=(G==null?void 0:G.content)??"";if(!K||K.startsWith("# Accessibility statement — error")){U(K||"Export failed — no response.");return}try{await navigator.clipboard.writeText(K)}catch{}const z=new Blob([K],{type:E==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),re=URL.createObjectURL(z);typeof chrome<"u"&&((k=chrome.tabs)!=null&&k.create)?await chrome.tabs.create({url:re,active:!0}).catch(()=>{window.open(re,"_blank","noopener,noreferrer")}):window.open(re,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(re),6e4),s()}catch(G){U(G instanceof Error?G.message:String(G))}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:E=>E.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked:r==="eaa",onChange:()=>i("eaa"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"EAA"})," (Directive 2019/882) — private sector. E-commerce, banking, transport, telecom, e-readers, media. Enforceable June 2025."]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"wad",checked:r==="wad",onChange:()=>i("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:A,type:"text",value:o,onChange:E=>l(E.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:d,onChange:E=>u(E.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:c,onChange:E=>p(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:C,onChange:E=>S(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:T,onChange:E=>H(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:m,onChange:E=>x(E.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:f,onChange:E=>w(E.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:j,onChange:E=>$(E.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:R,onChange:E=>N(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(Za).map(([E,P])=>e.jsxs("option",{value:E,children:[E," — ",P.name.replace(/^[A-Z]+\s*—\s*/,"")]},E))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:b,onChange:E=>I(E.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:g,onChange:E=>y(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),L&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:L})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void ee("markdown"),disabled:V,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:V?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void ee("html"),disabled:V,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:V?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:V,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 wa(){const t=v(k=>k.delta),s=v(k=>k.componentId),a=v(k=>k.results),n=v(k=>k.tier),r=v(k=>k.baselineList),i=v(k=>k.siteCrawlReport),[o,l]=h.useState(""),[d,u]=h.useState(""),[c,p]=h.useState(""),[m,x]=h.useState(""),[f,w]=h.useState(!1),[j,$]=h.useState(!1),[R,N]=h.useState(null),[b,I]=h.useState(null),[g,y]=h.useState(!1),[C,S]=h.useState(!1),[T,H]=h.useState(null),[V,W]=h.useState(!1);h.useEffect(()=>{Promise.all([J({type:"SETTINGS_GET",key:"githubRepoUrl"}),J({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),J({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),J({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([k,G,K,z])=>{l(typeof k.data=="string"?k.data:""),u(typeof G.data=="string"?G.data:""),p(typeof K.data=="string"?K.data:""),x(typeof z.data=="string"?z.data:"")})},[]),h.useEffect(()=>ye("BADGE_CLICKED_EVENT",G=>{const K=`viol-row-${G.violationId}`,z=document.getElementById(K);z&&(z.scrollIntoView({behavior:"smooth",block:"center"}),z.classList.add("ring-2","ring-rose-500"),setTimeout(()=>z.classList.remove("ring-2","ring-rose-500"),1500))}),[]),h.useEffect(()=>()=>{(async()=>{const k=await de();k&&(C&&await be(k,{type:"BADGES_HIDE_REQUEST",tabId:k}).catch(()=>{}),V&&await be(k,{type:"HEATMAP_HIDE_REQUEST",tabId:k}).catch(()=>{}))})()},[]);async function L(){const k=await de();if(!k){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(C){await be(k,{type:"BADGES_HIDE_REQUEST",tabId:k}).catch(()=>{}),S(!1),H(null);return}const G={critical:4,serious:3,moderate:2,minor:1},K=new Map;for(const ie of a)for(const ue of ie.violations)K.has(ue.matchKey)||K.set(ue.matchKey,ue);const re=Array.from(K.values()).sort((ie,ue)=>G[ue.impact]-G[ie.impact]).map((ie,ue)=>({id:ie.matchKey,index:ue+1,selector:ie.target.selector,impact:ie.impact,ruleId:ie.ruleId,wcagCriterion:ie.wcagCriterion}));if(re.length===0){he.polite("No violations to badge.");return}const se=await Ie(k,{type:"BADGES_SHOW_REQUEST",tabId:k,violations:re}).catch(()=>null);se&&(S(!0),H({rendered:se.rendered,requested:se.requested,clustered:se.clustered}),he.polite(`${se.rendered} violation badges shown on the page.`))}async function U(){const k=await de();if(!k){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(V){await be(k,{type:"HEATMAP_HIDE_REQUEST",tabId:k}).catch(()=>{}),W(!1);return}const G=new Map;for(const re of a)for(const se of re.violations)G.has(se.matchKey)||G.set(se.matchKey,se);const K=Array.from(G.values()).map(re=>({selector:re.target.selector,impact:re.impact}));if(K.length===0){he.polite("No violations to heatmap.");return}const z=await Ie(k,{type:"HEATMAP_SHOW_REQUEST",tabId:k,violations:K}).catch(()=>null);z&&(W(!0),he.polite(`Heatmap shown with ${z.rendered} violation blobs.`))}const A=xt(n,"exportJson"),O=aa[n].maxBaselines,M=r.some(k=>k.componentId===s),ee=M||r.length<O;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 E(){if(!s||a.length===0)return;const k=a.flatMap(ue=>ue.violations),G=a.flatMap(ue=>ue.announcements??[]),K=a.flatMap(ue=>ue.focusEvents??[]),z=a[0],se=(await J({type:"SETTINGS_GET",key:"stateMatrix"})).data??Kt;await le({type:"BASELINE_SET",componentId:s,violations:k,announcements:G,focusEvents:K,snapshotMeta:{url:window.location.href,axeVersion:z.axeVersion,matrixConfig:se,capturedAt:new Date().toISOString()}});const ie=await J({type:"BASELINE_COMPARE",componentId:s,currentViolations:k,announcements:G,focusEvents:K,currentMatrix:se});v.getState().setDelta(ie.delta),he.polite(`Baseline saved for ${s}.`)}async function P(){if(!s||!M||!window.confirm(`Remove the saved baseline for "${s}"?
17
17
 
18
- Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await de({type:"BASELINE_DELETE",componentId:s});const G=a.flatMap(ie=>ie.violations),H=a.flatMap(ie=>ie.announcements??[]),z=a.flatMap(ie=>ie.focusEvents??[]),re=await J({type:"BASELINE_COMPARE",componentId:s,currentViolations:G,announcements:H,focusEvents:z});v.getState().setDelta(re.delta);const se=await J({type:"BASELINE_LIST"});v.getState().setBaselineList(se.items),he.polite(`Baseline cleared for ${s}.`)}async function ne(N,G=!1){if(a.length===0)return;if(N==="ai-prompt"){const{copyAiFixerPrompt:Q}=await ke(async()=>{const{copyAiFixerPrompt:pe}=await import("./copy-ai-fixer-prompt-BCdNHN79.js");return{copyAiFixerPrompt:pe}},__vite__mapDeps([4,1,2]));await Q({results:a,componentId:s,delta:G?void 0:t,siteCrawlReport:i});return}let H;if((N==="defense-bundle"||N==="evidence-bundle"||N==="deposition-packet")&&s){const Q=await chrome.storage.local.get("igtRuns"),le=((Q==null?void 0:Q.igtRuns)??{})[s]??{};H=Object.values(le)}const se=await J({type:"EXPORT_REQUEST",format:N,results:a,delta:G?void 0:t??void 0,manualRuns:H,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:v.getState().lastAuditWallClockMs??void 0});if(N==="defense-bundle"||N==="evidence-bundle"||N==="deposition-packet"){const Q=mt(N,s);await aa()?Xe(se.content,Q):I({open:!0,format:N,content:se.content,filename:Q});return}if(N==="html-print"||N==="vpat"||N==="methodology-doc"||N==="conformance-crosswalk"||N==="executive-report"){$e(se.content);return}const ie=N==="json"?"application/json":N==="sarif"?"application/sarif+json":N==="ticket-bundle"?"text/markdown":"application/xml",ue=N==="junit"?"xml":N==="ticket-bundle"?"md":N,_=new Blob([se.content],{type:ie}),Y=URL.createObjectURL(_),q=document.createElement("a");q.href=Y,q.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${ue}`,q.click(),URL.revokeObjectURL(Y)}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:E,disabled:!ee,title:ee?void 0:`Free tier limits you to ${O} 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"}),M&&e.jsx("button",{onClick:P,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>w(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx("button",{type:"button",onClick:()=>void L(),"aria-pressed":C,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:C?"text-xs px-2 py-1 bg-rose-600 hover:bg-rose-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:C?"Hide badges":"Show badges 🎯"}),C&&R&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[R.rendered," of ",R.requested," rendered",R.clustered>0?` · ${R.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void U(),"aria-pressed":V,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:V?"text-xs px-2 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:V?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(Bi,{disabled:!k,onExport:ne,onAccessibilityStatement:()=>y(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!ee&&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 N=jt(t.new),G=jt(t.persistent),H=jt(t.fixed),z=[...N.review,...G.review];return e.jsxs(e.Fragment,{children:[e.jsx(Pe,{title:"New",violations:N.findings,count:N.findings.length,accent:"red",actions:[...o&&N.findings.length>0?[{label:"File GitHub issue",onClick:()=>Pi(o,s,N.findings)}]:[],...d&&N.findings.length>0?[{label:"File Jira issue",onClick:()=>Gi(d,s,N.findings)}]:[],...c&&N.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Vi(c,s,N.findings)}]:[],...m&&N.findings.length>0?[{label:"File GitLab issue",onClick:()=>Wi(m,s,N.findings)}]:[]]}),e.jsx(Pe,{title:"Persistent",violations:G.findings,count:G.findings.length,accent:"slate"}),e.jsx(Pe,{title:"Fixed",violations:H.findings,count:t.fixedCount,accent:"green"}),z.length>0&&e.jsx(Pe,{title:"Needs review (does not affect grade)",violations:z,count:z.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(Pe,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),b&&e.jsx(ba,{open:b.open,onClose:()=>I(null),format:b.format,content:b.content,filename:b.filename}),e.jsx(va,{open:g,onClose:()=>y(!1),results:a}),f&&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"})]})]}),T&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",T.chromeStorageKeysCleared," chrome.storage key",T.chromeStorageKeysCleared===1?"":"s"," + ",T.indexedDbsCleared.length," database",T.indexedDbsCleared.length===1?"":"s",".",T.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",T.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:T?e.jsx("button",{type:"button",onClick:()=>{w(!1),j(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>w(!1),disabled:A,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{$(!0);try{const N=await _i();j(N),await xt(),he.polite("Audit data reset. Ready for a fresh scan.")}catch(N){j({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[N instanceof Error?N.message:String(N)]})}finally{$(!1)}},disabled:A,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:A?"Resetting…":"Reset everything"})]})})]})})]})}const Mi={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function jt(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 Pe({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=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 ${Mi[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,u)=>e.jsx(Ye,{violation:d,alreadyAcknowledged:!0},u)):Ii(s).map(d=>e.jsx(Ci,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Pi(t,s,a){if(a.length===0)return;const{url:n}=Ri(t,s,a);ht(n)}function Gi(t,s,a){if(a.length===0)return;const{url:n}=Ti(t,s,a);ht(n)}function Vi(t,s,a){if(a.length===0)return;const{url:n}=$i(t,s,a);ht(n)}function Wi(t,s,a){if(a.length===0)return;const{url:n}=Li(t,s,a);ht(n)}function Bi({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=h.useState(!1),[o,l]=h.useState(!1);function d(u){i(!1),s(u,o)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(u=>!u),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 w-[260px] max-w-[calc(100vw-1rem)] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:u=>l(u.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ve,{onClick:()=>d("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ve,{onClick:()=>d("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ve,{onClick:()=>d("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ve,{onClick:()=>d("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ve,{onClick:()=>d("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ve,{onClick:()=>d("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ve,{onClick:()=>d("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx(ve,{onClick:()=>d("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(ve,{onClick:()=>d("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(ve,{onClick:()=>d("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ve,{onClick:()=>d("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ve,{onClick:()=>d("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx(ve,{onClick:()=>d("executive-report"),title:"Single-page executive HTML report: grade hero, top 3 risks, recommended next steps. Print-ready (Ctrl+P → Save as PDF). For stakeholder distribution rather than developer remediation.",children:"Executive report 📊"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ve,{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 ve({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 Hi="2024-07-25",Ki="Based on the W3C WCAG 3 Working Draft published 2024-07-25. Outcomes may shift before WCAG 3.0 reaches Recommendation; treat this view as a directional preview, not a conformance claim.",wa=[{id:"text-alternatives",category:"perceive",title:"Non-text content has a text alternative",description:"Images, icons, audio, and video have descriptive text alternatives so users who cannot perceive the original modality still get the meaning.",wcag2Criteria:["1.1.1","1.2.1","1.2.2","1.2.3","1.2.4","1.2.5"]},{id:"visual-distinction",category:"perceive",title:"Visual content is distinguishable",description:"Foreground content has sufficient contrast from background, both for text (APCA Lc thresholds in 3.0) and for non-text UI elements.",wcag2Criteria:["1.4.3","1.4.6","1.4.11"]},{id:"adaptable-presentation",category:"perceive",title:"Content adapts to user preferences",description:"Text spacing, zoom, reflow, and orientation respect user-agent and OS preferences without breaking layout or losing functionality.",wcag2Criteria:["1.3.4","1.4.4","1.4.10","1.4.12"]},{id:"meaningful-structure",category:"perceive",title:"Content structure is programmatically determinable",description:"Headings, lists, tables, regions, and other semantic structures are exposed in the accessibility tree so assistive technology can navigate them.",wcag2Criteria:["1.3.1","1.3.2","2.4.1","2.4.6"]},{id:"keyboard-operable",category:"operate",title:"All functionality is keyboard-operable",description:"Every interaction (including drag, pointer-gesture-driven, and complex widget interactions) has a keyboard equivalent that does not require timing or precision.",wcag2Criteria:["2.1.1","2.1.2","2.1.4","2.5.1","2.5.2","2.5.7"]},{id:"focus-management",category:"operate",title:"Focus is visible, ordered, and never obscured",description:"Keyboard focus is visually distinct, moves in a sensible order, never moves unexpectedly, and is never hidden by sticky headers or modals.",wcag2Criteria:["2.4.3","2.4.7","2.4.11","2.4.12"]},{id:"enough-time",category:"operate",title:"Users have enough time to complete tasks",description:"Time limits are adjustable, pauseable, or absent. Moving / blinking content can be paused. No content flashes more than three times per second.",wcag2Criteria:["2.2.1","2.2.2","2.3.1"]},{id:"navigable-content",category:"operate",title:"Content is navigable",description:"Pages have titles, link text describes the destination, multiple ways exist to find content, and skip-links bypass repeated blocks.",wcag2Criteria:["2.4.2","2.4.4","2.4.5"]},{id:"target-size",category:"operate",title:"Pointer targets are sufficiently sized",description:"Interactive targets are large enough to operate without precision-tap difficulty. Drag operations have a single-pointer alternative.",wcag2Criteria:["2.5.8","2.5.7"]},{id:"language-of-content",category:"understand",title:"Language of content is identified",description:"Page and language-of-parts are programmatically determinable so text-to-speech and other AT can pronounce content correctly.",wcag2Criteria:["3.1.1","3.1.2"]},{id:"predictable-behavior",category:"understand",title:"UI behavior is predictable",description:"Focusing or selecting an element does not cause unexpected context changes. Navigation and identification of repeated components is consistent across pages.",wcag2Criteria:["3.2.1","3.2.2","3.2.3","3.2.4","3.2.6"]},{id:"input-assistance",category:"understand",title:"Forms help users avoid and correct errors",description:"Required fields are labeled, errors are identified clearly, suggestions are offered when possible, and legal / financial forms have prevention mechanisms.",wcag2Criteria:["3.3.1","3.3.2","3.3.3","3.3.4","3.3.7"]},{id:"accessible-auth",category:"understand",title:"Authentication does not require cognitive function tests",description:"Login flows do not depend on memorizing characters, transcribing puzzles, or other cognitive function tests with no accessible alternative.",wcag2Criteria:["3.3.8","3.3.9"]},{id:"name-role-value",category:"robust",title:"UI components expose name, role, and value",description:"Every interactive element has a programmatically determinable name, role, and current state. Status messages reach assistive technology without focus changes.",wcag2Criteria:["4.1.2","4.1.3"]}];new Set(wa.flatMap(t=>t.wcag2Criteria));function zi(t,s){return wa.map(a=>{const n=a.wcag2Criteria.filter(o=>t.has(o)),r=a.wcag2Criteria.some(o=>s.has(o));let i;return n.length>0?i="has-violations":r?i="clean":i="not-evaluated",{outcome:a,violatedCriteria:n,status:i}})}const qi={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function ja(){const t=v(c=>c.results),s=v(c=>c.acknowledgedKeys),a=v(c=>c.dismissedKeys);if(t.length===0)return e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"wcag3-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. This view re-projects the audit's WCAG 2.x findings onto the WCAG 3 outcome structure."})]});const n=new Set,r=new Set;for(const c of t){for(const m of c.violations){if(m.needsReview){r.add(m.wcagCriterion);continue}if(s.has(m.matchKey)){r.add(m.wcagCriterion);continue}if(a.has(`violation::${m.matchKey}`)){r.add(m.wcagCriterion);continue}n.add(m.wcagCriterion),r.add(m.wcagCriterion)}const p=c.axeRulesEvaluated;if(p){for(const m of p.passed)r.add(m.wcagCriterion);for(const m of p.inapplicable)r.add(m.wcagCriterion);for(const m of p.incomplete)r.add(m.wcagCriterion)}}const i=zi(n,r),o=new Map;for(const c of i){const p=o.get(c.outcome.category)??[];p.push(c),o.set(c.outcome.category,p)}const l=i.filter(c=>c.status==="clean").length,d=i.filter(c=>c.status==="has-violations").length,u=i.filter(c=>c.status==="not-evaluated").length;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"wcag3-view-root",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-1",children:"Re-projects this audit's WCAG 2.x findings onto the WCAG 3 outcome structure."}),e.jsxs("p",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-1 mt-2",role:"status","data-testid":"wcag3-source-badge",children:["⚠ Preview based on WCAG 3 Working Draft ",e.jsx("strong",{children:Hi}),"."," ",Ki]})]}),e.jsxs("div",{className:"flex gap-2 text-[11px]",children:[e.jsxs("span",{className:"px-2 py-1 rounded bg-emerald-100 text-emerald-800",children:[l," clean"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-rose-100 text-rose-900",children:[d," with violations"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-slate-100 text-slate-700",children:[u," not evaluated"]})]}),["perceive","operate","understand","robust"].map(c=>{const p=o.get(c)??[];return e.jsxs("section",{className:"border border-slate-200 rounded bg-white","data-testid":`wcag3-category-${c}`,children:[e.jsxs("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:[qi[c]," · ",p.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:p.map(m=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(Qi,{status:m.status}),e.jsx("strong",{className:"text-xs",children:m.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:m.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",m.outcome.wcag2Criteria.join(", ")]}),m.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:m.violatedCriteria.join(", ")})]})]},m.outcome.id))})]},c)})]})}function Qi({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}const Yi=[{id:"overview",label:"Overview",hint:"Verification areas + WCAG coverage + evidence layers"},{id:"per-area",label:"Per-area",hint:"Drill into the 9 verification areas"},{id:"violations",label:"Violations",hint:"Flat list of every unique finding"},{id:"activity",label:"Activity",hint:"Live regions · focus events · tab/reading order"},{id:"delta",label:"Delta",hint:"Compared to the last accepted baseline"},{id:"wcag3",label:"WCAG 3",hint:"Forward-looking projection on the WCAG 3 outcome map"}],Ji={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function Xi(){const t=v(p=>p.results),s=v(p=>p.componentId),a=v(p=>p.findingsLens),n=v(p=>p.setFindingsLens),r=v(p=>p.setView),i=v(p=>p.status),[o,l]=h.useState({});h.useEffect(()=>{if(!s)return;let p=!1;return(async()=>{const m=await Je(s);if(p)return;const x={};for(const f of m)f.criterionId==="2.4.3"?x.focusOrder=f.verdict:f.criterionId==="2.1.2"?x.keyboardTrap=f.verdict:f.criterionId==="2.4.7"?x.focusVisible=f.verdict:f.criterionId==="1.3.2"?x.readingOrder=f.verdict:f.criterionId==="1.4.11"&&(x.nonTextContrast=f.verdict);l(x)})(),()=>{p=!0}},[s]);const d=Jt(t),[u,c]=h.useState([]);return h.useEffect(()=>{if(!s){c([]);return}let p=!1;return chrome.storage.local.get("igtRuns").then(m=>{if(p)return;const f=((m==null?void 0:m.igtRuns)??{})[s]??{};c(Object.values(f))}),()=>{p=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(Ls,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:i==="running"?"Audit in progress. Findings appear here when the matrix completes.":i==="failed"||i==="interrupted"?"Last audit didn't complete. Re-run the scan from the controls above.":"No audit results yet. Run a scan from the controls above."})})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(Ls,{setView:r}),e.jsx(eo,{results:t,interactiveVerdicts:o,manualRuns:u,aiResolvedFails:d}),e.jsx(Zi,{results:t}),e.jsx(to,{lens:a,setLens:n}),e.jsx(so,{lens:a,results:t,componentId:s,interactiveVerdicts:o,aiResolvedFails:d})]})}function Ls({setView:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>t("matrix"),className:"text-xs text-slate-600 hover:text-slate-900 hover:underline font-mono px-0.5",children:"← Dashboard"}),e.jsx("span",{className:"text-[11px] font-mono uppercase tracking-widest text-slate-400",children:"findings"})]})}function Zi({results:t}){const s=v(u=>u.crawlNavContext),a=v(u=>u.setCrawlNavContext),n=v(u=>u.setView);if(t.length===0)return null;const r=new Set(t.map(u=>u.pageUrl??u.scope??"").filter(Boolean)),i=r.size>1,o=i?null:Array.from(r)[0]??"(unknown)",l=(s==null?void 0:s.mode)==="page";function d(){a(null),n("crawl")}return e.jsxs("div",{className:`border rounded-lg px-3 py-2 text-[11px] leading-snug ${i?"border-blue-200 bg-blue-50 text-blue-900":l?"border-amber-200 bg-amber-50 text-amber-900":"border-slate-200 bg-slate-50 text-slate-700"}`,role:"note","aria-label":"Audit scope",children:[l&&e.jsx("button",{type:"button",onClick:()=>d(),className:"float-right text-[10px] font-semibold px-2 py-0.5 rounded border border-amber-400 bg-white text-amber-900 hover:bg-amber-100",children:"← Back to crawl report"}),i?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Site crawl · ",r.size," pages."]})," ","This grade reflects the site overall, not any individual page. Per-page drilldown is available in the Crawl tab."]}):l?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["One page from site crawl · ",o,"."]})," ",'This is the full per-page audit data for this URL — same lenses as a fresh single-page audit. Use the "Back to crawl report" button to return to the do-the-work report covering all crawled pages.']}):e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Single-page audit · ",o,"."]})," ","This grade reflects this page only. Multi-page criteria (3.2.3 Consistent Navigation, 3.2.4 Consistent Identification, 3.2.6 Consistent Help) are treated as N/A here — run a"," ",e.jsx("strong",{children:"Site Crawl"})," to evaluate them for the whole site."]})]})}function eo({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var f,w,A,$;const r=t.flatMap(T=>T.violations),i=v(T=>T.lastAuditWallClockMs),o=v(T=>T.acknowledgedKeys),l=v(T=>T.dismissedKeys),u=Yt({violations:r,auditRan:!0,manualRuns:a,workflows:xe,heuristicCounts:{tabOrder:((w=(f=t[0])==null?void 0:f.tabOrderIssues)==null?void 0:w.length)??0,readingOrder:(($=(A=t[0])==null?void 0:A.readingOrderIssues)==null?void 0:$.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(T=>({ruleId:T.ruleId,impact:"serious",selector:T.selector}))}).overallLetter,c=pa(r,n,o,l),p=vr(r,n,o,l),m=t.length,x=i??t.reduce((T,j)=>T+j.durationMs,0);return e.jsx("section",{className:"sticky top-0 z-10 border border-slate-200 rounded-lg bg-white overflow-hidden shadow-sm","aria-label":"Audit grade summary",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${Ji[u]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:u})}),e.jsxs("div",{className:"flex-1 px-3.5 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"overall grade · 9 verification areas"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`}),c>0&&p.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",p.length," WCAG criterion",p.length===1?"":"a"," (",p.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[m," state",m===1?"":"s"," tested · ",(x/1e3).toFixed(1),"s"]})]})]})})}function to({lens:t,setLens:s}){return e.jsx("nav",{className:"flex flex-wrap gap-1 border-b border-slate-200 pb-1.5",role:"tablist","aria-label":"Findings lens",children:Yi.map(a=>{const n=t===a.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>s(a.id),title:a.hint,className:n?"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md bg-slate-900 text-white":"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md text-slate-600 hover:bg-slate-100",children:a.label},a.id)})})}function so({lens:t,results:s,componentId:a,interactiveVerdicts:n,aiResolvedFails:r}){var i,o;return t==="overview"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(no,{componentId:a}),e.jsx(Cr,{violations:s.flatMap(l=>l.violations),componentId:a,hideOverallHeader:!0}),e.jsx(lo,{pageUrl:((i=s[0])==null?void 0:i.pageUrl)??((o=s[0])==null?void 0:o.scope)??""}),e.jsx(ro,{})]}):t==="per-area"?e.jsx(ui,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(io,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(fa,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(ya,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(ja,{})}):null}const Us={critical:0,serious:1,moderate:2,minor:3};function _s(t){return`${_e(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}const Nt=[{id:"2.4.3",label:"Focus order",blurb:"AI walks Tab/Shift+Tab and judges screenshot-by-screenshot whether focus reaches every interactive element."},{id:"2.1.2",label:"No keyboard trap",blurb:"AI Tab-cycles forward then Shift+Tab back; verifies every focusable can be left."},{id:"2.4.7",label:"Focus visible",blurb:"AI inspects each focus-state screenshot for a visible indicator (outline/ring/underline)."},{id:"1.3.2",label:"Meaningful sequence",blurb:"AI vision over the page screenshot judges whether DOM-flagged divergences are real reading-order breaks or layout artifacts."},{id:"1.4.11",label:"Non-text contrast",blurb:"AI vision evaluates UI controls + state indicators for adequate contrast against their adjacent colors."},{id:"2.5.3",label:"Label in Name",blurb:"DOM walker collects {visibleText, accessibleName} pairs across every interactive control; AI judges ambiguous cases (icons, plurals, smart-quotes)."}],ao={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function no({componentId:t}){const[s,a]=h.useState({});h.useEffect(()=>{let d=!1;return(async()=>{if(!t){a({});return}const u=await Je(t);if(d)return;const c={};for(const p of u)c[p.criterionId]=p;a(c)})(),()=>{d=!0}},[t]);const n={};for(const[d,u]of Object.entries(s))n[d]=u.verdict;const r=Object.values(n).length,i=Object.values(n).filter(d=>d==="pass").length,o=Object.values(n).filter(d=>d==="fail").length,l=Object.values(n).filter(d=>d==="uncertain").length;return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 border-b border-slate-100 flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-900",children:"AI verified"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-500",children:r===0?`not configured · all ${Nt.length} criteria pending human verification`:`${r}/${Nt.length} · ${i} pass · ${o} fail · ${l} uncertain`})]}),r===0?e.jsxs("div",{className:"px-3 py-2.5 text-[11px] text-slate-600 leading-snug",children:["When an Anthropic API key is set in ",e.jsx("strong",{children:"Settings → AI"}),', these 5 criteria run automatically after every audit — replacing manual keyboard and vision checks. Without a key, they show as "pending human verification" in the Evidence layers below.']}):e.jsx("ul",{className:"divide-y divide-slate-100",children:Nt.map(d=>{const u=s[d.id],c=u==null?void 0:u.verdict,p=u?$t(u.reasoning):!1,m=u?Xs(u.reasoning):!1,x=u?Lt(u.reasoning):null;return e.jsxs("li",{className:"px-3 py-2 flex items-start gap-2.5",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-medium rounded px-1.5 py-0.5 ${c?ao[c]:"bg-slate-200 text-slate-500"}`,title:c?`AI verdict: ${c}${x?` (cascade ${x})`:""}`:"AI did not produce a verdict on this criterion",children:c||"not run"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:d.id}),d.label,m&&e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal",children:"· manual override"})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:d.blurb}),p&&!m&&u&&e.jsxs("div",{className:"mt-1.5 bg-amber-50 border border-amber-300 rounded p-2 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-amber-900 font-medium",children:"AI cascade flagged this — fix the issue and re-audit."}),e.jsxs("details",{className:"text-[10px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-32 overflow-y-auto bg-white/50 p-1.5 rounded",children:u.reasoning})]})]})]})]},d.id)})})]})}function ro(){return e.jsxs("div",{className:"border-t border-slate-200 pt-3 space-y-1.5",children:[e.jsx("h3",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"how to read this"}),e.jsx(Ee,{title:"The overall grade",body:'Count-based aggregation of the 9 verification areas (rc.110). The headline letter is the worst sub-grade letter you have N of — one C drops the overall off A regardless of how clean the other 8 areas look. This keeps a single bad area from hiding behind a high arithmetic mean. It is separate from "WCAG 2.1 AA Status," which is the legal-conformance answer (binary: conformant or not). The grade can be A while AA Status says "Not conformant" if there are unresolved criterion-level items — those are different questions and both are reported.'}),e.jsx(Ee,{title:"WCAG 2.1 AA Status",body:"Separate from the letter grade. Says whether you can claim WCAG 2.1 AA conformance. It is binary: Conformant or Not conformant. When Not conformant, the breakdown shows how many criteria are failing (real axe/AI violations) and how many are inconclusive (items that need user disposition). Fix or mark verified to flip to Conformant."}),e.jsx(Ee,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Areas below A show "verify with X →" — but when an AI walkthrough has already produced a verdict for that criterion, the prompt is suppressed automatically.`}),e.jsx(Ee,{title:"AI does most of the human work",body:"Six AI walkthroughs auto-run when an Anthropic API key is configured: 2.4.3 Focus Order, 2.1.2 No Keyboard Trap, 2.4.7 Focus Visible, 1.3.2 Meaningful Sequence, 1.4.11 Non-text Contrast, 2.5.3 Label in Name. They drive real keyboard input + take screenshots + judge them with vision (and parse DOM accessible-name vs visible-text for 2.5.3) — exactly the work IGT manual workflows used to require. Their verdicts feed the Tab order / Keyboard / Reading order / Color & contrast / Forms sub-grades automatically. When AI returns a definitive pass or fail for an area, the heuristic findings for that area become supporting evidence rather than independent severity (rc.227). Humans only spot-check + attest before signing the formal report."}),e.jsx(Ee,{title:"Fix recipes",body:'Every finding includes specific remediation instructions in the AI fix prompt export (Delta lens → Export menu). The prompt also includes false-positive guidance (skip-links, multi-column layouts, portal-rendered modals) so AI can ask before "fixing" intentional patterns.'}),e.jsx(Ee,{title:"WCAG 2.1 AA coverage",body:"Of 50 applicable Level AA criteria, how many have a definite verdict from any layer (automation, AI, or human). Untested criteria don't cap your grade — automation did everything it could — but for a formal conformance claim, those still need explicit evaluation. Run a Site Crawl or open Compliance to fill the gaps."}),e.jsx(Ee,{title:"Path to full compliance",body:"The shortest sequence of actions: fix automated violations, let AI walkthroughs auto-resolve the keyboard/vision criteria, optionally spot-check via Compliance → Sign and seal. Export the AI fix prompt from the Delta lens for code-level walkthroughs of each issue."})]})}function Ee({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded bg-slate-50",children:[e.jsx("summary",{className:"px-2.5 py-1.5 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded",children:t}),e.jsx("p",{className:"px-2.5 pb-2 text-[11px] text-slate-700 leading-snug",children:s})]})}function io({results:t}){const s=v(r=>r.dismissedKeys),a=new Set,n=[];for(const r of t)for(const i of r.violations){if(s.has(`violation::${i.matchKey}`))continue;const o=_s(i);a.has(o)||(a.add(o),n.push(i))}return n.sort((r,i)=>{const o=Us[r.impact]??99,l=Us[i.impact]??99;return o-l}),n.length===0?e.jsxs("div",{className:"text-center text-sm text-slate-600 py-6",children:["No automation-detectable violations found across ",t.length," state",t.length===1?"":"s",". Switch to ",e.jsx("strong",{children:"Per-area"})," or"," ",e.jsx("strong",{children:"Activity"})," for heuristic findings axe doesn't cover."]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[n.length," unique violation",n.length===1?"":"s"," · sorted by impact"]}),n.map(r=>e.jsx(Ye,{violation:r},_s(r)))]})}const oo={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function lo({pageUrl:t}){const s=v(u=>u.tier),a=Gt(s),n=pt(s,"autoExportAuditReports"),[r,i]=h.useState(null),[o,l]=h.useState(null);if(h.useEffect(()=>{let u=!1;return(async()=>{const c=await ta();if(u||i(c),t){const p=await Cn(t);u||l(p)}})(),()=>{u=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?oo[r.formats[0]].split(" · ")[0]:`${r.formats.length} formats`;return e.jsxs("div",{className:"border border-emerald-200 rounded-lg bg-emerald-50 p-2.5 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-[12px] font-semibold text-emerald-900",children:"✓ Remediation trail active"}),e.jsx("span",{className:"text-[10px] text-emerald-800 font-mono",children:d})]}),o?e.jsxs("p",{className:"text-[10px] text-emerald-800 leading-snug",children:["Last exported ",e.jsx("span",{className:"font-mono",children:new Date(o.exportedAt).toLocaleString()})," ","as ",e.jsx("span",{className:"font-mono",children:o.filename})]}):e.jsx("p",{className:"text-[10px] text-emerald-800 italic",children:"No audit has auto-exported on this page yet. Your next audit will download to Downloads automatically."})]})}const Ot="igtRuns";async function co(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Qe(r,o.map(l=>({key:qe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Qe(r,o.map(l=>({key:ze(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const uo={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"}},po={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"}},mo={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Ds(t,s){const a=await ce();if(!a)return;const n=s?uo[t]:po[t];try{await be(a,n)}catch{}}async function ho(){const s=(await chrome.storage.local.get(Ot))[Ot];return s&&typeof s=="object"?s:{}}async function Os(t){await chrome.storage.local.set({[Ot]:t})}function xo(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 go(){const t=v(c=>c.componentId),s=v(c=>c.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{ho().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(c,p,m){var f;const x={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((f=o[c])==null?void 0:f.steps)??{},[p]:m},completedAt:new Date().toISOString()}}};if(n(x),Os(x),m.status==="pass"){const w=xe.find($=>$.id===c),A=w==null?void 0:w.steps.find($=>$.id===p);A!=null&&A.autoDismissActivity&&co(A.autoDismissActivity,s,p)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[c];const m={...a,[t]:p};n(m),Os(m)}const u=xe.find(c=>c.id===r);if(u){const c=o[u.id];return e.jsx(fo,{workflow:u,run:c,results:s,onAnswer:(p,m)=>l(u.id,p,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."}),xe.map(c=>{const p=o[c.id],m=p?Za(p,c):null,x=p?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.unanswered>0?"in-progress":"done":"unstarted",f={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${f}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&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:c.blurb}),p&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function fo({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const d={};for(const u of t.steps)d[u.id]=xo(u,a);return d},[t,a]);function o(){for(const d of t.steps){const u=i[d.id];(u==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`})}}const l=t.steps.filter(d=>{var u;return((u=i[d.id])==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,u)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[u+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const p=i[d.id];return p?p.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:p.ruleId})," ran clean across ",p.statesAudited," state",p.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:p.ruleId})," already found ",p.violationCount," violation",p.violationCount===1?"":"s"," in"," ",p.states.length," state",p.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${p.ruleId}, ${p.violationCount} hits in: ${p.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Ds(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",mo[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Ds(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(et,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(et,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(et,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(et,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:p=>n(d.id,{status:c.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const bo={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 et({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?bo[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const rt="savedFlows";async function vo(){const t=await chrome.storage.local.get(rt);return Array.isArray(t[rt])?t[rt]:[]}async function Fs(t){await chrome.storage.local.set({[rt]:t})}function yo(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{vo().then(s)},[]);async function o(){const c=await ce();if(!c){i("No audit-target tab found.");return}try{await be(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await ce();if(c)try{const p=await Ie(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),p.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${p.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:p.steps,savedAt:new Date().toISOString()},f=[x,...t];s(f),await Fs(f),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(p){i(`Stop failed: ${p instanceof Error?p.message:String(p)}`)}}async function d(c){const p=await ce();if(p){i(`Replaying "${c.name}"…`);try{const m=await Ie(p,{type:"FLOW_PLAY_REQUEST",steps:c.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 u(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(m=>m.id!==c);s(p),await Fs(p)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>u(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function wo(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(jo).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function jo(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function No(){const t=v(l=>l.baselineList),s=v(l=>l.tier),a=sa[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{ct().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await de({type:"BASELINE_DELETE",componentId:l}),await ct()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const d=wo(l.componentId),u=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),u&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(Re,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),u.criticalCount>0&&e.jsxs(Re,{tone:"rose",title:`${u.criticalCount} critical violations`,children:[u.criticalCount," critical"]}),u.seriousCount>0&&e.jsxs(Re,{tone:"orange",title:`${u.seriousCount} serious violations`,children:[u.seriousCount," serious"]}),u.focusResetCount>0&&e.jsxs(Re,{tone:"rose",title:`${u.focusResetCount} focus resets observed`,children:[u.focusResetCount," focus reset",u.focusResetCount===1?"":"s"]}),u.targetSizeFailCount>0&&e.jsxs(Re,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[u.targetSizeFailCount," small targets"]}),u.hoverContrastFail&&e.jsx(Re,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),u.announcementCount>0&&e.jsxs(Re,{tone:"indigo",title:"aria-live announcements observed",children:[u.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const ko={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 Re({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${ko[t]}`,children:a})}const it="wcagcheckr";function Z(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ke(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 So(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Ao(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 Co(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 Io(t){switch(t){case"A":return"grade-a";case"B":return"grade-b";case"C":return"grade-c";case"D":return"grade-d";case"F":return"grade-f"}}function Eo(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${Z(t.receipt.tsaName)}) — anchored ${Z(Ke(t.receipt.anchoredAt))}</td></tr>
18
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await le({type:"BASELINE_DELETE",componentId:s});const G=a.flatMap(ie=>ie.violations),K=a.flatMap(ie=>ie.announcements??[]),z=a.flatMap(ie=>ie.focusEvents??[]),re=await J({type:"BASELINE_COMPARE",componentId:s,currentViolations:G,announcements:K,focusEvents:z});v.getState().setDelta(re.delta);const se=await J({type:"BASELINE_LIST"});v.getState().setBaselineList(se.items),he.polite(`Baseline cleared for ${s}.`)}async function ne(k,G=!1){if(a.length===0)return;if(k==="ai-prompt"){const{copyAiFixerPrompt:Q}=await ke(async()=>{const{copyAiFixerPrompt:pe}=await import("./copy-ai-fixer-prompt-Cpl_NnwJ.js");return{copyAiFixerPrompt:pe}},__vite__mapDeps([4,1,2]));await Q({results:a,componentId:s,delta:G?void 0:t,siteCrawlReport:i});return}let K;if((k==="defense-bundle"||k==="evidence-bundle"||k==="deposition-packet")&&s){const Q=await chrome.storage.local.get("igtRuns"),ce=((Q==null?void 0:Q.igtRuns)??{})[s]??{};K=Object.values(ce)}const se=await J({type:"EXPORT_REQUEST",format:k,results:a,delta:G?void 0:t??void 0,manualRuns:K,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:v.getState().lastAuditWallClockMs??void 0});if(k==="defense-bundle"||k==="evidence-bundle"||k==="deposition-packet"){const Q=gt(k,s);await na()?Xe(se.content,Q):I({open:!0,format:k,content:se.content,filename:Q});return}if(k==="html-print"||k==="vpat"||k==="methodology-doc"||k==="conformance-crosswalk"||k==="executive-report"){$e(se.content);return}const ie=k==="json"?"application/json":k==="sarif"?"application/sarif+json":k==="ticket-bundle"?"text/markdown":"application/xml",ue=k==="junit"?"xml":k==="ticket-bundle"?"md":k,_=new Blob([se.content],{type:ie}),Y=URL.createObjectURL(_),q=document.createElement("a");q.href=Y,q.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${ue}`,q.click(),URL.revokeObjectURL(Y)}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:E,disabled:!ee,title:ee?void 0:`Free tier limits you to ${O} 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"}),M&&e.jsx("button",{onClick:P,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>w(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx("button",{type:"button",onClick:()=>void L(),"aria-pressed":C,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:C?"text-xs px-2 py-1 bg-rose-600 hover:bg-rose-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:C?"Hide badges":"Show badges 🎯"}),C&&T&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[T.rendered," of ",T.requested," rendered",T.clustered>0?` · ${T.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void U(),"aria-pressed":V,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:V?"text-xs px-2 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:V?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(Hi,{disabled:!A,onExport:ne,onAccessibilityStatement:()=>y(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!ee&&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 k=St(t.new),G=St(t.persistent),K=St(t.fixed),z=[...k.review,...G.review];return e.jsxs(e.Fragment,{children:[e.jsx(Ge,{title:"New",violations:k.findings,count:k.findings.length,accent:"red",actions:[...o&&k.findings.length>0?[{label:"File GitHub issue",onClick:()=>Gi(o,s,k.findings)}]:[],...d&&k.findings.length>0?[{label:"File Jira issue",onClick:()=>Vi(d,s,k.findings)}]:[],...c&&k.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>Wi(c,s,k.findings)}]:[],...m&&k.findings.length>0?[{label:"File GitLab issue",onClick:()=>Bi(m,s,k.findings)}]:[]]}),e.jsx(Ge,{title:"Persistent",violations:G.findings,count:G.findings.length,accent:"slate"}),e.jsx(Ge,{title:"Fixed",violations:K.findings,count:t.fixedCount,accent:"green"}),z.length>0&&e.jsx(Ge,{title:"Needs review (does not affect grade)",violations:z,count:z.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(Ge,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),b&&e.jsx(va,{open:b.open,onClose:()=>I(null),format:b.format,content:b.content,filename:b.filename}),e.jsx(ya,{open:g,onClose:()=>y(!1),results:a}),f&&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"})]})]}),R&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",R.chromeStorageKeysCleared," chrome.storage key",R.chromeStorageKeysCleared===1?"":"s"," + ",R.indexedDbsCleared.length," database",R.indexedDbsCleared.length===1?"":"s",".",R.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",R.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:R?e.jsx("button",{type:"button",onClick:()=>{w(!1),N(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>w(!1),disabled:j,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{$(!0);try{const k=await Di();N(k),await bt(),he.polite("Audit data reset. Ready for a fresh scan.")}catch(k){N({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[k instanceof Error?k.message:String(k)]})}finally{$(!1)}},disabled:j,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:j?"Resetting…":"Reset everything"})]})})]})})]})}const Pi={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function St(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 Ge({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=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 ${Pi[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,u)=>e.jsx(Je,{violation:d,alreadyAcknowledged:!0},u)):Ei(s).map(d=>e.jsx(Ii,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Gi(t,s,a){if(a.length===0)return;const{url:n}=Ti(t,s,a);ft(n)}function Vi(t,s,a){if(a.length===0)return;const{url:n}=$i(t,s,a);ft(n)}function Wi(t,s,a){if(a.length===0)return;const{url:n}=Li(t,s,a);ft(n)}function Bi(t,s,a){if(a.length===0)return;const{url:n}=Ui(t,s,a);ft(n)}function Hi({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=h.useState(!1),[o,l]=h.useState(!1);function d(u){i(!1),s(u,o)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(u=>!u),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 w-[260px] max-w-[calc(100vw-1rem)] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:u=>l(u.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ve,{onClick:()=>d("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ve,{onClick:()=>d("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ve,{onClick:()=>d("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ve,{onClick:()=>d("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ve,{onClick:()=>d("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ve,{onClick:()=>d("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ve,{onClick:()=>d("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx(ve,{onClick:()=>d("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(ve,{onClick:()=>d("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(ve,{onClick:()=>d("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ve,{onClick:()=>d("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ve,{onClick:()=>d("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx(ve,{onClick:()=>d("executive-report"),title:"Single-page executive HTML report: grade hero, top 3 risks, recommended next steps. Print-ready (Ctrl+P → Save as PDF). For stakeholder distribution rather than developer remediation.",children:"Executive report 📊"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ve,{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 ve({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const Ki="2024-07-25",zi="Based on the W3C WCAG 3 Working Draft published 2024-07-25. Outcomes may shift before WCAG 3.0 reaches Recommendation; treat this view as a directional preview, not a conformance claim.",ja=[{id:"text-alternatives",category:"perceive",title:"Non-text content has a text alternative",description:"Images, icons, audio, and video have descriptive text alternatives so users who cannot perceive the original modality still get the meaning.",wcag2Criteria:["1.1.1","1.2.1","1.2.2","1.2.3","1.2.4","1.2.5"]},{id:"visual-distinction",category:"perceive",title:"Visual content is distinguishable",description:"Foreground content has sufficient contrast from background, both for text (APCA Lc thresholds in 3.0) and for non-text UI elements.",wcag2Criteria:["1.4.3","1.4.6","1.4.11"]},{id:"adaptable-presentation",category:"perceive",title:"Content adapts to user preferences",description:"Text spacing, zoom, reflow, and orientation respect user-agent and OS preferences without breaking layout or losing functionality.",wcag2Criteria:["1.3.4","1.4.4","1.4.10","1.4.12"]},{id:"meaningful-structure",category:"perceive",title:"Content structure is programmatically determinable",description:"Headings, lists, tables, regions, and other semantic structures are exposed in the accessibility tree so assistive technology can navigate them.",wcag2Criteria:["1.3.1","1.3.2","2.4.1","2.4.6"]},{id:"keyboard-operable",category:"operate",title:"All functionality is keyboard-operable",description:"Every interaction (including drag, pointer-gesture-driven, and complex widget interactions) has a keyboard equivalent that does not require timing or precision.",wcag2Criteria:["2.1.1","2.1.2","2.1.4","2.5.1","2.5.2","2.5.7"]},{id:"focus-management",category:"operate",title:"Focus is visible, ordered, and never obscured",description:"Keyboard focus is visually distinct, moves in a sensible order, never moves unexpectedly, and is never hidden by sticky headers or modals.",wcag2Criteria:["2.4.3","2.4.7","2.4.11","2.4.12"]},{id:"enough-time",category:"operate",title:"Users have enough time to complete tasks",description:"Time limits are adjustable, pauseable, or absent. Moving / blinking content can be paused. No content flashes more than three times per second.",wcag2Criteria:["2.2.1","2.2.2","2.3.1"]},{id:"navigable-content",category:"operate",title:"Content is navigable",description:"Pages have titles, link text describes the destination, multiple ways exist to find content, and skip-links bypass repeated blocks.",wcag2Criteria:["2.4.2","2.4.4","2.4.5"]},{id:"target-size",category:"operate",title:"Pointer targets are sufficiently sized",description:"Interactive targets are large enough to operate without precision-tap difficulty. Drag operations have a single-pointer alternative.",wcag2Criteria:["2.5.8","2.5.7"]},{id:"language-of-content",category:"understand",title:"Language of content is identified",description:"Page and language-of-parts are programmatically determinable so text-to-speech and other AT can pronounce content correctly.",wcag2Criteria:["3.1.1","3.1.2"]},{id:"predictable-behavior",category:"understand",title:"UI behavior is predictable",description:"Focusing or selecting an element does not cause unexpected context changes. Navigation and identification of repeated components is consistent across pages.",wcag2Criteria:["3.2.1","3.2.2","3.2.3","3.2.4","3.2.6"]},{id:"input-assistance",category:"understand",title:"Forms help users avoid and correct errors",description:"Required fields are labeled, errors are identified clearly, suggestions are offered when possible, and legal / financial forms have prevention mechanisms.",wcag2Criteria:["3.3.1","3.3.2","3.3.3","3.3.4","3.3.7"]},{id:"accessible-auth",category:"understand",title:"Authentication does not require cognitive function tests",description:"Login flows do not depend on memorizing characters, transcribing puzzles, or other cognitive function tests with no accessible alternative.",wcag2Criteria:["3.3.8","3.3.9"]},{id:"name-role-value",category:"robust",title:"UI components expose name, role, and value",description:"Every interactive element has a programmatically determinable name, role, and current state. Status messages reach assistive technology without focus changes.",wcag2Criteria:["4.1.2","4.1.3"]}];new Set(ja.flatMap(t=>t.wcag2Criteria));function qi(t,s){return ja.map(a=>{const n=a.wcag2Criteria.filter(o=>t.has(o)),r=a.wcag2Criteria.some(o=>s.has(o));let i;return n.length>0?i="has-violations":r?i="clean":i="not-evaluated",{outcome:a,violatedCriteria:n,status:i}})}const Qi={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Na(){const t=v(c=>c.results),s=v(c=>c.acknowledgedKeys),a=v(c=>c.dismissedKeys);if(t.length===0)return e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"wcag3-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. This view re-projects the audit's WCAG 2.x findings onto the WCAG 3 outcome structure."})]});const n=new Set,r=new Set;for(const c of t){for(const m of c.violations){if(m.needsReview){r.add(m.wcagCriterion);continue}if(s.has(m.matchKey)){r.add(m.wcagCriterion);continue}if(a.has(`violation::${m.matchKey}`)){r.add(m.wcagCriterion);continue}n.add(m.wcagCriterion),r.add(m.wcagCriterion)}const p=c.axeRulesEvaluated;if(p){for(const m of p.passed)r.add(m.wcagCriterion);for(const m of p.inapplicable)r.add(m.wcagCriterion);for(const m of p.incomplete)r.add(m.wcagCriterion)}}const i=qi(n,r),o=new Map;for(const c of i){const p=o.get(c.outcome.category)??[];p.push(c),o.set(c.outcome.category,p)}const l=i.filter(c=>c.status==="clean").length,d=i.filter(c=>c.status==="has-violations").length,u=i.filter(c=>c.status==="not-evaluated").length;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"wcag3-view-root",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-1",children:"Re-projects this audit's WCAG 2.x findings onto the WCAG 3 outcome structure."}),e.jsxs("p",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-1 mt-2",role:"status","data-testid":"wcag3-source-badge",children:["⚠ Preview based on WCAG 3 Working Draft ",e.jsx("strong",{children:Ki}),"."," ",zi]})]}),e.jsxs("div",{className:"flex gap-2 text-[11px]",children:[e.jsxs("span",{className:"px-2 py-1 rounded bg-emerald-100 text-emerald-800",children:[l," clean"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-rose-100 text-rose-900",children:[d," with violations"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-slate-100 text-slate-700",children:[u," not evaluated"]})]}),["perceive","operate","understand","robust"].map(c=>{const p=o.get(c)??[];return e.jsxs("section",{className:"border border-slate-200 rounded bg-white","data-testid":`wcag3-category-${c}`,children:[e.jsxs("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:[Qi[c]," · ",p.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:p.map(m=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(Yi,{status:m.status}),e.jsx("strong",{className:"text-xs",children:m.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:m.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",m.outcome.wcag2Criteria.join(", ")]}),m.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:m.violatedCriteria.join(", ")})]})]},m.outcome.id))})]},c)})]})}function Yi({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}const Ji=[{id:"overview",label:"Overview",hint:"Verification areas + WCAG coverage + evidence layers"},{id:"per-area",label:"Per-area",hint:"Drill into the 9 verification areas"},{id:"violations",label:"Violations",hint:"Flat list of every unique finding"},{id:"activity",label:"Activity",hint:"Live regions · focus events · tab/reading order"},{id:"delta",label:"Delta",hint:"Compared to the last accepted baseline"},{id:"wcag3",label:"WCAG 3",hint:"Forward-looking projection on the WCAG 3 outcome map"}],Xi={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function Zi(){const t=v(p=>p.results),s=v(p=>p.componentId),a=v(p=>p.findingsLens),n=v(p=>p.setFindingsLens),r=v(p=>p.setView),i=v(p=>p.status),[o,l]=h.useState({});h.useEffect(()=>{if(!s)return;let p=!1;return(async()=>{const m=await Oe(s);if(p)return;const x={};for(const f of m)f.criterionId==="2.4.3"?x.focusOrder=f.verdict:f.criterionId==="2.1.2"?x.keyboardTrap=f.verdict:f.criterionId==="2.4.7"?x.focusVisible=f.verdict:f.criterionId==="1.3.2"?x.readingOrder=f.verdict:f.criterionId==="1.4.11"&&(x.nonTextContrast=f.verdict);l(x)})(),()=>{p=!0}},[s]);const d=Zt(t),[u,c]=h.useState([]);return h.useEffect(()=>{if(!s){c([]);return}let p=!1;return chrome.storage.local.get("igtRuns").then(m=>{if(p)return;const f=((m==null?void 0:m.igtRuns)??{})[s]??{};c(Object.values(f))}),()=>{p=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(_s,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:i==="running"?"Audit in progress. Findings appear here when the matrix completes.":i==="failed"||i==="interrupted"?"Last audit didn't complete. Re-run the scan from the controls above.":"No audit results yet. Run a scan from the controls above."})})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(_s,{setView:r}),e.jsx(to,{results:t,interactiveVerdicts:o,manualRuns:u,aiResolvedFails:d}),e.jsx(eo,{results:t}),e.jsx(so,{lens:a,setLens:n}),e.jsx(ao,{lens:a,results:t,componentId:s,interactiveVerdicts:o,aiResolvedFails:d})]})}function _s({setView:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>t("matrix"),className:"text-xs text-slate-600 hover:text-slate-900 hover:underline font-mono px-0.5",children:"← Dashboard"}),e.jsx("span",{className:"text-[11px] font-mono uppercase tracking-widest text-slate-400",children:"findings"})]})}function eo({results:t}){const s=v(u=>u.crawlNavContext),a=v(u=>u.setCrawlNavContext),n=v(u=>u.setView);if(t.length===0)return null;const r=new Set(t.map(u=>u.pageUrl??u.scope??"").filter(Boolean)),i=r.size>1,o=i?null:Array.from(r)[0]??"(unknown)",l=(s==null?void 0:s.mode)==="page";function d(){a(null),n("crawl")}return e.jsxs("div",{className:`border rounded-lg px-3 py-2 text-[11px] leading-snug ${i?"border-blue-200 bg-blue-50 text-blue-900":l?"border-amber-200 bg-amber-50 text-amber-900":"border-slate-200 bg-slate-50 text-slate-700"}`,role:"note","aria-label":"Audit scope",children:[l&&e.jsx("button",{type:"button",onClick:()=>d(),className:"float-right text-[10px] font-semibold px-2 py-0.5 rounded border border-amber-400 bg-white text-amber-900 hover:bg-amber-100",children:"← Back to crawl report"}),i?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Site crawl · ",r.size," pages."]})," ","This grade reflects the site overall, not any individual page. Per-page drilldown is available in the Crawl tab."]}):l?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["One page from site crawl · ",o,"."]})," ",'This is the full per-page audit data for this URL — same lenses as a fresh single-page audit. Use the "Back to crawl report" button to return to the do-the-work report covering all crawled pages.']}):e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Single-page audit · ",o,"."]})," ","This grade reflects this page only. Multi-page criteria (3.2.3 Consistent Navigation, 3.2.4 Consistent Identification, 3.2.6 Consistent Help) are treated as N/A here — run a"," ",e.jsx("strong",{children:"Site Crawl"})," to evaluate them for the whole site."]})]})}function to({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var f,w,j,$;const r=t.flatMap(R=>R.violations),i=v(R=>R.lastAuditWallClockMs),o=v(R=>R.acknowledgedKeys),l=v(R=>R.dismissedKeys),u=Xt({violations:r,auditRan:!0,manualRuns:a,workflows:xe,heuristicCounts:{tabOrder:((w=(f=t[0])==null?void 0:f.tabOrderIssues)==null?void 0:w.length)??0,readingOrder:(($=(j=t[0])==null?void 0:j.readingOrderIssues)==null?void 0:$.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(R=>({ruleId:R.ruleId,impact:"serious",selector:R.selector}))}).overallLetter,c=ma(r,n,o,l),p=yr(r,n,o,l),m=t.length,x=i??t.reduce((R,N)=>R+N.durationMs,0);return e.jsx("section",{className:"sticky top-0 z-10 border border-slate-200 rounded-lg bg-white overflow-hidden shadow-sm","aria-label":"Audit grade summary",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${Xi[u]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:u})}),e.jsxs("div",{className:"flex-1 px-3.5 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"overall grade · 9 verification areas"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`}),c>0&&p.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",p.length," WCAG criterion",p.length===1?"":"a"," (",p.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[m," state",m===1?"":"s"," tested · ",(x/1e3).toFixed(1),"s"]})]})]})})}function so({lens:t,setLens:s}){return e.jsx("nav",{className:"flex flex-wrap gap-1 border-b border-slate-200 pb-1.5",role:"tablist","aria-label":"Findings lens",children:Ji.map(a=>{const n=t===a.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>s(a.id),title:a.hint,className:n?"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md bg-slate-900 text-white":"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md text-slate-600 hover:bg-slate-100",children:a.label},a.id)})})}function ao({lens:t,results:s,componentId:a,interactiveVerdicts:n,aiResolvedFails:r}){var i,o;return t==="overview"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(no,{componentId:a,results:s}),e.jsx(lo,{componentId:a}),e.jsx(Ir,{violations:s.flatMap(l=>l.violations),componentId:a,hideOverallHeader:!0}),e.jsx(mo,{pageUrl:((i=s[0])==null?void 0:i.pageUrl)??((o=s[0])==null?void 0:o.scope)??""}),e.jsx(co,{})]}):t==="per-area"?e.jsx(pi,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(uo,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(ba,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(wa,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Na,{})}):null}const mt={critical:0,serious:1,moderate:2,minor:3};function ht(t){return`${_e(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function no({componentId:t,results:s}){var f,w;const a=v(j=>j.setFindingsLens),[n,r]=h.useState({}),[i,o]=h.useState({}),[l,d]=h.useState(0);h.useEffect(()=>{let j=!1;return(async()=>{if(!t){r({}),o({});return}const $=await Oe(t);if(j)return;const R={};for(const I of $)R[I.criterionId]=I;r(R);const N=await en([t]);if(j)return;const b={};for(const I of N)b[`${I.criterionId}::${I.pageUrl}`]=I;o(b)})(),()=>{j=!0}},[t,l]);const u=((f=s[0])==null?void 0:f.pageUrl)??((w=s[0])==null?void 0:w.scope)??"",c=rt.map(j=>({crit:j,record:n[j.id]??null})).filter(({record:j})=>j&&(j.verdict==="fail"||j.verdict==="uncertain")).filter(({crit:j})=>!i[`${j.id}::${u}`]),p=new Set,m=[];for(const j of s)for(const $ of j.violations){if($.needsReview)continue;const R=ht($);p.has(R)||(p.add(R),m.push($))}m.sort((j,$)=>(mt[j.impact]??99)-(mt[$.impact]??99));const x=c.length+m.length;return x===0?e.jsxs("section",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"✓"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Nothing needs your attention on this page."})]}),e.jsx("p",{className:"text-[11px] text-emerald-800 mt-1 leading-snug",children:"No axe violations, no AI walkthrough fails, no uncertain findings. The sub-grades and WCAG coverage below are informational — you've done the work here. Move on to the next page or export your defense bundle."})]}):e.jsxs("section",{className:"border border-rose-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 bg-rose-50 border-b border-rose-200",children:[e.jsxs("p",{className:"text-sm font-semibold text-rose-900",children:[x," item",x===1?"":"s"," need",x===1?"s":""," your attention"]}),e.jsx("p",{className:"text-[11px] text-rose-800 mt-0.5 leading-snug",children:"Each row below is one thing to fix or sign off on. Use the inline buttons — you don't need to leave this view."})]}),e.jsxs("ul",{className:"divide-y divide-slate-100",children:[c.map(({crit:j,record:$})=>e.jsx(ro,{componentId:t??"",pageUrl:u,criterionId:j.id,label:j.label,blurb:j.blurb,record:$,onChanged:()=>d(R=>R+1)},`wt::${j.id}`)),m.map(j=>e.jsx(io,{violation:j,onOpen:()=>a("violations")},`axe::${ht(j)}`))]})]})}function ro({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:i,onChanged:o}){const[l,d]=h.useState(!1),[u,c]=h.useState(""),[p,m]=h.useState(!1),[x,f]=h.useState(null),[w,j]=h.useState(!1),[$,R]=h.useState(!1),N=i.verdict,b=N==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function I(){m(!0),f(null);try{if(!u.trim()){f("Note is required — explain how you manually verified this."),m(!1);return}await Zs({componentId:t,criterionId:a,pageUrl:s,note:u.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:N}),o()}catch(y){f(y instanceof Error?y.message:String(y))}finally{m(!1)}}async function g(){var y;R(!0),f(null);try{const S=(y=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:y.id;if(!S){f("No active tab — open the audited page first."),R(!1);return}const H=await le({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:S,componentId:t,pageUrl:s});H.ok||f(H.error??"Re-run failed."),o()}catch(C){f(C instanceof Error?C.message:String(C))}finally{R(!1)}}return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${b}`,children:N}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:a}),n]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:N==="fail"?"AI walkthrough flagged a failure here. Fix the page and re-run, or verify manually and acknowledge.":"AI walkthrough couldn't decide. Fix the underlying ambiguity, or verify manually and acknowledge."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>j(y=>!y),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:w?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:$,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",title:"Re-run AI walkthrough after fixing the page (will switch to the active tab)",children:$?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{d(y=>!y),f(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",children:"✓ I verified manually"})]}),w&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2 mt-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"What the walkthrough does"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:r}),e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"AI reasoning"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap font-mono",children:i.reasoning})]}),l&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5 mt-1",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"How did you verify? (required, goes into the forensic record)"}),e.jsx("textarea",{value:u,onChange:y=>c(y.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),x&&e.jsx("p",{className:"text-[10px] text-rose-700",children:x}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void I(),disabled:p,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:p?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{d(!1),c(""),f(null)},disabled:p,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}),x&&!l&&e.jsx("p",{className:"text-[10px] text-rose-700",children:x})]})}function io({violation:t,onOpen:s}){const a=t.impact==="critical"?"bg-rose-200 text-rose-900":t.impact==="serious"?"bg-orange-200 text-orange-900":t.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700";return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${a}`,children:t.impact}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:t.wcagCriterion||"wcag"}),e.jsx("code",{className:"text-[11px] text-slate-700 bg-slate-100 px-1 rounded",children:t.ruleId})]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:t.description}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-0.5 font-mono break-all",children:t.target.selector})]})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("button",{type:"button",onClick:s,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Open in Violations →"})})]})}const rt=[{id:"2.4.3",label:"Focus order",blurb:"AI walks Tab/Shift+Tab and judges screenshot-by-screenshot whether focus reaches every interactive element."},{id:"2.1.2",label:"No keyboard trap",blurb:"AI Tab-cycles forward then Shift+Tab back; verifies every focusable can be left."},{id:"2.4.7",label:"Focus visible",blurb:"AI inspects each focus-state screenshot for a visible indicator (outline/ring/underline)."},{id:"1.3.2",label:"Meaningful sequence",blurb:"AI vision over the page screenshot judges whether DOM-flagged divergences are real reading-order breaks or layout artifacts."},{id:"1.4.11",label:"Non-text contrast",blurb:"AI vision evaluates UI controls + state indicators for adequate contrast against their adjacent colors."},{id:"2.5.3",label:"Label in Name",blurb:"DOM walker collects {visibleText, accessibleName} pairs across every interactive control; AI judges ambiguous cases (icons, plurals, smart-quotes)."}],oo={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function lo({componentId:t}){const[s,a]=h.useState({});h.useEffect(()=>{let d=!1;return(async()=>{if(!t){a({});return}const u=await Oe(t);if(d)return;const c={};for(const p of u)c[p.criterionId]=p;a(c)})(),()=>{d=!0}},[t]);const n={};for(const[d,u]of Object.entries(s))n[d]=u.verdict;const r=Object.values(n).length,i=Object.values(n).filter(d=>d==="pass").length,o=Object.values(n).filter(d=>d==="fail").length,l=Object.values(n).filter(d=>d==="uncertain").length;return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 border-b border-slate-100 flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-900",children:"AI verified"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-500",children:r===0?`not configured · all ${rt.length} criteria pending human verification`:`${r}/${rt.length} · ${i} pass · ${o} fail · ${l} uncertain`})]}),r===0?e.jsxs("div",{className:"px-3 py-2.5 text-[11px] text-slate-600 leading-snug",children:["When an Anthropic API key is set in ",e.jsx("strong",{children:"Settings → AI"}),', these 5 criteria run automatically after every audit — replacing manual keyboard and vision checks. Without a key, they show as "pending human verification" in the Evidence layers below.']}):e.jsx("ul",{className:"divide-y divide-slate-100",children:rt.map(d=>{const u=s[d.id],c=u==null?void 0:u.verdict,p=u?Ut(u.reasoning):!1,m=u?Xs(u.reasoning):!1,x=u?_t(u.reasoning):null;return e.jsxs("li",{className:"px-3 py-2 flex items-start gap-2.5",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-medium rounded px-1.5 py-0.5 ${c?oo[c]:"bg-slate-200 text-slate-500"}`,title:c?`AI verdict: ${c}${x?` (cascade ${x})`:""}`:"AI did not produce a verdict on this criterion",children:c||"not run"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:d.id}),d.label,m&&e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal",children:"· manual override"})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:d.blurb}),p&&!m&&u&&e.jsxs("div",{className:"mt-1.5 bg-amber-50 border border-amber-300 rounded p-2 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-amber-900 font-medium",children:"AI cascade flagged this — fix the issue and re-audit."}),e.jsxs("details",{className:"text-[10px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-32 overflow-y-auto bg-white/50 p-1.5 rounded",children:u.reasoning})]})]})]})]},d.id)})})]})}function co(){return e.jsxs("div",{className:"border-t border-slate-200 pt-3 space-y-1.5",children:[e.jsx("h3",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"how to read this"}),e.jsx(Ee,{title:"The overall grade",body:'Count-based aggregation of the 9 verification areas (rc.110). The headline letter is the worst sub-grade letter you have N of — one C drops the overall off A regardless of how clean the other 8 areas look. This keeps a single bad area from hiding behind a high arithmetic mean. It is separate from "WCAG 2.1 AA Status," which is the legal-conformance answer (binary: conformant or not). The grade can be A while AA Status says "Not conformant" if there are unresolved criterion-level items — those are different questions and both are reported.'}),e.jsx(Ee,{title:"WCAG 2.1 AA Status",body:"Separate from the letter grade. Says whether you can claim WCAG 2.1 AA conformance. It is binary: Conformant or Not conformant. When Not conformant, the breakdown shows how many criteria are failing (real axe/AI violations) and how many are inconclusive (items that need user disposition). Fix or mark verified to flip to Conformant."}),e.jsx(Ee,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Areas below A show "verify with X →" — but when an AI walkthrough has already produced a verdict for that criterion, the prompt is suppressed automatically.`}),e.jsx(Ee,{title:"AI does most of the human work",body:"Six AI walkthroughs auto-run when an Anthropic API key is configured: 2.4.3 Focus Order, 2.1.2 No Keyboard Trap, 2.4.7 Focus Visible, 1.3.2 Meaningful Sequence, 1.4.11 Non-text Contrast, 2.5.3 Label in Name. They drive real keyboard input + take screenshots + judge them with vision (and parse DOM accessible-name vs visible-text for 2.5.3) — exactly the work IGT manual workflows used to require. Their verdicts feed the Tab order / Keyboard / Reading order / Color & contrast / Forms sub-grades automatically. When AI returns a definitive pass or fail for an area, the heuristic findings for that area become supporting evidence rather than independent severity (rc.227). Humans only spot-check + attest before signing the formal report."}),e.jsx(Ee,{title:"Fix recipes",body:'Every finding includes specific remediation instructions in the AI fix prompt export (Delta lens → Export menu). The prompt also includes false-positive guidance (skip-links, multi-column layouts, portal-rendered modals) so AI can ask before "fixing" intentional patterns.'}),e.jsx(Ee,{title:"WCAG 2.1 AA coverage",body:"Of 50 applicable Level AA criteria, how many have a definite verdict from any layer (automation, AI, or human). Untested criteria don't cap your grade — automation did everything it could — but for a formal conformance claim, those still need explicit evaluation. Run a Site Crawl or open Compliance to fill the gaps."}),e.jsx(Ee,{title:"Path to full compliance",body:"The shortest sequence of actions: fix automated violations, let AI walkthroughs auto-resolve the keyboard/vision criteria, optionally spot-check via Compliance → Sign and seal. Export the AI fix prompt from the Delta lens for code-level walkthroughs of each issue."})]})}function Ee({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded bg-slate-50",children:[e.jsx("summary",{className:"px-2.5 py-1.5 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded",children:t}),e.jsx("p",{className:"px-2.5 pb-2 text-[11px] text-slate-700 leading-snug",children:s})]})}function uo({results:t}){const s=v(r=>r.dismissedKeys),a=new Set,n=[];for(const r of t)for(const i of r.violations){if(s.has(`violation::${i.matchKey}`))continue;const o=ht(i);a.has(o)||(a.add(o),n.push(i))}return n.sort((r,i)=>{const o=mt[r.impact]??99,l=mt[i.impact]??99;return o-l}),n.length===0?e.jsxs("div",{className:"text-center text-sm text-slate-600 py-6",children:["No automation-detectable violations found across ",t.length," state",t.length===1?"":"s",". Switch to ",e.jsx("strong",{children:"Per-area"})," or"," ",e.jsx("strong",{children:"Activity"})," for heuristic findings axe doesn't cover."]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[n.length," unique violation",n.length===1?"":"s"," · sorted by impact"]}),n.map(r=>e.jsx(Je,{violation:r},ht(r)))]})}const po={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function mo({pageUrl:t}){const s=v(u=>u.tier),a=Wt(s),n=xt(s,"autoExportAuditReports"),[r,i]=h.useState(null),[o,l]=h.useState(null);if(h.useEffect(()=>{let u=!1;return(async()=>{const c=await sa();if(u||i(c),t){const p=await In(t);u||l(p)}})(),()=>{u=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?po[r.formats[0]].split(" · ")[0]:`${r.formats.length} formats`;return e.jsxs("div",{className:"border border-emerald-200 rounded-lg bg-emerald-50 p-2.5 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-[12px] font-semibold text-emerald-900",children:"✓ Remediation trail active"}),e.jsx("span",{className:"text-[10px] text-emerald-800 font-mono",children:d})]}),o?e.jsxs("p",{className:"text-[10px] text-emerald-800 leading-snug",children:["Last exported ",e.jsx("span",{className:"font-mono",children:new Date(o.exportedAt).toLocaleString()})," ","as ",e.jsx("span",{className:"font-mono",children:o.filename})]}):e.jsx("p",{className:"text-[10px] text-emerald-800 italic",children:"No audit has auto-exported on this page yet. Your next audit will download to Downloads automatically."})]})}const Mt="igtRuns";async function ho(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Ye(r,o.map(l=>({key:Qe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Ye(r,o.map(l=>({key:qe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const xo={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"}},go={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"}},fo={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Ds(t,s){const a=await de();if(!a)return;const n=s?xo[t]:go[t];try{await be(a,n)}catch{}}async function bo(){const s=(await chrome.storage.local.get(Mt))[Mt];return s&&typeof s=="object"?s:{}}async function Os(t){await chrome.storage.local.set({[Mt]:t})}function vo(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 yo(){const t=v(c=>c.componentId),s=v(c=>c.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{bo().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(c,p,m){var f;const x={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((f=o[c])==null?void 0:f.steps)??{},[p]:m},completedAt:new Date().toISOString()}}};if(n(x),Os(x),m.status==="pass"){const w=xe.find($=>$.id===c),j=w==null?void 0:w.steps.find($=>$.id===p);j!=null&&j.autoDismissActivity&&ho(j.autoDismissActivity,s,p)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[c];const m={...a,[t]:p};n(m),Os(m)}const u=xe.find(c=>c.id===r);if(u){const c=o[u.id];return e.jsx(wo,{workflow:u,run:c,results:s,onAnswer:(p,m)=>l(u.id,p,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."}),xe.map(c=>{const p=o[c.id],m=p?tn(p,c):null,x=p?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.unanswered>0?"in-progress":"done":"unstarted",f={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${f}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&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:c.blurb}),p&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function wo({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const d={};for(const u of t.steps)d[u.id]=vo(u,a);return d},[t,a]);function o(){for(const d of t.steps){const u=i[d.id];(u==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`})}}const l=t.steps.filter(d=>{var u;return((u=i[d.id])==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,u)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[u+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const p=i[d.id];return p?p.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:p.ruleId})," ran clean across ",p.statesAudited," state",p.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:p.ruleId})," already found ",p.violationCount," violation",p.violationCount===1?"":"s"," in"," ",p.states.length," state",p.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${p.ruleId}, ${p.violationCount} hits in: ${p.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Ds(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",fo[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Ds(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(et,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(et,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(et,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(et,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:p=>n(d.id,{status:c.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const jo={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 et({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?jo[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const it="savedFlows";async function No(){const t=await chrome.storage.local.get(it);return Array.isArray(t[it])?t[it]:[]}async function Fs(t){await chrome.storage.local.set({[it]:t})}function ko(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{No().then(s)},[]);async function o(){const c=await de();if(!c){i("No audit-target tab found.");return}try{await be(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await de();if(c)try{const p=await Ie(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),p.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${p.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:p.steps,savedAt:new Date().toISOString()},f=[x,...t];s(f),await Fs(f),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(p){i(`Stop failed: ${p instanceof Error?p.message:String(p)}`)}}async function d(c){const p=await de();if(p){i(`Replaying "${c.name}"…`);try{const m=await Ie(p,{type:"FLOW_PLAY_REQUEST",steps:c.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 u(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(m=>m.id!==c);s(p),await Fs(p)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>u(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function So(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(Ao).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function Ao(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Co(){const t=v(l=>l.baselineList),s=v(l=>l.tier),a=aa[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{dt().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await le({type:"BASELINE_DELETE",componentId:l}),await dt()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const d=So(l.componentId),u=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),u&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(Re,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),u.criticalCount>0&&e.jsxs(Re,{tone:"rose",title:`${u.criticalCount} critical violations`,children:[u.criticalCount," critical"]}),u.seriousCount>0&&e.jsxs(Re,{tone:"orange",title:`${u.seriousCount} serious violations`,children:[u.seriousCount," serious"]}),u.focusResetCount>0&&e.jsxs(Re,{tone:"rose",title:`${u.focusResetCount} focus resets observed`,children:[u.focusResetCount," focus reset",u.focusResetCount===1?"":"s"]}),u.targetSizeFailCount>0&&e.jsxs(Re,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[u.targetSizeFailCount," small targets"]}),u.hoverContrastFail&&e.jsx(Re,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),u.announcementCount>0&&e.jsxs(Re,{tone:"indigo",title:"aria-live announcements observed",children:[u.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const Io={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 Re({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Io[t]}`,children:a})}const ot="wcagcheckr";function Z(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ze(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 Eo(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Ro(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 To(t){const s=new Map;for(const a of t){const n=s.get(a.componentId);n?(n.entries.push(a),a.receipt&&n.anchoredCount++,a.capturedAt>n.latest.capturedAt&&(n.latest=a,n.pageUrl=a.pageUrl)):s.set(a.componentId,{componentId:a.componentId,pageUrl:a.pageUrl,entries:[a],latest:a,anchoredCount:a.receipt?1:0})}for(const a of s.values())a.entries.sort((n,r)=>r.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function $o(t){switch(t){case"A":return"grade-a";case"B":return"grade-b";case"C":return"grade-c";case"D":return"grade-d";case"F":return"grade-f"}}function Lo(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${Z(t.receipt.tsaName)}) — anchored ${Z(ze(t.receipt.anchoredAt))}</td></tr>
19
19
  <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${Z(t.receipt.serverKeyFingerprint)}</code></td></tr>
20
- ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${Z(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${Z(it)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
20
+ ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${Z(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${Z(ot)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
21
21
  <article class="entry">
22
22
  <header class="entry-header">
23
- <span class="grade-badge ${Io(t.grade)}">${Z(t.grade)}</span>
23
+ <span class="grade-badge ${$o(t.grade)}">${Z(t.grade)}</span>
24
24
  <div class="entry-headline">
25
- <div class="entry-time">${Z(Ke(t.capturedAt))}</div>
25
+ <div class="entry-time">${Z(ze(t.capturedAt))}</div>
26
26
  <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
27
27
  </div>
28
28
  </header>
@@ -34,15 +34,15 @@ Future audits will treat every detected violation as new (no delta filtering). T
34
34
  <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
35
35
  ${n}
36
36
  </table>
37
- </article>`}function Ro(t){return`
37
+ </article>`}function Uo(t){return`
38
38
  <section class="component-section">
39
39
  <h2>
40
40
  <span class="component-id">${Z(t.componentId)}</span>
41
41
  <span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
42
42
  </h2>
43
43
  <p class="component-url"><strong>Page audited:</strong> <code>${Z(t.pageUrl)}</code></p>
44
- ${t.entries.map(Eo).join("")}
45
- </section>`}function Na(t){const{entries:s,extensionVersion:a}=t,n=Co(s),r=Ao(s),i=(t.axeVersions??So(s)).join(", "),o=s.length,l=s.filter(c=>c.receipt).length,d=o-l,u=Ke(new Date().toISOString());return`<!doctype html>
44
+ ${t.entries.map(Lo).join("")}
45
+ </section>`}function ka(t){const{entries:s,extensionVersion:a}=t,n=To(s),r=Ro(s),i=(t.axeVersions??Eo(s)).join(", "),o=s.length,l=s.filter(c=>c.receipt).length,d=o-l,u=ze(new Date().toISOString());return`<!doctype html>
46
46
  <html lang="en">
47
47
  <head>
48
48
  <meta charset="utf-8" />
@@ -191,13 +191,13 @@ Future audits will treat every detected violation as new (no delta filtering). T
191
191
  ${t.preparedBy?`<dt>Prepared by</dt><dd>${Z(t.preparedBy)}</dd>`:""}
192
192
  ${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${Z(t.jurisdiction)}</dd>`:""}
193
193
  <dt>Report generated</dt><dd>${Z(u)}</dd>
194
- <dt>Audit period</dt><dd>${r?`${Z(Ke(r.earliest))} — ${Z(Ke(r.latest))}`:"No audits recorded"}</dd>
194
+ <dt>Audit period</dt><dd>${r?`${Z(ze(r.earliest))} — ${Z(ze(r.latest))}`:"No audits recorded"}</dd>
195
195
  </dl>
196
196
  </section>
197
197
 
198
198
  <aside class="attestation">
199
199
  <h3>Attestation</h3>
200
- <p>The audit records summarized below were captured by the <strong>${Z(it)}</strong> Chrome extension, version <strong>${Z(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${Z(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>
200
+ <p>The audit records summarized below were captured by the <strong>${Z(ot)}</strong> Chrome extension, version <strong>${Z(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${Z(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>
201
201
  <p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
202
202
  <p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
203
203
  </aside>
@@ -208,10 +208,10 @@ Future audits will treat every detected violation as new (no delta filtering). T
208
208
  <tr><th>Local-only audits</th><td>${d}</td></tr>
209
209
  <tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
210
210
  <tr><th>axe-core version(s) observed</th><td>${Z(i||"n/a")}</td></tr>
211
- <tr><th>Tool</th><td>${Z(it)} ${Z(a)}</td></tr>
211
+ <tr><th>Tool</th><td>${Z(ot)} ${Z(a)}</td></tr>
212
212
  </table>
213
213
 
214
- ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Ro).join("")}
214
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Uo).join("")}
215
215
 
216
216
  <section class="methodology">
217
217
  <h2>Methodology</h2>
@@ -235,17 +235,17 @@ Future audits will treat every detected violation as new (no delta filtering). T
235
235
  </section>
236
236
 
237
237
  <footer>
238
- <span>Generated ${Z(u)} by ${Z(it)} ${Z(a)}</span>
238
+ <span>Generated ${Z(u)} by ${Z(ot)} ${Z(a)}</span>
239
239
  <span>${o} audit${o===1?"":"s"} · ${l} anchored · ${n.length} component${n.length===1?"":"s"}</span>
240
240
  </footer>
241
241
  </body>
242
- </html>`}async function Xt(t){const s=Na(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}const To=Object.freeze(Object.defineProperty({__proto__:null,buildPreLitigationReportHtml:Na,openPreLitigationReport:Xt},Symbol.toStringTag,{value:"Module"})),$o={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"},Lo={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Uo={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 ka({onBack:t}){const s=v(w=>w.siteCrawlStatus),a=v(w=>w.siteCrawlProgress),n=v(w=>w.siteCrawlReport),r=v(w=>w.siteCrawlError),[i,o]=h.useState(""),[l,d]=h.useState(25),[u,c]=h.useState(""),[p,m]=h.useState("");i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(w=>{var $;const A=($=w[0])==null?void 0:$.url;A&&/^https?:\/\//.test(A)&&i===""&&o(A)});function x(){if(!i||l>=5&&!window.confirm(`Each of the ${l} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${l*5} minutes. Proceed?`))return;v.getState().setSiteCrawlStatus("running"),v.getState().setSiteCrawlReport(null),v.getState().setSiteCrawlError(null);const w=u.trim(),A=p.trim();for(const[$,T]of[["Include",w],["Exclude",A]])if(T)try{new RegExp(T)}catch(j){window.alert(`${$} regex is invalid:
242
+ </html>`}async function es(t){const s=ka(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}const _o=Object.freeze(Object.defineProperty({__proto__:null,buildPreLitigationReportHtml:ka,openPreLitigationReport:es},Symbol.toStringTag,{value:"Module"})),Do={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"},Oo={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Fo={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 Sa({onBack:t}){const s=v(w=>w.siteCrawlStatus),a=v(w=>w.siteCrawlProgress),n=v(w=>w.siteCrawlReport),r=v(w=>w.siteCrawlError),[i,o]=h.useState(""),[l,d]=h.useState(25),[u,c]=h.useState(""),[p,m]=h.useState("");i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(w=>{var $;const j=($=w[0])==null?void 0:$.url;j&&/^https?:\/\//.test(j)&&i===""&&o(j)});function x(){if(!i||l>=5&&!window.confirm(`Each of the ${l} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${l*5} minutes. Proceed?`))return;v.getState().setSiteCrawlStatus("running"),v.getState().setSiteCrawlReport(null),v.getState().setSiteCrawlError(null);const w=u.trim(),j=p.trim();for(const[$,R]of[["Include",w],["Exclude",j]])if(R)try{new RegExp(R)}catch(N){window.alert(`${$} regex is invalid:
243
243
 
244
- ${j instanceof Error?j.message:String(j)}
244
+ ${N instanceof Error?N.message:String(N)}
245
245
 
246
- Fix or clear the field and try again.`),v.getState().setSiteCrawlStatus("idle");return}Ne({type:"START_SITE_CRAWL",startUrl:i,maxPages:l,...w?{includeRegex:w}:{},...A?{excludeRegex:A}:{}})}function f(){de({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),e.jsxs("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Heads-up if you're logged in."})," ","The crawler follows whatever links appear in the rendered page — so if you're authenticated to the target site, it will walk into the authenticated nav (admin pages, dashboards, account pages) and try to audit them. Some of those may 404 or behave unexpectedly without specific context. For a clean public-site crawl, log out first or run from an incognito window."]}),e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2.5 py-2 text-[11px] text-slate-700 leading-snug",children:[e.jsx("strong",{children:"Audit depth is configured in Settings, not here."})," ","Each page in the crawl runs your current single-page audit pipeline — the state matrix (pseudo-states · themes · directions · breakpoints), AI walkthroughs, and disabled-rules list. Set those in"," ",e.jsx("strong",{children:"Settings → State Matrix"})," (the ⚙ icon at the top of the side panel) before starting a crawl. If your single-page audit is currently set to the full 72-state matrix, every crawled page runs all 72 states."]}),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:w=>o(w.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:w=>d(Math.min(200,Math.max(1,parseInt(w.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your configured single-page pipeline — see Settings → State Matrix for what that means."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-include",className:"block text-[11px] text-slate-500 mb-1",children:"Include only URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-include",type:"text",value:u,onChange:w=>c(w.target.value),placeholder:"^https://example\\.com/products/",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["When set, only URLs matching this regex get crawled. Useful for scoping a crawl to one section, e.g. ",e.jsx("code",{children:"/blog/"}),"."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-exclude",className:"block text-[11px] text-slate-500 mb-1",children:"Exclude URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-exclude",type:"text",value:p,onChange:w=>m(w.target.value),placeholder:"/admin|/dashboard|/account|/login",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"URLs matching this regex are skipped. Helpful when logged in to the target site — keep the crawl on the public surface."})]}),e.jsx("button",{type:"button",onClick:x,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:f,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(_o,{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 _o({report:t}){function s(){ke(async()=>{const{renderSiteReportHtml:g}=await import("./site-report-renderer-uSajBWRd.js");return{renderSiteReportHtml:g}},__vite__mapDeps([5,0,1,2,3])).then(({renderSiteReportHtml:g})=>{const y=g(t);$e(y)})}const[a,n]=h.useState(!1),[r,i]=h.useState({state:"idle"});async function o(){if(window.confirm(`Save the current crawl as the site baseline?
246
+ Fix or clear the field and try again.`),v.getState().setSiteCrawlStatus("idle");return}Ne({type:"START_SITE_CRAWL",startUrl:i,maxPages:l,...w?{includeRegex:w}:{},...j?{excludeRegex:j}:{}})}function f(){le({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),e.jsxs("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Heads-up if you're logged in."})," ","The crawler follows whatever links appear in the rendered page — so if you're authenticated to the target site, it will walk into the authenticated nav (admin pages, dashboards, account pages) and try to audit them. Some of those may 404 or behave unexpectedly without specific context. For a clean public-site crawl, log out first or run from an incognito window."]}),e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2.5 py-2 text-[11px] text-slate-700 leading-snug",children:[e.jsx("strong",{children:"Audit depth is configured in Settings, not here."})," ","Each page in the crawl runs your current single-page audit pipeline — the state matrix (pseudo-states · themes · directions · breakpoints), AI walkthroughs, and disabled-rules list. Set those in"," ",e.jsx("strong",{children:"Settings → State Matrix"})," (the ⚙ icon at the top of the side panel) before starting a crawl. If your single-page audit is currently set to the full 72-state matrix, every crawled page runs all 72 states."]}),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:w=>o(w.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:w=>d(Math.min(200,Math.max(1,parseInt(w.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your configured single-page pipeline — see Settings → State Matrix for what that means."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-include",className:"block text-[11px] text-slate-500 mb-1",children:"Include only URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-include",type:"text",value:u,onChange:w=>c(w.target.value),placeholder:"^https://example\\.com/products/",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["When set, only URLs matching this regex get crawled. Useful for scoping a crawl to one section, e.g. ",e.jsx("code",{children:"/blog/"}),"."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-exclude",className:"block text-[11px] text-slate-500 mb-1",children:"Exclude URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-exclude",type:"text",value:p,onChange:w=>m(w.target.value),placeholder:"/admin|/dashboard|/account|/login",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"URLs matching this regex are skipped. Helpful when logged in to the target site — keep the crawl on the public surface."})]}),e.jsx("button",{type:"button",onClick:x,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:f,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(Mo,{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 Mo({report:t}){function s(){ke(async()=>{const{renderSiteReportHtml:g}=await import("./site-report-renderer-CAdiagxw.js");return{renderSiteReportHtml:g}},__vite__mapDeps([5,0,1,2,3])).then(({renderSiteReportHtml:g})=>{const y=g(t);$e(y)})}const[a,n]=h.useState(!1),[r,i]=h.useState({state:"idle"});async function o(){if(window.confirm(`Save the current crawl as the site baseline?
247
247
 
248
- Each of the ${t.pagesAudited} crawled page${t.pagesAudited===1?"":"s"} will be saved as its own baseline. Future audits + re-crawls will show delta against these snapshots. Any existing baselines for these same components will be overwritten.`)){i({state:"running",current:0,total:t.pagesAudited});try{const C=(await J({type:"SETTINGS_GET",key:"stateMatrix"})).data??Bt,S=await Ut();if(!S||S.length===0){i({state:"error",message:"No per-URL results found in storage. Re-run the crawl."});return}let R=0,K=0;for(let V=0;V<S.length;V++){const W=S[V];if(i({state:"running",current:V,total:S.length}),W.error||W.results.length===0||!W.componentId){K++;continue}try{const L=W.results.flatMap(M=>M.violations),U=W.results.flatMap(M=>M.announcements??[]),k=W.results.flatMap(M=>M.focusEvents??[]),O=W.results[0];await de({type:"BASELINE_SET",componentId:W.componentId,violations:L,announcements:U,focusEvents:k,snapshotMeta:{url:W.url,axeVersion:O.axeVersion,matrixConfig:C,capturedAt:new Date().toISOString()}}),R++}catch(L){console.warn("[site-crawl-panel] BASELINE_SET failed for",W.url,L),K++}}try{const V=await J({type:"BASELINE_LIST"});v.getState().setBaselineList(V.items)}catch{}i({state:"done",saved:R,failed:K})}catch(y){i({state:"error",message:y instanceof Error?y.message:String(y)})}}}const[l,d]=h.useState(null),[u,c]=h.useState(null),[p,m]=h.useState(!1),[x,f]=h.useState(!1);async function w(){c(null);try{const g=await Ut();if(!g||g.length===0){c("No per-URL results found. Re-run the crawl.");return}if(!g.some(C=>{var S;return(((S=C.results)==null?void 0:S.length)??0)>0})){c("Crawled pages have no audit results to use.");return}m(!0)}catch(g){c(g instanceof Error?g.message:String(g))}}const[A,$]=h.useState({state:"idle"});async function T(){var K,V,W;const{createZip:g}=await ke(async()=>{const{createZip:L}=await import("./zip-encoder-CtULHXx_.js");return{createZip:L}},[]),{renderSiteReportHtml:y}=await ke(async()=>{const{renderSiteReportHtml:L}=await import("./site-report-renderer-uSajBWRd.js");return{renderSiteReportHtml:L}},__vite__mapDeps([5,0,1,2,3])),C=[{format:"defense-bundle",filename:"defense-bundle.html"},{format:"deposition-packet",filename:"deposition-packet.html"},{format:"evidence-bundle",filename:"evidence-bundle.html"},{format:"vpat",filename:"vpat.html"},{format:"conformance-crosswalk",filename:"conformance-crosswalk.html"},{format:"methodology-doc",filename:"methodology-doc.html"},{format:"executive-report",filename:"executive-report.html"}],S=[],R=[];$({state:"running",current:"site-report.html",doneCount:0,totalCount:C.length+3});try{try{const P=y(t);R.push({name:"site-report.html",content:P})}catch{S.push("site-report.html")}$(P=>P.state==="running"?{...P,current:"ai-fix-prompt.md",doneCount:P.doneCount+1}:P);try{const P=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]});P!=null&&P.content&&P.content.length>50?R.push({name:"ai-fix-prompt.md",content:P.content}):S.push("ai-fix-prompt.md")}catch{S.push("ai-fix-prompt.md")}for(const{format:P,filename:ne}of C){$(N=>N.state==="running"?{...N,current:ne,doneCount:N.doneCount+1}:N);try{const N=await J({type:"EXPORT_REQUEST",format:P,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});N!=null&&N.content&&N.content.length>50?R.push({name:ne,content:N.content}):S.push(ne)}catch(N){console.warn(`[bulk-export] ${P} failed`,N),S.push(ne)}}$(P=>P.state==="running"?{...P,current:"pre-litigation-report.html",doneCount:P.doneCount+1}:P);try{const P=await ot();if(P.length>0){const ne=typeof chrome<"u"&&((W=(V=(K=chrome.runtime)==null?void 0:K.getManifest)==null?void 0:V.call(K))==null?void 0:W.version)||"1.0.0",{buildPreLitigationReportHtml:N}=await ke(async()=>{const{buildPreLitigationReportHtml:H}=await Promise.resolve().then(()=>To);return{buildPreLitigationReportHtml:H}},void 0),G=N({entries:P,extensionVersion:ne});R.push({name:"pre-litigation-report.html",content:G})}else S.push("pre-litigation-report.html (no forensic entries yet)")}catch{S.push("pre-litigation-report.html")}const L=`wcagcheckr — Site-wide compliance bundle
248
+ Each of the ${t.pagesAudited} crawled page${t.pagesAudited===1?"":"s"} will be saved as its own baseline. Future audits + re-crawls will show delta against these snapshots. Any existing baselines for these same components will be overwritten.`)){i({state:"running",current:0,total:t.pagesAudited});try{const C=(await J({type:"SETTINGS_GET",key:"stateMatrix"})).data??Kt,S=await Dt();if(!S||S.length===0){i({state:"error",message:"No per-URL results found in storage. Re-run the crawl."});return}let T=0,H=0;for(let V=0;V<S.length;V++){const W=S[V];if(i({state:"running",current:V,total:S.length}),W.error||W.results.length===0||!W.componentId){H++;continue}try{const L=W.results.flatMap(M=>M.violations),U=W.results.flatMap(M=>M.announcements??[]),A=W.results.flatMap(M=>M.focusEvents??[]),O=W.results[0];await le({type:"BASELINE_SET",componentId:W.componentId,violations:L,announcements:U,focusEvents:A,snapshotMeta:{url:W.url,axeVersion:O.axeVersion,matrixConfig:C,capturedAt:new Date().toISOString()}}),T++}catch(L){console.warn("[site-crawl-panel] BASELINE_SET failed for",W.url,L),H++}}try{const V=await J({type:"BASELINE_LIST"});v.getState().setBaselineList(V.items)}catch{}i({state:"done",saved:T,failed:H})}catch(y){i({state:"error",message:y instanceof Error?y.message:String(y)})}}}const[l,d]=h.useState(null),[u,c]=h.useState(null),[p,m]=h.useState(!1),[x,f]=h.useState(!1);async function w(){c(null);try{const g=await Dt();if(!g||g.length===0){c("No per-URL results found. Re-run the crawl.");return}if(!g.some(C=>{var S;return(((S=C.results)==null?void 0:S.length)??0)>0})){c("Crawled pages have no audit results to use.");return}m(!0)}catch(g){c(g instanceof Error?g.message:String(g))}}const[j,$]=h.useState({state:"idle"});async function R(){var H,V,W;const{createZip:g}=await ke(async()=>{const{createZip:L}=await import("./zip-encoder-CtULHXx_.js");return{createZip:L}},[]),{renderSiteReportHtml:y}=await ke(async()=>{const{renderSiteReportHtml:L}=await import("./site-report-renderer-CAdiagxw.js");return{renderSiteReportHtml:L}},__vite__mapDeps([5,0,1,2,3])),C=[{format:"defense-bundle",filename:"defense-bundle.html"},{format:"deposition-packet",filename:"deposition-packet.html"},{format:"evidence-bundle",filename:"evidence-bundle.html"},{format:"vpat",filename:"vpat.html"},{format:"conformance-crosswalk",filename:"conformance-crosswalk.html"},{format:"methodology-doc",filename:"methodology-doc.html"},{format:"executive-report",filename:"executive-report.html"}],S=[],T=[];$({state:"running",current:"site-report.html",doneCount:0,totalCount:C.length+3});try{try{const P=y(t);T.push({name:"site-report.html",content:P})}catch{S.push("site-report.html")}$(P=>P.state==="running"?{...P,current:"ai-fix-prompt.md",doneCount:P.doneCount+1}:P);try{const P=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]});P!=null&&P.content&&P.content.length>50?T.push({name:"ai-fix-prompt.md",content:P.content}):S.push("ai-fix-prompt.md")}catch{S.push("ai-fix-prompt.md")}for(const{format:P,filename:ne}of C){$(k=>k.state==="running"?{...k,current:ne,doneCount:k.doneCount+1}:k);try{const k=await J({type:"EXPORT_REQUEST",format:P,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});k!=null&&k.content&&k.content.length>50?T.push({name:ne,content:k.content}):S.push(ne)}catch(k){console.warn(`[bulk-export] ${P} failed`,k),S.push(ne)}}$(P=>P.state==="running"?{...P,current:"pre-litigation-report.html",doneCount:P.doneCount+1}:P);try{const P=await lt();if(P.length>0){const ne=typeof chrome<"u"&&((W=(V=(H=chrome.runtime)==null?void 0:H.getManifest)==null?void 0:V.call(H))==null?void 0:W.version)||"1.0.0",{buildPreLitigationReportHtml:k}=await ke(async()=>{const{buildPreLitigationReportHtml:K}=await Promise.resolve().then(()=>_o);return{buildPreLitigationReportHtml:K}},void 0),G=k({entries:P,extensionVersion:ne});T.push({name:"pre-litigation-report.html",content:G})}else S.push("pre-litigation-report.html (no forensic entries yet)")}catch{S.push("pre-litigation-report.html")}const L=`wcagcheckr — Site-wide compliance bundle
249
249
  ========================================
250
250
 
251
251
  Generated: ${new Date().toISOString()}
@@ -255,7 +255,7 @@ Site grade: ${t.siteGrade}
255
255
  Unique violations site-wide: ${t.totalUniqueViolations}
256
256
 
257
257
  Contents:
258
- `+R.map(P=>` - ${P.name}`).join(`
258
+ `+T.map(P=>` - ${P.name}`).join(`
259
259
  `)+`
260
260
 
261
261
  `+(S.length>0?`Skipped (not included):
@@ -265,12 +265,12 @@ Contents:
265
265
  `:"")+`Each HTML report opens directly in a browser. Use
266
266
  Ctrl+P → Save as PDF in the report you want sealed for legal
267
267
  or compliance submission.
268
- `;if(R.unshift({name:"README.txt",content:L}),R.length===0){$({state:"error",message:"No reports could be generated. Re-run the crawl and try again."});return}const U=g(R),k=new Date().toISOString().slice(0,10),O=t.startUrl.replace(/^https?:\/\//,"").replace(/[^a-z0-9]/gi,"-").replace(/-+/g,"-").slice(0,32).toLowerCase()||"crawl",M=`wcagcheckr-site-bundle-${k}-${O}.zip`,ee=URL.createObjectURL(U),E=document.createElement("a");E.href=ee,E.download=M,document.body.appendChild(E),E.click(),document.body.removeChild(E),setTimeout(()=>URL.revokeObjectURL(ee),3e4),$({state:"done",included:R.length,skipped:S})}catch(L){$({state:"error",message:L instanceof Error?L.message:String(L)})}}async function j(){var g,y,C;f(!0),c(null);try{const S=await ot();if(S.length===0){c("No forensic-log entries yet. Generate a defense bundle or deposition packet first — those create the anchored entries the pre-litigation report documents.");return}const R=typeof chrome<"u"&&((C=(y=(g=chrome.runtime)==null?void 0:g.getManifest)==null?void 0:y.call(g))==null?void 0:C.version)||"1.0.0";await Xt({entries:S,extensionVersion:R})}catch(S){c(S instanceof Error?S.message:String(S))}finally{f(!1)}}async function b(g,y){d(g),c(null);try{const C=`site:${t.startUrl}`,S=await J({type:"EXPORT_REQUEST",format:g,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});if(!(S!=null&&S.content)||S.content.length<50){c(`Generation returned empty content for ${g}.`);return}if(y==="download"){const R=mt(g,C);Xe(S.content,R)}else $e(S.content)}catch(C){c(C instanceof Error?C.message:String(C))}finally{d(null)}}async function I(){n(!0);try{const g=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),y=(g==null?void 0:g.content)??"";if(!y){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(y)}catch{}$e(y,"text/markdown;charset=utf-8")}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${$o[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Lo[t.siteRisk]}`,children:en[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.totalNeedsReview>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:t.totalNeedsReview})," need",t.totalNeedsReview===1?"s":""," review"]}),t.totalWalkthroughFindings>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:t.totalWalkthroughFindings})," AI walkthrough finding",t.totalWalkthroughFindings===1?"":"s"]}),t.walkthroughAcknowledgements.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{className:"text-emerald-700",children:t.walkthroughAcknowledgements.length})," human-verified"]}),t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 font-medium",children:"📊 Open full site report (standalone HTML)"}),e.jsx("button",{type:"button",onClick:I,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsx("button",{type:"button",onClick:()=>void o(),disabled:r.state==="running",className:"w-full text-sm px-4 py-2.5 border border-emerald-500 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 font-medium",title:"Save each crawled page's current state as its baseline. Future audits + re-crawls show delta against this snapshot.",children:r.state==="running"?`Saving baselines… ${r.current+1}/${r.total}`:"📌 Set this crawl as the site baseline"}),r.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Saved ",r.saved," baseline",r.saved===1?"":"s",r.failed>0&&` · ${r.failed} failed (re-crawl those pages and retry)`]}),r.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",r.message]}),e.jsxs("div",{className:"border border-slate-200 rounded-lg p-3 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-700",children:"Site-wide compliance documents"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Generate the same legal / compliance / industry docs you can produce from a single-page audit — but covering the whole crawled site. Use these to respond to demand letters, file VPATs, or document remediation history."}),e.jsx("button",{type:"button",onClick:()=>void T(),disabled:A.state==="running",className:"w-full text-sm px-4 py-2.5 bg-slate-900 text-white rounded hover:bg-slate-800 disabled:opacity-50 font-medium",title:"Generate all compliance docs at once and download as a single .zip file",children:A.state==="running"?`Generating ${A.current} (${A.doneCount}/${A.totalCount})…`:"📦 Download all reports as a zip"}),A.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Bundled ",A.included," file",A.included===1?"":"s"," into the zip",A.skipped.length>0&&e.jsxs(e.Fragment,{children:[" ","· skipped ",A.skipped.length,":",e.jsx("ul",{className:"mt-0.5 ml-3 list-disc",children:A.skipped.map(g=>e.jsx("li",{className:"break-all",children:g},g))})]})]}),A.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",A.message]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[e.jsx(Ce,{label:"⚖ Defense bundle",sub:"Forensic-anchored HTML evidence — download + Ctrl+P to seal as PDF",busy:l==="defense-bundle",disabled:l!==null,onClick:()=>void b("defense-bundle","download")}),e.jsx(Ce,{label:"📜 Deposition packet",sub:"Court-grade — cover sheet, chain of custody, sworn declaration template",busy:l==="deposition-packet",disabled:l!==null,onClick:()=>void b("deposition-packet","download")}),e.jsx(Ce,{label:"📂 Evidence bundle",sub:"Same shape as Defense — neutral 'evidence' framing",busy:l==="evidence-bundle",disabled:l!==null,onClick:()=>void b("evidence-bundle","download")}),e.jsx(Ce,{label:"📋 VPAT (Voluntary Product Accessibility Template)",sub:"Formal industry conformance template — opens in new tab",busy:l==="vpat",disabled:l!==null,onClick:()=>void b("vpat","open-in-tab")}),e.jsx(Ce,{label:"🔄 Conformance crosswalk",sub:"WCAG 2.1 AA criterion-by-criterion conformance table",busy:l==="conformance-crosswalk",disabled:l!==null,onClick:()=>void b("conformance-crosswalk","open-in-tab")}),e.jsx(Ce,{label:"🔬 Methodology doc",sub:"How this audit was conducted — defensibility documentation",busy:l==="methodology-doc",disabled:l!==null,onClick:()=>void b("methodology-doc","open-in-tab")}),e.jsx(Ce,{label:"📊 Executive report",sub:"Stakeholder summary — grade hero, top risks, next steps. Print-ready.",busy:l==="executive-report",disabled:l!==null,onClick:()=>void b("executive-report","open-in-tab")}),e.jsx(Ce,{label:"📃 Accessibility statement",sub:"Public WCAG conformance statement (HTML or Markdown) — opens a dialog for org info",busy:!1,disabled:l!==null,onClick:()=>void w()}),e.jsx(Ce,{label:"📋 Pre-litigation report",sub:"Audit-history record across time — requires anchored entries (generate a defense bundle first)",busy:x,disabled:l!==null||x,onClick:()=>void j()})]}),u&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",u]})]}),e.jsx(va,{open:p,onClose:()=>m(!1),results:[],siteCrawlSource:!0}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"This report is your do-the-work list."})," ","Each finding below is grouped by whether it's likely a"," ",e.jsx("strong",{children:"shared resource"})," (a CSS rule, component, or layout that affects multiple pages — fix it once, helps everywhere) or ",e.jsx("strong",{children:"page-specific"})," (only that one URL). Click any affected URL to open that page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)."]}),e.jsx(kt,{title:"Shared resources — fix once, helps multiple pages",sectionKind:"shared-actionable",groups:t.findingGroups.filter(g=>g.isShared&&!g.needsReview),openPage:Ge}),e.jsx(kt,{title:"Page-specific — one-off; fix on that page",sectionKind:"local-actionable",groups:t.findingGroups.filter(g=>!g.isShared&&!g.needsReview),openPage:Ge}),t.consistencyFindings.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700 mb-2",children:["Site-wide patterns (",t.consistencyFindings.length,")"]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:"Inconsistencies the comparators only see across pages — navigation order divergence, identification mismatches, redundant entry. WCAG 3.2.3 / 3.2.4 / 3.2.6."}),e.jsx("ul",{className:"space-y-2",children:t.consistencyFindings.map((g,y)=>e.jsxs("li",{className:"border border-blue-200 rounded p-2.5 bg-blue-50 text-xs",children:[e.jsxs("p",{className:"font-mono text-[10px] text-blue-700",children:[g.ruleId," · WCAG ",g.wcagCriterion," · ",g.impact]}),e.jsx("p",{className:"text-sm text-blue-900 mt-1",children:g.description}),g.details&&e.jsx("p",{className:"text-[11px] text-blue-800 mt-1 whitespace-pre-wrap leading-snug",children:g.details}),g.pages.length>0&&e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-blue-700",children:"Pages compared:"}),g.pages.map(C=>e.jsxs("button",{type:"button",onClick:()=>void Ge(C.url),className:"block w-full text-left text-[11px] font-mono text-blue-800 hover:text-blue-900 hover:underline truncate",children:["→ ",C.url]},C.url))]})]},y))})]}),e.jsx(kt,{title:"Needs human review",sectionKind:"needs-review",groups:t.findingGroups.filter(g=>g.needsReview),openPage:Ge,hint:"AI flagged these as possibly failing but couldn't decide — you need to look + judge. They don't count toward the severity total above."}),t.findingGroups.length===0&&t.consistencyFindings.length===0&&e.jsxs("div",{className:"border border-emerald-200 rounded p-3 bg-emerald-50 text-xs text-emerald-900",children:[e.jsxs("strong",{children:["✓ No findings across the ",t.pagesAudited," crawled page",t.pagesAudited===1?"":"s","."]})," Per-page audits all completed cleanly. Drill into any page below to see the full per-page Findings if you want to verify or run guided manual checks."]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:["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.map(g=>{const y=g.walkthroughFindings.length,C=g.walkthroughAcknowledgements.length,S=[...g.walkthroughFindings.map(R=>`${R.criterionId} ${R.verdict.toUpperCase()}`),...g.walkthroughAcknowledgements.map(R=>`${R.criterionId} ✓ack`)].join(", ");return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void Ge(g.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:S?`Walkthrough findings on this page: ${S}. Click to drill in.`:"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 ${g.grade==="A"?"text-emerald-700":g.grade==="B"?"text-lime-700":g.grade==="C"?"text-yellow-700":g.grade==="D"?"text-orange-700":"text-rose-700"}`,children:g.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:g.url}),e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0 tabular-nums",title:"axe violations",children:[g.uniqueViolations," axe"]}),e.jsxs("span",{className:`text-[10px] shrink-0 tabular-nums font-medium ${y>0?"text-rose-700":C>0?"text-emerald-700":"text-slate-400"}`,title:y>0||C>0?`${y} walkthrough finding${y===1?"":"s"}${C>0?`, ${C} acknowledged`:""}`:"No walkthrough findings",children:[y," walkthru",C>0?` (${C}✓)`:""]}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},g.url)})})]})]})}async function Ge(t){try{const s=await Ut(),a=s==null?void 0:s.find(n=>n.url===t);if(!a||a.results.length===0||!a.componentId){console.warn("[site-crawl-panel] no cached crawl results for",t);return}try{const{getResolutionsForPage:n}=await ke(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-V0TlccxL.js").then(o=>o.aE);return{getResolutionsForPage:i}},__vite__mapDeps([0,1,2,3])),r=await n(t);v.getState().setResolutionsForUrl(t,r)}catch{}v.getState().setResults(a.results,a.delta,a.componentId),v.getState().setCrawlNavContext({mode:"page",url:t});try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}v.getState().setView("report"),v.getState().setFindingsLens("overview")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}function Ce({label:t,sub:s,busy:a,disabled:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,disabled:n,className:"w-full text-left px-3 py-2 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-medium text-slate-900",children:a?`Generating ${t.replace(/^[^a-zA-Z]+/,"")}…`:t}),e.jsx("div",{className:"text-[10px] text-slate-600 leading-snug mt-0.5",children:s})]})}function kt({title:t,sectionKind:s,groups:a,openPage:n,hint:r}){if(a.length===0)return null;const i=s==="needs-review",o=i?"text-amber-700":"text-slate-500",l=i?"border-amber-200 bg-amber-50":"border-slate-200 bg-white",d=i?"bg-amber-200 text-amber-900":"";return e.jsxs("div",{children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wide mb-2 ${o}`,children:[t," (",a.length,")"]}),r&&e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:r}),e.jsx("ul",{className:"space-y-2",children:a.map((u,c)=>e.jsx(Do,{group:u,sectionKind:s,cardCls:l,labelCls:d,openPage:n},`${u.ruleId}::${u.representativeSelector}::${c}`))})]})}function Do({group:t,sectionKind:s,cardCls:a,labelCls:n,openPage:r}){const i=tn(t.ruleId),l=i.whatsWrong&&i.whatsWrong!=="An accessibility rule failed on this page.",d=l?i.whatsWrong:t.axeDescription||`Rule "${t.ruleId}" was flagged — see axe-core docs for this rule.`,u=l?i.whyItMatters:null,c=l?i.howToFix:null,p=s==="needs-review",m=s==="shared-actionable",x=p?"review":t.impact,f=p?`${n} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`:`${Uo[t.impact]} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`;return e.jsxs("li",{className:`border rounded p-2.5 text-xs ${a}`,children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:f,children:x}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 mt-0.5 break-all",children:[t.ruleId,t.wcagCriterion&&` · WCAG ${t.wcagCriterion}`]}),e.jsxs("p",{className:"text-[11px] text-slate-600 mt-1",children:[m?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Shared"})," — found on"," ",e.jsx("strong",{children:t.pages.length})," page",t.pages.length===1?"":"s",". Likely a shared component or CSS rule — fix once."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Page-specific"})," — only on this one page."]}),t.totalOccurrences>t.pages.length&&e.jsxs(e.Fragment,{children:[" · ",t.totalOccurrences," matrix-state occurrences"]})]})]})]}),(u||c)&&e.jsxs("div",{className:"ml-7 mb-2 space-y-1.5",children:[u&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Why it matters"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u})]}),c&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"How to fix"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:c})]})]}),t.representativeSelector&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Where to find it"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-700 break-all",children:t.representativeSelector}),t.representativeOuterHTML&&e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 break-all mt-0.5 line-clamp-2",children:[t.representativeOuterHTML.slice(0,200),t.representativeOuterHTML.length>200?"…":""]})]}),t.failureSummary&&!l&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Detail"}),e.jsxs("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:[t.failureSummary.slice(0,600),t.failureSummary.length>600?"…":""]})]}),e.jsxs("div",{className:"ml-7",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-0.5",children:p?"Open to review":"Affected pages"}),e.jsx("ul",{className:"space-y-0.5",children:t.pages.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(w.url),className:"block w-full text-left text-[11px] font-mono text-brand-700 hover:text-brand-900 hover:underline truncate",title:"Open this page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)",children:["→ ",w.url]})},w.url))})]})]})}const St="onboardingDismissed",At=[{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 Oo(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(St).then(l=>{l[St]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[St]:!0}),s(!1),n(0)}const i=a===At.length-1,o=At[a];return e.jsxs(De,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",At.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Fo(){const t=v(n=>n.status),s=v(n=>n.errorMessage),a=v(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Mo(){const t=v(d=>d.aiFailure),s=v(d=>d.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",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,u)=>e.jsx("li",{children:d},u))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Ms(){const[t,s]=h.useState(!1);return h.useEffect(()=>ye("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),v.getState().setStatus("idle"))}),[]),e.jsxs(De,{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 Po(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{sn().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await rs(),v.getState().startNewScan(),t.mode==="storybook-all"?Ne({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&Ne({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await rs(),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 Ct="storybook:hintDismissed";function Go(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(Ct))[Ct])return;const o=await ce();if(o)try{const u=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(p=c.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(c=>{var p;return(p=c.result)==null?void 0:p.detected});u&&(n((l=u.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Ct]:!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 Vo(){var i;const t=v(o=>o.results),s=v(o=>o.baselineList),a=v(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Wo(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 Wo(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function Bo(){const t=v(l=>l.results),s=v(l=>l.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=an(r,a.length>0?{runs:a,workflows:xe}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Ho(){const t=v(a=>a.setUserMode);function s(a){t(a),de({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 Ko=["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"],zo={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 qo(t){const s=new Set(Ko),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,u])=>({ruleId:d,instanceCount:u})).sort((d,u)=>u.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,u)=>d+u,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:zo[o]}}const Sa={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Qo={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Sa]},Yo={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Sa]};function Zt(t){return t==="thorough"?Yo:Qo}function Ps(t){const s=Zt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Aa(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[r,i]=h.useState(0),[o,l]=h.useState(!1),[d,u]=h.useState(""),[c,p]=h.useState(""),[m,x]=h.useState(""),[f,w]=h.useState(!1);if(h.useEffect(()=>{let b=!1;return s(null),n(null),ot().then(I=>{b||s(I)}).catch(I=>{b||n(I instanceof Error?I.message:String(I))}),()=>{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 A=t.length,$=t.filter(b=>b.receipt).length;async function T(){if(!(!t||t.length===0)){w(!0);try{await Xt({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:m.trim()||void 0}),l(!1)}finally{w(!1)}}}async function j(){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},I=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),g=URL.createObjectURL(I),y=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,C=document.createElement("a");C.href=g,C.download=y,C.click(),setTimeout(()=>URL.revokeObjectURL(g),1e3)}return A===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[A," ",A===1?"entry":"entries",$>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[$," RFC 3161-anchored"]})]}),$===0&&A>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(b=>!b),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void j(),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"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:b=>u(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:c,onChange:b=>p(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:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:f||A===0,onClick:T,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:f?"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 Jo(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let d=!1;return ot().then(u=>{d||s(u)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:o.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(De,{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(Aa,{})})})]})}function Xo(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Zo={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."},el={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."},tl={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},sl={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Ca(){const t=v(p=>p.tier),s=v(p=>p.trialDaysRemaining),a=v(p=>p.seatsUsed),n=v(p=>p.seatsTotal),r=v(p=>p.planCode),i=v(p=>p.licenseDaysRemaining),o=v(p=>p.pastDue),[l,d]=h.useState(!1);if(t==="solo"&&r==="solo-single-month"){const p=i,m=p!==null&&p<=7,x=p===null?"":p===0?"expires today":p===1?"1 day left":`${p} days left`;return e.jsxs("aside",{"aria-label":"License status",className: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:()=>d(!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 de({type:"OPEN_SETTINGS"}),className:m?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Tt,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?sl:tl,m=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:p.perks,x=t==="team"&&a!==null&&n!==null&&a>n,f=t==="team"&&a!==null&&n!==null&&a===n,w=o?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:f?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${w.bg} border-b ${w.border} px-3 py-2 space-y-1 text-[11px] ${w.shadow}`,children:[e.jsxs("div",{className:w.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",p.label]}),e.jsxs("span",{className:w.subtitle,children:[" · ",m]})]}),o&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),f&&!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 de({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const u=t==="trial"?Zo:el,c=t==="trial"?Xo(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:u.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:c})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:u.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:u.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void de({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(Tt,{open:l,onClose:()=>d(!1)})]})}const al={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"},nl={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Gs={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},rl={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"},Vs={critical:0,serious:1,moderate:2,minor:3};function il(){const t=v(p=>p.setUserMode),s=v(p=>p.status),a=v(p=>p.setStatus),n=v(p=>p.errorMessage),r=v(p=>p.setError),[i,o]=h.useState(!1),[l,d]=h.useState(!1),u=h.useRef(s);h.useEffect(()=>{if(u.current==="running"&&s==="complete"){d(!0);const p=setTimeout(()=>d(!1),3500);return u.current=s,()=>clearTimeout(p)}u.current=s},[s]),h.useEffect(()=>{if(s!=="running")return;const p=setTimeout(()=>{v.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(p)},[s,a,r]);function c(){t("dev"),de({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(Ca,{}),e.jsx(ua,{}),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(da,{}),e.jsx("button",{type:"button",onClick:c,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(ol,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{v.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(ka,{onBack:()=>o(!1)}):e.jsx(cl,{onPickCrawl:()=>o(!0)}),l&&e.jsx(ll,{})]}),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 ol(){const t=v(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void de({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 ll(){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 cl({onPickCrawl:t}){const s=v(p=>p.status),a=v(p=>p.results),[n,r]=h.useState("quick"),[i,o]=h.useState("all"),l=s==="running",d=a.flatMap(p=>p.violations),u=a.length>0;function c(){Ne({type:"START_AUDIT",mode:"full-page",matrixOverride:Zt(n)}),v.getState().startNewScan(),he.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:c,disabled:l,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(ul,{depth:n,onChange:r,disabled:l})]}),!u&&!l&&e.jsx(dl,{}),u&&e.jsx(pl,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function dl(){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 ul({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(Ws,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Ps("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Ws,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Ps("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Ws({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 pl({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var g;const r=v(y=>y.status),i=v(y=>y.results),o=v(y=>y.freshThisSession),l=v(y=>y.componentId),d=(g=i[0])==null?void 0:g.startedAt,u=qo(t),c=r==="running",[p,m]=h.useState([]);h.useEffect(()=>{if(!l){m([]);return}let y=!1;return chrome.storage.local.get("igtRuns").then(C=>{if(y)return;const R=((C==null?void 0:C.igtRuns)??{})[l]??{};m(Object.values(R))}),()=>{y=!0}},[l]);const x=v(y=>y.acknowledgedKeys),f=i.length>0?Js(i,{runs:p,workflows:xe},"2.1","AA",x):void 0;function w(){Ne({type:"START_AUDIT",mode:"full-page",matrixOverride:Zt(n)}),v.getState().startNewScan(),he.polite("Re-scanning this page now.")}const A=s==="lawsuit-risk"?t.filter(y=>y.impact==="critical"||y.impact==="serious"):t,$=new Map;for(const y of A){const C=_e(y.ruleId,y.target.selector);$.has(C)||$.set(C,y)}const T=Array.from($.values()),j=new Map;for(const y of T){const C=j.get(y.ruleId)??[];C.push(y),j.set(y.ruleId,C)}const b=Array.from(j.entries()).sort((y,C)=>(Vs[y[1][0].impact]??99)-(Vs[C[1][0].impact]??99)),I=t.filter(y=>y.impact==="critical"||y.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(bl,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void xt(),disabled:c,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:w,disabled:c,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:c?"Scanning…":"↻ Scan again"})]})]}),c?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${al[u.tier]}`,children:[!o&&d&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${nl[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${Gs[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Gs[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!c&&f&&!f.canClaimConformance&&e.jsx(ml,{coverage:f}),!c&&f&&f.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 ",f.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(fl,{}),e.jsx(Jo,{}),t.length>0&&e.jsx(hl,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:I}),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(([y,C])=>e.jsx(xl,{ruleId:y,violations:C},y))]})]})}function ml({coverage:t}){const s=v(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),de({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 hl({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 xl({ruleId:t,violations:s}){var p;const[a,n]=h.useState(!1),r=(p=s.find(m=>m.target.opacityContext))==null?void 0:p.target.opacityContext,i=nn(t,r),o=s[0].impact,l=s[0],u=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,c=l.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${rl[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:u}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((m,x)=>e.jsx(gl,{violation:m},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function gl({violation:t}){const s=v(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=h.useState(null);async function r(i){i.stopPropagation();const o=await ce();if(o)try{const l=await Ie(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const tt=[{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 fl(){const t=v(c=>c.results),s=v(c=>c.componentId),[a,n]=h.useState(null),[r,i]=h.useState(!1),[o,l]=h.useState(null);async function d(c,p){if(t.length!==0){n(c);try{const m=await J({type:"EXPORT_REQUEST",format:c,results:t,wallClockMs:v.getState().lastAuditWallClockMs??void 0});if(c==="defense-bundle"||c==="evidence-bundle"){const x=mt(c,s);await aa()?Xe(m.content,x):l({open:!0,format:c,content:m.content,filename:x})}else if(p)$e(m.content);else{try{await navigator.clipboard.writeText(m.content),he.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const f=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
268
+ `;if(T.unshift({name:"README.txt",content:L}),T.length===0){$({state:"error",message:"No reports could be generated. Re-run the crawl and try again."});return}const U=g(T),A=new Date().toISOString().slice(0,10),O=t.startUrl.replace(/^https?:\/\//,"").replace(/[^a-z0-9]/gi,"-").replace(/-+/g,"-").slice(0,32).toLowerCase()||"crawl",M=`wcagcheckr-site-bundle-${A}-${O}.zip`,ee=URL.createObjectURL(U),E=document.createElement("a");E.href=ee,E.download=M,document.body.appendChild(E),E.click(),document.body.removeChild(E),setTimeout(()=>URL.revokeObjectURL(ee),3e4),$({state:"done",included:T.length,skipped:S})}catch(L){$({state:"error",message:L instanceof Error?L.message:String(L)})}}async function N(){var g,y,C;f(!0),c(null);try{const S=await lt();if(S.length===0){c("No forensic-log entries yet. Generate a defense bundle or deposition packet first — those create the anchored entries the pre-litigation report documents.");return}const T=typeof chrome<"u"&&((C=(y=(g=chrome.runtime)==null?void 0:g.getManifest)==null?void 0:y.call(g))==null?void 0:C.version)||"1.0.0";await es({entries:S,extensionVersion:T})}catch(S){c(S instanceof Error?S.message:String(S))}finally{f(!1)}}async function b(g,y){d(g),c(null);try{const C=`site:${t.startUrl}`,S=await J({type:"EXPORT_REQUEST",format:g,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});if(!(S!=null&&S.content)||S.content.length<50){c(`Generation returned empty content for ${g}.`);return}if(y==="download"){const T=gt(g,C);Xe(S.content,T)}else $e(S.content)}catch(C){c(C instanceof Error?C.message:String(C))}finally{d(null)}}async function I(){n(!0);try{const g=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),y=(g==null?void 0:g.content)??"";if(!y){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(y)}catch{}$e(y,"text/markdown;charset=utf-8")}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Do[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Oo[t.siteRisk]}`,children:sn[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.totalNeedsReview>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:t.totalNeedsReview})," need",t.totalNeedsReview===1?"s":""," review"]}),t.totalWalkthroughFindings>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:t.totalWalkthroughFindings})," AI walkthrough finding",t.totalWalkthroughFindings===1?"":"s"]}),t.walkthroughAcknowledgements.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{className:"text-emerald-700",children:t.walkthroughAcknowledgements.length})," human-verified"]}),t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 font-medium",children:"📊 Open full site report (standalone HTML)"}),e.jsx("button",{type:"button",onClick:I,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsx("button",{type:"button",onClick:()=>void o(),disabled:r.state==="running",className:"w-full text-sm px-4 py-2.5 border border-emerald-500 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 font-medium",title:"Save each crawled page's current state as its baseline. Future audits + re-crawls show delta against this snapshot.",children:r.state==="running"?`Saving baselines… ${r.current+1}/${r.total}`:"📌 Set this crawl as the site baseline"}),r.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Saved ",r.saved," baseline",r.saved===1?"":"s",r.failed>0&&` · ${r.failed} failed (re-crawl those pages and retry)`]}),r.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",r.message]}),e.jsxs("div",{className:"border border-slate-200 rounded-lg p-3 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-700",children:"Site-wide compliance documents"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Generate the same legal / compliance / industry docs you can produce from a single-page audit — but covering the whole crawled site. Use these to respond to demand letters, file VPATs, or document remediation history."}),e.jsx("button",{type:"button",onClick:()=>void R(),disabled:j.state==="running",className:"w-full text-sm px-4 py-2.5 bg-slate-900 text-white rounded hover:bg-slate-800 disabled:opacity-50 font-medium",title:"Generate all compliance docs at once and download as a single .zip file",children:j.state==="running"?`Generating ${j.current} (${j.doneCount}/${j.totalCount})…`:"📦 Download all reports as a zip"}),j.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Bundled ",j.included," file",j.included===1?"":"s"," into the zip",j.skipped.length>0&&e.jsxs(e.Fragment,{children:[" ","· skipped ",j.skipped.length,":",e.jsx("ul",{className:"mt-0.5 ml-3 list-disc",children:j.skipped.map(g=>e.jsx("li",{className:"break-all",children:g},g))})]})]}),j.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",j.message]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[e.jsx(Ce,{label:"⚖ Defense bundle",sub:"Forensic-anchored HTML evidence — download + Ctrl+P to seal as PDF",busy:l==="defense-bundle",disabled:l!==null,onClick:()=>void b("defense-bundle","download")}),e.jsx(Ce,{label:"📜 Deposition packet",sub:"Court-grade — cover sheet, chain of custody, sworn declaration template",busy:l==="deposition-packet",disabled:l!==null,onClick:()=>void b("deposition-packet","download")}),e.jsx(Ce,{label:"📂 Evidence bundle",sub:"Same shape as Defense — neutral 'evidence' framing",busy:l==="evidence-bundle",disabled:l!==null,onClick:()=>void b("evidence-bundle","download")}),e.jsx(Ce,{label:"📋 VPAT (Voluntary Product Accessibility Template)",sub:"Formal industry conformance template — opens in new tab",busy:l==="vpat",disabled:l!==null,onClick:()=>void b("vpat","open-in-tab")}),e.jsx(Ce,{label:"🔄 Conformance crosswalk",sub:"WCAG 2.1 AA criterion-by-criterion conformance table",busy:l==="conformance-crosswalk",disabled:l!==null,onClick:()=>void b("conformance-crosswalk","open-in-tab")}),e.jsx(Ce,{label:"🔬 Methodology doc",sub:"How this audit was conducted — defensibility documentation",busy:l==="methodology-doc",disabled:l!==null,onClick:()=>void b("methodology-doc","open-in-tab")}),e.jsx(Ce,{label:"📊 Executive report",sub:"Stakeholder summary — grade hero, top risks, next steps. Print-ready.",busy:l==="executive-report",disabled:l!==null,onClick:()=>void b("executive-report","open-in-tab")}),e.jsx(Ce,{label:"📃 Accessibility statement",sub:"Public WCAG conformance statement (HTML or Markdown) — opens a dialog for org info",busy:!1,disabled:l!==null,onClick:()=>void w()}),e.jsx(Ce,{label:"📋 Pre-litigation report",sub:"Audit-history record across time — requires anchored entries (generate a defense bundle first)",busy:x,disabled:l!==null||x,onClick:()=>void N()})]}),u&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",u]})]}),e.jsx(ya,{open:p,onClose:()=>m(!1),results:[],siteCrawlSource:!0}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"This report is your do-the-work list."})," ","Each finding below is grouped by whether it's likely a"," ",e.jsx("strong",{children:"shared resource"})," (a CSS rule, component, or layout that affects multiple pages — fix it once, helps everywhere) or ",e.jsx("strong",{children:"page-specific"})," (only that one URL). Click any affected URL to open that page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)."]}),e.jsx(At,{title:"Shared resources — fix once, helps multiple pages",sectionKind:"shared-actionable",groups:t.findingGroups.filter(g=>g.isShared&&!g.needsReview),openPage:Ve}),e.jsx(At,{title:"Page-specific — one-off; fix on that page",sectionKind:"local-actionable",groups:t.findingGroups.filter(g=>!g.isShared&&!g.needsReview),openPage:Ve}),t.consistencyFindings.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700 mb-2",children:["Site-wide patterns (",t.consistencyFindings.length,")"]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:"Inconsistencies the comparators only see across pages — navigation order divergence, identification mismatches, redundant entry. WCAG 3.2.3 / 3.2.4 / 3.2.6."}),e.jsx("ul",{className:"space-y-2",children:t.consistencyFindings.map((g,y)=>e.jsxs("li",{className:"border border-blue-200 rounded p-2.5 bg-blue-50 text-xs",children:[e.jsxs("p",{className:"font-mono text-[10px] text-blue-700",children:[g.ruleId," · WCAG ",g.wcagCriterion," · ",g.impact]}),e.jsx("p",{className:"text-sm text-blue-900 mt-1",children:g.description}),g.details&&e.jsx("p",{className:"text-[11px] text-blue-800 mt-1 whitespace-pre-wrap leading-snug",children:g.details}),g.pages.length>0&&e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-blue-700",children:"Pages compared:"}),g.pages.map(C=>e.jsxs("button",{type:"button",onClick:()=>void Ve(C.url),className:"block w-full text-left text-[11px] font-mono text-blue-800 hover:text-blue-900 hover:underline truncate",children:["→ ",C.url]},C.url))]})]},y))})]}),e.jsx(At,{title:"Needs human review",sectionKind:"needs-review",groups:t.findingGroups.filter(g=>g.needsReview),openPage:Ve,hint:"AI flagged these as possibly failing but couldn't decide — you need to look + judge. They don't count toward the severity total above."}),t.findingGroups.length===0&&t.consistencyFindings.length===0&&e.jsxs("div",{className:"border border-emerald-200 rounded p-3 bg-emerald-50 text-xs text-emerald-900",children:[e.jsxs("strong",{children:["✓ No findings across the ",t.pagesAudited," crawled page",t.pagesAudited===1?"":"s","."]})," Per-page audits all completed cleanly. Drill into any page below to see the full per-page Findings if you want to verify or run guided manual checks."]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:["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.map(g=>{const y=g.walkthroughFindings.length,C=g.walkthroughAcknowledgements.length,S=[...g.walkthroughFindings.map(T=>`${T.criterionId} ${T.verdict.toUpperCase()}`),...g.walkthroughAcknowledgements.map(T=>`${T.criterionId} ✓ack`)].join(", ");return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void Ve(g.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:S?`Walkthrough findings on this page: ${S}. Click to drill in.`:"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 ${g.grade==="A"?"text-emerald-700":g.grade==="B"?"text-lime-700":g.grade==="C"?"text-yellow-700":g.grade==="D"?"text-orange-700":"text-rose-700"}`,children:g.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:g.url}),e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0 tabular-nums",title:"axe violations",children:[g.uniqueViolations," axe"]}),e.jsxs("span",{className:`text-[10px] shrink-0 tabular-nums font-medium ${y>0?"text-rose-700":C>0?"text-emerald-700":"text-slate-400"}`,title:y>0||C>0?`${y} walkthrough finding${y===1?"":"s"}${C>0?`, ${C} acknowledged`:""}`:"No walkthrough findings",children:[y," walkthru",C>0?` (${C}✓)`:""]}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},g.url)})})]})]})}async function Ve(t){try{const s=await Dt(),a=s==null?void 0:s.find(n=>n.url===t);if(!a||a.results.length===0||!a.componentId){console.warn("[site-crawl-panel] no cached crawl results for",t);return}try{const{getResolutionsForPage:n}=await ke(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-r1WNrwB5.js").then(o=>o.aF);return{getResolutionsForPage:i}},__vite__mapDeps([0,1,2,3])),r=await n(t);v.getState().setResolutionsForUrl(t,r)}catch{}v.getState().setResults(a.results,a.delta,a.componentId),v.getState().setCrawlNavContext({mode:"page",url:t});try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}v.getState().setView("report"),v.getState().setFindingsLens("overview")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}function Ce({label:t,sub:s,busy:a,disabled:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,disabled:n,className:"w-full text-left px-3 py-2 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-medium text-slate-900",children:a?`Generating ${t.replace(/^[^a-zA-Z]+/,"")}…`:t}),e.jsx("div",{className:"text-[10px] text-slate-600 leading-snug mt-0.5",children:s})]})}function At({title:t,sectionKind:s,groups:a,openPage:n,hint:r}){if(a.length===0)return null;const i=s==="needs-review",o=i?"text-amber-700":"text-slate-500",l=i?"border-amber-200 bg-amber-50":"border-slate-200 bg-white",d=i?"bg-amber-200 text-amber-900":"";return e.jsxs("div",{children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wide mb-2 ${o}`,children:[t," (",a.length,")"]}),r&&e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:r}),e.jsx("ul",{className:"space-y-2",children:a.map((u,c)=>e.jsx(Po,{group:u,sectionKind:s,cardCls:l,labelCls:d,openPage:n},`${u.ruleId}::${u.representativeSelector}::${c}`))})]})}function Po({group:t,sectionKind:s,cardCls:a,labelCls:n,openPage:r}){const i=an(t.ruleId),l=i.whatsWrong&&i.whatsWrong!=="An accessibility rule failed on this page.",d=l?i.whatsWrong:t.axeDescription||`Rule "${t.ruleId}" was flagged — see axe-core docs for this rule.`,u=l?i.whyItMatters:null,c=l?i.howToFix:null,p=s==="needs-review",m=s==="shared-actionable",x=p?"review":t.impact,f=p?`${n} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`:`${Fo[t.impact]} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`;return e.jsxs("li",{className:`border rounded p-2.5 text-xs ${a}`,children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:f,children:x}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 mt-0.5 break-all",children:[t.ruleId,t.wcagCriterion&&` · WCAG ${t.wcagCriterion}`]}),e.jsxs("p",{className:"text-[11px] text-slate-600 mt-1",children:[m?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Shared"})," — found on"," ",e.jsx("strong",{children:t.pages.length})," page",t.pages.length===1?"":"s",". Likely a shared component or CSS rule — fix once."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Page-specific"})," — only on this one page."]}),t.totalOccurrences>t.pages.length&&e.jsxs(e.Fragment,{children:[" · ",t.totalOccurrences," matrix-state occurrences"]})]})]})]}),(u||c)&&e.jsxs("div",{className:"ml-7 mb-2 space-y-1.5",children:[u&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Why it matters"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u})]}),c&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"How to fix"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:c})]})]}),t.representativeSelector&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Where to find it"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-700 break-all",children:t.representativeSelector}),t.representativeOuterHTML&&e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 break-all mt-0.5 line-clamp-2",children:[t.representativeOuterHTML.slice(0,200),t.representativeOuterHTML.length>200?"…":""]})]}),t.failureSummary&&!l&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Detail"}),e.jsxs("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:[t.failureSummary.slice(0,600),t.failureSummary.length>600?"…":""]})]}),e.jsxs("div",{className:"ml-7",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-0.5",children:p?"Open to review":"Affected pages"}),e.jsx("ul",{className:"space-y-0.5",children:t.pages.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(w.url),className:"block w-full text-left text-[11px] font-mono text-brand-700 hover:text-brand-900 hover:underline truncate",title:"Open this page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)",children:["→ ",w.url]})},w.url))})]})]})}const Ct="onboardingDismissed",It=[{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 Go(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(Ct).then(l=>{l[Ct]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ct]:!0}),s(!1),n(0)}const i=a===It.length-1,o=It[a];return e.jsxs(De,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",It.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Vo(){const t=v(n=>n.status),s=v(n=>n.errorMessage),a=v(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Wo(){const t=v(d=>d.aiFailure),s=v(d=>d.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",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,u)=>e.jsx("li",{children:d},u))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Ms(){const[t,s]=h.useState(!1);return h.useEffect(()=>ye("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),v.getState().setStatus("idle"))}),[]),e.jsxs(De,{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 Bo(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{nn().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await os(),v.getState().startNewScan(),t.mode==="storybook-all"?Ne({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&Ne({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await os(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Et="storybook:hintDismissed";function Ho(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(Et))[Et])return;const o=await de();if(o)try{const u=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(p=c.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(c=>{var p;return(p=c.result)==null?void 0:p.detected});u&&(n((l=u.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Et]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function Ko(){var i;const t=v(o=>o.results),s=v(o=>o.baselineList),a=v(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${zo(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 zo(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function qo(){const t=v(l=>l.results),s=v(l=>l.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=rn(r,a.length>0?{runs:a,workflows:xe}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Qo(){const t=v(a=>a.setUserMode);function s(a){t(a),le({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 Yo=["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"],Jo={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 Xo(t){const s=new Set(Yo),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,u])=>({ruleId:d,instanceCount:u})).sort((d,u)=>u.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,u)=>d+u,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Jo[o]}}const Aa={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Zo={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Aa]},el={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Aa]};function ts(t){return t==="thorough"?el:Zo}function Ps(t){const s=ts(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Ca(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[r,i]=h.useState(0),[o,l]=h.useState(!1),[d,u]=h.useState(""),[c,p]=h.useState(""),[m,x]=h.useState(""),[f,w]=h.useState(!1);if(h.useEffect(()=>{let b=!1;return s(null),n(null),lt().then(I=>{b||s(I)}).catch(I=>{b||n(I instanceof Error?I.message:String(I))}),()=>{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 j=t.length,$=t.filter(b=>b.receipt).length;async function R(){if(!(!t||t.length===0)){w(!0);try{await es({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:m.trim()||void 0}),l(!1)}finally{w(!1)}}}async function N(){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},I=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),g=URL.createObjectURL(I),y=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,C=document.createElement("a");C.href=g,C.download=y,C.click(),setTimeout(()=>URL.revokeObjectURL(g),1e3)}return j===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:[j," ",j===1?"entry":"entries",$>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[$," RFC 3161-anchored"]})]}),$===0&&j>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(b=>!b),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void N(),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"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:b=>u(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:c,onChange:b=>p(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:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:f||j===0,onClick:R,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:f?"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 tl(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let d=!1;return lt().then(u=>{d||s(u)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:o.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(De,{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(Ca,{})})})]})}function sl(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const al={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."},nl={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."},rl={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},il={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Ia(){const t=v(p=>p.tier),s=v(p=>p.trialDaysRemaining),a=v(p=>p.seatsUsed),n=v(p=>p.seatsTotal),r=v(p=>p.planCode),i=v(p=>p.licenseDaysRemaining),o=v(p=>p.pastDue),[l,d]=h.useState(!1);if(t==="solo"&&r==="solo-single-month"){const p=i,m=p!==null&&p<=7,x=p===null?"":p===0?"expires today":p===1?"1 day left":`${p} days left`;return e.jsxs("aside",{"aria-label":"License status",className: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:()=>d(!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 le({type:"OPEN_SETTINGS"}),className:m?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Lt,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?il:rl,m=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:p.perks,x=t==="team"&&a!==null&&n!==null&&a>n,f=t==="team"&&a!==null&&n!==null&&a===n,w=o?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:f?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${w.bg} border-b ${w.border} px-3 py-2 space-y-1 text-[11px] ${w.shadow}`,children:[e.jsxs("div",{className:w.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",p.label]}),e.jsxs("span",{className:w.subtitle,children:[" · ",m]})]}),o&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),f&&!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 le({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const u=t==="trial"?al:nl,c=t==="trial"?sl(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:u.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:c})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:u.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:u.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void le({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Lt,{open:l,onClose:()=>d(!1)})]})}const ol={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"},ll={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Gs={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},cl={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"},Vs={critical:0,serious:1,moderate:2,minor:3};function dl(){const t=v(p=>p.setUserMode),s=v(p=>p.status),a=v(p=>p.setStatus),n=v(p=>p.errorMessage),r=v(p=>p.setError),[i,o]=h.useState(!1),[l,d]=h.useState(!1),u=h.useRef(s);h.useEffect(()=>{if(u.current==="running"&&s==="complete"){d(!0);const p=setTimeout(()=>d(!1),3500);return u.current=s,()=>clearTimeout(p)}u.current=s},[s]),h.useEffect(()=>{if(s!=="running")return;const p=setTimeout(()=>{v.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(p)},[s,a,r]);function c(){t("dev"),le({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(Ia,{}),e.jsx(pa,{}),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(ua,{}),e.jsx("button",{type:"button",onClick:c,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(ul,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{v.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(Sa,{onBack:()=>o(!1)}):e.jsx(ml,{onPickCrawl:()=>o(!0)}),l&&e.jsx(pl,{})]}),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 ul(){const t=v(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void le({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 pl(){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 ml({onPickCrawl:t}){const s=v(p=>p.status),a=v(p=>p.results),[n,r]=h.useState("quick"),[i,o]=h.useState("all"),l=s==="running",d=a.flatMap(p=>p.violations),u=a.length>0;function c(){Ne({type:"START_AUDIT",mode:"full-page",matrixOverride:ts(n)}),v.getState().startNewScan(),he.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:c,disabled:l,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(xl,{depth:n,onChange:r,disabled:l})]}),!u&&!l&&e.jsx(hl,{}),u&&e.jsx(gl,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function hl(){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 xl({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(Ws,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Ps("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Ws,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Ps("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Ws({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 gl({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var g;const r=v(y=>y.status),i=v(y=>y.results),o=v(y=>y.freshThisSession),l=v(y=>y.componentId),d=(g=i[0])==null?void 0:g.startedAt,u=Xo(t),c=r==="running",[p,m]=h.useState([]);h.useEffect(()=>{if(!l){m([]);return}let y=!1;return chrome.storage.local.get("igtRuns").then(C=>{if(y)return;const T=((C==null?void 0:C.igtRuns)??{})[l]??{};m(Object.values(T))}),()=>{y=!0}},[l]);const x=v(y=>y.acknowledgedKeys),f=i.length>0?Js(i,{runs:p,workflows:xe},"2.1","AA",x):void 0;function w(){Ne({type:"START_AUDIT",mode:"full-page",matrixOverride:ts(n)}),v.getState().startNewScan(),he.polite("Re-scanning this page now.")}const j=s==="lawsuit-risk"?t.filter(y=>y.impact==="critical"||y.impact==="serious"):t,$=new Map;for(const y of j){const C=_e(y.ruleId,y.target.selector);$.has(C)||$.set(C,y)}const R=Array.from($.values()),N=new Map;for(const y of R){const C=N.get(y.ruleId)??[];C.push(y),N.set(y.ruleId,C)}const b=Array.from(N.entries()).sort((y,C)=>(Vs[y[1][0].impact]??99)-(Vs[C[1][0].impact]??99)),I=t.filter(y=>y.impact==="critical"||y.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(jl,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void bt(),disabled:c,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:w,disabled:c,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:c?"Scanning…":"↻ Scan again"})]})]}),c?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${ol[u.tier]}`,children:[!o&&d&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ll[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${Gs[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Gs[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!c&&f&&!f.canClaimConformance&&e.jsx(fl,{coverage:f}),!c&&f&&f.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 ",f.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(wl,{}),e.jsx(tl,{}),t.length>0&&e.jsx(bl,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:I}),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(([y,C])=>e.jsx(vl,{ruleId:y,violations:C},y))]})]})}function fl({coverage:t}){const s=v(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),le({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 bl({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 vl({ruleId:t,violations:s}){var p;const[a,n]=h.useState(!1),r=(p=s.find(m=>m.target.opacityContext))==null?void 0:p.target.opacityContext,i=on(t,r),o=s[0].impact,l=s[0],u=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,c=l.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${cl[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:u}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((m,x)=>e.jsx(yl,{violation:m},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function yl({violation:t}){const s=v(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=h.useState(null);async function r(i){i.stopPropagation();const o=await de();if(o)try{const l=await Ie(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const tt=[{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 wl(){const t=v(c=>c.results),s=v(c=>c.componentId),[a,n]=h.useState(null),[r,i]=h.useState(!1),[o,l]=h.useState(null);async function d(c,p){if(t.length!==0){n(c);try{const m=await J({type:"EXPORT_REQUEST",format:c,results:t,wallClockMs:v.getState().lastAuditWallClockMs??void 0});if(c==="defense-bundle"||c==="evidence-bundle"){const x=gt(c,s);await na()?Xe(m.content,x):l({open:!0,format:c,content:m.content,filename:x})}else if(p)$e(m.content);else{try{await navigator.clipboard.writeText(m.content),he.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const f=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
269
269
  <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
270
270
  .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
271
271
  pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
272
272
  <div class="banner"><strong>✓ Copied to clipboard.</strong> Paste this into ChatGPT, Claude, or your favorite AI assistant. The AI will walk you through fixes for your specific situation.</div>
273
- <pre>${m.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`;$e(f,"text/html")}}finally{n(null)}}}const u=r?tt:tt.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:u.map(c=>e.jsx("button",{type:"button",onClick:()=>void d(c.id,c.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:c.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:c.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:c.desc})]}),a===c.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},c.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",tt.length-2," more report option",tt.length-2===1?"":"s"," ↓"]}),o&&e.jsx(ba,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function bl({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 vl(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const d of l){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),i=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:o,selector:c.target.selector})}const u=d.axeRulesEvaluated;if(u){for(const c of u.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of u.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of u.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function yl(t,s,a){const n=[];let r=0,i=0,o=0,l=0;for(const u of a){const c=u.steps.filter(p=>p.wcag===t);if(c.length!==0){r+=c.length;for(const[p,m]of s){const x=m[u.id];if(!x){i+=c.length;continue}for(const f of c){const w=x.steps[f.id];if(!w){i++;continue}w.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${u.id}.${f.id}`,description:f.question,pageUrl:p,notes:w.notes})):w.status==="skip"?i++:w.status==="not-applicable"?(o++,l++):o++}}}}const d=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function wl(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 jl(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 Nl(t,s){var p;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=Wt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=rn(t.targetVersion,t.targetLevel),o=[];for(const m of i){const x=vl(m.id,s.auditsByUrl,s.acknowledgedMatchKeys),f=yl(m.id,s.igtRunsByUrl,s.workflows),w=x.rulesFiring.size===0&&f.stepsCovering===0,A={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:f.stepsCovering,igtFailures:f.failures,unmapped:w},$=(p=t.overrides)==null?void 0:p[m.id];let T,j,b=!1;if($)T=$.verdict,j=$.rationale,b=!0;else{const I=r.get(m.id);I?T=I.state:T=wl(A,f.unanswered,x.hasIncomplete,f.allNotApplicable),j=jl(m,T,A)}o.push({criterion:m,understandingUrl:on(m,t.targetVersion),verdict:T,signals:A,overridden:b,rationale:j})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const m of o)m.verdict==="pass"?l.pass++:m.verdict==="fail"?l.fail++:m.verdict==="inconclusive"?l.inconclusive++:m.verdict==="not-applicable"?l.notApplicable++:m.verdict==="not-evaluated"&&l.notEvaluated++;function d(m){const x={A:1,AA:2,AAA:3},f=x[m];return o.every(w=>x[w.criterion.level]>f?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let u=null;d("AAA")?u="AAA":d("AA")?u="AA":d("A")&&(u="A");const c=u===t.targetLevel||u==="AAA"&&t.targetLevel==="AA"||u==="AAA"&&t.targetLevel==="A"||u==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:o,summary:{totalCriteria:o.length,pass:l.pass,fail:l.fail,inconclusive:l.inconclusive,notApplicable:l.notApplicable,notEvaluated:l.notEvaluated,levelAchieved:u,meetsTarget:c}}}const kl={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Bs={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function D(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ve(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 Sl(t,s,a,n){const{inputs:r,rows:i,summary:o,generatedAt:l}=t,d=o.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,u=new Map;for(const p of i){const m=p.criterion.id.split(".").slice(0,2).join("."),x=u.get(m)??[];x.push(p),u.set(m,x)}const c=Array.from(u.entries()).sort(([p],[m])=>p.localeCompare(m,void 0,{numeric:!0})).map(([p,m])=>`
273
+ <pre>${m.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`;$e(f,"text/html")}}finally{n(null)}}}const u=r?tt:tt.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:u.map(c=>e.jsx("button",{type:"button",onClick:()=>void d(c.id,c.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:c.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:c.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:c.desc})]}),a===c.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},c.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",tt.length-2," more report option",tt.length-2===1?"":"s"," ↓"]}),o&&e.jsx(va,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function jl({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 Nl(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const d of l){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),i=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:o,selector:c.target.selector})}const u=d.axeRulesEvaluated;if(u){for(const c of u.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of u.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of u.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function kl(t,s,a){const n=[];let r=0,i=0,o=0,l=0;for(const u of a){const c=u.steps.filter(p=>p.wcag===t);if(c.length!==0){r+=c.length;for(const[p,m]of s){const x=m[u.id];if(!x){i+=c.length;continue}for(const f of c){const w=x.steps[f.id];if(!w){i++;continue}w.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${u.id}.${f.id}`,description:f.question,pageUrl:p,notes:w.notes})):w.status==="skip"?i++:w.status==="not-applicable"?(o++,l++):o++}}}}const d=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function Sl(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 Al(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 Cl(t,s){var p;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=Ht({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=ln(t.targetVersion,t.targetLevel),o=[];for(const m of i){const x=Nl(m.id,s.auditsByUrl,s.acknowledgedMatchKeys),f=kl(m.id,s.igtRunsByUrl,s.workflows),w=x.rulesFiring.size===0&&f.stepsCovering===0,j={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:f.stepsCovering,igtFailures:f.failures,unmapped:w},$=(p=t.overrides)==null?void 0:p[m.id];let R,N,b=!1;if($)R=$.verdict,N=$.rationale,b=!0;else{const I=r.get(m.id);I?R=I.state:R=Sl(j,f.unanswered,x.hasIncomplete,f.allNotApplicable),N=Al(m,R,j)}o.push({criterion:m,understandingUrl:cn(m,t.targetVersion),verdict:R,signals:j,overridden:b,rationale:N})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const m of o)m.verdict==="pass"?l.pass++:m.verdict==="fail"?l.fail++:m.verdict==="inconclusive"?l.inconclusive++:m.verdict==="not-applicable"?l.notApplicable++:m.verdict==="not-evaluated"&&l.notEvaluated++;function d(m){const x={A:1,AA:2,AAA:3},f=x[m];return o.every(w=>x[w.criterion.level]>f?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let u=null;d("AAA")?u="AAA":d("AA")?u="AA":d("A")&&(u="A");const c=u===t.targetLevel||u==="AAA"&&t.targetLevel==="AA"||u==="AAA"&&t.targetLevel==="A"||u==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:o,summary:{totalCriteria:o.length,pass:l.pass,fail:l.fail,inconclusive:l.inconclusive,notApplicable:l.notApplicable,notEvaluated:l.notEvaluated,levelAchieved:u,meetsTarget:c}}}const Il={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Bs={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function D(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function We(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function El(t,s,a,n){const{inputs:r,rows:i,summary:o,generatedAt:l}=t,d=o.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,u=new Map;for(const p of i){const m=p.criterion.id.split(".").slice(0,2).join("."),x=u.get(m)??[];x.push(p),u.set(m,x)}const c=Array.from(u.entries()).sort(([p],[m])=>p.localeCompare(m,void 0,{numeric:!0})).map(([p,m])=>`
274
274
  <h3 class="guideline-h">Guideline ${D(p)}</h3>
275
275
  <table class="criteria-table">
276
276
  <thead>
@@ -284,7 +284,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
284
284
  <td><a href="${D(x.understandingUrl)}" target="_blank" rel="noopener">${D(x.criterion.id)}</a></td>
285
285
  <td>${D(x.criterion.title)}</td>
286
286
  <td>${D(x.criterion.level)}</td>
287
- <td><span class="verdict-badge ${Bs[x.verdict]}">${kl[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
287
+ <td><span class="verdict-badge ${Bs[x.verdict]}">${Il[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
288
288
  <td class="rationale">${D(x.rationale)}</td>
289
289
  </tr>
290
290
  ${x.signals.axeFailures.length>0||x.signals.igtFailures.length>0?`
@@ -427,7 +427,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
427
427
  <dt>Target conformance level</dt>
428
428
  <dd>WCAG ${D(r.targetVersion)} Level ${D(r.targetLevel)}</dd>
429
429
  <dt>Report generated</dt>
430
- <dd>${D(Ve(l))}</dd>
430
+ <dd>${D(We(l))}</dd>
431
431
  <dt>Evaluator</dt>
432
432
  <dd>
433
433
  ${D(r.evaluator.name)}
@@ -520,7 +520,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
520
520
  <p style="font-size: 10pt;">The content of this report was hashed and the hash was anchored to a public RFC 3161 Time Stamping Authority, then counter-signed by the wcagcheckr server's ed25519 key. Any alteration to the conformance-bearing content above invalidates the hash; the receipt below is verifiable offline by anyone with the wcagcheckr-ci CLI.</p>
521
521
  <table class="anchor-table">
522
522
  <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${D(s.reportHash)}</code></td></tr>
523
- <tr><th>Anchored at</th><td>${D(Ve(s.receipt.anchoredAt))}</td></tr>
523
+ <tr><th>Anchored at</th><td>${D(We(s.receipt.anchoredAt))}</td></tr>
524
524
  <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${D(s.receipt.tsaName)}</td></tr>
525
525
  <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${D(s.receipt.serverKeyFingerprint)}</code></td></tr>
526
526
  ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${D(s.receipt.prevAuditHash)}</code></td></tr>`:""}
@@ -551,8 +551,8 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
551
551
  <table class="anchor-table" style="margin-top: 14pt;">
552
552
  <tr><th>Signed by</th><td><strong>${D(a.signerName)}</strong>${a.signerOrganization?` &middot; ${D(a.signerOrganization)}`:""} &middot; <code>${D(a.signerEmail)}</code></td></tr>
553
553
  ${a.signerQualifications?`<tr><th>Qualifications</th><td>${D(a.signerQualifications)}</td></tr>`:""}
554
- <tr><th>Signed at</th><td>${D(Ve(a.signedAt))}</td></tr>
555
- <tr><th>Audit captured at</th><td>${D(Ve(a.auditCapturedAt))}</td></tr>
554
+ <tr><th>Signed at</th><td>${D(We(a.signedAt))}</td></tr>
555
+ <tr><th>Audit captured at</th><td>${D(We(a.auditCapturedAt))}</td></tr>
556
556
  <tr><th>Scope of attestation</th><td>${D(a.scope)}</td></tr>
557
557
  ${a.signatureReceipt?`<tr><th>Signature anchor</th><td>${D(a.signatureReceipt.tsaName)} &middot; <code class="hash">${D(a.signatureReceipt.timestampHex.slice(0,24))}…</code></td></tr>`:""}
558
558
  </table>
@@ -568,13 +568,13 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
568
568
  `}
569
569
 
570
570
  <footer class="report-footer">
571
- <span>Generated ${D(Ve(l))} by wcagcheckr</span>
571
+ <span>Generated ${D(We(l))} by wcagcheckr</span>
572
572
  <span>${o.totalCriteria} criteria · ${o.pass} pass · ${o.fail} fail · ${o.inconclusive} inconclusive</span>
573
573
  </footer>
574
574
  </body>
575
- </html>`}async function Al(t,s,a,n){const r=Sl(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(i);await chrome.tabs.create({url:o})}const It=ea("wcag-em-anchor"),Cl="https://api.wcagcheckr.com",Il="wcagcheckr",El=15e3;function Ia(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 Rl(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 Tl(t){return Rl(ln(Ia(t)))}function $l(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 Ll(t,s){const a=await Tl(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Cl}/v1/products/${Il}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(El)});if(!i.ok)return It.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return $l(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(It.warn("anchor returned malformed receipt",o),null)}catch(i){return It.warn("anchor request failed",i),null}}function Ul(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Ia(t)}}const Ft="auditAttestations",Mt="auditAttestation:defaultSigner";function es(t,s){return`${t}::${s}`}async function ts(){try{const s=(await chrome.storage.local.get(Ft))[Ft];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ea(t){await chrome.storage.local.set({[Ft]:t})}async function _l(t){const s=await ts();s[es(t.componentId,t.auditCapturedAt)]=t,await Ea(s)}async function Ra(t,s){return(await ts())[es(t,s)]??null}async function Dl(t,s){const a=await ts();delete a[es(t,s)],await Ea(a)}async function Ol(){try{const s=(await chrome.storage.local.get(Mt))[Mt];return s&&typeof s=="object"?s:null}catch{return null}}async function Fl(t){await chrome.storage.local.set({[Mt]:t})}function Ml(t,s){return t.auditCapturedAt!==s}function Pl(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 Gl(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,d]=h.useState(""),[u,c]=h.useState(""),[p,m]=h.useState(""),[x,f]=h.useState(""),[w,A]=h.useState("");h.useEffect(()=>{let I=!1;return Promise.all([Ra(t.componentId,t.auditCapturedAt),Ol()]).then(([g,y])=>{I||(a(g),g?(d(g.signerName),c(g.signerEmail),m(g.signerOrganization??""),f(g.signerQualifications??""),A(g.claim)):y&&(d(y.signerName),c(y.signerEmail),m(y.signerOrganization??""),f(y.signerQualifications??"")),A(C=>C||Pl({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{I=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function $(){if(!l.trim()||!u.trim())return;const I={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:l.trim(),signerEmail:u.trim(),signerOrganization:p.trim()||void 0,signerQualifications:x.trim()||void 0,claim:w.trim(),scope:t.scope};await _l(I),await Fl({signerName:I.signerName,signerEmail:I.signerEmail,signerOrganization:I.signerOrganization,signerQualifications:I.signerQualifications}),a(I),o(!1)}async function T(){await Dl(t.componentId,t.auditCapturedAt),a(null),o(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const j=s&&Ml(s,t.auditCapturedAt);if(s&&!j&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void T(),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&&j&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const b=l.trim().length>0&&u.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:l,onChange:I=>d(I.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:u,onChange:I=>c(I.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:p,onChange:I=>m(I.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:I=>f(I.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:w,onChange:I=>A(I.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!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 Pt="spotAuditReviews";function Ta(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function ss(){try{const s=(await chrome.storage.local.get(Pt))[Pt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function $a(t){await chrome.storage.local.set({[Pt]:t})}async function Vl(t){const s=await ss();s[t.key]=t,await $a(s)}async function Wl(t){const s=await ss();delete s[t],await $a(s)}async function La(){const t=await ss();return Object.values(t)}function Ua(t,s){const a=new Map(s.map(o=>[o.key,o]));let n=0,r=0,i=0;for(const o of t){const l=a.get(o);l&&(n++,l.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function Bl(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 Hl(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const o=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,l=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${o}::${i.selector}`):void 0;n.push({key:Ta({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:l})}return n}const Kl={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"},zl={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 ql({verdicts:t,incompleteResolutions:s}){const a=h.useMemo(()=>Hl(t,s),[t,s]),[n,r]=h.useState([]),[i,o]=h.useState(!0),[l,d]=h.useState(null),[u,c]=h.useState(5),[p,m]=h.useState(!1);h.useEffect(()=>{let b=!1;return La().then(I=>{b||(r(I),o(!1))}),()=>{b=!0}},[]);const x=h.useMemo(()=>a.map(b=>b.key),[a]),f=h.useMemo(()=>Ua(x,n),[x,n]),A=(p?x:l||n.filter(b=>x.includes(b.key)).map(b=>b.key)).map(b=>a.find(I=>I.key===b)).filter(b=>!!b);async function $(b,I,g){const y={key:b.key,criterionId:b.criterionId,ruleOrStepId:b.ruleOrStepId,pageUrl:b.pageUrl,selector:b.selector,verdict:I,correction:(g==null?void 0:g.trim())||void 0,reviewedAt:new Date().toISOString()};await Vl(y),r(C=>[y,...C.filter(S=>S.key!==y.key)])}async function T(b){await Wl(b.key),r(I=>I.filter(g=>g.key!==b.key))}function j(){d(Bl(x,u)),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(st,{label:"AI determinations",value:f.total}),e.jsx(st,{label:"Reviewed",value:f.reviewed,accent:"text-slate-900"}),e.jsx(st,{label:"Agreed",value:f.agreed,accent:"text-emerald-700"}),e.jsx(st,{label:"Disagreed",value:f.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:u,onChange:b=>c(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:j,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),d(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:p?"Hide list":`Show all (${a.length})`}),l&&e.jsx("button",{type:"button",onClick:()=>d(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):A.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:A.map(b=>e.jsx(Ql,{row:b,review:n.find(I=>I.key===b.key)??null,onAgree:()=>void $(b,"agreed"),onDisagree:I=>void $(b,"disagreed",I),onClear:()=>void T(b)},b.key))})]})}function st({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 Ql(t){const{row:s,review:a}=t,[n,r]=h.useState(!1),[i,o]=h.useState((a==null?void 0:a.correction)??""),l=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${l==="agreed"?"border-emerald-300 bg-emerald-50/50":l==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${Kl[s.outcome]}`,children:zl[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${l==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${l==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),l&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&l==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:d=>o(d.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),o((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Le(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,d]=h.useState(null),[u,c]=h.useState(null),[p,m]=h.useState(!1),[x,f]=h.useState(""),[w,A]=h.useState(!1),[$,T]=h.useState(null);h.useEffect(()=>{let y=!1;return Promise.all([cn(t.componentId,t.criterionId),dn(t.componentId,t.criterionId,t.pageUrl)]).then(([C,S])=>{y||(a(C),c(S),r(!1))}),()=>{y=!0}},[t.componentId,t.criterionId,t.pageUrl]);async function j(){o(!0),d(null);try{const C=await de({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});C.ok?C.result&&a(C.result):d(C.error??"Audit failed.")}catch(y){d(y instanceof Error?y.message:String(y))}finally{o(!1)}}async function b(){await mn(t.componentId,t.criterionId),a(null)}async function I(){if(s){A(!0),T(null);try{if(!x||!x.trim()){T("Note is required — explain how you manually verified this."),A(!1);return}if(s.verdict==="pass"){T("This walkthrough already passed — no acknowledgement needed."),A(!1);return}const y={componentId:t.componentId,criterionId:t.criterionId,pageUrl:t.pageUrl,note:x.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:s.verdict};await pn(y),c(y),m(!1),f("")}catch(y){T(y instanceof Error?y.message:String(y))}finally{A(!1)}}}async function g(){A(!0);try{await un(t.componentId,t.criterionId,t.pageUrl),c(null)}finally{A(!1)}}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!l&&e.jsx("button",{type:"button",onClick:()=>void j(),disabled:i,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),l&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:l}),e.jsx("button",{type:"button",onClick:()=>void j(),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 ${$t(s.reasoning)?"border-2 border-amber-500 bg-amber-50":s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[$t(s.reasoning)&&e.jsxs("div",{className:"bg-amber-100 border border-amber-400 rounded p-2 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500 text-white font-bold uppercase tracking-wide",children:"AI cascade flagged this"})}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:["AI's automation paths all flagged this criterion. The verdict is",e.jsx("strong",{children:" fail"}),". The path forward is to fix the underlying issue on the page and re-audit. Read AI's reasoning below to see what it flagged."]}),e.jsxs("details",{className:"text-[11px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-40 overflow-y-auto bg-white/60 p-2 rounded",children:s.reasoning})]}),e.jsx("button",{type:"button",onClick:()=>void j(),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",title:"After fixing the page, re-run the walkthrough to confirm the fix.",children:i?"Re-running…":"Re-run walkthrough"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:Xs(s.reasoning)?`Manual · ${s.verdict}`:Lt(s.reasoning)?`Cascade · ${Lt(s.reasoning)} → ${s.verdict}`:`AI: ${s.verdict}`}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug whitespace-pre-wrap",children:s.reasoning}),(()=>{const y=(s.steps??[]).filter(C=>C.action!=="initial").length;return y===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 (",y," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(C=>C.action!=="initial").map(C=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",C.focused.role||C.focused.tag,"]"]})," ",C.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:C.focused.selector})]},C.ordinal))})]})})(),s.verdict!=="pass"&&e.jsx("div",{className:"mt-2 pt-2 border-t border-dashed border-slate-300",children:u?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-200 text-emerald-900 font-bold uppercase tracking-wide",children:"✓ Human verified"}),e.jsx("span",{className:"text-[10px] text-emerald-800",children:new Date(u.acknowledgedAt).toLocaleString()})]}),e.jsxs("p",{className:"text-[11px] text-emerald-900 leading-snug",children:[e.jsx("strong",{children:"Verification note:"})," ",u.note]}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:w,className:"text-[10px] px-2 py-0.5 border border-emerald-300 bg-white text-emerald-800 rounded hover:bg-emerald-50 disabled:opacity-50",children:w?"Removing…":"Un-acknowledge"})]}):p?e.jsxs("div",{className:"bg-slate-50 border border-slate-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-slate-700 block",children:"Manual verification note (required)"}),e.jsxs("p",{className:"text-[10px] text-slate-600 leading-snug",children:["Describe what you did to verify this passes WCAG ",t.criterionId,". This note becomes part of the forensic record on every export — be specific."]}),e.jsx("textarea",{value:x,onChange:y=>f(y.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-slate-300 rounded resize-y min-h-[60px]",autoFocus:!0}),$&&e.jsx("p",{className:"text-[10px] text-rose-700",children:$}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void I(),disabled:w,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:w?"Saving…":"Confirm acknowledgement"}),e.jsx("button",{type:"button",onClick:()=>{m(!1),f(""),T(null)},disabled:w,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{m(!0),T(null)},className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",title:"After verifying manually that this criterion passes, log your verification here. Required note is preserved in the forensic record.",children:"✓ I verified this manually"})}),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void j(),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 b(),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 Yl(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let n=!1;return ce().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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."}),e.jsx(Le,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.5.3",criterionTitle:"Label in Name",description:"Programmatic DOM walk + AI fallback. Scans every interactive control for a mismatch between its visible label text and its programmatically-determined accessible name — the failure mode that breaks speech recognition (e.g., visible 'Submit' but accessible 'Continue')."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const Hs="igtRuns",Jl={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"},Xl={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Zl(){var se,ie,ue;const t=v(_=>_.results),s=v(_=>_.acknowledgedKeys),[a,n]=h.useState(""),[r,i]=h.useState(""),o=xn,l=hn,[d,u]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,p]=h.useState(""),[m,x]=h.useState(""),[f,w]=h.useState(""),[A,$]=h.useState(""),[T,j]=h.useState(""),[b,I]=h.useState(""),[g,y]=h.useState({}),[C,S]=h.useState(!1),[R,K]=h.useState([]),[V,W]=h.useState([]),[L,U]=h.useState(null),[k,O]=h.useState(!1),[M,ee]=h.useState(null);h.useEffect(()=>{let _=!1;return chrome.storage.local.get(Hs).then(Y=>{if(_)return;const q=Y[Hs]??{};y(q),S(!0)}).catch(()=>{_||S(!0)}),()=>{_=!0}},[]),h.useEffect(()=>{var pe;const _=(pe=t[0])==null?void 0:pe.componentId;if(!_)return;let Y=!1;const q=()=>{Je(_).then(le=>{Y||W(le.map(me=>({criterionId:me.criterionId,ruleId:`ai-interactive::${me.criterionId}`,pageUrl:me.pageUrl,verdict:me.verdict,reasoning:me.reasoning})))})};q();const Q=le=>{le.interactiveAuditResults&&q()};return chrome.storage.local.onChanged.addListener(Q),()=>{Y=!0,chrome.storage.local.onChanged.removeListener(Q)}},[t]),h.useEffect(()=>{var _;if(!a&&((_=t[0])!=null&&_.pageUrl))try{const Y=new URL(t[0].pageUrl);n(Y.hostname),i(Y.origin)}catch{}},[t,a]),h.useEffect(()=>{const _=new Set;for(const q of t)_.add(q.pageUrl??q.scope);if(_.size===0){K([]);return}let Y=!1;return Promise.all(Array.from(_).map(q=>He(q))).then(q=>{Y||K(q.flat())}).catch(()=>{}),()=>{Y=!0}},[t]);const E=h.useMemo(()=>{const _=new Map,Y=new Map;for(const Q of t){const pe=Q.pageUrl??Q.scope,le=_.get(pe)??[];le.push(Q),_.set(pe,le)}const q=new Map;for(const Q of t){const pe=Q.pageUrl??Q.scope;q.set(Q.componentId,pe)}for(const[Q,pe]of Object.entries(g)){const le=q.get(Q);if(!le)continue;const me=Y.get(le)??{};Object.assign(me,pe),Y.set(le,me)}return{auditsByUrl:_,igtRunsByUrl:Y,workflows:xe,acknowledgedMatchKeys:s,incompleteResolutions:R,interactiveAuditResults:V}},[t,g,s,R,V]),P=h.useMemo(()=>{const _=[],Y=new Set;for(const q of E.auditsByUrl.keys())Y.has(q)||(Y.add(q),_.push({url:q,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const q of b.split(`
576
- `).map(Q=>Q.trim()).filter(Boolean))Y.has(q)||(Y.add(q),_.push({url:q,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return _},[E,b]),ne=h.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(_=>_.trim()).filter(Boolean),pageSample:P,evaluator:{name:m||"(evaluator name pending)",organization:f||void 0,qualifications:A||void 0,contact:T||void 0}}),[a,r,o,l,d,c,P,m,f,A,T]),N=h.useMemo(()=>C?Nl(ne,E):null,[ne,E,C]),G=h.useMemo(()=>{const _=Array.from(E.auditsByUrl.values()).flat(),Y=Object.values(g).flatMap(q=>Object.values(q));return Wt({audits:_,igtRuns:Y,workflows:xe,acknowledgedMatchKeys:s,incompleteResolutions:R,interactiveAuditResults:V})},[E,g,s,R,V]);async function H(){if(!N)return;const _=t[0],Y=_!=null&&_.componentId&&(_!=null&&_.startedAt)?await Ra(_.componentId,_.startedAt):null,q=await La(),Q=[];for(const le of G.values())for(const me of le.evidence)me.source==="ai"&&Q.push(Ta({criterionId:le.criterionId,ruleOrStepId:me.ruleOrStepId,pageUrl:me.pageUrl,selector:me.selector}));const pe=Ua(Q,q);await Al(N,L,Y,pe)}async function z(){if(N){O(!0),ee(null);try{const _=await Ll(N);if(!_){ee("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}U(_)}finally{O(!1)}}}function re(){var me,F,X;if(!N||!L)return;const _=((X=(F=(me=chrome.runtime).getManifest)==null?void 0:F.call(me))==null?void 0:X.version)??"0.0.0",Y=Ul(N,L,_),q=new Blob([JSON.stringify(Y,null,2)],{type:"application/json"}),Q=URL.createObjectURL(q),pe=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,le=document.createElement("a");le.href=Q,le.download=pe,le.click(),setTimeout(()=>URL.revokeObjectURL(Q),1e3)}return h.useEffect(()=>{U(null),ee(null)},[a,r,d,c,m,f,A,T,b]),C?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."})]}),N&&N.summary.totalCriteria>0&&e.jsx(ec,{totalCriteria:N.summary.totalCriteria,pass:N.summary.pass,fail:N.summary.fail,inconclusive:N.summary.inconclusive,notEvaluated:N.summary.notEvaluated,notApplicable:N.summary.notApplicable,levelAchieved:N.summary.levelAchieved,meetsTarget:N.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:E.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:_=>n(_.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:_=>i(_.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",l]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:_=>u(_.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:_=>p(_.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.",E.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:E.auditsByUrl.size})," URL",E.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:_=>I(_.target.value),rows:3,placeholder:`https://app.example.com/checkout
577
- https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:m,onChange:_=>x(_.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:f,onChange:_=>w(_.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:A,onChange:_=>$(_.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:T,onChange:_=>j(_.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),N&&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 (",N.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:N.rows.map(_=>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:[_.criterion.id," · ",_.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:_.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Jl[_.verdict]}`,children:Xl[_.verdict]})]},_.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),L?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[L.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",L.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),M&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:M}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!N||!a||!m||k,onClick:()=>void z(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:k?"Anchoring…":L?"Re-anchor":"Anchor this report"}),L&&e.jsx("button",{type:"button",onClick:re,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"})]})]}),N&&((se=t[0])==null?void 0:se.componentId)&&e.jsx(Yl,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),N&&e.jsx(ql,{verdicts:G,incompleteResolutions:R}),N&&((ie=t[0])==null?void 0:ie.componentId)&&((ue=t[0])==null?void 0:ue.startedAt)&&e.jsx(Gl,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:N.summary.pass+N.summary.fail+N.summary.inconclusive+N.summary.notApplicable,totalCount:N.summary.totalCriteria,canClaimConformance:N.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:!N||!a||!m,onClick:()=>void H(),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 ec({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:d,targetLevel:u,auditedUrlCount:c}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${d} Level ${u}`:`Does not currently meet WCAG ${d} Level ${u}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const tc={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function sc(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 ac(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+vn[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 nc(){return crypto.randomUUID()}function rc(){const[t,s]=h.useState([]),[a,n]=h.useState(!0),[r,i]=h.useState(""),[o,l]=h.useState("daily"),[d,u]=h.useState(null),[c,p]=h.useState(!1),[m,x]=h.useState(gn),[f,w]=h.useState("idle"),[A,$]=h.useState(!1),[T,j]=h.useState(null);async function b(){n(!0);try{const S=await Zs();S.sort((R,K)=>R.enabled!==K.enabled?R.enabled?-1:1:K.createdAt.localeCompare(R.createdAt)),s(S)}finally{n(!1)}}h.useEffect(()=>{b(),(async()=>{const S=await fn();x(S)})()},[]);async function I(S){if(j(null),S.webhookEnabled&&S.webhookUrl.trim().length>0)try{if(new URL(S.webhookUrl).protocol!=="https:"){j("Webhook URL must use https://");return}}catch{j("Webhook URL is not a valid https:// URL.");return}w("saving"),await bn(S),x(S),w("saved"),setTimeout(()=>w("idle"),1500)}async function g(){u(null);const S=r.trim();if(!S){u("URL is required.");return}try{new URL(S)}catch{u("Must be a valid URL (e.g. https://example.com/).");return}p(!0);try{const R={id:nc(),url:S,cadence:o,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await is(R),await os(R),i(""),l("daily"),await b(),await vt()}finally{p(!1)}}async function y(S){const R={...S,enabled:!S.enabled};await is(R),R.enabled?await os(R):await ls(S.id),await b(),await vt()}async function C(S){window.confirm(`Remove the scheduled audit for ${S.url}? Run history for this schedule will also be deleted.`)&&(await ls(S.id),await yn(S.id),await wn(S.id),await b(),await vt())}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:()=>$(S=>!S),"aria-expanded":A,className:"w-full flex items-center justify-between px-3 py-2 text-left font-medium hover:bg-slate-50",children:[e.jsxs("span",{children:["Alert preferences",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:A?"▾":"▸"})]}),A&&e.jsxs("div",{className:"px-3 pb-3 space-y-2.5 border-t border-slate-100 pt-3",children:[e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Alerts fire when a scheduled audit finds NEW violations vs. the saved baseline. Email goes to your license-registered address (server-enforced). Webhook is your own URL."}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-email-enabled",type:"checkbox",checked:m.emailEnabled,onChange:S=>void I({...m,emailEnabled:S.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:S=>void I({...m,webhookEnabled:S.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:S=>x({...m,webhookUrl:S.target.value}),onBlur:()=>void I(m),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),T&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:T})]}),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:S=>void I({...m,minImpact:S.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"})]})]}),f==="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:S=>i(S.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:o,onChange:S=>l(S.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),d&&e.jsx("div",{className:"text-rose-700",role:"alert",children:d}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:c||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:c?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(S=>e.jsx("li",{className:`border rounded p-2.5 ${S.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:S.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[tc[S.cadence]," · last run ",sc(S.lastRunAt)," ·"," ","next ",ac(S)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[S.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",S.lastTotalViolations??0," violation",(S.lastTotalViolations??0)===1?"":"s"]}),S.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:S.lastError??"",children:"✗ failed"}),S.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),S.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"}),(S.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:["⚠ ",S.lastNewViolationCount," new vs baseline"]}),!S.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 y(S),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:S.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void C(S),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},S.id))})]})}const Ks={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function _a(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function ic(t){let s=0,a=0,n=0,r=0,i=0,o=0,l=0,d=0;for(const u of t){if(!u.enabled){a++;continue}s++;const c=_a(u);c==="clean"?n++:c==="new-violations"?r++:c==="failed"?i++:c==="pending"&&o++,l+=u.lastNewViolationCount??0,d+=u.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:o,totalNewViolations:l,totalViolationsAcrossSchedules:d}}function oc(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,i=n.lastNewViolationCount??0;if(r!==i)return i-r;const o=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-o}).slice(0,s).map(a=>({scheduleId:a.id,url:a.url,cadence:a.cadence,lastRunAt:a.lastRunAt??null,lastTotalViolations:a.lastTotalViolations??0,lastNewViolationCount:a.lastNewViolationCount??0,state:_a(a)}))}function lc(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 Da(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),i=[];for(let l=s-1;l>=0;l--){const d=new Date(r.getTime()-l*864e5);i.push({date:d.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const o=new Map(i.map(l=>[l.date,l]));for(const l of t){const d=l.ranAt.slice(0,10),u=o.get(d);u&&(u.runs++,u.totalViolations+=l.totalViolations,u.newViolations+=l.newVsBaselineViolations)}return i}function cc(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return Da(r,a,n)}function dc(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=Ks[n.cadence]*6e4;if(n.lastRunAt){const i=s.getTime()-new Date(n.lastRunAt).getTime();if(i>r*2){const o=Math.round(i/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${o}h (expected every ${Ks[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 zs(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 Oa(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function qs({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(l=>l.totalViolations)),r=a/Math.max(1,t.length-1),i=t.map((l,d)=>{const u=d*r,c=s-l.totalViolations/n*(s-4)-2;return`${u.toFixed(1)},${c.toFixed(1)}`}),o=t.map((l,d)=>{const u=d*r,c=s-l.newViolations/n*(s-4)-2;return`${u.toFixed(1)},${c.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:o.join(" ")})]})}function at({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 uc({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:Oa(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function pc(){const[t,s]=h.useState([]),[a,n]=h.useState([]),[r,i]=h.useState(!0);h.useEffect(()=>{(async()=>{i(!0);try{const[p,m]=await Promise.all([Zs(),jn()]);s(p),n(m)}finally{i(!1)}})()},[]);const o=ic(t),l=oc(t,5),d=lc(t,a,10),u=Da(a,30),c=dc(t);return r?e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading dashboard…"}):t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Nothing to summarize yet. Add a scheduled audit from the Schedules tab to start collecting cross-page compliance posture here."})]}):e.jsxs("div",{className:"p-3 space-y-4 text-xs","data-testid":"risk-view-root",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Aggregate posture across every scheduled audit. Read-only — schedules themselves are managed in the Schedules tab."})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 space-y-2 bg-white",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:["Posture · ",o.enabledSchedules," enabled",o.pausedSchedules>0?` · ${o.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(at,{state:"clean",count:o.cleanCount}),e.jsx(at,{state:"new-violations",count:o.newViolationsCount}),e.jsx(at,{state:"failed",count:o.failedCount}),e.jsx(at,{state:"pending",count:o.pendingCount})]}),o.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[o.totalNewViolations," new WCAG violation",o.totalNewViolations===1?"":"s"," vs baseline across all schedules."]})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-trend-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"30-day trend"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qs,{buckets:u}),e.jsxs("div",{className:"text-[10px] text-slate-500 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-slate-400 mr-1"})," total violations"]}),e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-rose-600 mr-1"})," new vs baseline"]}),e.jsxs("div",{className:"pt-1 text-slate-400",children:["Sum across ",o.enabledSchedules," schedule",o.enabledSchedules===1?"":"s"]})]})]})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",c.length]}),e.jsx("ul",{className:"space-y-1.5",children:c.map((p,m)=>e.jsx(uc,{item:p},`${p.kind}-${p.scheduleId}-${m}`))})]}),l.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-top-exposed-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Most exposed pages"}),e.jsx("ul",{className:"space-y-1.5",children:l.map(p=>{const m=cc(p.scheduleId,a,14),x=m.some(f=>f.runs>0);return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-mono text-[11px] break-all",children:p.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[p.lastTotalViolations," total · ",p.cadence," ·"," ","last run ",p.lastRunAt?zs(p.lastRunAt):"never"]})]}),x&&e.jsx("span",{className:"shrink-0",title:"Last 14 days · new violations vs baseline","data-testid":"risk-top-exposed-sparkline",children:e.jsx(qs,{buckets:m,height:20,width:56})}),p.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",p.lastNewViolationCount," new"]})]},p.scheduleId)})})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:d.map((p,m)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:zs(p.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:Oa(p.scheduleUrl)}),p.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:p.error,children:"failed"}):p.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",p.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${p.scheduleId}-${p.ranAt}-${m}`))})]})]})}const mc="https://api.anthropic.com/v1/messages",hc="2023-06-01",xc="claude-sonnet-4-6",gc={input:3/1e6,output:15/1e6},fc={input:1/1e6,output:5/1e6},bc=`You are wcagcheckr's accessibility-audit co-pilot.
575
+ </html>`}async function Rl(t,s,a,n){const r=El(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(i);await chrome.tabs.create({url:o})}const Rt=ta("wcag-em-anchor"),Tl="https://api.wcagcheckr.com",$l="wcagcheckr",Ll=15e3;function Ea(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 Ul(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 _l(t){return Ul(dn(Ea(t)))}function Dl(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 Ol(t,s){const a=await _l(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Tl}/v1/products/${$l}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Ll)});if(!i.ok)return Rt.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return Dl(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(Rt.warn("anchor returned malformed receipt",o),null)}catch(i){return Rt.warn("anchor request failed",i),null}}function Fl(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Ea(t)}}const Pt="auditAttestations",Gt="auditAttestation:defaultSigner";function ss(t,s){return`${t}::${s}`}async function as(){try{const s=(await chrome.storage.local.get(Pt))[Pt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ra(t){await chrome.storage.local.set({[Pt]:t})}async function Ml(t){const s=await as();s[ss(t.componentId,t.auditCapturedAt)]=t,await Ra(s)}async function Ta(t,s){return(await as())[ss(t,s)]??null}async function Pl(t,s){const a=await as();delete a[ss(t,s)],await Ra(a)}async function Gl(){try{const s=(await chrome.storage.local.get(Gt))[Gt];return s&&typeof s=="object"?s:null}catch{return null}}async function Vl(t){await chrome.storage.local.set({[Gt]:t})}function Wl(t,s){return t.auditCapturedAt!==s}function Bl(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 Hl(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,d]=h.useState(""),[u,c]=h.useState(""),[p,m]=h.useState(""),[x,f]=h.useState(""),[w,j]=h.useState("");h.useEffect(()=>{let I=!1;return Promise.all([Ta(t.componentId,t.auditCapturedAt),Gl()]).then(([g,y])=>{I||(a(g),g?(d(g.signerName),c(g.signerEmail),m(g.signerOrganization??""),f(g.signerQualifications??""),j(g.claim)):y&&(d(y.signerName),c(y.signerEmail),m(y.signerOrganization??""),f(y.signerQualifications??"")),j(C=>C||Bl({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{I=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function $(){if(!l.trim()||!u.trim())return;const I={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:l.trim(),signerEmail:u.trim(),signerOrganization:p.trim()||void 0,signerQualifications:x.trim()||void 0,claim:w.trim(),scope:t.scope};await Ml(I),await Vl({signerName:I.signerName,signerEmail:I.signerEmail,signerOrganization:I.signerOrganization,signerQualifications:I.signerQualifications}),a(I),o(!1)}async function R(){await Pl(t.componentId,t.auditCapturedAt),a(null),o(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const N=s&&Wl(s,t.auditCapturedAt);if(s&&!N&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void R(),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&&N&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const b=l.trim().length>0&&u.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:l,onChange:I=>d(I.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:u,onChange:I=>c(I.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:p,onChange:I=>m(I.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:I=>f(I.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:w,onChange:I=>j(I.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!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 Vt="spotAuditReviews";function $a(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function ns(){try{const s=(await chrome.storage.local.get(Vt))[Vt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function La(t){await chrome.storage.local.set({[Vt]:t})}async function Kl(t){const s=await ns();s[t.key]=t,await La(s)}async function zl(t){const s=await ns();delete s[t],await La(s)}async function Ua(){const t=await ns();return Object.values(t)}function _a(t,s){const a=new Map(s.map(o=>[o.key,o]));let n=0,r=0,i=0;for(const o of t){const l=a.get(o);l&&(n++,l.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function ql(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 Ql(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const o=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,l=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${o}::${i.selector}`):void 0;n.push({key:$a({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:l})}return n}const Yl={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"},Jl={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 Xl({verdicts:t,incompleteResolutions:s}){const a=h.useMemo(()=>Ql(t,s),[t,s]),[n,r]=h.useState([]),[i,o]=h.useState(!0),[l,d]=h.useState(null),[u,c]=h.useState(5),[p,m]=h.useState(!1);h.useEffect(()=>{let b=!1;return Ua().then(I=>{b||(r(I),o(!1))}),()=>{b=!0}},[]);const x=h.useMemo(()=>a.map(b=>b.key),[a]),f=h.useMemo(()=>_a(x,n),[x,n]),j=(p?x:l||n.filter(b=>x.includes(b.key)).map(b=>b.key)).map(b=>a.find(I=>I.key===b)).filter(b=>!!b);async function $(b,I,g){const y={key:b.key,criterionId:b.criterionId,ruleOrStepId:b.ruleOrStepId,pageUrl:b.pageUrl,selector:b.selector,verdict:I,correction:(g==null?void 0:g.trim())||void 0,reviewedAt:new Date().toISOString()};await Kl(y),r(C=>[y,...C.filter(S=>S.key!==y.key)])}async function R(b){await zl(b.key),r(I=>I.filter(g=>g.key!==b.key))}function N(){d(ql(x,u)),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(st,{label:"AI determinations",value:f.total}),e.jsx(st,{label:"Reviewed",value:f.reviewed,accent:"text-slate-900"}),e.jsx(st,{label:"Agreed",value:f.agreed,accent:"text-emerald-700"}),e.jsx(st,{label:"Disagreed",value:f.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:u,onChange:b=>c(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:N,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),d(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:p?"Hide list":`Show all (${a.length})`}),l&&e.jsx("button",{type:"button",onClick:()=>d(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):j.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:j.map(b=>e.jsx(Zl,{row:b,review:n.find(I=>I.key===b.key)??null,onAgree:()=>void $(b,"agreed"),onDisagree:I=>void $(b,"disagreed",I),onClear:()=>void R(b)},b.key))})]})}function st({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 Zl(t){const{row:s,review:a}=t,[n,r]=h.useState(!1),[i,o]=h.useState((a==null?void 0:a.correction)??""),l=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${l==="agreed"?"border-emerald-300 bg-emerald-50/50":l==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${Yl[s.outcome]}`,children:Jl[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${l==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${l==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),l&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&l==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:d=>o(d.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),o((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Le(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,d]=h.useState(null),[u,c]=h.useState(null),[p,m]=h.useState(!1),[x,f]=h.useState(""),[w,j]=h.useState(!1),[$,R]=h.useState(null);h.useEffect(()=>{let y=!1;return Promise.all([un(t.componentId,t.criterionId),pn(t.componentId,t.criterionId,t.pageUrl)]).then(([C,S])=>{y||(a(C),c(S),r(!1))}),()=>{y=!0}},[t.componentId,t.criterionId,t.pageUrl]);async function N(){o(!0),d(null);try{const C=await le({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});C.ok?C.result&&a(C.result):d(C.error??"Audit failed.")}catch(y){d(y instanceof Error?y.message:String(y))}finally{o(!1)}}async function b(){await hn(t.componentId,t.criterionId),a(null)}async function I(){if(s){j(!0),R(null);try{if(!x||!x.trim()){R("Note is required — explain how you manually verified this."),j(!1);return}if(s.verdict==="pass"){R("This walkthrough already passed — no acknowledgement needed."),j(!1);return}const y={componentId:t.componentId,criterionId:t.criterionId,pageUrl:t.pageUrl,note:x.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:s.verdict};await Zs(y),c(y),m(!1),f("")}catch(y){R(y instanceof Error?y.message:String(y))}finally{j(!1)}}}async function g(){j(!0);try{await mn(t.componentId,t.criterionId,t.pageUrl),c(null)}finally{j(!1)}}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!l&&e.jsx("button",{type:"button",onClick:()=>void N(),disabled:i,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),l&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:l}),e.jsx("button",{type:"button",onClick:()=>void N(),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 ${Ut(s.reasoning)?"border-2 border-amber-500 bg-amber-50":s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[Ut(s.reasoning)&&e.jsxs("div",{className:"bg-amber-100 border border-amber-400 rounded p-2 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500 text-white font-bold uppercase tracking-wide",children:"AI cascade flagged this"})}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:["AI's automation paths all flagged this criterion. The verdict is",e.jsx("strong",{children:" fail"}),". The path forward is to fix the underlying issue on the page and re-audit. Read AI's reasoning below to see what it flagged."]}),e.jsxs("details",{className:"text-[11px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-40 overflow-y-auto bg-white/60 p-2 rounded",children:s.reasoning})]}),e.jsx("button",{type:"button",onClick:()=>void N(),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",title:"After fixing the page, re-run the walkthrough to confirm the fix.",children:i?"Re-running…":"Re-run walkthrough"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:Xs(s.reasoning)?`Manual · ${s.verdict}`:_t(s.reasoning)?`Cascade · ${_t(s.reasoning)} → ${s.verdict}`:`AI: ${s.verdict}`}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug whitespace-pre-wrap",children:s.reasoning}),(()=>{const y=(s.steps??[]).filter(C=>C.action!=="initial").length;return y===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 (",y," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(C=>C.action!=="initial").map(C=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",C.focused.role||C.focused.tag,"]"]})," ",C.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:C.focused.selector})]},C.ordinal))})]})})(),s.verdict!=="pass"&&e.jsx("div",{className:"mt-2 pt-2 border-t border-dashed border-slate-300",children:u?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-200 text-emerald-900 font-bold uppercase tracking-wide",children:"✓ Human verified"}),e.jsx("span",{className:"text-[10px] text-emerald-800",children:new Date(u.acknowledgedAt).toLocaleString()})]}),e.jsxs("p",{className:"text-[11px] text-emerald-900 leading-snug",children:[e.jsx("strong",{children:"Verification note:"})," ",u.note]}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:w,className:"text-[10px] px-2 py-0.5 border border-emerald-300 bg-white text-emerald-800 rounded hover:bg-emerald-50 disabled:opacity-50",children:w?"Removing…":"Un-acknowledge"})]}):p?e.jsxs("div",{className:"bg-slate-50 border border-slate-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-slate-700 block",children:"Manual verification note (required)"}),e.jsxs("p",{className:"text-[10px] text-slate-600 leading-snug",children:["Describe what you did to verify this passes WCAG ",t.criterionId,". This note becomes part of the forensic record on every export — be specific."]}),e.jsx("textarea",{value:x,onChange:y=>f(y.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-slate-300 rounded resize-y min-h-[60px]",autoFocus:!0}),$&&e.jsx("p",{className:"text-[10px] text-rose-700",children:$}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void I(),disabled:w,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:w?"Saving…":"Confirm acknowledgement"}),e.jsx("button",{type:"button",onClick:()=>{m(!1),f(""),R(null)},disabled:w,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>{m(!0),R(null)},className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",title:"After verifying manually that this criterion passes, log your verification here. Required note is preserved in the forensic record.",children:"✓ I verified this manually"})}),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void N(),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 b(),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 ec(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let n=!1;return de().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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."}),e.jsx(Le,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.5.3",criterionTitle:"Label in Name",description:"Programmatic DOM walk + AI fallback. Scans every interactive control for a mismatch between its visible label text and its programmatically-determined accessible name — the failure mode that breaks speech recognition (e.g., visible 'Submit' but accessible 'Continue')."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const Hs="igtRuns",tc={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"},sc={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function ac(){var se,ie,ue;const t=v(_=>_.results),s=v(_=>_.acknowledgedKeys),[a,n]=h.useState(""),[r,i]=h.useState(""),o=gn,l=xn,[d,u]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,p]=h.useState(""),[m,x]=h.useState(""),[f,w]=h.useState(""),[j,$]=h.useState(""),[R,N]=h.useState(""),[b,I]=h.useState(""),[g,y]=h.useState({}),[C,S]=h.useState(!1),[T,H]=h.useState([]),[V,W]=h.useState([]),[L,U]=h.useState(null),[A,O]=h.useState(!1),[M,ee]=h.useState(null);h.useEffect(()=>{let _=!1;return chrome.storage.local.get(Hs).then(Y=>{if(_)return;const q=Y[Hs]??{};y(q),S(!0)}).catch(()=>{_||S(!0)}),()=>{_=!0}},[]),h.useEffect(()=>{var pe;const _=(pe=t[0])==null?void 0:pe.componentId;if(!_)return;let Y=!1;const q=()=>{Oe(_).then(ce=>{Y||W(ce.map(me=>({criterionId:me.criterionId,ruleId:`ai-interactive::${me.criterionId}`,pageUrl:me.pageUrl,verdict:me.verdict,reasoning:me.reasoning})))})};q();const Q=ce=>{ce.interactiveAuditResults&&q()};return chrome.storage.local.onChanged.addListener(Q),()=>{Y=!0,chrome.storage.local.onChanged.removeListener(Q)}},[t]),h.useEffect(()=>{var _;if(!a&&((_=t[0])!=null&&_.pageUrl))try{const Y=new URL(t[0].pageUrl);n(Y.hostname),i(Y.origin)}catch{}},[t,a]),h.useEffect(()=>{const _=new Set;for(const q of t)_.add(q.pageUrl??q.scope);if(_.size===0){H([]);return}let Y=!1;return Promise.all(Array.from(_).map(q=>Ke(q))).then(q=>{Y||H(q.flat())}).catch(()=>{}),()=>{Y=!0}},[t]);const E=h.useMemo(()=>{const _=new Map,Y=new Map;for(const Q of t){const pe=Q.pageUrl??Q.scope,ce=_.get(pe)??[];ce.push(Q),_.set(pe,ce)}const q=new Map;for(const Q of t){const pe=Q.pageUrl??Q.scope;q.set(Q.componentId,pe)}for(const[Q,pe]of Object.entries(g)){const ce=q.get(Q);if(!ce)continue;const me=Y.get(ce)??{};Object.assign(me,pe),Y.set(ce,me)}return{auditsByUrl:_,igtRunsByUrl:Y,workflows:xe,acknowledgedMatchKeys:s,incompleteResolutions:T,interactiveAuditResults:V}},[t,g,s,T,V]),P=h.useMemo(()=>{const _=[],Y=new Set;for(const q of E.auditsByUrl.keys())Y.has(q)||(Y.add(q),_.push({url:q,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const q of b.split(`
576
+ `).map(Q=>Q.trim()).filter(Boolean))Y.has(q)||(Y.add(q),_.push({url:q,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return _},[E,b]),ne=h.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(_=>_.trim()).filter(Boolean),pageSample:P,evaluator:{name:m||"(evaluator name pending)",organization:f||void 0,qualifications:j||void 0,contact:R||void 0}}),[a,r,o,l,d,c,P,m,f,j,R]),k=h.useMemo(()=>C?Cl(ne,E):null,[ne,E,C]),G=h.useMemo(()=>{const _=Array.from(E.auditsByUrl.values()).flat(),Y=Object.values(g).flatMap(q=>Object.values(q));return Ht({audits:_,igtRuns:Y,workflows:xe,acknowledgedMatchKeys:s,incompleteResolutions:T,interactiveAuditResults:V})},[E,g,s,T,V]);async function K(){if(!k)return;const _=t[0],Y=_!=null&&_.componentId&&(_!=null&&_.startedAt)?await Ta(_.componentId,_.startedAt):null,q=await Ua(),Q=[];for(const ce of G.values())for(const me of ce.evidence)me.source==="ai"&&Q.push($a({criterionId:ce.criterionId,ruleOrStepId:me.ruleOrStepId,pageUrl:me.pageUrl,selector:me.selector}));const pe=_a(Q,q);await Rl(k,L,Y,pe)}async function z(){if(k){O(!0),ee(null);try{const _=await Ol(k);if(!_){ee("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}U(_)}finally{O(!1)}}}function re(){var me,F,X;if(!k||!L)return;const _=((X=(F=(me=chrome.runtime).getManifest)==null?void 0:F.call(me))==null?void 0:X.version)??"0.0.0",Y=Fl(k,L,_),q=new Blob([JSON.stringify(Y,null,2)],{type:"application/json"}),Q=URL.createObjectURL(q),pe=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,ce=document.createElement("a");ce.href=Q,ce.download=pe,ce.click(),setTimeout(()=>URL.revokeObjectURL(Q),1e3)}return h.useEffect(()=>{U(null),ee(null)},[a,r,d,c,m,f,j,R,b]),C?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."})]}),k&&k.summary.totalCriteria>0&&e.jsx(nc,{totalCriteria:k.summary.totalCriteria,pass:k.summary.pass,fail:k.summary.fail,inconclusive:k.summary.inconclusive,notEvaluated:k.summary.notEvaluated,notApplicable:k.summary.notApplicable,levelAchieved:k.summary.levelAchieved,meetsTarget:k.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:E.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:_=>n(_.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:_=>i(_.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",l]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:_=>u(_.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:_=>p(_.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.",E.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:E.auditsByUrl.size})," URL",E.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:_=>I(_.target.value),rows:3,placeholder:`https://app.example.com/checkout
577
+ https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:m,onChange:_=>x(_.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:f,onChange:_=>w(_.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:j,onChange:_=>$(_.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:R,onChange:_=>N(_.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),k&&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 (",k.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:k.rows.map(_=>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:[_.criterion.id," · ",_.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:_.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${tc[_.verdict]}`,children:sc[_.verdict]})]},_.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),L?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[L.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",L.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),M&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:M}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!k||!a||!m||A,onClick:()=>void z(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:A?"Anchoring…":L?"Re-anchor":"Anchor this report"}),L&&e.jsx("button",{type:"button",onClick:re,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"})]})]}),k&&((se=t[0])==null?void 0:se.componentId)&&e.jsx(ec,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),k&&e.jsx(Xl,{verdicts:G,incompleteResolutions:T}),k&&((ie=t[0])==null?void 0:ie.componentId)&&((ue=t[0])==null?void 0:ue.startedAt)&&e.jsx(Hl,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:k.summary.pass+k.summary.fail+k.summary.inconclusive+k.summary.notApplicable,totalCount:k.summary.totalCriteria,canClaimConformance:k.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:!k||!a||!m,onClick:()=>void K(),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 nc({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:d,targetLevel:u,auditedUrlCount:c}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${d} Level ${u}`:`Does not currently meet WCAG ${d} Level ${u}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const rc={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function ic(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 oc(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+yn[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 lc(){return crypto.randomUUID()}function cc(){const[t,s]=h.useState([]),[a,n]=h.useState(!0),[r,i]=h.useState(""),[o,l]=h.useState("daily"),[d,u]=h.useState(null),[c,p]=h.useState(!1),[m,x]=h.useState(fn),[f,w]=h.useState("idle"),[j,$]=h.useState(!1),[R,N]=h.useState(null);async function b(){n(!0);try{const S=await ea();S.sort((T,H)=>T.enabled!==H.enabled?T.enabled?-1:1:H.createdAt.localeCompare(T.createdAt)),s(S)}finally{n(!1)}}h.useEffect(()=>{b(),(async()=>{const S=await bn();x(S)})()},[]);async function I(S){if(N(null),S.webhookEnabled&&S.webhookUrl.trim().length>0)try{if(new URL(S.webhookUrl).protocol!=="https:"){N("Webhook URL must use https://");return}}catch{N("Webhook URL is not a valid https:// URL.");return}w("saving"),await vn(S),x(S),w("saved"),setTimeout(()=>w("idle"),1500)}async function g(){u(null);const S=r.trim();if(!S){u("URL is required.");return}try{new URL(S)}catch{u("Must be a valid URL (e.g. https://example.com/).");return}p(!0);try{const T={id:lc(),url:S,cadence:o,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await ls(T),await cs(T),i(""),l("daily"),await b(),await jt()}finally{p(!1)}}async function y(S){const T={...S,enabled:!S.enabled};await ls(T),T.enabled?await cs(T):await ds(S.id),await b(),await jt()}async function C(S){window.confirm(`Remove the scheduled audit for ${S.url}? Run history for this schedule will also be deleted.`)&&(await ds(S.id),await wn(S.id),await jn(S.id),await b(),await jt())}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:()=>$(S=>!S),"aria-expanded":j,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:j?"▾":"▸"})]}),j&&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:S=>void I({...m,emailEnabled:S.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:S=>void I({...m,webhookEnabled:S.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:S=>x({...m,webhookUrl:S.target.value}),onBlur:()=>void I(m),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),R&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:R})]}),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:S=>void I({...m,minImpact:S.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"})]})]}),f==="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:S=>i(S.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:o,onChange:S=>l(S.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),d&&e.jsx("div",{className:"text-rose-700",role:"alert",children:d}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:c||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:c?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(S=>e.jsx("li",{className:`border rounded p-2.5 ${S.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:S.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[rc[S.cadence]," · last run ",ic(S.lastRunAt)," ·"," ","next ",oc(S)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[S.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",S.lastTotalViolations??0," violation",(S.lastTotalViolations??0)===1?"":"s"]}),S.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:S.lastError??"",children:"✗ failed"}),S.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),S.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"}),(S.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:["⚠ ",S.lastNewViolationCount," new vs baseline"]}),!S.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 y(S),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:S.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void C(S),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},S.id))})]})}const Ks={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function Da(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function dc(t){let s=0,a=0,n=0,r=0,i=0,o=0,l=0,d=0;for(const u of t){if(!u.enabled){a++;continue}s++;const c=Da(u);c==="clean"?n++:c==="new-violations"?r++:c==="failed"?i++:c==="pending"&&o++,l+=u.lastNewViolationCount??0,d+=u.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:o,totalNewViolations:l,totalViolationsAcrossSchedules:d}}function uc(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,i=n.lastNewViolationCount??0;if(r!==i)return i-r;const o=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-o}).slice(0,s).map(a=>({scheduleId:a.id,url:a.url,cadence:a.cadence,lastRunAt:a.lastRunAt??null,lastTotalViolations:a.lastTotalViolations??0,lastNewViolationCount:a.lastNewViolationCount??0,state:Da(a)}))}function pc(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 Oa(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),i=[];for(let l=s-1;l>=0;l--){const d=new Date(r.getTime()-l*864e5);i.push({date:d.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const o=new Map(i.map(l=>[l.date,l]));for(const l of t){const d=l.ranAt.slice(0,10),u=o.get(d);u&&(u.runs++,u.totalViolations+=l.totalViolations,u.newViolations+=l.newVsBaselineViolations)}return i}function mc(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return Oa(r,a,n)}function hc(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=Ks[n.cadence]*6e4;if(n.lastRunAt){const i=s.getTime()-new Date(n.lastRunAt).getTime();if(i>r*2){const o=Math.round(i/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${o}h (expected every ${Ks[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 zs(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 Fa(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function qs({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(l=>l.totalViolations)),r=a/Math.max(1,t.length-1),i=t.map((l,d)=>{const u=d*r,c=s-l.totalViolations/n*(s-4)-2;return`${u.toFixed(1)},${c.toFixed(1)}`}),o=t.map((l,d)=>{const u=d*r,c=s-l.newViolations/n*(s-4)-2;return`${u.toFixed(1)},${c.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:o.join(" ")})]})}function at({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 xc({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:Fa(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function gc(){const[t,s]=h.useState([]),[a,n]=h.useState([]),[r,i]=h.useState(!0);h.useEffect(()=>{(async()=>{i(!0);try{const[p,m]=await Promise.all([ea(),Nn()]);s(p),n(m)}finally{i(!1)}})()},[]);const o=dc(t),l=uc(t,5),d=pc(t,a,10),u=Oa(a,30),c=hc(t);return r?e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading dashboard…"}):t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Nothing to summarize yet. Add a scheduled audit from the Schedules tab to start collecting cross-page compliance posture here."})]}):e.jsxs("div",{className:"p-3 space-y-4 text-xs","data-testid":"risk-view-root",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Aggregate posture across every scheduled audit. Read-only — schedules themselves are managed in the Schedules tab."})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 space-y-2 bg-white",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:["Posture · ",o.enabledSchedules," enabled",o.pausedSchedules>0?` · ${o.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(at,{state:"clean",count:o.cleanCount}),e.jsx(at,{state:"new-violations",count:o.newViolationsCount}),e.jsx(at,{state:"failed",count:o.failedCount}),e.jsx(at,{state:"pending",count:o.pendingCount})]}),o.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[o.totalNewViolations," new WCAG violation",o.totalNewViolations===1?"":"s"," vs baseline across all schedules."]})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-trend-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"30-day trend"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qs,{buckets:u}),e.jsxs("div",{className:"text-[10px] text-slate-500 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-slate-400 mr-1"})," total violations"]}),e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-rose-600 mr-1"})," new vs baseline"]}),e.jsxs("div",{className:"pt-1 text-slate-400",children:["Sum across ",o.enabledSchedules," schedule",o.enabledSchedules===1?"":"s"]})]})]})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",c.length]}),e.jsx("ul",{className:"space-y-1.5",children:c.map((p,m)=>e.jsx(xc,{item:p},`${p.kind}-${p.scheduleId}-${m}`))})]}),l.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-top-exposed-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Most exposed pages"}),e.jsx("ul",{className:"space-y-1.5",children:l.map(p=>{const m=mc(p.scheduleId,a,14),x=m.some(f=>f.runs>0);return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-mono text-[11px] break-all",children:p.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[p.lastTotalViolations," total · ",p.cadence," ·"," ","last run ",p.lastRunAt?zs(p.lastRunAt):"never"]})]}),x&&e.jsx("span",{className:"shrink-0",title:"Last 14 days · new violations vs baseline","data-testid":"risk-top-exposed-sparkline",children:e.jsx(qs,{buckets:m,height:20,width:56})}),p.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",p.lastNewViolationCount," new"]})]},p.scheduleId)})})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:d.map((p,m)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:zs(p.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:Fa(p.scheduleUrl)}),p.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:p.error,children:"failed"}):p.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",p.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${p.scheduleId}-${p.ranAt}-${m}`))})]})]})}const fc="https://api.anthropic.com/v1/messages",bc="2023-06-01",vc="claude-sonnet-4-6",yc={input:3/1e6,output:15/1e6},wc={input:1/1e6,output:5/1e6},jc=`You are wcagcheckr's accessibility-audit co-pilot.
578
578
 
579
579
  You answer the user's questions about THEIR audit results. You will be given the audit's structured data (violations, WCAG criteria, severities, components) in the user-supplied <audit-context> block.
580
580
 
@@ -585,10 +585,10 @@ Rules:
585
585
  - When you cite a WCAG criterion, use the dotted SC number (e.g. 1.4.3).
586
586
  - Don't be cheerful or evangelical. Be factual.
587
587
  - If the user asks for the impact-priority order, sort: critical > serious > moderate > minor.
588
- - The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function vc(t,s,a){const n=a.includes("haiku")?fc:gc;return t*n.input+s*n.output}async function yc(t){const s=t.model||xc,a=t.maxTokens??800;if(t.messages.length===0||t.messages[t.messages.length-1].role!=="user")throw new Error("chatComplete: messages must end with a user turn");let n=t.system??bc;!t.system&&t.auditContext&&(n+=`
588
+ - The user is technical. Skip explanations of basic accessibility terms unless they ask.`;function Nc(t,s,a){const n=a.includes("haiku")?wc:yc;return t*n.input+s*n.output}async function kc(t){const s=t.model||vc,a=t.maxTokens??800;if(t.messages.length===0||t.messages[t.messages.length-1].role!=="user")throw new Error("chatComplete: messages must end with a user turn");let n=t.system??jc;!t.system&&t.auditContext&&(n+=`
589
589
 
590
590
  <audit-context>
591
591
  ${t.auditContext}
592
- </audit-context>`);const r=await fetch(mc,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":hc,"anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:s,max_tokens:a,system:n,messages:t.messages}),signal:t.signal});if(!r.ok){const c=await r.text().catch(()=>"");throw new Error(`Anthropic API ${r.status}: ${c.slice(0,300)}`)}const i=await r.json(),o=i.content.filter(c=>c.type==="text").map(c=>c.text).join(`
593
- `).trim(),l=i.usage.input_tokens,d=i.usage.output_tokens,u=vc(l,d,s);if(t.maxCostUsd!==void 0&&u>t.maxCostUsd)throw new Error(`chat turn cost $${u.toFixed(4)} exceeded maxCostUsd $${t.maxCostUsd.toFixed(4)}`);return{text:o,inputTokens:l,outputTokens:d,costUsd:u,model:i.model}}function wc(t){const s=[];t.pageUrl&&s.push(`page: ${t.pageUrl}`),t.componentId&&s.push(`component: ${t.componentId}`),s.push(`violations: ${t.violations.length}`),s.push("");const a=new Set;for(const n of t.violations){const r=`${n.ruleId}::${n.target.selector}`;if(a.has(r))continue;a.add(r);const i=n.target.outerHTML.length>200?n.target.outerHTML.slice(0,197)+"...":n.target.outerHTML;s.push(`- [${n.impact}] ${n.ruleId} (WCAG ${n.wcagCriterion} ${n.wcagLevel})`),s.push(` selector: ${n.target.selector}`),s.push(` html: ${i}`),s.push(` axe says: ${n.description}`),s.push("")}return s.join(`
594
- `)}const Qs="aiConfig";function jc(){var j;const t=v(b=>b.results),s=v(b=>b.componentId),[a,n]=h.useState([]),[r,i]=h.useState(""),[o,l]=h.useState(!1),[d,u]=h.useState(!1),[c,p]=h.useState("claude-sonnet-4-6"),m=h.useRef(""),x=h.useRef(null);h.useEffect(()=>{(async()=>{const I=(await chrome.storage.local.get(Qs))[Qs];m.current=(I==null?void 0:I.apiKey)??"",u(!!(I!=null&&I.apiKey)),I!=null&&I.model&&p(I.model)})()},[]),h.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[a.length]);const f=t.flatMap(b=>b.violations),w=wc({componentId:s??void 0,pageUrl:(j=t[0])==null?void 0:j.pageUrl,violations:f.map(b=>({ruleId:b.ruleId,wcagCriterion:b.wcagCriterion,wcagLevel:b.wcagLevel,impact:b.impact,description:b.description,target:{selector:b.target.selector,outerHTML:b.target.outerHTML}}))}),A=a.reduce((b,I)=>b+(I.costUsd??0),0);async function $(){const b=r.trim();if(!b||o||!m.current)return;i("");const I={role:"user",content:b},g=[...a,I];n(g),l(!0);try{const y=g.map(S=>({role:S.role,content:S.content})),C=await yc({apiKey:m.current,model:c,messages:y,auditContext:w});n([...g,{role:"assistant",content:C.text,costUsd:C.costUsd,inputTokens:C.inputTokens,outputTokens:C.outputTokens}])}catch(y){n([...g,{role:"assistant",content:"",error:y instanceof Error?y.message:String(y)}])}finally{l(!1)}}function T(){n([])}return d?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",A.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:T,className:"text-slate-600 hover:text-slate-900 underline",children:"Clear"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Ask questions about THIS audit (",f.length," violation",f.length===1?"":"s","). The model answers from the structured audit data only — it won't invent findings or check the live page."]}),e.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto space-y-2 border border-slate-200 rounded p-2 bg-white min-h-[200px]","data-testid":"copilot-transcript",children:[a.length===0?e.jsx("p",{className:"text-slate-400 italic text-[11px]",children:`Try: "Which 3 issues are highest priority?" · "Explain finding #1 in plain language" · "What's the cheapest fix on this page?"`}):a.map((b,I)=>e.jsxs("div",{className:b.role==="user"?"border-l-2 border-brand-400 pl-2 py-1":"border-l-2 border-emerald-400 pl-2 py-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-slate-500",children:b.role==="user"?"You":"Co-pilot"}),b.error?e.jsx("p",{className:"text-rose-700 whitespace-pre-wrap",children:b.error}):e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:b.content}),b.role==="assistant"&&b.costUsd!==void 0&&e.jsxs("p",{className:"text-[10px] text-slate-400 mt-1",children:["$",b.costUsd.toFixed(4)," · ",b.inputTokens,"→",b.outputTokens," tok"]})]},I)),o&&e.jsx("div",{className:"border-l-2 border-emerald-200 pl-2 py-1 text-[11px] text-slate-400 italic",children:"Thinking…"})]}),e.jsxs("form",{onSubmit:b=>{b.preventDefault(),$()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:b=>i(b.target.value),placeholder:"Ask about this audit…",disabled:o,"aria-label":"Co-pilot prompt",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50"}),e.jsx("button",{type:"submit",disabled:o||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:o?"Sending…":"Send"})]})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("p",{className:"text-slate-600 leading-snug",children:["The co-pilot uses your own Anthropic API key (BYOK) to answer questions about the current audit. Configure your key in ",e.jsx("strong",{children:"Settings → AI"})," to enable."]})]})}function Nc(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState(""),[d,u]=h.useState(new Set);async function c(){i(null),n(!0);try{const x=await ce();if(!x){i("No audited tab. Open a page to audit, then return here.");return}const f=await J({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:x});if(!f.ok||!f.nodes){i(f.error??"Snapshot failed for an unknown reason.");return}s(f.nodes)}finally{n(!1)}}function p(x){u(f=>{const w=new Set(f);return w.has(x)?w.delete(x):w.add(x),w})}const m=t&&o?t.filter(x=>x.role.toLowerCase().includes(o.toLowerCase())||x.name.toLowerCase().includes(o.toLowerCase())):t;return e.jsxs("div",{className:"p-3 text-xs flex flex-col h-full","data-testid":"ax-tree-view",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Accessibility tree"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"Snapshot of the browser's computed AX tree — what screen readers actually consume."})]}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value:o,onChange:x=>l(x.target.value),placeholder:"Filter by role or name…","aria-label":"Filter ax-tree",className:"flex-1 min-w-[140px] border border-slate-300 rounded px-2 py-1"}),e.jsxs("span",{className:"text-slate-500","data-testid":"ax-tree-node-count",children:[(m==null?void 0:m.length)??0," node",((m==null?void 0:m.length)??0)===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto border border-slate-200 rounded bg-white p-2 font-mono text-[11px]",children:[!t&&!a&&e.jsxs("p",{className:"text-slate-400 italic text-center pt-8",children:["Click ",e.jsx("strong",{children:"Snapshot tree"})," above to capture the audited tab's accessibility tree."]}),t&&m&&e.jsx(kc,{nodes:t,filtered:m,collapsed:d,onToggle:p})]})]})}function kc({nodes:t,filtered:s,collapsed:a,onToggle:n}){if(s.length!==t.length)return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:s.map(o=>e.jsx("li",{role:"treeitem",children:e.jsx(Ma,{node:o,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},o.nodeId))});const r=new Map;for(const o of t){const l=o.parentId,d=r.get(l)??[];d.push(o),r.set(l,d)}const i=r.get(void 0)??t.filter(o=>!o.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:i.map(o=>e.jsx(Fa,{node:o,depth:0,byParent:r,collapsed:a,onToggle:n},o.nodeId))})}function Fa({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const i=a.get(t.nodeId)??[],o=i.length>0,l=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":o?!l:void 0,children:[e.jsx(Ma,{node:t,depth:s,collapsed:l,onToggle:()=>r(t.nodeId),hasChildren:o}),!l&&o&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:i.map(d=>e.jsx(Fa,{node:d,depth:s+1,byParent:a,collapsed:n,onToggle:r},d.nodeId))})]})}function Ma({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const i=t.properties.filter(o=>o.value!==!1&&o.value!==""&&o.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),i.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:i.map(o=>`${o.name}=${String(o.value)}`).join(" · ")})]})}function Sc(){const t=v(u=>u.results),[s,a]=h.useState(!1),[n,r]=h.useState(null),[i,o]=h.useState(null);async function l(){r(null),a(!0);try{const u=await ce();if(!u){r("No audited tab. Open a page first.");return}const c=await Ie(u,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:u});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const p=new Map;for(const f of t)for(const w of f.violations)p.has(w.target.selector)||p.set(w.target.selector,w.matchKey);const m=c.references.map(f=>({violationMatchKey:p.get(f.selector)??null,referencedTokens:f.referencedTokens})),x=c.tokens;o(En(x,m))}finally{a(!1)}}const d=i?In(i):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":i?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),d&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(We,{label:"Total tokens",value:d.totalTokens}),e.jsx(We,{label:"Color tokens",value:d.colorTokens}),e.jsx(We,{label:"Used",value:d.usedTokens}),e.jsx(We,{label:"Unused",value:d.unusedTokens,tint:d.unusedTokens>0?"amber":"slate"}),e.jsx(We,{label:"In violations",value:d.violatingTokens,tint:d.violatingTokens>0?"rose":"slate"})]}),i&&i.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:i.map(u=>e.jsxs("li",{className:"px-3 py-2 space-y-1","data-testid":"ds-token-row",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:u.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:u.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",u.token.value]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["declared on ",e.jsx("code",{children:u.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[u.usageCount," usage",u.usageCount===1?"":"s"]}),u.violationMatchKeys.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"text-rose-700 font-semibold",children:[u.violationMatchKeys.length," violation",u.violationMatchKeys.length===1?"":"s"]})]})]})]},u.token.name))})]}):i?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function We({label:t,value:s,tint:a}){const n={slate:"bg-slate-50 text-slate-700",amber:"bg-amber-50 text-amber-800",rose:"bg-rose-50 text-rose-900"};return e.jsxs("div",{className:`px-2 py-1.5 rounded ${n[a??"slate"]}`,children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide",children:t}),e.jsx("div",{className:"text-base font-semibold leading-tight",children:s})]})}const Et="onboarding:dismissed",Rt="onboarding:exportTried",nt="onboarding:collapsed";function Ac(){const t=v(y=>y.tier),s=v(y=>y.results),a=v(y=>y.baselineList),[n,r]=h.useState(!1),[i,o]=h.useState(!1),[l,d]=h.useState(!1),[u,c]=h.useState(!1),[p,m]=h.useState(null);h.useEffect(()=>{(async()=>{const y=await chrome.storage.local.get([Et,Rt,nt]);r(y[Et]===!0),d(y[Rt]===!0),typeof y[nt]=="boolean"&&m(y[nt]);const C=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],S=await Promise.all(C.map(R=>J({type:"SETTINGS_GET",key:R})));c(S.some(R=>typeof R.data=="string"&&R.data.length>0)),o(!0)})()},[]);const x=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:l?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:u?"done":"pending",optional:!0}],f=x.filter(y=>!y.optional),w=x.filter(y=>y.state==="done").length,A=f.filter(y=>y.state==="done").length,$=w===x.length,T=A===f.length;if(!i||n||T)return null;async function j(){r(!0),await chrome.storage.local.set({[Et]:!0})}async function b(){const y=!l;d(y),await chrome.storage.local.set({[Rt]:y})}const I=p??w>0;async function g(){const y=!I;m(y),await chrome.storage.local.set({[nt]:y})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void g(),"aria-expanded":!I,"aria-controls":"onboarding-checklist-body",className:"flex-1 text-left flex items-center gap-1.5 hover:text-amber-950",children:[e.jsx("span",{className:"text-amber-800 text-[10px]","aria-hidden":"true",children:I?"▸":"▾"}),e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",w," of ",x.length," done"]})]}),e.jsx("button",{type:"button",onClick:()=>void j(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none",children:"✕"})]}),!I&&e.jsxs("div",{id:"onboarding-checklist-body",className:"mt-1.5",children:[e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug mb-1.5",children:["Quick checklist to get you started. ",$?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:x.map(y=>e.jsx("li",{className:"flex items-start gap-1.5",children:y.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:y.state==="done",onChange:()=>void b(),className:"mt-0.5","aria-label":y.label}),e.jsx("span",{className:y.state==="done"?"line-through text-amber-700":"text-amber-900",children:y.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:y.state==="done"?"✓":"○"}),e.jsxs("span",{className:y.state==="done"?"line-through text-amber-700":"text-amber-900",children:[y.label,y.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},y.id))})]})]})}function Cc(){const[t,s]=h.useState(""),[a,n]=h.useState(!1),[r,i]=h.useState(null);async function o(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const l=await de({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(l!=null&&l.validated)){const d=l!=null&&l.seatClaim&&"reason"in l.seatClaim?l.seatClaim.reason:null,u=l!=null&&l.seatClaim&&"hint"in l.seatClaim?l.seatClaim.hint:void 0;i(d==="cap-reached"?`License is at seat capacity. ${u??"Release a seat from another device or contact support."}`:d==="not-found"?"License not found. Check the token and try again.":d==="network"?`Network error: ${l!=null&&l.seatClaim&&"message"in l.seatClaim?l.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(l){i(l instanceof Error?l.message:String(l))}finally{n(!1)}}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white border border-slate-200 rounded-lg shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Private build phase"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"wcagcheckr is still in private development. Access is currently limited to issued team licenses. If you've been given a license token, paste it below to activate."}),e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:["If you don't have a license and would like beta access, email"," ",e.jsx("a",{href:"mailto:cliff@locustware.com?subject=wcagcheckr%20beta%20access",className:"text-brand-700 hover:underline",children:"cliff@locustware.com"}),". The public launch is coming."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"lockout-license-token",className:"block text-xs font-medium text-slate-700",children:"License token"}),e.jsx("textarea",{id:"lockout-license-token",value:t,onChange:l=>s(l.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void o(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function Dc(){const t=v(o=>o.view),s=v(o=>o.userMode),a=v(o=>o.tier),[n,r]=h.useState(!1);h.useEffect(()=>{const o=setTimeout(()=>r(!0),600);return()=>clearTimeout(o)},[]);const i=n&&Gt(a);return h.useEffect(()=>{const o=Pn(),d=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),u=Un();na({forceRefresh:!0}).catch(()=>{}),ct().catch(()=>{}),Mn().catch(()=>{}),Gn().catch(()=>{}),On().catch(()=>{}),Nn().then(m=>{v.getState().setAcknowledgedKeys(new Set(m.map(x=>x.matchKey)))}).catch(()=>{});const c=v.subscribe((m,x)=>{var A,$;const f=(A=m.results[0])==null?void 0:A.pageUrl,w=($=x.results[0])==null?void 0:$.pageUrl;!f||f===w||zt(f).then(T=>{v.getState().setDismissedKeys(new Set(Object.keys(T)))}).catch(()=>{})});kn().then(m=>{m&&v.setState({siteCrawlReport:m})}).catch(()=>{});const p=m=>{if(m.key!=="Escape")return;const{pinnedMatchKey:x,setPinned:f,results:w}=v.getState();x&&(f(null),ce().then(A=>{var $;A&&be(A,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:A},($=w[0])==null?void 0:$.frameId).catch(()=>{})}))};return window.addEventListener("keydown",p),()=>{u(),o.disconnect(),d==null||d.disconnect(),window.removeEventListener("keydown",p),c()}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(Cc,{}),e.jsx(Ze,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Ho,{}),e.jsx(Ze,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(il,{}),e.jsx(Ms,{}),e.jsx(Ze,{})]}):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(Ca,{}),e.jsx(ua,{}),e.jsx(sr,{}),e.jsx(Ac,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[t==="matrix"&&e.jsxs(e.Fragment,{children:[e.jsx(ir,{}),e.jsx(pr,{}),e.jsx(Go,{}),e.jsx(Po,{})]}),e.jsx(hr,{}),e.jsx(Fo,{}),e.jsx(Mo,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(jr,{}),t==="report"&&e.jsx(Xi,{}),t==="delta"&&e.jsx(ya,{}),t==="activity"&&e.jsx(fa,{}),t==="guided"&&e.jsx(go,{}),t==="flows"&&e.jsx(yo,{}),t==="scorecard"&&e.jsx(No,{}),t==="crawl"&&e.jsx(ka,{}),t==="forensic"&&e.jsx(Aa,{}),t==="compliance"&&e.jsx(Zl,{}),t==="schedules"&&e.jsx(rc,{}),t==="risk"&&e.jsx(pc,{}),t==="copilot"&&e.jsx(jc,{}),t==="ax-tree"&&e.jsx(Nc,{}),t==="wcag3"&&e.jsx(ja,{}),t==="tokens"&&e.jsx(Sc,{})]})]}),e.jsx(Bo,{}),e.jsx(Vo,{}),e.jsx(Oo,{}),e.jsx(Ms,{}),e.jsx(Ze,{})]})}class Oc extends Be.Component{constructor(){super(...arguments);ns(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{Dc as A,Oc as E,_c as d};
592
+ </audit-context>`);const r=await fetch(fc,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":bc,"anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:s,max_tokens:a,system:n,messages:t.messages}),signal:t.signal});if(!r.ok){const c=await r.text().catch(()=>"");throw new Error(`Anthropic API ${r.status}: ${c.slice(0,300)}`)}const i=await r.json(),o=i.content.filter(c=>c.type==="text").map(c=>c.text).join(`
593
+ `).trim(),l=i.usage.input_tokens,d=i.usage.output_tokens,u=Nc(l,d,s);if(t.maxCostUsd!==void 0&&u>t.maxCostUsd)throw new Error(`chat turn cost $${u.toFixed(4)} exceeded maxCostUsd $${t.maxCostUsd.toFixed(4)}`);return{text:o,inputTokens:l,outputTokens:d,costUsd:u,model:i.model}}function Sc(t){const s=[];t.pageUrl&&s.push(`page: ${t.pageUrl}`),t.componentId&&s.push(`component: ${t.componentId}`),s.push(`violations: ${t.violations.length}`),s.push("");const a=new Set;for(const n of t.violations){const r=`${n.ruleId}::${n.target.selector}`;if(a.has(r))continue;a.add(r);const i=n.target.outerHTML.length>200?n.target.outerHTML.slice(0,197)+"...":n.target.outerHTML;s.push(`- [${n.impact}] ${n.ruleId} (WCAG ${n.wcagCriterion} ${n.wcagLevel})`),s.push(` selector: ${n.target.selector}`),s.push(` html: ${i}`),s.push(` axe says: ${n.description}`),s.push("")}return s.join(`
594
+ `)}const Qs="aiConfig";function Ac(){var N;const t=v(b=>b.results),s=v(b=>b.componentId),[a,n]=h.useState([]),[r,i]=h.useState(""),[o,l]=h.useState(!1),[d,u]=h.useState(!1),[c,p]=h.useState("claude-sonnet-4-6"),m=h.useRef(""),x=h.useRef(null);h.useEffect(()=>{(async()=>{const I=(await chrome.storage.local.get(Qs))[Qs];m.current=(I==null?void 0:I.apiKey)??"",u(!!(I!=null&&I.apiKey)),I!=null&&I.model&&p(I.model)})()},[]),h.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[a.length]);const f=t.flatMap(b=>b.violations),w=Sc({componentId:s??void 0,pageUrl:(N=t[0])==null?void 0:N.pageUrl,violations:f.map(b=>({ruleId:b.ruleId,wcagCriterion:b.wcagCriterion,wcagLevel:b.wcagLevel,impact:b.impact,description:b.description,target:{selector:b.target.selector,outerHTML:b.target.outerHTML}}))}),j=a.reduce((b,I)=>b+(I.costUsd??0),0);async function $(){const b=r.trim();if(!b||o||!m.current)return;i("");const I={role:"user",content:b},g=[...a,I];n(g),l(!0);try{const y=g.map(S=>({role:S.role,content:S.content})),C=await kc({apiKey:m.current,model:c,messages:y,auditContext:w});n([...g,{role:"assistant",content:C.text,costUsd:C.costUsd,inputTokens:C.inputTokens,outputTokens:C.outputTokens}])}catch(y){n([...g,{role:"assistant",content:"",error:y instanceof Error?y.message:String(y)}])}finally{l(!1)}}function R(){n([])}return d?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",j.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:R,className:"text-slate-600 hover:text-slate-900 underline",children:"Clear"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Ask questions about THIS audit (",f.length," violation",f.length===1?"":"s","). The model answers from the structured audit data only — it won't invent findings or check the live page."]}),e.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto space-y-2 border border-slate-200 rounded p-2 bg-white min-h-[200px]","data-testid":"copilot-transcript",children:[a.length===0?e.jsx("p",{className:"text-slate-400 italic text-[11px]",children:`Try: "Which 3 issues are highest priority?" · "Explain finding #1 in plain language" · "What's the cheapest fix on this page?"`}):a.map((b,I)=>e.jsxs("div",{className:b.role==="user"?"border-l-2 border-brand-400 pl-2 py-1":"border-l-2 border-emerald-400 pl-2 py-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-slate-500",children:b.role==="user"?"You":"Co-pilot"}),b.error?e.jsx("p",{className:"text-rose-700 whitespace-pre-wrap",children:b.error}):e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:b.content}),b.role==="assistant"&&b.costUsd!==void 0&&e.jsxs("p",{className:"text-[10px] text-slate-400 mt-1",children:["$",b.costUsd.toFixed(4)," · ",b.inputTokens,"→",b.outputTokens," tok"]})]},I)),o&&e.jsx("div",{className:"border-l-2 border-emerald-200 pl-2 py-1 text-[11px] text-slate-400 italic",children:"Thinking…"})]}),e.jsxs("form",{onSubmit:b=>{b.preventDefault(),$()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:b=>i(b.target.value),placeholder:"Ask about this audit…",disabled:o,"aria-label":"Co-pilot prompt",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50"}),e.jsx("button",{type:"submit",disabled:o||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:o?"Sending…":"Send"})]})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("p",{className:"text-slate-600 leading-snug",children:["The co-pilot uses your own Anthropic API key (BYOK) to answer questions about the current audit. Configure your key in ",e.jsx("strong",{children:"Settings → AI"})," to enable."]})]})}function Cc(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState(""),[d,u]=h.useState(new Set);async function c(){i(null),n(!0);try{const x=await de();if(!x){i("No audited tab. Open a page to audit, then return here.");return}const f=await J({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:x});if(!f.ok||!f.nodes){i(f.error??"Snapshot failed for an unknown reason.");return}s(f.nodes)}finally{n(!1)}}function p(x){u(f=>{const w=new Set(f);return w.has(x)?w.delete(x):w.add(x),w})}const m=t&&o?t.filter(x=>x.role.toLowerCase().includes(o.toLowerCase())||x.name.toLowerCase().includes(o.toLowerCase())):t;return e.jsxs("div",{className:"p-3 text-xs flex flex-col h-full","data-testid":"ax-tree-view",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Accessibility tree"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"Snapshot of the browser's computed AX tree — what screen readers actually consume."})]}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value:o,onChange:x=>l(x.target.value),placeholder:"Filter by role or name…","aria-label":"Filter ax-tree",className:"flex-1 min-w-[140px] border border-slate-300 rounded px-2 py-1"}),e.jsxs("span",{className:"text-slate-500","data-testid":"ax-tree-node-count",children:[(m==null?void 0:m.length)??0," node",((m==null?void 0:m.length)??0)===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto border border-slate-200 rounded bg-white p-2 font-mono text-[11px]",children:[!t&&!a&&e.jsxs("p",{className:"text-slate-400 italic text-center pt-8",children:["Click ",e.jsx("strong",{children:"Snapshot tree"})," above to capture the audited tab's accessibility tree."]}),t&&m&&e.jsx(Ic,{nodes:t,filtered:m,collapsed:d,onToggle:p})]})]})}function Ic({nodes:t,filtered:s,collapsed:a,onToggle:n}){if(s.length!==t.length)return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:s.map(o=>e.jsx("li",{role:"treeitem",children:e.jsx(Pa,{node:o,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},o.nodeId))});const r=new Map;for(const o of t){const l=o.parentId,d=r.get(l)??[];d.push(o),r.set(l,d)}const i=r.get(void 0)??t.filter(o=>!o.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:i.map(o=>e.jsx(Ma,{node:o,depth:0,byParent:r,collapsed:a,onToggle:n},o.nodeId))})}function Ma({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const i=a.get(t.nodeId)??[],o=i.length>0,l=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":o?!l:void 0,children:[e.jsx(Pa,{node:t,depth:s,collapsed:l,onToggle:()=>r(t.nodeId),hasChildren:o}),!l&&o&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:i.map(d=>e.jsx(Ma,{node:d,depth:s+1,byParent:a,collapsed:n,onToggle:r},d.nodeId))})]})}function Pa({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const i=t.properties.filter(o=>o.value!==!1&&o.value!==""&&o.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),i.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:i.map(o=>`${o.name}=${String(o.value)}`).join(" · ")})]})}function Ec(){const t=v(u=>u.results),[s,a]=h.useState(!1),[n,r]=h.useState(null),[i,o]=h.useState(null);async function l(){r(null),a(!0);try{const u=await de();if(!u){r("No audited tab. Open a page first.");return}const c=await Ie(u,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:u});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const p=new Map;for(const f of t)for(const w of f.violations)p.has(w.target.selector)||p.set(w.target.selector,w.matchKey);const m=c.references.map(f=>({violationMatchKey:p.get(f.selector)??null,referencedTokens:f.referencedTokens})),x=c.tokens;o(Rn(x,m))}finally{a(!1)}}const d=i?En(i):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":i?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),d&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(Be,{label:"Total tokens",value:d.totalTokens}),e.jsx(Be,{label:"Color tokens",value:d.colorTokens}),e.jsx(Be,{label:"Used",value:d.usedTokens}),e.jsx(Be,{label:"Unused",value:d.unusedTokens,tint:d.unusedTokens>0?"amber":"slate"}),e.jsx(Be,{label:"In violations",value:d.violatingTokens,tint:d.violatingTokens>0?"rose":"slate"})]}),i&&i.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:i.map(u=>e.jsxs("li",{className:"px-3 py-2 space-y-1","data-testid":"ds-token-row",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:u.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:u.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",u.token.value]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["declared on ",e.jsx("code",{children:u.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[u.usageCount," usage",u.usageCount===1?"":"s"]}),u.violationMatchKeys.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"text-rose-700 font-semibold",children:[u.violationMatchKeys.length," violation",u.violationMatchKeys.length===1?"":"s"]})]})]})]},u.token.name))})]}):i?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function Be({label:t,value:s,tint:a}){const n={slate:"bg-slate-50 text-slate-700",amber:"bg-amber-50 text-amber-800",rose:"bg-rose-50 text-rose-900"};return e.jsxs("div",{className:`px-2 py-1.5 rounded ${n[a??"slate"]}`,children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide",children:t}),e.jsx("div",{className:"text-base font-semibold leading-tight",children:s})]})}const Tt="onboarding:dismissed",$t="onboarding:exportTried",nt="onboarding:collapsed";function Rc(){const t=v(y=>y.tier),s=v(y=>y.results),a=v(y=>y.baselineList),[n,r]=h.useState(!1),[i,o]=h.useState(!1),[l,d]=h.useState(!1),[u,c]=h.useState(!1),[p,m]=h.useState(null);h.useEffect(()=>{(async()=>{const y=await chrome.storage.local.get([Tt,$t,nt]);r(y[Tt]===!0),d(y[$t]===!0),typeof y[nt]=="boolean"&&m(y[nt]);const C=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],S=await Promise.all(C.map(T=>J({type:"SETTINGS_GET",key:T})));c(S.some(T=>typeof T.data=="string"&&T.data.length>0)),o(!0)})()},[]);const x=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:l?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:u?"done":"pending",optional:!0}],f=x.filter(y=>!y.optional),w=x.filter(y=>y.state==="done").length,j=f.filter(y=>y.state==="done").length,$=w===x.length,R=j===f.length;if(!i||n||R)return null;async function N(){r(!0),await chrome.storage.local.set({[Tt]:!0})}async function b(){const y=!l;d(y),await chrome.storage.local.set({[$t]:y})}const I=p??w>0;async function g(){const y=!I;m(y),await chrome.storage.local.set({[nt]:y})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void g(),"aria-expanded":!I,"aria-controls":"onboarding-checklist-body",className:"flex-1 text-left flex items-center gap-1.5 hover:text-amber-950",children:[e.jsx("span",{className:"text-amber-800 text-[10px]","aria-hidden":"true",children:I?"▸":"▾"}),e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",w," of ",x.length," done"]})]}),e.jsx("button",{type:"button",onClick:()=>void N(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none",children:"✕"})]}),!I&&e.jsxs("div",{id:"onboarding-checklist-body",className:"mt-1.5",children:[e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug mb-1.5",children:["Quick checklist to get you started. ",$?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:x.map(y=>e.jsx("li",{className:"flex items-start gap-1.5",children:y.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:y.state==="done",onChange:()=>void b(),className:"mt-0.5","aria-label":y.label}),e.jsx("span",{className:y.state==="done"?"line-through text-amber-700":"text-amber-900",children:y.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:y.state==="done"?"✓":"○"}),e.jsxs("span",{className:y.state==="done"?"line-through text-amber-700":"text-amber-900",children:[y.label,y.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},y.id))})]})]})}function Tc(){const[t,s]=h.useState(""),[a,n]=h.useState(!1),[r,i]=h.useState(null);async function o(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const l=await le({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(l!=null&&l.validated)){const d=l!=null&&l.seatClaim&&"reason"in l.seatClaim?l.seatClaim.reason:null,u=l!=null&&l.seatClaim&&"hint"in l.seatClaim?l.seatClaim.hint:void 0;i(d==="cap-reached"?`License is at seat capacity. ${u??"Release a seat from another device or contact support."}`:d==="not-found"?"License not found. Check the token and try again.":d==="network"?`Network error: ${l!=null&&l.seatClaim&&"message"in l.seatClaim?l.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(l){i(l instanceof Error?l.message:String(l))}finally{n(!1)}}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white border border-slate-200 rounded-lg shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Private build phase"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"wcagcheckr is still in private development. Access is currently limited to issued team licenses. If you've been given a license token, paste it below to activate."}),e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:["If you don't have a license and would like beta access, email"," ",e.jsx("a",{href:"mailto:cliff@locustware.com?subject=wcagcheckr%20beta%20access",className:"text-brand-700 hover:underline",children:"cliff@locustware.com"}),". The public launch is coming."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"lockout-license-token",className:"block text-xs font-medium text-slate-700",children:"License token"}),e.jsx("textarea",{id:"lockout-license-token",value:t,onChange:l=>s(l.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void o(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function Pc(){const t=v(o=>o.view),s=v(o=>o.userMode),a=v(o=>o.tier),[n,r]=h.useState(!1);h.useEffect(()=>{const o=setTimeout(()=>r(!0),600);return()=>clearTimeout(o)},[]);const i=n&&Wt(a);return h.useEffect(()=>{const o=Gn(),d=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),u=_n();ra({forceRefresh:!0}).catch(()=>{}),dt().catch(()=>{}),Pn().catch(()=>{}),Vn().catch(()=>{}),Fn().catch(()=>{}),kn().then(m=>{v.getState().setAcknowledgedKeys(new Set(m.map(x=>x.matchKey)))}).catch(()=>{});const c=v.subscribe((m,x)=>{var j,$;const f=(j=m.results[0])==null?void 0:j.pageUrl,w=($=x.results[0])==null?void 0:$.pageUrl;!f||f===w||Qt(f).then(R=>{v.getState().setDismissedKeys(new Set(Object.keys(R)))}).catch(()=>{})});Sn().then(m=>{m&&v.setState({siteCrawlReport:m})}).catch(()=>{});const p=m=>{if(m.key!=="Escape")return;const{pinnedMatchKey:x,setPinned:f,results:w}=v.getState();x&&(f(null),de().then(j=>{var $;j&&be(j,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:j},($=w[0])==null?void 0:$.frameId).catch(()=>{})}))};return window.addEventListener("keydown",p),()=>{u(),o.disconnect(),d==null||d.disconnect(),window.removeEventListener("keydown",p),c()}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(Tc,{}),e.jsx(Ze,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Qo,{}),e.jsx(Ze,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(dl,{}),e.jsx(Ms,{}),e.jsx(Ze,{})]}):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(Ia,{}),e.jsx(pa,{}),e.jsx(ar,{}),e.jsx(Rc,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[t==="matrix"&&e.jsxs(e.Fragment,{children:[e.jsx(or,{}),e.jsx(mr,{}),e.jsx(Ho,{}),e.jsx(Bo,{})]}),e.jsx(xr,{}),e.jsx(Vo,{}),e.jsx(Wo,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Nr,{}),t==="report"&&e.jsx(Zi,{}),t==="delta"&&e.jsx(wa,{}),t==="activity"&&e.jsx(ba,{}),t==="guided"&&e.jsx(yo,{}),t==="flows"&&e.jsx(ko,{}),t==="scorecard"&&e.jsx(Co,{}),t==="crawl"&&e.jsx(Sa,{}),t==="forensic"&&e.jsx(Ca,{}),t==="compliance"&&e.jsx(ac,{}),t==="schedules"&&e.jsx(cc,{}),t==="risk"&&e.jsx(gc,{}),t==="copilot"&&e.jsx(Ac,{}),t==="ax-tree"&&e.jsx(Cc,{}),t==="wcag3"&&e.jsx(Na,{}),t==="tokens"&&e.jsx(Ec,{})]})]}),e.jsx(qo,{}),e.jsx(Ko,{}),e.jsx(Go,{}),e.jsx(Ms,{}),e.jsx(Ze,{})]})}class Gc extends He.Component{constructor(){super(...arguments);is(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{Pc as A,Gc as E,Mc as d};