@wcag-checkr/ci 1.0.0-rc.21 → 1.0.0-rc.22

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.
@@ -5,7 +5,7 @@
5
5
  (async () => {
6
6
  const { onExecute } = await import(
7
7
  /* @vite-ignore */
8
- chrome.runtime.getURL("assets/content-script.ts-D0-ItOIg.js")
8
+ chrome.runtime.getURL("assets/content-script.ts-CW_Q6_SY.js")
9
9
  );
10
10
  onExecute?.({ perf: { injectTime, loadTime: performance.now() - injectTime } });
11
11
  })().catch(console.error);
@@ -1,6 +1,6 @@
1
- import"./modulepreload-polyfill-B5Qt9EMX.js";import{a as q,R as P,u as W,j as e,b as X,r as c,d as ue,P as U,e as F,f as xe,g as Pe,h as Me,i as R,C as Ue,A as K,k as De,c as $e}from"./styles-C3k-Qle5.js";import{c as me,r as w,o as Ge,s as C,O as Z,a as Oe}from"./crash-reporter-Dc5lvxvY.js";import{T as Be,P as _,r as Ke,D as Ve,a as ee}from"./state-DFZV6oiO.js";import{D as V,l as He,c as Je}from"./ai-usage-log-MwwSLQII.js";import"./_commonjsHelpers-Cpj98o6Y.js";function Ye(t){const s=t+"CollectionProvider",[a,n]=q(s),[l,u]=a(s,{collectionRef:{current:null},itemMap:new Map}),d=v=>{const{scope:b,children:i}=v,f=P.useRef(null),j=P.useRef(new Map).current;return e.jsx(l,{scope:b,itemMap:j,collectionRef:f,children:i})};d.displayName=s;const r=t+"CollectionSlot",x=X(r),o=P.forwardRef((v,b)=>{const{scope:i,children:f}=v,j=u(r,i),k=W(b,j.collectionRef);return e.jsx(x,{ref:k,children:f})});o.displayName=r;const m=t+"CollectionItemSlot",p="data-radix-collection-item",h=X(m),y=P.forwardRef((v,b)=>{const{scope:i,children:f,...j}=v,k=P.useRef(null),A=W(b,k),T=u(m,i);return P.useEffect(()=>(T.itemMap.set(k,{ref:k,...j}),()=>void T.itemMap.delete(k))),e.jsx(h,{[p]:"",ref:A,children:f})});y.displayName=m;function N(v){const b=u(t+"CollectionConsumer",v);return P.useCallback(()=>{const f=b.collectionRef.current;if(!f)return[];const j=Array.from(f.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((T,L)=>j.indexOf(T.ref.current)-j.indexOf(L.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:d,Slot:o,ItemSlot:y},N,n]}var We=c.createContext(void 0);function pe(t){const s=c.useContext(We);return t||s||"ltr"}var H="rovingFocusGroup.onEntryFocus",ze={bubbles:!1,cancelable:!0},$="RovingFocusGroup",[z,he,qe]=Ye($),[Qe,be]=q($,[qe]),[Xe,Ze]=Qe($),fe=c.forwardRef((t,s)=>e.jsx(z.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(z.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(et,{...t,ref:s})})}));fe.displayName=$;var et=c.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,orientation:n,loop:l=!1,dir:u,currentTabStopId:d,defaultCurrentTabStopId:r,onCurrentTabStopIdChange:x,onEntryFocus:o,preventScrollOnEntryFocus:m=!1,...p}=t,h=c.useRef(null),y=W(s,h),N=pe(u),[v,b]=xe({prop:d,defaultProp:r??null,onChange:x,caller:$}),[i,f]=c.useState(!1),j=Pe(o),k=he(a),A=c.useRef(!1),[T,L]=c.useState(0);return c.useEffect(()=>{const g=h.current;if(g)return g.addEventListener(H,j),()=>g.removeEventListener(H,j)},[j]),e.jsx(Xe,{scope:a,orientation:n,dir:N,loop:l,currentTabStopId:v,onItemFocus:c.useCallback(g=>b(g),[b]),onItemShiftTab:c.useCallback(()=>f(!0),[]),onFocusableItemAdd:c.useCallback(()=>L(g=>g+1),[]),onFocusableItemRemove:c.useCallback(()=>L(g=>g-1),[]),children:e.jsx(U.div,{tabIndex:i||T===0?-1:0,"data-orientation":n,...p,ref:y,style:{outline:"none",...t.style},onMouseDown:F(t.onMouseDown,()=>{A.current=!0}),onFocus:F(t.onFocus,g=>{const S=!A.current;if(g.target===g.currentTarget&&S&&!i){const I=new CustomEvent(H,ze);if(g.currentTarget.dispatchEvent(I),!I.defaultPrevented){const E=k().filter(M=>M.focusable),_e=E.find(M=>M.active),Fe=E.find(M=>M.id===v),Le=[_e,Fe,...E].filter(Boolean).map(M=>M.ref.current);ve(Le,m)}}A.current=!1}),onBlur:F(t.onBlur,()=>f(!1))})})}),ge="RovingFocusGroupItem",ye=c.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,focusable:n=!0,active:l=!1,tabStopId:u,children:d,...r}=t,x=ue(),o=u||x,m=Ze(ge,a),p=m.currentTabStopId===o,h=he(a),{onFocusableItemAdd:y,onFocusableItemRemove:N,currentTabStopId:v}=m;return c.useEffect(()=>{if(n)return y(),()=>N()},[n,y,N]),e.jsx(z.ItemSlot,{scope:a,id:o,focusable:n,active:l,children:e.jsx(U.span,{tabIndex:p?0:-1,"data-orientation":m.orientation,...r,ref:s,onMouseDown:F(t.onMouseDown,b=>{n?m.onItemFocus(o):b.preventDefault()}),onFocus:F(t.onFocus,()=>m.onItemFocus(o)),onKeyDown:F(t.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){m.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const i=at(b,m.orientation,m.dir);if(i!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let j=h().filter(k=>k.focusable).map(k=>k.ref.current);if(i==="last")j.reverse();else if(i==="prev"||i==="next"){i==="prev"&&j.reverse();const k=j.indexOf(b.currentTarget);j=m.loop?nt(j,k+1):j.slice(k+1)}setTimeout(()=>ve(j))}}),children:typeof d=="function"?d({isCurrentTabStop:p,hasTabStop:v!=null}):d})})});ye.displayName=ge;var tt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function st(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function at(t,s,a){const n=st(t.key,a);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return tt[n]}function ve(t,s=!1){const a=document.activeElement;for(const n of t)if(n===a||(n.focus({preventScroll:s}),document.activeElement!==a))return}function nt(t,s){return t.map((a,n)=>t[(s+n)%t.length])}var rt=fe,ot=ye,B="Tabs",[lt]=q(B,[be]),je=be(),[it,Q]=lt(B),Ne=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,onValueChange:l,defaultValue:u,orientation:d="horizontal",dir:r,activationMode:x="automatic",...o}=t,m=pe(r),[p,h]=xe({prop:n,onChange:l,defaultProp:u??"",caller:B});return e.jsx(it,{scope:a,baseId:ue(),value:p,onValueChange:h,orientation:d,dir:m,activationMode:x,children:e.jsx(U.div,{dir:m,"data-orientation":d,...o,ref:s})})});Ne.displayName=B;var ke="TabsList",Se=c.forwardRef((t,s)=>{const{__scopeTabs:a,loop:n=!0,...l}=t,u=Q(ke,a),d=je(a);return e.jsx(rt,{asChild:!0,...d,orientation:u.orientation,dir:u.dir,loop:n,children:e.jsx(U.div,{role:"tablist","aria-orientation":u.orientation,...l,ref:s})})});Se.displayName=ke;var Te="TabsTrigger",we=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,disabled:l=!1,...u}=t,d=Q(Te,a),r=je(a),x=Ie(d.baseId,n),o=Ae(d.baseId,n),m=n===d.value;return e.jsx(ot,{asChild:!0,...r,focusable:!l,active:m,children:e.jsx(U.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":o,"data-state":m?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:x,...u,ref:s,onMouseDown:F(t.onMouseDown,p=>{!l&&p.button===0&&p.ctrlKey===!1?d.onValueChange(n):p.preventDefault()}),onKeyDown:F(t.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&d.onValueChange(n)}),onFocus:F(t.onFocus,()=>{const p=d.activationMode!=="manual";!m&&!l&&p&&d.onValueChange(n)})})})});we.displayName=Te;var Ce="TabsContent",Ee=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,forceMount:l,children:u,...d}=t,r=Q(Ce,a),x=Ie(r.baseId,n),o=Ae(r.baseId,n),m=n===r.value,p=c.useRef(m);return c.useEffect(()=>{const h=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(h)},[]),e.jsx(Me,{present:l||m,children:({present:h})=>e.jsx(U.div,{"data-state":m?"active":"inactive","data-orientation":r.orientation,role:"tabpanel","aria-labelledby":x,hidden:!h,id:o,tabIndex:0,...d,ref:s,style:{...t.style,animationDuration:p.current?"0s":void 0},children:h&&u})})});Ee.displayName=Ce;function Ie(t,s){return`${t}-trigger-${s}`}function Ae(t,s){return`${t}-content-${s}`}var ct=Ne,dt=Se,ut=we,G=Ee;const xt=["default","hover","focus","focus-visible","active","disabled"],mt=["light","dark","forced-colors-active","forced-colors-none"],pt=["ltr","rtl"];function ht({value:t,onChange:s}){function a(l,u){return l.includes(u)?l.filter(d=>d!==u):[...l,u]}function n(){const l=t.ariaVariations.length===0?1:t.ariaVariations.length;return t.pseudoStates.length*l*t.themes.length*t.directions.length*t.breakpoints.length}return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[e.jsx(O,{label:"Pseudo-states",all:xt,selected:t.pseudoStates,onToggle:l=>s({...t,pseudoStates:a(t.pseudoStates,l)})}),e.jsx(O,{label:"Themes",all:mt,selected:t.themes,onToggle:l=>s({...t,themes:a(t.themes,l)})}),e.jsx(O,{label:"Directions",all:pt,selected:t.directions,onToggle:l=>s({...t,directions:a(t.directions,l)})}),e.jsx(O,{label:"Breakpoints",all:t.breakpointPresets.map(l=>l.id),selected:t.breakpoints,onToggle:l=>s({...t,breakpoints:a(t.breakpoints,l)})}),e.jsxs("p",{className:"text-xs text-slate-500 pt-2 border-t border-slate-100",children:[e.jsx("strong",{children:n()})," audits per component"]})]})}function O({label:t,all:s,selected:a,onToggle:n}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium mb-1.5",children:t}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(l=>{const u=a.includes(l);return e.jsx("button",{type:"button",onClick:()=>n(l),className:u?"text-xs px-2 py-1 rounded bg-brand-500 text-white":"text-xs px-2 py-1 rounded bg-slate-100 text-slate-700 hover:bg-slate-200",children:l},l)})})]})}function bt({value:t,onChange:s}){const[a,n]=c.useState(""),[l,u]=c.useState("");function d(o){o.preventDefault();const m=a.trim(),p=l.trim();!m||!p||(s({...t,[m]:p}),n(""),u(""))}function r(o){const m={...t};delete m[o],s(m)}const x=Object.entries(t);return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[x.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no aliases"}):e.jsx("ul",{className:"space-y-1",children:x.map(([o,m])=>e.jsxs("li",{className:"text-xs flex items-center justify-between gap-2 border border-slate-100 rounded p-1.5",children:[e.jsxs("span",{className:"font-mono truncate",title:`${o} → ${m}`,children:[o," ",e.jsx("span",{className:"text-slate-500",children:"→"})," ",m]}),e.jsx("button",{onClick:()=>r(o),className:"text-slate-500 hover:text-red-600 shrink-0","aria-label":`Remove alias ${o}`,children:"×"})]},o))}),e.jsxs("form",{onSubmit:d,className:"grid grid-cols-[1fr_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-500 mb-1",children:"From"}),e.jsx("input",{type:"text",value:a,onChange:o=>n(o.target.value),placeholder:"https://example.com::testid:btn-a",className:"w-full text-xs border border-slate-300 rounded px-2 py-1 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-500 mb-1",children:"Treat as"}),e.jsx("input",{type:"text",value:l,onChange:o=>u(o.target.value),placeholder:"https://example.com::testid:btn-canonical",className:"w-full text-xs border border-slate-300 rounded px-2 py-1 font-mono"})]}),e.jsx("button",{type:"submit",className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",disabled:!a.trim()||!l.trim(),children:"Add"})]})]})}const te=me("billing-portal-client"),ft="https://api.wcagcheckr.com",gt="wcagcheckr",yt=15e3;async function vt(t){const s=`${ft}/v1/products/${gt}/billing-portal`;try{const a=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout(yt)}),n=await a.json().catch(()=>null);return a.ok?n!=null&&n.url?{ok:!0,url:n.url}:{ok:!1,error:"malformed response — no url",status:a.status}:(te.warn(`billing portal HTTP ${a.status}`,n),{ok:!1,status:a.status,error:(n==null?void 0:n.hint)??(n==null?void 0:n.error)??`HTTP ${a.status}`})}catch(a){return te.warn("billing portal request failed",a),{ok:!1,error:a instanceof Error?a.message:String(a)}}}const se=me("subscription-resume-client"),jt="https://api.wcagcheckr.com",Nt="wcagcheckr",kt=1e4;async function St(t){try{const s=await fetch(`${jt}/v1/products/${Nt}/subscription/resume`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout(kt)}),a=await s.json().catch(()=>null);return s.ok?{ok:!0,alreadyActive:(a==null?void 0:a.alreadyActive)===!0}:(se.warn(`resume http ${s.status}`,a),{ok:!1,status:s.status,error:(a==null?void 0:a.hint)??(a==null?void 0:a.error)??`HTTP ${s.status}`})}catch(s){return se.warn("resume request failed",s),{ok:!1,error:s instanceof Error?s.message:String(s)}}}const Tt={trial:"Trial",free:"Free",solo:"Solo",team:"Team"},wt={free:"Free",solo:"Solo (monthly)","solo-yearly":"Solo (yearly)","solo-single-month":"Solo (single month — non-recurring)",team:"Team (5 seats, monthly)","team-yearly":"Team (5 seats, yearly)","team-15":"Team (15 seats, monthly)","team-15-yearly":"Team (15 seats, yearly)"},Ct=new Set(["solo-single-month"]);function Et(t){if(!t)return null;const s=new Date(t).getTime()-Date.now();return Number.isFinite(s)?Math.ceil(s/(24*60*60*1e3)):null}function D(t){return t?wt[t]??t:"—"}function J(t){if(!t)return"no expiry on file";try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return t}}function It({tier:t,onTierChange:s}){const[a,n]=c.useState(null),[l,u]=c.useState(null),[d,r]=c.useState(!1),[x,o]=c.useState(""),[m,p]=c.useState(!1),[h,y]=c.useState(null),[N,v]=c.useState(!1),[b,i]=c.useState(!1),f=c.useCallback(async g=>{const I=(await chrome.storage.local.get("licenseToken")).licenseToken??null;if(n(I),!I){u(null);return}try{const E=await w({type:"LICENSE_VALIDATE_REQUEST",token:I,forceRefresh:(g==null?void 0:g.forceRefresh)===!0});u(E)}catch{u(null)}},[]);c.useEffect(()=>(f({forceRefresh:!0}),Ge("LICENSE_CHANGED_EVENT",()=>{f()})),[f]);async function j(){if(x.trim()){p(!0),y(null);try{const g=await w({type:"LICENSE_SET_REQUEST",token:x.trim()}),S=await w({type:"LICENSE_VALIDATE_REQUEST",token:x.trim()});if(S.valid&&S.plan){const I=_t(S.plan);s(I);let E=`Activated as ${D(S.plan)}.`;g.seatClaim.ok?g.seatClaim.overCapacity&&(E=`Activated as ${D(S.plan)}. Note: this license is currently OVER its seat cap (${g.seatClaim.seatsUsed} of ${g.seatClaim.seatsTotal} seats). Release one or upgrade.`):g.seatClaim.reason==="cap-reached"?E=`Activated as ${D(S.plan)}, BUT this license is at its seat capacity (${g.seatClaim.seatsUsed} of ${g.seatClaim.seatsTotal} seats used). Release a seat from another device, or upgrade to a higher-seat plan. This device's seat won't be active until you do.`:g.seatClaim.reason==="network"&&(E=`Activated as ${D(S.plan)}. (Seat-tracking ping failed — retrying in the background.)`),y(E),g.seatClaim.ok&&!g.seatClaim.overCapacity?R.polite(E):R.assertive(E),o(""),r(!1),await f()}else{const I="Token did not validate. Check the value and try again.";y(I),R.assertive(I)}}catch(g){const S=g instanceof Error?g.message:String(g);y(S),R.assertive(S)}finally{p(!1)}}}async function k(){if(a)try{await navigator.clipboard.writeText(a),v(!0),setTimeout(()=>v(!1),2e3)}catch{}}async function A(){if(window.confirm(`Remove the active license token from this extension?
1
+ import"./modulepreload-polyfill-B5Qt9EMX.js";import{a as q,R as P,u as W,j as e,b as X,r as c,d as ue,P as U,e as L,f as xe,g as Pe,h as Me,i as R,C as Ue,A as K,k as De,c as $e}from"./styles-C3k-Qle5.js";import{c as me,r as w,o as Oe,s as C,O as Z,a as Ge}from"./crash-reporter-Dc5lvxvY.js";import{T as Be,P as _,r as Ke,D as Ve,a as ee}from"./state-DFZV6oiO.js";import{c as He,D as V,l as Je,a as Ye}from"./ai-usage-log-Dj9Ub_DT.js";import"./_commonjsHelpers-Cpj98o6Y.js";function We(t){const s=t+"CollectionProvider",[a,n]=q(s),[l,u]=a(s,{collectionRef:{current:null},itemMap:new Map}),d=v=>{const{scope:b,children:i}=v,f=P.useRef(null),j=P.useRef(new Map).current;return e.jsx(l,{scope:b,itemMap:j,collectionRef:f,children:i})};d.displayName=s;const r=t+"CollectionSlot",x=X(r),o=P.forwardRef((v,b)=>{const{scope:i,children:f}=v,j=u(r,i),k=W(b,j.collectionRef);return e.jsx(x,{ref:k,children:f})});o.displayName=r;const m=t+"CollectionItemSlot",h="data-radix-collection-item",p=X(m),y=P.forwardRef((v,b)=>{const{scope:i,children:f,...j}=v,k=P.useRef(null),A=W(b,k),T=u(m,i);return P.useEffect(()=>(T.itemMap.set(k,{ref:k,...j}),()=>void T.itemMap.delete(k))),e.jsx(p,{[h]:"",ref:A,children:f})});y.displayName=m;function N(v){const b=u(t+"CollectionConsumer",v);return P.useCallback(()=>{const f=b.collectionRef.current;if(!f)return[];const j=Array.from(f.querySelectorAll(`[${h}]`));return Array.from(b.itemMap.values()).sort((T,F)=>j.indexOf(T.ref.current)-j.indexOf(F.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:d,Slot:o,ItemSlot:y},N,n]}var ze=c.createContext(void 0);function he(t){const s=c.useContext(ze);return t||s||"ltr"}var H="rovingFocusGroup.onEntryFocus",qe={bubbles:!1,cancelable:!0},$="RovingFocusGroup",[z,pe,Qe]=We($),[Xe,be]=q($,[Qe]),[Ze,et]=Xe($),fe=c.forwardRef((t,s)=>e.jsx(z.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(z.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(tt,{...t,ref:s})})}));fe.displayName=$;var tt=c.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,orientation:n,loop:l=!1,dir:u,currentTabStopId:d,defaultCurrentTabStopId:r,onCurrentTabStopIdChange:x,onEntryFocus:o,preventScrollOnEntryFocus:m=!1,...h}=t,p=c.useRef(null),y=W(s,p),N=he(u),[v,b]=xe({prop:d,defaultProp:r??null,onChange:x,caller:$}),[i,f]=c.useState(!1),j=Pe(o),k=pe(a),A=c.useRef(!1),[T,F]=c.useState(0);return c.useEffect(()=>{const g=p.current;if(g)return g.addEventListener(H,j),()=>g.removeEventListener(H,j)},[j]),e.jsx(Ze,{scope:a,orientation:n,dir:N,loop:l,currentTabStopId:v,onItemFocus:c.useCallback(g=>b(g),[b]),onItemShiftTab:c.useCallback(()=>f(!0),[]),onFocusableItemAdd:c.useCallback(()=>F(g=>g+1),[]),onFocusableItemRemove:c.useCallback(()=>F(g=>g-1),[]),children:e.jsx(U.div,{tabIndex:i||T===0?-1:0,"data-orientation":n,...h,ref:y,style:{outline:"none",...t.style},onMouseDown:L(t.onMouseDown,()=>{A.current=!0}),onFocus:L(t.onFocus,g=>{const S=!A.current;if(g.target===g.currentTarget&&S&&!i){const I=new CustomEvent(H,qe);if(g.currentTarget.dispatchEvent(I),!I.defaultPrevented){const E=k().filter(M=>M.focusable),_e=E.find(M=>M.active),Le=E.find(M=>M.id===v),Fe=[_e,Le,...E].filter(Boolean).map(M=>M.ref.current);ve(Fe,m)}}A.current=!1}),onBlur:L(t.onBlur,()=>f(!1))})})}),ge="RovingFocusGroupItem",ye=c.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,focusable:n=!0,active:l=!1,tabStopId:u,children:d,...r}=t,x=ue(),o=u||x,m=et(ge,a),h=m.currentTabStopId===o,p=pe(a),{onFocusableItemAdd:y,onFocusableItemRemove:N,currentTabStopId:v}=m;return c.useEffect(()=>{if(n)return y(),()=>N()},[n,y,N]),e.jsx(z.ItemSlot,{scope:a,id:o,focusable:n,active:l,children:e.jsx(U.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...r,ref:s,onMouseDown:L(t.onMouseDown,b=>{n?m.onItemFocus(o):b.preventDefault()}),onFocus:L(t.onFocus,()=>m.onItemFocus(o)),onKeyDown:L(t.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){m.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const i=nt(b,m.orientation,m.dir);if(i!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let j=p().filter(k=>k.focusable).map(k=>k.ref.current);if(i==="last")j.reverse();else if(i==="prev"||i==="next"){i==="prev"&&j.reverse();const k=j.indexOf(b.currentTarget);j=m.loop?rt(j,k+1):j.slice(k+1)}setTimeout(()=>ve(j))}}),children:typeof d=="function"?d({isCurrentTabStop:h,hasTabStop:v!=null}):d})})});ye.displayName=ge;var st={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function at(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function nt(t,s,a){const n=at(t.key,a);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return st[n]}function ve(t,s=!1){const a=document.activeElement;for(const n of t)if(n===a||(n.focus({preventScroll:s}),document.activeElement!==a))return}function rt(t,s){return t.map((a,n)=>t[(s+n)%t.length])}var ot=fe,lt=ye,B="Tabs",[it]=q(B,[be]),je=be(),[ct,Q]=it(B),Ne=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,onValueChange:l,defaultValue:u,orientation:d="horizontal",dir:r,activationMode:x="automatic",...o}=t,m=he(r),[h,p]=xe({prop:n,onChange:l,defaultProp:u??"",caller:B});return e.jsx(ct,{scope:a,baseId:ue(),value:h,onValueChange:p,orientation:d,dir:m,activationMode:x,children:e.jsx(U.div,{dir:m,"data-orientation":d,...o,ref:s})})});Ne.displayName=B;var ke="TabsList",Se=c.forwardRef((t,s)=>{const{__scopeTabs:a,loop:n=!0,...l}=t,u=Q(ke,a),d=je(a);return e.jsx(ot,{asChild:!0,...d,orientation:u.orientation,dir:u.dir,loop:n,children:e.jsx(U.div,{role:"tablist","aria-orientation":u.orientation,...l,ref:s})})});Se.displayName=ke;var Te="TabsTrigger",we=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,disabled:l=!1,...u}=t,d=Q(Te,a),r=je(a),x=Ie(d.baseId,n),o=Ae(d.baseId,n),m=n===d.value;return e.jsx(lt,{asChild:!0,...r,focusable:!l,active:m,children:e.jsx(U.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":o,"data-state":m?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:x,...u,ref:s,onMouseDown:L(t.onMouseDown,h=>{!l&&h.button===0&&h.ctrlKey===!1?d.onValueChange(n):h.preventDefault()}),onKeyDown:L(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&d.onValueChange(n)}),onFocus:L(t.onFocus,()=>{const h=d.activationMode!=="manual";!m&&!l&&h&&d.onValueChange(n)})})})});we.displayName=Te;var Ce="TabsContent",Ee=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,forceMount:l,children:u,...d}=t,r=Q(Ce,a),x=Ie(r.baseId,n),o=Ae(r.baseId,n),m=n===r.value,h=c.useRef(m);return c.useEffect(()=>{const p=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(p)},[]),e.jsx(Me,{present:l||m,children:({present:p})=>e.jsx(U.div,{"data-state":m?"active":"inactive","data-orientation":r.orientation,role:"tabpanel","aria-labelledby":x,hidden:!p,id:o,tabIndex:0,...d,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:p&&u})})});Ee.displayName=Ce;function Ie(t,s){return`${t}-trigger-${s}`}function Ae(t,s){return`${t}-content-${s}`}var dt=Ne,ut=Se,xt=we,O=Ee;const mt=["default","hover","focus","focus-visible","active","disabled"],ht=["light","dark","forced-colors-active","forced-colors-none"],pt=["ltr","rtl"];function bt({value:t,onChange:s}){function a(l,u){return l.includes(u)?l.filter(d=>d!==u):[...l,u]}function n(){const l=t.ariaVariations.length===0?1:t.ariaVariations.length;return t.pseudoStates.length*l*t.themes.length*t.directions.length*t.breakpoints.length}return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[e.jsx(G,{label:"Pseudo-states",all:mt,selected:t.pseudoStates,onToggle:l=>s({...t,pseudoStates:a(t.pseudoStates,l)})}),e.jsx(G,{label:"Themes",all:ht,selected:t.themes,onToggle:l=>s({...t,themes:a(t.themes,l)})}),e.jsx(G,{label:"Directions",all:pt,selected:t.directions,onToggle:l=>s({...t,directions:a(t.directions,l)})}),e.jsx(G,{label:"Breakpoints",all:t.breakpointPresets.map(l=>l.id),selected:t.breakpoints,onToggle:l=>s({...t,breakpoints:a(t.breakpoints,l)})}),e.jsxs("p",{className:"text-xs text-slate-500 pt-2 border-t border-slate-100",children:[e.jsx("strong",{children:n()})," audits per component"]})]})}function G({label:t,all:s,selected:a,onToggle:n}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium mb-1.5",children:t}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(l=>{const u=a.includes(l);return e.jsx("button",{type:"button",onClick:()=>n(l),className:u?"text-xs px-2 py-1 rounded bg-brand-500 text-white":"text-xs px-2 py-1 rounded bg-slate-100 text-slate-700 hover:bg-slate-200",children:l},l)})})]})}function ft({value:t,onChange:s}){const[a,n]=c.useState(""),[l,u]=c.useState("");function d(o){o.preventDefault();const m=a.trim(),h=l.trim();!m||!h||(s({...t,[m]:h}),n(""),u(""))}function r(o){const m={...t};delete m[o],s(m)}const x=Object.entries(t);return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[x.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no aliases"}):e.jsx("ul",{className:"space-y-1",children:x.map(([o,m])=>e.jsxs("li",{className:"text-xs flex items-center justify-between gap-2 border border-slate-100 rounded p-1.5",children:[e.jsxs("span",{className:"font-mono truncate",title:`${o} → ${m}`,children:[o," ",e.jsx("span",{className:"text-slate-500",children:"→"})," ",m]}),e.jsx("button",{onClick:()=>r(o),className:"text-slate-500 hover:text-red-600 shrink-0","aria-label":`Remove alias ${o}`,children:"×"})]},o))}),e.jsxs("form",{onSubmit:d,className:"grid grid-cols-[1fr_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-500 mb-1",children:"From"}),e.jsx("input",{type:"text",value:a,onChange:o=>n(o.target.value),placeholder:"https://example.com::testid:btn-a",className:"w-full text-xs border border-slate-300 rounded px-2 py-1 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-500 mb-1",children:"Treat as"}),e.jsx("input",{type:"text",value:l,onChange:o=>u(o.target.value),placeholder:"https://example.com::testid:btn-canonical",className:"w-full text-xs border border-slate-300 rounded px-2 py-1 font-mono"})]}),e.jsx("button",{type:"submit",className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",disabled:!a.trim()||!l.trim(),children:"Add"})]})]})}const te=me("billing-portal-client"),gt="https://api.wcagcheckr.com",yt="wcagcheckr",vt=15e3;async function jt(t){const s=`${gt}/v1/products/${yt}/billing-portal`;try{const a=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout(vt)}),n=await a.json().catch(()=>null);return a.ok?n!=null&&n.url?{ok:!0,url:n.url}:{ok:!1,error:"malformed response — no url",status:a.status}:(te.warn(`billing portal HTTP ${a.status}`,n),{ok:!1,status:a.status,error:(n==null?void 0:n.hint)??(n==null?void 0:n.error)??`HTTP ${a.status}`})}catch(a){return te.warn("billing portal request failed",a),{ok:!1,error:a instanceof Error?a.message:String(a)}}}const se=me("subscription-resume-client"),Nt="https://api.wcagcheckr.com",kt="wcagcheckr",St=1e4;async function Tt(t){try{const s=await fetch(`${Nt}/v1/products/${kt}/subscription/resume`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout(St)}),a=await s.json().catch(()=>null);return s.ok?{ok:!0,alreadyActive:(a==null?void 0:a.alreadyActive)===!0}:(se.warn(`resume http ${s.status}`,a),{ok:!1,status:s.status,error:(a==null?void 0:a.hint)??(a==null?void 0:a.error)??`HTTP ${s.status}`})}catch(s){return se.warn("resume request failed",s),{ok:!1,error:s instanceof Error?s.message:String(s)}}}const wt={trial:"Trial",free:"Free",solo:"Solo",team:"Team"},Ct={free:"Free",solo:"Solo (monthly)","solo-yearly":"Solo (yearly)","solo-single-month":"Solo (single month — non-recurring)",team:"Team (5 seats, monthly)","team-yearly":"Team (5 seats, yearly)","team-15":"Team (15 seats, monthly)","team-15-yearly":"Team (15 seats, yearly)"},Et=new Set(["solo-single-month"]);function It(t){if(!t)return null;const s=new Date(t).getTime()-Date.now();return Number.isFinite(s)?Math.ceil(s/(24*60*60*1e3)):null}function D(t){return t?Ct[t]??t:"—"}function J(t){if(!t)return"no expiry on file";try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return t}}function At({tier:t,onTierChange:s}){const[a,n]=c.useState(null),[l,u]=c.useState(null),[d,r]=c.useState(!1),[x,o]=c.useState(""),[m,h]=c.useState(!1),[p,y]=c.useState(null),[N,v]=c.useState(!1),[b,i]=c.useState(!1),f=c.useCallback(async g=>{const I=(await chrome.storage.local.get("licenseToken")).licenseToken??null;if(n(I),!I){u(null);return}try{const E=await w({type:"LICENSE_VALIDATE_REQUEST",token:I,forceRefresh:(g==null?void 0:g.forceRefresh)===!0});u(E)}catch{u(null)}},[]);c.useEffect(()=>(f({forceRefresh:!0}),Oe("LICENSE_CHANGED_EVENT",()=>{f()})),[f]);async function j(){if(x.trim()){h(!0),y(null);try{const g=await w({type:"LICENSE_SET_REQUEST",token:x.trim()}),S=await w({type:"LICENSE_VALIDATE_REQUEST",token:x.trim()});if(S.valid&&S.plan){const I=Lt(S.plan);s(I);let E=`Activated as ${D(S.plan)}.`;g.seatClaim.ok?g.seatClaim.overCapacity&&(E=`Activated as ${D(S.plan)}. Note: this license is currently OVER its seat cap (${g.seatClaim.seatsUsed} of ${g.seatClaim.seatsTotal} seats). Release one or upgrade.`):g.seatClaim.reason==="cap-reached"?E=`Activated as ${D(S.plan)}, BUT this license is at its seat capacity (${g.seatClaim.seatsUsed} of ${g.seatClaim.seatsTotal} seats used). Release a seat from another device, or upgrade to a higher-seat plan. This device's seat won't be active until you do.`:g.seatClaim.reason==="network"&&(E=`Activated as ${D(S.plan)}. (Seat-tracking ping failed — retrying in the background.)`),y(E),g.seatClaim.ok&&!g.seatClaim.overCapacity?R.polite(E):R.assertive(E),o(""),r(!1),await f()}else{const I="Token did not validate. Check the value and try again.";y(I),R.assertive(I)}}catch(g){const S=g instanceof Error?g.message:String(g);y(S),R.assertive(S)}finally{h(!1)}}}async function k(){if(a)try{await navigator.clipboard.writeText(a),v(!0),setTimeout(()=>v(!1),2e3)}catch{}}async function A(){if(window.confirm(`Remove the active license token from this extension?
2
2
 
3
- Your subscription stays active server-side — you can paste the same token back in any time. The extension will fall back to trial / free until then.`)){a&&await Ke(a),await chrome.storage.local.remove("licenseToken"),n(null),u(null);try{const S=await w({type:"TIER_GET"});s(S.tier)}catch{s("free")}R.polite("License token removed.")}}const T=Be[t],L=a!==null&&(l==null?void 0:l.valid)===!0;return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Current tier"}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-slate-100 text-slate-700",children:Tt[t]})]}),e.jsxs("ul",{className:"text-xs text-slate-600 space-y-1",children:[e.jsxs("li",{children:["Components:"," ",Number.isFinite(T.maxComponents)?T.maxComponents:"unlimited"]}),e.jsxs("li",{children:["Baselines:"," ",Number.isFinite(T.maxBaselines)?T.maxBaselines:"unlimited"]}),e.jsxs("li",{children:["State matrix: ",T.stateMatrix]}),e.jsxs("li",{children:["Storybook auto-iterate: ",T.storybookAutoIterate?"yes":"no"]}),e.jsxs("li",{children:["JSON export: ",T.exportJson?"yes":"no"]}),e.jsxs("li",{children:["SARIF / JUnit export: ",T.exportSarif?"yes":"no"]})]}),L&&l?e.jsx(At,{token:a,info:l,copied:N,onCopy:k,onRemove:A,onUseDifferent:()=>r(!0),onManageSubscription:async()=>{const g=await vt({licenseToken:a});g.ok?window.open(g.url,"_blank","noopener,noreferrer"):(y(`Couldn't open billing portal: ${g.error}`),R.assertive("Could not open billing portal."))},onResumeSubscription:async()=>{const g=await St({licenseToken:a});if(g.ok){const S=g.alreadyActive?"Subscription was already active — no change needed.":"Subscription resumed. Cancellation has been reversed.";y(S),R.polite(S),await f({forceRefresh:!0})}else y(`Couldn't resume subscription: ${g.error}`),R.assertive("Could not resume subscription.")},onRenew:()=>i(!0),message:h}):a?e.jsx(Rt,{token:a,onRemove:A,onUseDifferent:()=>r(!0)}):e.jsx(ae,{token:x,onTokenChange:o,submitting:m,message:h,onSubmit:j}),L&&d&&e.jsx(ae,{token:x,onTokenChange:o,submitting:m,message:h,onSubmit:j,replacing:!0,onCancel:()=>{r(!1),o(""),y(null)}}),!L&&(t==="trial"||t==="free")&&e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:"Solo"}),": $",_.solo.monthlyUsd,"/mo (recurring) ·"," ","$",_.solo.yearlyUsd,"/yr (save ",Math.round(100-_.solo.yearlyUsd/(_.solo.monthlyUsd*12)*100),"%) ·"," ","$",_.solo.singleMonthUsd," single month (no recurring) · single user."]}),e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:"Team"}),": $",_.team.fiveSeatMonthlyUsd,"/mo for 5 seats ·"," ","$",_.team.fifteenSeatMonthlyUsd,"/mo for 15 seats."]}),e.jsx("button",{type:"button",onClick:()=>i(!0),className:"inline-block text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Upgrade →"})]}),e.jsx(Ue,{open:b,onClose:()=>i(!1)})]})}function At({token:t,info:s,copied:a,onCopy:n,onRemove:l,onUseDifferent:u,onManageSubscription:d,onResumeSubscription:r,onRenew:x,message:o}){const m=s.features,p=typeof(m==null?void 0:m.seatsUsed)=="number"?m.seatsUsed:null,h=typeof(m==null?void 0:m.seatsTotal)=="number"?m.seatsTotal:null,y=h!==null,N=p!==null&&h!==null&&p>h,v=p!==null&&h!==null&&p===h,b=s.plan?Ct.has(s.plan):!1,i=Et(s.expiresAt),f=b&&i!==null&&i<=7;return e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:"Active license"}),e.jsx("span",{className:s.cancelAtPeriodEnd?"text-[10px] px-1.5 py-0.5 rounded-full bg-amber-100 text-amber-900":"text-[10px] px-1.5 py-0.5 rounded-full bg-emerald-100 text-emerald-800",children:s.cancelAtPeriodEnd?"cancellation scheduled":s.status??"unknown"})]}),s.pastDueSince&&e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded p-2 text-[11px] text-rose-900",children:[e.jsx("strong",{children:"Payment failed."})," Stripe couldn't charge your card. Access continues during the grace period (usually up to 7 days while Stripe retries), then this license will cancel automatically."," ",e.jsx("button",{type:"button",onClick:d,className:"font-medium underline-offset-2 hover:underline",children:"Update your card via the Stripe portal →"})]}),s.cancelAtPeriodEnd&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded p-2 text-[11px] text-amber-900 space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Cancellation scheduled."})," Your subscription was cancelled via Stripe. Access continues until ",e.jsx("strong",{children:J(s.expiresAt)}),", then this license stops working."]}),e.jsx("button",{type:"button",onClick:r,className:"text-[11px] font-medium underline-offset-2 hover:underline",children:"Resume subscription →"})]}),N&&e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded p-2 text-[11px] text-rose-900",children:[e.jsx("strong",{children:"Over seat capacity."})," This license has"," ",e.jsx("strong",{children:p})," seats in use but the plan only includes"," ",e.jsx("strong",{children:h}),". New devices will be rejected. Release a seat from another device, or upgrade to a higher-seat plan via Manage subscription below."]}),v&&!N&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded p-2 text-[11px] text-amber-900",children:[e.jsx("strong",{children:"At seat capacity."})," All ",e.jsx("strong",{children:h})," seats are in use. The next new device that tries to activate this license will be rejected until a seat is released."]}),e.jsxs("dl",{className:"text-xs text-slate-600 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1",children:[e.jsx("dt",{className:"text-slate-500",children:"Plan"}),e.jsx("dd",{children:D(s.plan)}),e.jsx("dt",{className:"text-slate-500",children:"Email"}),e.jsx("dd",{className:"truncate",children:s.email??"—"}),e.jsx("dt",{className:"text-slate-500",children:b?"Expires":"Renews / ends"}),e.jsxs("dd",{children:[J(s.expiresAt),i!==null&&i>=0&&i<=14?e.jsx("span",{className:f?"ml-2 text-[10px] text-amber-900 bg-amber-100 rounded px-1.5 py-0.5":"ml-2 text-[10px] text-slate-500",children:i===0?"today":i===1?"1 day left":`${i} days left`}):null]}),s.trialEndsAt?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-slate-500",children:"Trial ends"}),e.jsx("dd",{children:J(s.trialEndsAt)})]}):null,y?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-slate-500",children:"Seats"}),e.jsx("dd",{children:p!==null?`${p} of ${h} used`:`${h} total`})]}):null]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-500 mb-1",children:"Token"}),e.jsxs("div",{className:"flex items-stretch gap-1",children:[e.jsx("code",{className:"flex-1 font-mono text-[11px] bg-slate-100 border border-slate-200 rounded px-2 py-1.5 select-all break-all",children:t}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1.5 border border-slate-300 rounded bg-white hover:bg-slate-50 shrink-0",children:a?"Copied ✓":"Copy"})]})]}),e.jsx("div",{className:"pt-1 flex flex-wrap gap-2",children:b?e.jsx("button",{type:"button",onClick:x,className:f?"text-xs px-3 py-1.5 bg-amber-500 text-white rounded hover:bg-amber-600":"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",title:"Buy another month — extends your existing license, no new token to copy",children:f?`Renew now — $${_.solo.singleMonthUsd} →`:`Buy another month — $${_.solo.singleMonthUsd} →`}):e.jsx("button",{type:"button",onClick:d,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",title:"Open Stripe's billing portal — change plan or seat count, update card, view invoices, cancel",children:"Manage subscription →"})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:u,className:"text-[11px] text-brand-600 hover:underline",children:"Use a different token"}),e.jsx("span",{className:"text-slate-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:l,className:"text-[11px] text-rose-700 hover:underline",children:"Remove license from this extension"})]}),o&&e.jsx("p",{className:"text-xs text-slate-600 pt-1",children:o})]})}function Rt({token:t,onRemove:s,onUseDifferent:a}){return e.jsxs("div",{className:"border-t border-rose-100 pt-3 space-y-2 bg-rose-50/40 -mx-3 px-3 pb-2 rounded-b",children:[e.jsxs("p",{className:"text-xs text-rose-800",children:[e.jsx("strong",{children:"License token rejected by the server."})," The token may have been revoked, the subscription canceled, or the network is down. Verify your subscription and try a different token — or remove this one and continue on the trial / free tier."]}),e.jsx("p",{className:"text-[11px] text-rose-700 font-mono break-all",children:t}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:a,className:"text-[11px] text-brand-600 hover:underline",children:"Use a different token"}),e.jsx("span",{className:"text-slate-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-rose-700 hover:underline",children:"Remove and continue without a license"})]})]})}function ae({token:t,onTokenChange:s,submitting:a,message:n,onSubmit:l,replacing:u,onCancel:d}){return e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsx("label",{htmlFor:"opt-license-token",className:"block text-xs font-medium",children:u?"Replace with a different token":"Activate license token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"opt-license-token",type:"text",value:t,onChange:r=>s(r.target.value),placeholder:"00000000-0000-0000-0000-000000000000",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1 font-mono"}),e.jsx("button",{onClick:l,disabled:a||!t.trim(),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:a?"Validating…":u?"Replace":"Activate"}),u&&d&&e.jsx("button",{type:"button",onClick:d,className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Cancel"})]}),n&&e.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function _t(t){return t==="solo"||t==="solo-yearly"||t==="solo-single-month"?"solo":t==="team"||t==="team-15"||t==="team-yearly"||t==="team-15-yearly"?"team":"free"}const Ft=new Set(Ve.map(t=>t.id));function Lt({presets:t,onChange:s}){const[a,n]=c.useState({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1});function l(r){r.preventDefault();const x=a.id.trim();!x||t.some(o=>o.id===x)||(s([...t,{...a,id:x,label:a.label.trim()||`${x} (${a.width}×${a.height})`}]),n({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1}))}function u(r){s(t.filter(x=>x.id!==r))}function d(r,x){s(t.map(o=>o.id===r?{...o,...x}:o))}return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no breakpoints"}):e.jsx("ul",{className:"space-y-1.5",children:t.map(r=>{const x=Ft.has(r.id);return e.jsxs("li",{className:"grid grid-cols-[1fr_70px_70px_auto_auto] gap-2 items-center text-xs",children:[e.jsxs("span",{className:"font-medium truncate",title:r.id,children:[r.label,x&&e.jsx("span",{className:"text-slate-500 font-normal ml-1",children:"(default)"})]}),e.jsx("input",{type:"number",value:r.width,onChange:o=>d(r.id,{width:Number(o.target.value)||0}),className:"text-xs border border-slate-300 rounded px-1.5 py-1 w-full","aria-label":`Width for ${r.label}`,min:1}),e.jsx("input",{type:"number",value:r.height,onChange:o=>d(r.id,{height:Number(o.target.value)||0}),className:"text-xs border border-slate-300 rounded px-1.5 py-1 w-full","aria-label":`Height for ${r.label}`,min:1}),e.jsxs("label",{className:"flex items-center gap-1 text-slate-600",children:[e.jsx("input",{type:"checkbox",checked:r.mobile,onChange:o=>d(r.id,{mobile:o.target.checked})}),"mobile"]}),x?e.jsx("span",{className:"w-4","aria-hidden":"true"}):e.jsx("button",{onClick:()=>u(r.id),className:"text-slate-500 hover:text-red-600","aria-label":`Remove ${r.label}`,children:"×"})]},r.id)})}),e.jsxs("form",{onSubmit:l,className:"grid grid-cols-[1fr_1fr_70px_70px_auto] gap-2 items-end pt-3 border-t border-slate-100",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-id",className:"block text-xs text-slate-500 mb-1",children:"ID"}),e.jsx("input",{id:"bp-draft-id",type:"text",value:a.id,onChange:r=>n({...a,id:r.target.value}),placeholder:"laptop",className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-label",className:"block text-xs text-slate-500 mb-1",children:"Label"}),e.jsx("input",{id:"bp-draft-label",type:"text",value:a.label,onChange:r=>n({...a,label:r.target.value}),placeholder:"Laptop (1440×900)",className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-width",className:"block text-xs text-slate-500 mb-1",children:"W"}),e.jsx("input",{id:"bp-draft-width",type:"number",value:a.width,onChange:r=>n({...a,width:Number(r.target.value)||0}),min:1,className:"w-full text-xs border border-slate-300 rounded px-1.5 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-height",className:"block text-xs text-slate-500 mb-1",children:"H"}),e.jsx("input",{id:"bp-draft-height",type:"number",value:a.height,onChange:r=>n({...a,height:Number(r.target.value)||0}),min:1,className:"w-full text-xs border border-slate-300 rounded px-1.5 py-1"})]}),e.jsx("button",{type:"submit",disabled:!a.id.trim()||t.some(r=>r.id===a.id.trim()),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:"Add"})]})]})}function Pt({stateMatrix:t,componentIdAliases:s,onImport:a}){const n=c.useRef(null),[l,u]=c.useState(null);function d(){const x={schemaVersion:1,exportedAt:new Date().toISOString(),stateMatrix:t,componentIdAliases:s},o=new Blob([JSON.stringify(x,null,2)],{type:"application/json"}),m=URL.createObjectURL(o),p=document.createElement("a");p.href=m,p.download=`wcag-auditor-settings-${new Date().toISOString().slice(0,10)}.json`,p.click(),URL.revokeObjectURL(m),u("Exported.")}async function r(x){var o,m;u(null);try{const p=await x.text(),h=JSON.parse(p);if(h.schemaVersion!==1)throw new Error(`Unsupported schemaVersion: ${h.schemaVersion}`);if(!((o=h.stateMatrix)!=null&&o.pseudoStates)||!((m=h.stateMatrix)!=null&&m.breakpointPresets))throw new Error("stateMatrix is malformed");await C({type:"SETTINGS_SET",key:"stateMatrix",value:h.stateMatrix}),await C({type:"SETTINGS_SET",key:"componentIdAliases",value:h.componentIdAliases??{}}),a({stateMatrix:h.stateMatrix,componentIdAliases:h.componentIdAliases??{}}),u("Imported.")}catch(p){u(`Import failed: ${p instanceof Error?p.message:String(p)}`)}}return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:d,className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 rounded",children:"Export settings"}),e.jsx("button",{onClick:()=>{var x;return(x=n.current)==null?void 0:x.click()},className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 rounded",children:"Import settings…"}),e.jsx("input",{ref:n,type:"file",accept:"application/json,.json",className:"hidden",onChange:x=>{var m;const o=(m=x.target.files)==null?void 0:m[0];o&&r(o),x.target.value=""}})]}),l&&e.jsx("p",{className:"text-xs text-slate-600",children:l})]})}function Mt(){const[t,s]=c.useState(null);c.useEffect(()=>{chrome.storage.local.get(Z).then(n=>s(n[Z]===!0))},[]);async function a(){const n=!t;s(n),await Oe(n)}return t===null?e.jsx("p",{className:"text-xs text-slate-500",children:"Loading…"}):e.jsx("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:e.jsxs("label",{className:"flex items-start gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a,className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Send anonymized crash reports"}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:"When the extension hits an unexpected error, send the error message + redacted stack trace + extension version. URLs, emails, and license tokens are stripped before sending. No audit data, page content, or browsing history is included."})]})]})})}function Ut(){const[t,s]=c.useState(null);c.useEffect(()=>{chrome.storage.local.get(K).then(n=>s(n[K]===!0))},[]);async function a(){const n=!t;s(n),await chrome.storage.local.set({[K]:n})}return t===null?e.jsx("p",{className:"text-xs text-slate-500",children:"Loading…"}):e.jsx("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:e.jsxs("label",{className:"flex items-start gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a,className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Skip the download confirmation"}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:"By default, generating a defense or evidence bundle pops up a small confirmation asking whether to download or preview. Enable this to skip the prompt and have the file land directly in your Downloads folder. Keep it off if you'd rather decide each time (recommended for non-technical users — surprise downloads can be alarming)."})]})]})})}const ne="disabledRules";function Dt(){const[t,s]=c.useState(""),[a,n]=c.useState(!1),[l,u]=c.useState(null);c.useEffect(()=>{w({type:"SETTINGS_GET",key:ne}).then(r=>{const x=Array.isArray(r.data)?r.data:[];s(x.join(`
3
+ Your subscription stays active server-side — you can paste the same token back in any time. The extension will fall back to trial / free until then.`)){a&&await Ke(a),await chrome.storage.local.remove("licenseToken"),n(null),u(null);try{const S=await w({type:"TIER_GET"});s(S.tier)}catch{s("free")}R.polite("License token removed.")}}const T=Be[t],F=a!==null&&(l==null?void 0:l.valid)===!0;return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Current tier"}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-slate-100 text-slate-700",children:wt[t]})]}),e.jsxs("ul",{className:"text-xs text-slate-600 space-y-1",children:[e.jsxs("li",{children:["Components:"," ",Number.isFinite(T.maxComponents)?T.maxComponents:"unlimited"]}),e.jsxs("li",{children:["Baselines:"," ",Number.isFinite(T.maxBaselines)?T.maxBaselines:"unlimited"]}),e.jsxs("li",{children:["State matrix: ",T.stateMatrix]}),e.jsxs("li",{children:["Storybook auto-iterate: ",T.storybookAutoIterate?"yes":"no"]}),e.jsxs("li",{children:["JSON export: ",T.exportJson?"yes":"no"]}),e.jsxs("li",{children:["SARIF / JUnit export: ",T.exportSarif?"yes":"no"]})]}),F&&l?e.jsx(Rt,{token:a,info:l,copied:N,onCopy:k,onRemove:A,onUseDifferent:()=>r(!0),onManageSubscription:async()=>{const g=await jt({licenseToken:a});g.ok?window.open(g.url,"_blank","noopener,noreferrer"):(y(`Couldn't open billing portal: ${g.error}`),R.assertive("Could not open billing portal."))},onResumeSubscription:async()=>{const g=await Tt({licenseToken:a});if(g.ok){const S=g.alreadyActive?"Subscription was already active — no change needed.":"Subscription resumed. Cancellation has been reversed.";y(S),R.polite(S),await f({forceRefresh:!0})}else y(`Couldn't resume subscription: ${g.error}`),R.assertive("Could not resume subscription.")},onRenew:()=>i(!0),message:p}):a?e.jsx(_t,{token:a,onRemove:A,onUseDifferent:()=>r(!0)}):e.jsx(ae,{token:x,onTokenChange:o,submitting:m,message:p,onSubmit:j}),F&&d&&e.jsx(ae,{token:x,onTokenChange:o,submitting:m,message:p,onSubmit:j,replacing:!0,onCancel:()=>{r(!1),o(""),y(null)}}),!F&&(t==="trial"||t==="free")&&e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:"Solo"}),": $",_.solo.monthlyUsd,"/mo (recurring) ·"," ","$",_.solo.yearlyUsd,"/yr (save ",Math.round(100-_.solo.yearlyUsd/(_.solo.monthlyUsd*12)*100),"%) ·"," ","$",_.solo.singleMonthUsd," single month (no recurring) · single user."]}),e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:"Team"}),": $",_.team.fiveSeatMonthlyUsd,"/mo for 5 seats ·"," ","$",_.team.fifteenSeatMonthlyUsd,"/mo for 15 seats."]}),e.jsx("button",{type:"button",onClick:()=>i(!0),className:"inline-block text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Upgrade →"})]}),e.jsx(Ue,{open:b,onClose:()=>i(!1)})]})}function Rt({token:t,info:s,copied:a,onCopy:n,onRemove:l,onUseDifferent:u,onManageSubscription:d,onResumeSubscription:r,onRenew:x,message:o}){const m=s.features,h=typeof(m==null?void 0:m.seatsUsed)=="number"?m.seatsUsed:null,p=typeof(m==null?void 0:m.seatsTotal)=="number"?m.seatsTotal:null,y=p!==null,N=h!==null&&p!==null&&h>p,v=h!==null&&p!==null&&h===p,b=s.plan?Et.has(s.plan):!1,i=It(s.expiresAt),f=b&&i!==null&&i<=7;return e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:"Active license"}),e.jsx("span",{className:s.cancelAtPeriodEnd?"text-[10px] px-1.5 py-0.5 rounded-full bg-amber-100 text-amber-900":"text-[10px] px-1.5 py-0.5 rounded-full bg-emerald-100 text-emerald-800",children:s.cancelAtPeriodEnd?"cancellation scheduled":s.status??"unknown"})]}),s.pastDueSince&&e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded p-2 text-[11px] text-rose-900",children:[e.jsx("strong",{children:"Payment failed."})," Stripe couldn't charge your card. Access continues during the grace period (usually up to 7 days while Stripe retries), then this license will cancel automatically."," ",e.jsx("button",{type:"button",onClick:d,className:"font-medium underline-offset-2 hover:underline",children:"Update your card via the Stripe portal →"})]}),s.cancelAtPeriodEnd&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded p-2 text-[11px] text-amber-900 space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Cancellation scheduled."})," Your subscription was cancelled via Stripe. Access continues until ",e.jsx("strong",{children:J(s.expiresAt)}),", then this license stops working."]}),e.jsx("button",{type:"button",onClick:r,className:"text-[11px] font-medium underline-offset-2 hover:underline",children:"Resume subscription →"})]}),N&&e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded p-2 text-[11px] text-rose-900",children:[e.jsx("strong",{children:"Over seat capacity."})," This license has"," ",e.jsx("strong",{children:h})," seats in use but the plan only includes"," ",e.jsx("strong",{children:p}),". New devices will be rejected. Release a seat from another device, or upgrade to a higher-seat plan via Manage subscription below."]}),v&&!N&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded p-2 text-[11px] text-amber-900",children:[e.jsx("strong",{children:"At seat capacity."})," All ",e.jsx("strong",{children:p})," seats are in use. The next new device that tries to activate this license will be rejected until a seat is released."]}),e.jsxs("dl",{className:"text-xs text-slate-600 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1",children:[e.jsx("dt",{className:"text-slate-500",children:"Plan"}),e.jsx("dd",{children:D(s.plan)}),e.jsx("dt",{className:"text-slate-500",children:"Email"}),e.jsx("dd",{className:"truncate",children:s.email??"—"}),e.jsx("dt",{className:"text-slate-500",children:b?"Expires":"Renews / ends"}),e.jsxs("dd",{children:[J(s.expiresAt),i!==null&&i>=0&&i<=14?e.jsx("span",{className:f?"ml-2 text-[10px] text-amber-900 bg-amber-100 rounded px-1.5 py-0.5":"ml-2 text-[10px] text-slate-500",children:i===0?"today":i===1?"1 day left":`${i} days left`}):null]}),s.trialEndsAt?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-slate-500",children:"Trial ends"}),e.jsx("dd",{children:J(s.trialEndsAt)})]}):null,y?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-slate-500",children:"Seats"}),e.jsx("dd",{children:h!==null?`${h} of ${p} used`:`${p} total`})]}):null]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-500 mb-1",children:"Token"}),e.jsxs("div",{className:"flex items-stretch gap-1",children:[e.jsx("code",{className:"flex-1 font-mono text-[11px] bg-slate-100 border border-slate-200 rounded px-2 py-1.5 select-all break-all",children:t}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1.5 border border-slate-300 rounded bg-white hover:bg-slate-50 shrink-0",children:a?"Copied ✓":"Copy"})]})]}),e.jsx("div",{className:"pt-1 flex flex-wrap gap-2",children:b?e.jsx("button",{type:"button",onClick:x,className:f?"text-xs px-3 py-1.5 bg-amber-500 text-white rounded hover:bg-amber-600":"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",title:"Buy another month — extends your existing license, no new token to copy",children:f?`Renew now — $${_.solo.singleMonthUsd} →`:`Buy another month — $${_.solo.singleMonthUsd} →`}):e.jsx("button",{type:"button",onClick:d,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",title:"Open Stripe's billing portal — change plan or seat count, update card, view invoices, cancel",children:"Manage subscription →"})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:u,className:"text-[11px] text-brand-600 hover:underline",children:"Use a different token"}),e.jsx("span",{className:"text-slate-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:l,className:"text-[11px] text-rose-700 hover:underline",children:"Remove license from this extension"})]}),o&&e.jsx("p",{className:"text-xs text-slate-600 pt-1",children:o})]})}function _t({token:t,onRemove:s,onUseDifferent:a}){return e.jsxs("div",{className:"border-t border-rose-100 pt-3 space-y-2 bg-rose-50/40 -mx-3 px-3 pb-2 rounded-b",children:[e.jsxs("p",{className:"text-xs text-rose-800",children:[e.jsx("strong",{children:"License token rejected by the server."})," The token may have been revoked, the subscription canceled, or the network is down. Verify your subscription and try a different token — or remove this one and continue on the trial / free tier."]}),e.jsx("p",{className:"text-[11px] text-rose-700 font-mono break-all",children:t}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:a,className:"text-[11px] text-brand-600 hover:underline",children:"Use a different token"}),e.jsx("span",{className:"text-slate-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-rose-700 hover:underline",children:"Remove and continue without a license"})]})]})}function ae({token:t,onTokenChange:s,submitting:a,message:n,onSubmit:l,replacing:u,onCancel:d}){return e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsx("label",{htmlFor:"opt-license-token",className:"block text-xs font-medium",children:u?"Replace with a different token":"Activate license token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"opt-license-token",type:"text",value:t,onChange:r=>s(r.target.value),placeholder:"00000000-0000-0000-0000-000000000000",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1 font-mono"}),e.jsx("button",{onClick:l,disabled:a||!t.trim(),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:a?"Validating…":u?"Replace":"Activate"}),u&&d&&e.jsx("button",{type:"button",onClick:d,className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Cancel"})]}),n&&e.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function Lt(t){return t==="solo"||t==="solo-yearly"||t==="solo-single-month"?"solo":t==="team"||t==="team-15"||t==="team-yearly"||t==="team-15-yearly"?"team":"free"}const Ft=new Set(Ve.map(t=>t.id));function Pt({presets:t,onChange:s}){const[a,n]=c.useState({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1});function l(r){r.preventDefault();const x=a.id.trim();!x||t.some(o=>o.id===x)||(s([...t,{...a,id:x,label:a.label.trim()||`${x} (${a.width}×${a.height})`}]),n({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1}))}function u(r){s(t.filter(x=>x.id!==r))}function d(r,x){s(t.map(o=>o.id===r?{...o,...x}:o))}return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no breakpoints"}):e.jsx("ul",{className:"space-y-1.5",children:t.map(r=>{const x=Ft.has(r.id);return e.jsxs("li",{className:"grid grid-cols-[1fr_70px_70px_auto_auto] gap-2 items-center text-xs",children:[e.jsxs("span",{className:"font-medium truncate",title:r.id,children:[r.label,x&&e.jsx("span",{className:"text-slate-500 font-normal ml-1",children:"(default)"})]}),e.jsx("input",{type:"number",value:r.width,onChange:o=>d(r.id,{width:Number(o.target.value)||0}),className:"text-xs border border-slate-300 rounded px-1.5 py-1 w-full","aria-label":`Width for ${r.label}`,min:1}),e.jsx("input",{type:"number",value:r.height,onChange:o=>d(r.id,{height:Number(o.target.value)||0}),className:"text-xs border border-slate-300 rounded px-1.5 py-1 w-full","aria-label":`Height for ${r.label}`,min:1}),e.jsxs("label",{className:"flex items-center gap-1 text-slate-600",children:[e.jsx("input",{type:"checkbox",checked:r.mobile,onChange:o=>d(r.id,{mobile:o.target.checked})}),"mobile"]}),x?e.jsx("span",{className:"w-4","aria-hidden":"true"}):e.jsx("button",{onClick:()=>u(r.id),className:"text-slate-500 hover:text-red-600","aria-label":`Remove ${r.label}`,children:"×"})]},r.id)})}),e.jsxs("form",{onSubmit:l,className:"grid grid-cols-[1fr_1fr_70px_70px_auto] gap-2 items-end pt-3 border-t border-slate-100",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-id",className:"block text-xs text-slate-500 mb-1",children:"ID"}),e.jsx("input",{id:"bp-draft-id",type:"text",value:a.id,onChange:r=>n({...a,id:r.target.value}),placeholder:"laptop",className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-label",className:"block text-xs text-slate-500 mb-1",children:"Label"}),e.jsx("input",{id:"bp-draft-label",type:"text",value:a.label,onChange:r=>n({...a,label:r.target.value}),placeholder:"Laptop (1440×900)",className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-width",className:"block text-xs text-slate-500 mb-1",children:"W"}),e.jsx("input",{id:"bp-draft-width",type:"number",value:a.width,onChange:r=>n({...a,width:Number(r.target.value)||0}),min:1,className:"w-full text-xs border border-slate-300 rounded px-1.5 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-height",className:"block text-xs text-slate-500 mb-1",children:"H"}),e.jsx("input",{id:"bp-draft-height",type:"number",value:a.height,onChange:r=>n({...a,height:Number(r.target.value)||0}),min:1,className:"w-full text-xs border border-slate-300 rounded px-1.5 py-1"})]}),e.jsx("button",{type:"submit",disabled:!a.id.trim()||t.some(r=>r.id===a.id.trim()),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:"Add"})]})]})}function Mt({stateMatrix:t,componentIdAliases:s,onImport:a}){const n=c.useRef(null),[l,u]=c.useState(null);function d(){const x={schemaVersion:1,exportedAt:new Date().toISOString(),stateMatrix:t,componentIdAliases:s},o=new Blob([JSON.stringify(x,null,2)],{type:"application/json"}),m=URL.createObjectURL(o),h=document.createElement("a");h.href=m,h.download=`wcag-auditor-settings-${new Date().toISOString().slice(0,10)}.json`,h.click(),URL.revokeObjectURL(m),u("Exported.")}async function r(x){var o,m;u(null);try{const h=await x.text(),p=JSON.parse(h);if(p.schemaVersion!==1)throw new Error(`Unsupported schemaVersion: ${p.schemaVersion}`);if(!((o=p.stateMatrix)!=null&&o.pseudoStates)||!((m=p.stateMatrix)!=null&&m.breakpointPresets))throw new Error("stateMatrix is malformed");await C({type:"SETTINGS_SET",key:"stateMatrix",value:p.stateMatrix}),await C({type:"SETTINGS_SET",key:"componentIdAliases",value:p.componentIdAliases??{}}),a({stateMatrix:p.stateMatrix,componentIdAliases:p.componentIdAliases??{}}),u("Imported.")}catch(h){u(`Import failed: ${h instanceof Error?h.message:String(h)}`)}}return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:d,className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 rounded",children:"Export settings"}),e.jsx("button",{onClick:()=>{var x;return(x=n.current)==null?void 0:x.click()},className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 rounded",children:"Import settings…"}),e.jsx("input",{ref:n,type:"file",accept:"application/json,.json",className:"hidden",onChange:x=>{var m;const o=(m=x.target.files)==null?void 0:m[0];o&&r(o),x.target.value=""}})]}),l&&e.jsx("p",{className:"text-xs text-slate-600",children:l})]})}function Ut(){const[t,s]=c.useState(null);c.useEffect(()=>{chrome.storage.local.get(Z).then(n=>s(n[Z]===!0))},[]);async function a(){const n=!t;s(n),await Ge(n)}return t===null?e.jsx("p",{className:"text-xs text-slate-500",children:"Loading…"}):e.jsx("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:e.jsxs("label",{className:"flex items-start gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a,className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Send anonymized crash reports"}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:"When the extension hits an unexpected error, send the error message + redacted stack trace + extension version. URLs, emails, and license tokens are stripped before sending. No audit data, page content, or browsing history is included."})]})]})})}function Dt(){const[t,s]=c.useState(null);c.useEffect(()=>{chrome.storage.local.get(K).then(n=>s(n[K]===!0))},[]);async function a(){const n=!t;s(n),await chrome.storage.local.set({[K]:n})}return t===null?e.jsx("p",{className:"text-xs text-slate-500",children:"Loading…"}):e.jsx("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:e.jsxs("label",{className:"flex items-start gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a,className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Skip the download confirmation"}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:"By default, generating a defense or evidence bundle pops up a small confirmation asking whether to download or preview. Enable this to skip the prompt and have the file land directly in your Downloads folder. Keep it off if you'd rather decide each time (recommended for non-technical users — surprise downloads can be alarming)."})]})]})})}function $t(){const[t,s]=c.useState(null),[a,n]=c.useState(!1);async function l(){const d=await chrome.storage.local.get(null),r=Object.keys(d).filter(x=>x.startsWith("auditCache:"));s(r.length)}c.useEffect(()=>{l()},[]);async function u(){n(!0);try{await He(),await l()}finally{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Audit cache"}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:"Repeat audits of the same component skip the state-matrix iteration when the DOM is unchanged from the last audit (10-50× faster). The fingerprint is DOM-only — if you change ONLY CSS, the cache won't notice and will return stale results. Clear it here when that happens."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:u,disabled:a||(t??0)===0,className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 disabled:opacity-50 disabled:cursor-not-allowed border border-slate-300 rounded",children:a?"Clearing…":"Clear audit cache"}),e.jsx("span",{className:"text-xs text-slate-500",children:t===null?"Loading…":t===0?"Cache is empty.":`${t} cached audit${t===1?"":"s"}.`})]})]})}const ne="disabledRules";function Ot(){const[t,s]=c.useState(""),[a,n]=c.useState(!1),[l,u]=c.useState(null);c.useEffect(()=>{w({type:"SETTINGS_GET",key:ne}).then(r=>{const x=Array.isArray(r.data)?r.data:[];s(x.join(`
4
4
  `)),n(!0)})},[]);function d(r){const x=r.split(`
5
5
  `).map(o=>o.trim()).filter(o=>o.length>0);C({type:"SETTINGS_SET",key:ne,value:x}),u(Date.now())}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Rule IDs to skip during audits. One per line. Use exact axe-core rule IDs (e.g.,"," ",e.jsx("code",{className:"bg-slate-100 text-slate-700 px-1 rounded",children:"color-contrast"}),","," ",e.jsx("code",{className:"bg-slate-100 text-slate-700 px-1 rounded",children:"region"}),","," ",e.jsx("code",{className:"bg-slate-100 text-slate-700 px-1 rounded",children:"landmark-one-main"}),")."]}),e.jsx("textarea",{value:t,onChange:r=>s(r.target.value),onBlur:r=>d(r.target.value),rows:6,spellCheck:!1,placeholder:`region
6
- landmark-one-main`,className:"w-full text-xs font-mono border border-slate-300 rounded p-2 resize-y"}),l&&e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Saved at ",new Date(l).toLocaleTimeString(),"."]}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Full rule list:"," ",e.jsx("a",{href:"https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md",target:"_blank",rel:"noreferrer",className:"text-brand-600 hover:underline",children:"axe-core/doc/rule-descriptions.md"})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const re="githubRepoUrl",$t=/^https:\/\/github\.com\/[^/]+\/[^/]+\/?$/;function Gt(){const[t,s]=c.useState(""),[a,n]=c.useState(!1),[l,u]=c.useState(null);c.useEffect(()=>{w({type:"SETTINGS_GET",key:re}).then(r=>{const x=typeof r.data=="string"?r.data:"";s(x),n(!0)})},[]);function d(r){const x=r.trim().replace(/\/$/,"");if(x.length>0&&!$t.test(x+"/")){u("Expected format: https://github.com/owner/repo");return}u(null),C({type:"SETTINGS_SET",key:re,value:x})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:'Paste your repository URL to enable "File GitHub issue" buttons in the Delta view. Issues are opened in a new tab with title and body pre-filled — you confirm and submit on GitHub.'}),e.jsx("input",{type:"url",value:t,onChange:r=>s(r.target.value),onBlur:r=>d(r.target.value),placeholder:"https://github.com/owner/repo",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),l&&e.jsx("p",{className:"text-[11px] text-rose-600",children:l})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const oe="jiraInstanceUrl",Ot=/^https:\/\/[^/]+\.atlassian\.net\/?$/;function Bt(){const[t,s]=c.useState(""),[a,n]=c.useState(!1),[l,u]=c.useState(null);c.useEffect(()=>{w({type:"SETTINGS_GET",key:oe}).then(r=>{const x=typeof r.data=="string"?r.data:"";s(x),n(!0)})},[]);function d(r){const x=r.trim().replace(/\/$/,"");if(x.length>0&&!Ot.test(x+"/")){u("Expected format: https://your-team.atlassian.net");return}u(null),C({type:"SETTINGS_SET",key:oe,value:x})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:'Paste your Jira Cloud instance URL to enable "File Jira issue" in the Delta view. Issues open in a new tab pre-filled — you confirm and submit on Jira.'}),e.jsx("input",{type:"url",value:t,onChange:r=>s(r.target.value),onBlur:r=>d(r.target.value),placeholder:"https://your-team.atlassian.net",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),l&&e.jsx("p",{className:"text-[11px] text-rose-600",children:l})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const le="cloudSyncEnabled",ie="cloudSyncEndpoint",Kt="https://api.wcagcheckr.com";function Vt(){const[t,s]=c.useState(!1),[a,n]=c.useState(Kt),[l,u]=c.useState(!1),[d,r]=c.useState(!1),[x,o]=c.useState(null);c.useEffect(()=>{Promise.all([w({type:"SETTINGS_GET",key:le}),w({type:"SETTINGS_GET",key:ie})]).then(([y,N])=>{s(y.data===!0),typeof N.data=="string"&&N.data&&n(N.data),u(!0)})},[]);function m(y){s(y),C({type:"SETTINGS_SET",key:le,value:y})}function p(y){const N=y.trim().replace(/\/$/,"");n(N),C({type:"SETTINGS_SET",key:ie,value:N})}async function h(){r(!0),o(null);try{const y="To pull baselines now, reload the extension at chrome://extensions. The service worker pulls on every start.";o(y),R.polite(y)}finally{r(!1)}}return l?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Sync baselines across devices via your license. Disabled by default — local-first storage means the extension works fully offline. Cloud is mirror, not source of truth on the local machine."}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:y=>m(y.target.checked)}),e.jsx("span",{children:"Enable cloud sync"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-500 block mb-1",children:"Sync endpoint"}),e.jsx("input",{type:"url",value:a,onChange:y=>n(y.target.value),onBlur:y=>p(y.target.value),disabled:!t,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50 disabled:text-slate-500"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Default points at the WCAG Auditor cloud-sync VPS. Replace with your own server URL if you self-host the baseline endpoints."})]}),e.jsx("button",{type:"button",onClick:h,disabled:!t||d,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:d?"Pulling…":"Pull now"}),x&&e.jsx("p",{className:"text-[11px] text-slate-500",children:x})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const ce="runsPerState";function Ht(){const[t,s]=c.useState(1),[a,n]=c.useState(!1);c.useEffect(()=>{w({type:"SETTINGS_GET",key:ce}).then(u=>{const d=typeof u.data=="number"?u.data:1;s(d),n(!0)})},[]);function l(u){s(u),C({type:"SETTINGS_SET",key:ce,value:u})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Real-world pages are non-deterministic — animations, third-party scripts, lazy-loaded content can produce different violation counts on identical re-runs. Higher run counts let the auditor classify violations as ",e.jsx("strong",{children:"stable"})," (seen in every run) vs"," ",e.jsx("strong",{children:"flaky"})," (only some runs). Tradeoff: each step costs an extra audit pass."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{htmlFor:"reliability-runs-per-state",className:"text-xs text-slate-700",children:"Audit runs per state:"}),e.jsxs("select",{id:"reliability-runs-per-state",value:t,onChange:u=>l(Number(u.target.value)),className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:1,children:"1 (fastest)"}),e.jsx("option",{value:2,children:"2 (balanced)"}),e.jsx("option",{value:3,children:"3 (most reliable)"})]})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function Jt(){const[t,s]=c.useState("owner"),[a,n]=c.useState(!1);c.useEffect(()=>{w({type:"SETTINGS_GET",key:"userMode"}).then(u=>{const d=u.data;(d==="owner"||d==="dev")&&s(d),n(!0)})},[]);function l(u){s(u),C({type:"SETTINGS_SET",key:"userMode",value:u})}return a?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Switches the side panel between two surfaces. Owner mode is simpler and avoids jargon; developer mode shows the full feature set (visualizers, baselines, exports, AI fixit prompt)."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(de,{active:t==="owner",icon:"🏪",label:"Site owner",desc:"Plain-language results, whole-site scan, send-to-developer report.",onClick:()=>l("owner")}),e.jsx(de,{active:t==="dev",icon:"⚙️",label:"Developer / agency",desc:"Full feature surface — visualizers, exports, baselines, IGT, AI fixit prompt.",onClick:()=>l("dev")})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function de({active:t,icon:s,label:a,desc:n,onClick:l}){return e.jsx("button",{type:"button",onClick:l,className:`text-left rounded p-3 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-2 ring-brand-500/30":"border-slate-300 bg-white hover:border-slate-400 hover:bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg","aria-hidden":"true",children:s}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-xs",children:a}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:n})]})]})})}const Y="aiConfig";function Yt(){const[t,s]=c.useState(V),[a,n]=c.useState(!1),[l,u]=c.useState(!1),[d,r]=c.useState(null),[x,o]=c.useState(null),[m,p]=c.useState(!1);async function h(){r(await He(10))}c.useEffect(()=>{h()},[]);async function y(){p(!0),o(null);try{if(!t.apiKey){o({ok:!1,message:"No API key entered yet."});return}const i=await fetch("https://api.anthropic.com/v1/messages",{method:"POST",headers:{"x-api-key":t.apiKey,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:t.model||"claude-haiku-4-5",max_tokens:5,messages:[{role:"user",content:"ok"}]})}),f=await i.json().catch(()=>null);if(!f){o({ok:!1,message:`Provider returned no JSON (HTTP ${i.status}).`});return}if("error"in f){o({ok:!1,message:`${f.error.type}: ${f.error.message}`});return}o({ok:!0,message:`Authenticated, account funded. Test call used ${f.usage.input_tokens}+${f.usage.output_tokens} tokens (~$0.0001).`})}catch(i){o({ok:!1,message:i instanceof Error?i.message:String(i)})}finally{p(!1)}}async function N(){typeof confirm=="function"&&!confirm("Clear the local AI usage log? Provider-side billing records are unaffected.")||(await Je(),await h())}c.useEffect(()=>{w({type:"SETTINGS_GET",key:Y}).then(i=>{const f=i.data;f&&s({...V,...f,enabledChecks:{...V.enabledChecks,...f.enabledChecks??{}}}),n(!0)})},[]);function v(i){const f={...t,...i};s(f),C({type:"SETTINGS_SET",key:Y,value:f})}function b(i){const f={...t,enabledChecks:{...t.enabledChecks,...i}};s(f),C({type:"SETTINGS_SET",key:Y,value:f})}return a?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"Adds vision-verified alt-text checking, heading-quality judgment, sensory-language detection, and ARIA semantic verification to every audit. Each check uses a small AI call against your configured provider; per-audit cost is hard-capped to prevent surprise bills."}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:i=>v({enabled:i.target.checked})}),e.jsx("span",{children:e.jsx("strong",{children:"Enable AI augmentation"})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-provider",className:"block text-xs text-slate-500 mb-1",children:"Provider"}),e.jsxs("select",{id:"ai-provider",value:t.provider,onChange:i=>v({provider:i.target.value}),disabled:!t.enabled,className:"text-xs border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"anthropic",children:"Anthropic (Claude)"}),e.jsx("option",{value:"openai",children:"OpenAI (GPT) — coming soon"}),e.jsx("option",{value:"gemini",children:"Google (Gemini) — coming soon"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"ai-key",className:"block text-xs text-slate-500 mb-1",children:["API key",e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"stored locally; never sent anywhere except your chosen provider"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"ai-key",type:l?"text":"password",value:t.apiKey,onChange:i=>v({apiKey:i.target.value.trim()}),disabled:!t.enabled,placeholder:"sk-ant-…",className:"flex-1 text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),e.jsx("button",{type:"button",onClick:()=>u(!l),className:"text-[11px] px-2 border border-slate-300 rounded hover:bg-slate-50",children:l?"Hide":"Show"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-model",className:"block text-xs text-slate-500 mb-1",children:"Model override (optional)"}),e.jsx("input",{id:"ai-model",type:"text",value:t.model??"",onChange:i=>v({model:i.target.value.trim()}),disabled:!t.enabled,placeholder:"claude-3-5-sonnet-20241022 (default)",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Leave blank for provider default. Use a haiku-class model for cheap-fast checks."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-cap",className:"block text-xs text-slate-500 mb-1",children:"Per-audit cost cap (USD)"}),e.jsx("input",{id:"ai-cap",type:"number",step:.5,min:0,value:t.costCapUsd,onChange:i=>v({costCapUsd:Math.max(0,parseFloat(i.target.value)||0)}),disabled:!t.enabled,className:"w-32 text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Hard ceiling — once exceeded, remaining AI checks for the audit are skipped."})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Checks to run"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.altText,onChange:i=>b({altText:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Alt text"})," — verify every image's alt accurately describes it (vision call, ~$0.005 each)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.headings,onChange:i=>b({headings:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Headings"})," — judge whether headings describe their sections (text-only, cheap)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.sensory,onChange:i=>b({sensory:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Sensory language"}),' — flag instructions like "click the round button" (text-only, cheap)']})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.aria,onChange:i=>b({aria:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"ARIA semantics"})," — verify role= attributes match element behavior (more expensive; opt-in)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.imageOfText,onChange:i=>b({imageOfText:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Images of text"})," (WCAG 1.4.5) — flag banner / share-card / infographic images that bake text into the raster (vision; capped to ",t.imageOfTextMaxImages," largest images / audit)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.colorOnlyMeaning,onChange:i=>b({colorOnlyMeaning:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Color-only meaning"})," (WCAG 1.4.1) — flag status indicators / icons / instructions where only color conveys meaning (vision call)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.genericLinkText,onChange:i=>b({genericLinkText:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Generic link text"}),` (WCAG 2.4.4) — flag "click here"-style links where surrounding context doesn't clarify the destination (text-only, cheap)`]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.wallOfText,onChange:i=>b({wallOfText:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Wall of text"})," (WCAG 3.1.5) — flag long-form content with no subheadings, lists, or paragraph breaks (text-only, cheap)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.languageMismatch,onChange:i=>b({languageMismatch:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Language mismatch"})," (WCAG 3.1.1 / 3.1.2) — flag content that doesn't match the declared ",e.jsx("code",{children:"lang"})," attribute (text-only, cheap)"]})]})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Connection test"}),e.jsx("p",{className:"text-[11px] text-slate-500 mb-2",children:"Fires a 5-token call to your provider to confirm the key authenticates and the account is funded. Costs ≈ $0.0001."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void y(),disabled:!t.apiKey||m,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:m?"Testing…":"Test connection"}),x&&e.jsxs("span",{className:`text-[11px] ${x.ok?"text-emerald-700":"text-rose-700"}`,children:[x.ok?"✓ ":"✗ ",x.message]})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Local usage"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Tracked locally per audit. Providers don't expose live balance via API, so check"," ",e.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-brand-700 underline",children:"console.anthropic.com → Plans & Billing"})," ","for your real balance."]}),d&&d.totalAudits===0&&e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"No AI-augmented audits recorded yet."}),d&&d.totalAudits>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"All-time spent"}),e.jsxs("div",{className:"font-semibold text-slate-800",children:["$",d.totalSpentUsd.toFixed(4)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[d.totalAudits," audit",d.totalAudits===1?"":"s"]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"This month"}),e.jsxs("div",{className:"font-semibold text-slate-800",children:["$",d.spentThisMonthUsd.toFixed(4)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[d.auditsThisMonth," audit",d.auditsThisMonth===1?"":"s"]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"Avg / audit"}),e.jsx("div",{className:"font-semibold text-slate-800",children:d.averageCostUsd!=null?`$${d.averageCostUsd.toFixed(4)}`:"—"})]})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"text-[11px] cursor-pointer text-slate-600",children:"By check type"}),e.jsx("ul",{className:"mt-1 text-[11px] text-slate-700",children:Object.entries(d.byCheck).map(([i,f])=>e.jsxs("li",{className:"flex items-center justify-between py-0.5",children:[e.jsx("code",{className:"font-mono",children:i}),e.jsxs("span",{children:["$",(f??0).toFixed(4)]})]},i))})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"text-[11px] cursor-pointer text-slate-600",children:"Recent audits (last 10)"}),e.jsxs("table",{className:"mt-1 w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 text-left",children:[e.jsx("th",{className:"py-0.5 pr-2 font-medium",children:"When"}),e.jsx("th",{className:"py-0.5 pr-2 font-medium",children:"Target"}),e.jsx("th",{className:"py-0.5 pr-2 font-medium text-right",children:"Cost"}),e.jsx("th",{className:"py-0.5 font-medium text-right",children:"Findings"})]})}),e.jsx("tbody",{children:d.recent.map((i,f)=>e.jsxs("tr",{className:"border-t border-slate-100",children:[e.jsx("td",{className:"py-0.5 pr-2 text-slate-600",children:new Date(i.at).toLocaleDateString()}),e.jsx("td",{className:"py-0.5 pr-2 text-slate-700 truncate max-w-[180px]",title:i.pageUrl,children:i.pageUrl}),e.jsxs("td",{className:"py-0.5 pr-2 text-right font-mono",children:["$",i.totalCostUsd.toFixed(4),i.capExceeded&&e.jsx("span",{className:"text-amber-700 ml-1",title:"Cost cap exceeded",children:"⚠"}),i.failureReason&&e.jsx("span",{className:"text-red-700 ml-1",title:`AI failure: ${i.failureReason}`,children:"✗"})]}),e.jsx("td",{className:"py-0.5 text-right",children:i.findingsCount})]},f))})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:()=>void N(),className:"text-[11px] text-slate-500 hover:text-rose-600 underline-offset-2 hover:underline",children:"Clear local usage log"})})]})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function Wt(){const[t,s]=c.useState(null),[a,n]=c.useState("trial");c.useEffect(()=>{w({type:"SETTINGS_GET_ALL"}).then(o=>{const m=o.data??{};s({stateMatrix:m.stateMatrix??ee,componentIdAliases:m.componentIdAliases??{}})}),w({type:"TIER_GET"}).then(o=>n(o.tier))},[]);function l(o){t&&(s({...t,stateMatrix:o}),C({type:"SETTINGS_SET",key:"stateMatrix",value:o}))}function u(o){if(!t)return;const m=new Set(o.map(h=>h.id)),p=t.stateMatrix.breakpoints.filter(h=>m.has(h));l({...t.stateMatrix,breakpointPresets:o,breakpoints:p.length>0?p:o[0]?[o[0].id]:[]})}function d(o){t&&(s({...t,componentIdAliases:o}),C({type:"SETTINGS_SET",key:"componentIdAliases",value:o}))}function r(){t&&(typeof confirm=="function"&&!confirm("Reset state matrix to defaults?")||l(ee))}if(!t)return e.jsx("div",{className:"p-8 text-sm text-slate-500",children:"Loading…"});const x=a==="free";return e.jsxs("div",{className:"max-w-2xl mx-auto p-3 sm:p-6 space-y-6 text-sm",children:[e.jsxs("header",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Settings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Changes are saved automatically. Close this tab to return to the audit panel."})]}),e.jsx("button",{type:"button",onClick:()=>{window.close()},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 shrink-0",children:"Done"})]}),e.jsx("main",{"aria-label":"Settings",children:e.jsxs(ct,{defaultValue:"audit",className:"space-y-4",children:[e.jsx(dt,{className:"flex flex-wrap gap-1 border-b border-slate-200","aria-label":"Settings categories",children:[{value:"audit",label:"Audit"},{value:"integrations",label:"Integrations"},{value:"account",label:"Account"},{value:"advanced",label:"Advanced"}].map(o=>e.jsx(ut,{value:o.value,className:"text-xs px-3 py-1.5 text-slate-600 hover:text-slate-900 data-[state=active]:text-brand-700 data-[state=active]:border-b-2 data-[state=active]:border-brand-500 -mb-px",children:o.label},o.value))}),e.jsxs(G,{value:"audit",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"State matrix"}),e.jsx("button",{onClick:r,className:"text-xs text-slate-500 hover:text-slate-900",children:"Reset to defaults"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Which states each audit covers. Larger matrix = more coverage but slower runs."}),x&&e.jsx("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"Free tier audits the default state only — your matrix selections below will be ignored until you upgrade."}),e.jsx(ht,{value:t.stateMatrix,onChange:l})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Breakpoint presets"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Customize widths/heights and add your own breakpoints. Toggle which ones audit under in the State matrix section above."}),e.jsx(Lt,{presets:t.stateMatrix.breakpointPresets,onChange:u})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Audit reliability"}),e.jsx(Ht,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Disabled rules"}),e.jsx(Dt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Component identity aliases"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Map two component IDs to the same canonical ID — useful when the same component is identified differently across pages."}),e.jsx(bt,{value:t.componentIdAliases,onChange:d})]})]}),e.jsxs(G,{value:"integrations",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"GitHub issue tracker"}),e.jsx(Gt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Jira issue tracker"}),e.jsx(Bt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Cloud sync (baselines)"}),e.jsx(Vt,{})]})]}),e.jsxs(G,{value:"account",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"User mode"}),e.jsx(Jt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"License"}),e.jsx(It,{tier:a,onTierChange:n})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Crash reporting"}),e.jsx(Mt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI augmentation"}),e.jsx(Yt,{})]})]}),e.jsxs(G,{value:"advanced",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Report download behavior"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Defense / evidence bundles default to a confirmation prompt before downloading. Power users who export many bundles can skip the prompt here."}),e.jsx(Ut,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Import / export"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Share matrix + alias config with your team, or back up before major changes."}),e.jsx(Pt,{stateMatrix:t.stateMatrix,componentIdAliases:t.componentIdAliases,onImport:o=>s(o)})]})]})]})}),e.jsx(De,{})]})}const Re=document.getElementById("root");if(!Re)throw new Error("options: #root not found");$e(Re).render(e.jsx(P.StrictMode,{children:e.jsx(Wt,{})}));
6
+ landmark-one-main`,className:"w-full text-xs font-mono border border-slate-300 rounded p-2 resize-y"}),l&&e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Saved at ",new Date(l).toLocaleTimeString(),"."]}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Full rule list:"," ",e.jsx("a",{href:"https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md",target:"_blank",rel:"noreferrer",className:"text-brand-600 hover:underline",children:"axe-core/doc/rule-descriptions.md"})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const re="githubRepoUrl",Gt=/^https:\/\/github\.com\/[^/]+\/[^/]+\/?$/;function Bt(){const[t,s]=c.useState(""),[a,n]=c.useState(!1),[l,u]=c.useState(null);c.useEffect(()=>{w({type:"SETTINGS_GET",key:re}).then(r=>{const x=typeof r.data=="string"?r.data:"";s(x),n(!0)})},[]);function d(r){const x=r.trim().replace(/\/$/,"");if(x.length>0&&!Gt.test(x+"/")){u("Expected format: https://github.com/owner/repo");return}u(null),C({type:"SETTINGS_SET",key:re,value:x})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:'Paste your repository URL to enable "File GitHub issue" buttons in the Delta view. Issues are opened in a new tab with title and body pre-filled — you confirm and submit on GitHub.'}),e.jsx("input",{type:"url",value:t,onChange:r=>s(r.target.value),onBlur:r=>d(r.target.value),placeholder:"https://github.com/owner/repo",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),l&&e.jsx("p",{className:"text-[11px] text-rose-600",children:l})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const oe="jiraInstanceUrl",Kt=/^https:\/\/[^/]+\.atlassian\.net\/?$/;function Vt(){const[t,s]=c.useState(""),[a,n]=c.useState(!1),[l,u]=c.useState(null);c.useEffect(()=>{w({type:"SETTINGS_GET",key:oe}).then(r=>{const x=typeof r.data=="string"?r.data:"";s(x),n(!0)})},[]);function d(r){const x=r.trim().replace(/\/$/,"");if(x.length>0&&!Kt.test(x+"/")){u("Expected format: https://your-team.atlassian.net");return}u(null),C({type:"SETTINGS_SET",key:oe,value:x})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:'Paste your Jira Cloud instance URL to enable "File Jira issue" in the Delta view. Issues open in a new tab pre-filled — you confirm and submit on Jira.'}),e.jsx("input",{type:"url",value:t,onChange:r=>s(r.target.value),onBlur:r=>d(r.target.value),placeholder:"https://your-team.atlassian.net",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),l&&e.jsx("p",{className:"text-[11px] text-rose-600",children:l})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const le="cloudSyncEnabled",ie="cloudSyncEndpoint",Ht="https://api.wcagcheckr.com";function Jt(){const[t,s]=c.useState(!1),[a,n]=c.useState(Ht),[l,u]=c.useState(!1),[d,r]=c.useState(!1),[x,o]=c.useState(null);c.useEffect(()=>{Promise.all([w({type:"SETTINGS_GET",key:le}),w({type:"SETTINGS_GET",key:ie})]).then(([y,N])=>{s(y.data===!0),typeof N.data=="string"&&N.data&&n(N.data),u(!0)})},[]);function m(y){s(y),C({type:"SETTINGS_SET",key:le,value:y})}function h(y){const N=y.trim().replace(/\/$/,"");n(N),C({type:"SETTINGS_SET",key:ie,value:N})}async function p(){r(!0),o(null);try{const y="To pull baselines now, reload the extension at chrome://extensions. The service worker pulls on every start.";o(y),R.polite(y)}finally{r(!1)}}return l?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Sync baselines across devices via your license. Disabled by default — local-first storage means the extension works fully offline. Cloud is mirror, not source of truth on the local machine."}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:y=>m(y.target.checked)}),e.jsx("span",{children:"Enable cloud sync"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-500 block mb-1",children:"Sync endpoint"}),e.jsx("input",{type:"url",value:a,onChange:y=>n(y.target.value),onBlur:y=>h(y.target.value),disabled:!t,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50 disabled:text-slate-500"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Default points at the WCAG Auditor cloud-sync VPS. Replace with your own server URL if you self-host the baseline endpoints."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!t||d,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:d?"Pulling…":"Pull now"}),x&&e.jsx("p",{className:"text-[11px] text-slate-500",children:x})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const ce="runsPerState";function Yt(){const[t,s]=c.useState(1),[a,n]=c.useState(!1);c.useEffect(()=>{w({type:"SETTINGS_GET",key:ce}).then(u=>{const d=typeof u.data=="number"?u.data:1;s(d),n(!0)})},[]);function l(u){s(u),C({type:"SETTINGS_SET",key:ce,value:u})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Real-world pages are non-deterministic — animations, third-party scripts, lazy-loaded content can produce different violation counts on identical re-runs. Higher run counts let the auditor classify violations as ",e.jsx("strong",{children:"stable"})," (seen in every run) vs"," ",e.jsx("strong",{children:"flaky"})," (only some runs). Tradeoff: each step costs an extra audit pass."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{htmlFor:"reliability-runs-per-state",className:"text-xs text-slate-700",children:"Audit runs per state:"}),e.jsxs("select",{id:"reliability-runs-per-state",value:t,onChange:u=>l(Number(u.target.value)),className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:1,children:"1 (fastest)"}),e.jsx("option",{value:2,children:"2 (balanced)"}),e.jsx("option",{value:3,children:"3 (most reliable)"})]})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function Wt(){const[t,s]=c.useState("owner"),[a,n]=c.useState(!1);c.useEffect(()=>{w({type:"SETTINGS_GET",key:"userMode"}).then(u=>{const d=u.data;(d==="owner"||d==="dev")&&s(d),n(!0)})},[]);function l(u){s(u),C({type:"SETTINGS_SET",key:"userMode",value:u})}return a?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Switches the side panel between two surfaces. Owner mode is simpler and avoids jargon; developer mode shows the full feature set (visualizers, baselines, exports, AI fixit prompt)."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(de,{active:t==="owner",icon:"🏪",label:"Site owner",desc:"Plain-language results, whole-site scan, send-to-developer report.",onClick:()=>l("owner")}),e.jsx(de,{active:t==="dev",icon:"⚙️",label:"Developer / agency",desc:"Full feature surface — visualizers, exports, baselines, IGT, AI fixit prompt.",onClick:()=>l("dev")})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function de({active:t,icon:s,label:a,desc:n,onClick:l}){return e.jsx("button",{type:"button",onClick:l,className:`text-left rounded p-3 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-2 ring-brand-500/30":"border-slate-300 bg-white hover:border-slate-400 hover:bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg","aria-hidden":"true",children:s}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-xs",children:a}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:n})]})]})})}const Y="aiConfig";function zt(){const[t,s]=c.useState(V),[a,n]=c.useState(!1),[l,u]=c.useState(!1),[d,r]=c.useState(null),[x,o]=c.useState(null),[m,h]=c.useState(!1);async function p(){r(await Je(10))}c.useEffect(()=>{p()},[]);async function y(){h(!0),o(null);try{if(!t.apiKey){o({ok:!1,message:"No API key entered yet."});return}const i=await fetch("https://api.anthropic.com/v1/messages",{method:"POST",headers:{"x-api-key":t.apiKey,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:t.model||"claude-haiku-4-5",max_tokens:5,messages:[{role:"user",content:"ok"}]})}),f=await i.json().catch(()=>null);if(!f){o({ok:!1,message:`Provider returned no JSON (HTTP ${i.status}).`});return}if("error"in f){o({ok:!1,message:`${f.error.type}: ${f.error.message}`});return}o({ok:!0,message:`Authenticated, account funded. Test call used ${f.usage.input_tokens}+${f.usage.output_tokens} tokens (~$0.0001).`})}catch(i){o({ok:!1,message:i instanceof Error?i.message:String(i)})}finally{h(!1)}}async function N(){typeof confirm=="function"&&!confirm("Clear the local AI usage log? Provider-side billing records are unaffected.")||(await Ye(),await p())}c.useEffect(()=>{w({type:"SETTINGS_GET",key:Y}).then(i=>{const f=i.data;f&&s({...V,...f,enabledChecks:{...V.enabledChecks,...f.enabledChecks??{}}}),n(!0)})},[]);function v(i){const f={...t,...i};s(f),C({type:"SETTINGS_SET",key:Y,value:f})}function b(i){const f={...t,enabledChecks:{...t.enabledChecks,...i}};s(f),C({type:"SETTINGS_SET",key:Y,value:f})}return a?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"Adds vision-verified alt-text checking, heading-quality judgment, sensory-language detection, and ARIA semantic verification to every audit. Each check uses a small AI call against your configured provider; per-audit cost is hard-capped to prevent surprise bills."}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:i=>v({enabled:i.target.checked})}),e.jsx("span",{children:e.jsx("strong",{children:"Enable AI augmentation"})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-provider",className:"block text-xs text-slate-500 mb-1",children:"Provider"}),e.jsxs("select",{id:"ai-provider",value:t.provider,onChange:i=>v({provider:i.target.value}),disabled:!t.enabled,className:"text-xs border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"anthropic",children:"Anthropic (Claude)"}),e.jsx("option",{value:"openai",children:"OpenAI (GPT) — coming soon"}),e.jsx("option",{value:"gemini",children:"Google (Gemini) — coming soon"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"ai-key",className:"block text-xs text-slate-500 mb-1",children:["API key",e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"stored locally; never sent anywhere except your chosen provider"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"ai-key",type:l?"text":"password",value:t.apiKey,onChange:i=>v({apiKey:i.target.value.trim()}),disabled:!t.enabled,placeholder:"sk-ant-…",className:"flex-1 text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),e.jsx("button",{type:"button",onClick:()=>u(!l),className:"text-[11px] px-2 border border-slate-300 rounded hover:bg-slate-50",children:l?"Hide":"Show"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-model",className:"block text-xs text-slate-500 mb-1",children:"Model override (optional)"}),e.jsx("input",{id:"ai-model",type:"text",value:t.model??"",onChange:i=>v({model:i.target.value.trim()}),disabled:!t.enabled,placeholder:"claude-3-5-sonnet-20241022 (default)",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Leave blank for provider default. Use a haiku-class model for cheap-fast checks."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-cap",className:"block text-xs text-slate-500 mb-1",children:"Per-audit cost cap (USD)"}),e.jsx("input",{id:"ai-cap",type:"number",step:.5,min:0,value:t.costCapUsd,onChange:i=>v({costCapUsd:Math.max(0,parseFloat(i.target.value)||0)}),disabled:!t.enabled,className:"w-32 text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Hard ceiling — once exceeded, remaining AI checks for the audit are skipped."})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Checks to run"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.altText,onChange:i=>b({altText:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Alt text"})," — verify every image's alt accurately describes it (vision call, ~$0.005 each)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.headings,onChange:i=>b({headings:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Headings"})," — judge whether headings describe their sections (text-only, cheap)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.sensory,onChange:i=>b({sensory:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Sensory language"}),' — flag instructions like "click the round button" (text-only, cheap)']})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.aria,onChange:i=>b({aria:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"ARIA semantics"})," — verify role= attributes match element behavior (more expensive; opt-in)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.imageOfText,onChange:i=>b({imageOfText:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Images of text"})," (WCAG 1.4.5) — flag banner / share-card / infographic images that bake text into the raster (vision; capped to ",t.imageOfTextMaxImages," largest images / audit)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.colorOnlyMeaning,onChange:i=>b({colorOnlyMeaning:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Color-only meaning"})," (WCAG 1.4.1) — flag status indicators / icons / instructions where only color conveys meaning (vision call)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.genericLinkText,onChange:i=>b({genericLinkText:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Generic link text"}),` (WCAG 2.4.4) — flag "click here"-style links where surrounding context doesn't clarify the destination (text-only, cheap)`]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.wallOfText,onChange:i=>b({wallOfText:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Wall of text"})," (WCAG 3.1.5) — flag long-form content with no subheadings, lists, or paragraph breaks (text-only, cheap)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.languageMismatch,onChange:i=>b({languageMismatch:i.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Language mismatch"})," (WCAG 3.1.1 / 3.1.2) — flag content that doesn't match the declared ",e.jsx("code",{children:"lang"})," attribute (text-only, cheap)"]})]})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Connection test"}),e.jsx("p",{className:"text-[11px] text-slate-500 mb-2",children:"Fires a 5-token call to your provider to confirm the key authenticates and the account is funded. Costs ≈ $0.0001."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void y(),disabled:!t.apiKey||m,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:m?"Testing…":"Test connection"}),x&&e.jsxs("span",{className:`text-[11px] ${x.ok?"text-emerald-700":"text-rose-700"}`,children:[x.ok?"✓ ":"✗ ",x.message]})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Local usage"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Tracked locally per audit. Providers don't expose live balance via API, so check"," ",e.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-brand-700 underline",children:"console.anthropic.com → Plans & Billing"})," ","for your real balance."]}),d&&d.totalAudits===0&&e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"No AI-augmented audits recorded yet."}),d&&d.totalAudits>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"All-time spent"}),e.jsxs("div",{className:"font-semibold text-slate-800",children:["$",d.totalSpentUsd.toFixed(4)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[d.totalAudits," audit",d.totalAudits===1?"":"s"]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"This month"}),e.jsxs("div",{className:"font-semibold text-slate-800",children:["$",d.spentThisMonthUsd.toFixed(4)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[d.auditsThisMonth," audit",d.auditsThisMonth===1?"":"s"]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"Avg / audit"}),e.jsx("div",{className:"font-semibold text-slate-800",children:d.averageCostUsd!=null?`$${d.averageCostUsd.toFixed(4)}`:"—"})]})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"text-[11px] cursor-pointer text-slate-600",children:"By check type"}),e.jsx("ul",{className:"mt-1 text-[11px] text-slate-700",children:Object.entries(d.byCheck).map(([i,f])=>e.jsxs("li",{className:"flex items-center justify-between py-0.5",children:[e.jsx("code",{className:"font-mono",children:i}),e.jsxs("span",{children:["$",(f??0).toFixed(4)]})]},i))})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"text-[11px] cursor-pointer text-slate-600",children:"Recent audits (last 10)"}),e.jsxs("table",{className:"mt-1 w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 text-left",children:[e.jsx("th",{className:"py-0.5 pr-2 font-medium",children:"When"}),e.jsx("th",{className:"py-0.5 pr-2 font-medium",children:"Target"}),e.jsx("th",{className:"py-0.5 pr-2 font-medium text-right",children:"Cost"}),e.jsx("th",{className:"py-0.5 font-medium text-right",children:"Findings"})]})}),e.jsx("tbody",{children:d.recent.map((i,f)=>e.jsxs("tr",{className:"border-t border-slate-100",children:[e.jsx("td",{className:"py-0.5 pr-2 text-slate-600",children:new Date(i.at).toLocaleDateString()}),e.jsx("td",{className:"py-0.5 pr-2 text-slate-700 truncate max-w-[180px]",title:i.pageUrl,children:i.pageUrl}),e.jsxs("td",{className:"py-0.5 pr-2 text-right font-mono",children:["$",i.totalCostUsd.toFixed(4),i.capExceeded&&e.jsx("span",{className:"text-amber-700 ml-1",title:"Cost cap exceeded",children:"⚠"}),i.failureReason&&e.jsx("span",{className:"text-red-700 ml-1",title:`AI failure: ${i.failureReason}`,children:"✗"})]}),e.jsx("td",{className:"py-0.5 text-right",children:i.findingsCount})]},f))})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:()=>void N(),className:"text-[11px] text-slate-500 hover:text-rose-600 underline-offset-2 hover:underline",children:"Clear local usage log"})})]})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function qt(){const[t,s]=c.useState(null),[a,n]=c.useState("trial");c.useEffect(()=>{w({type:"SETTINGS_GET_ALL"}).then(o=>{const m=o.data??{};s({stateMatrix:m.stateMatrix??ee,componentIdAliases:m.componentIdAliases??{}})}),w({type:"TIER_GET"}).then(o=>n(o.tier))},[]);function l(o){t&&(s({...t,stateMatrix:o}),C({type:"SETTINGS_SET",key:"stateMatrix",value:o}))}function u(o){if(!t)return;const m=new Set(o.map(p=>p.id)),h=t.stateMatrix.breakpoints.filter(p=>m.has(p));l({...t.stateMatrix,breakpointPresets:o,breakpoints:h.length>0?h:o[0]?[o[0].id]:[]})}function d(o){t&&(s({...t,componentIdAliases:o}),C({type:"SETTINGS_SET",key:"componentIdAliases",value:o}))}function r(){t&&(typeof confirm=="function"&&!confirm("Reset state matrix to defaults?")||l(ee))}if(!t)return e.jsx("div",{className:"p-8 text-sm text-slate-500",children:"Loading…"});const x=a==="free";return e.jsxs("div",{className:"max-w-2xl mx-auto p-3 sm:p-6 space-y-6 text-sm",children:[e.jsxs("header",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Settings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Changes are saved automatically. Close this tab to return to the audit panel."})]}),e.jsx("button",{type:"button",onClick:()=>{window.close()},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 shrink-0",children:"Done"})]}),e.jsx("main",{"aria-label":"Settings",children:e.jsxs(dt,{defaultValue:"audit",className:"space-y-4",children:[e.jsx(ut,{className:"flex flex-wrap gap-1 border-b border-slate-200","aria-label":"Settings categories",children:[{value:"audit",label:"Audit"},{value:"integrations",label:"Integrations"},{value:"account",label:"Account"},{value:"advanced",label:"Advanced"}].map(o=>e.jsx(xt,{value:o.value,className:"text-xs px-3 py-1.5 text-slate-600 hover:text-slate-900 data-[state=active]:text-brand-700 data-[state=active]:border-b-2 data-[state=active]:border-brand-500 -mb-px",children:o.label},o.value))}),e.jsxs(O,{value:"audit",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"State matrix"}),e.jsx("button",{onClick:r,className:"text-xs text-slate-500 hover:text-slate-900",children:"Reset to defaults"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Which states each audit covers. Larger matrix = more coverage but slower runs."}),x&&e.jsx("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"Free tier audits the default state only — your matrix selections below will be ignored until you upgrade."}),e.jsx(bt,{value:t.stateMatrix,onChange:l})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Breakpoint presets"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Customize widths/heights and add your own breakpoints. Toggle which ones audit under in the State matrix section above."}),e.jsx(Pt,{presets:t.stateMatrix.breakpointPresets,onChange:u})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Audit reliability"}),e.jsx(Yt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Disabled rules"}),e.jsx(Ot,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Component identity aliases"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Map two component IDs to the same canonical ID — useful when the same component is identified differently across pages."}),e.jsx(ft,{value:t.componentIdAliases,onChange:d})]})]}),e.jsxs(O,{value:"integrations",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"GitHub issue tracker"}),e.jsx(Bt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Jira issue tracker"}),e.jsx(Vt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Cloud sync (baselines)"}),e.jsx(Jt,{})]})]}),e.jsxs(O,{value:"account",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"User mode"}),e.jsx(Wt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"License"}),e.jsx(At,{tier:a,onTierChange:n})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Crash reporting"}),e.jsx(Ut,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI augmentation"}),e.jsx(zt,{})]})]}),e.jsxs(O,{value:"advanced",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Report download behavior"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Defense / evidence bundles default to a confirmation prompt before downloading. Power users who export many bundles can skip the prompt here."}),e.jsx(Dt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Performance"}),e.jsx($t,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Import / export"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Share matrix + alias config with your team, or back up before major changes."}),e.jsx(Mt,{stateMatrix:t.stateMatrix,componentIdAliases:t.componentIdAliases,onImport:o=>s(o)})]})]})]})}),e.jsx(De,{})]})}const Re=document.getElementById("root");if(!Re)throw new Error("options: #root not found");$e(Re).render(e.jsx(P.StrictMode,{children:e.jsx(qt,{})}));