aria-ease 7.5.0 → 7.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -81
- package/dist/ToggleComponentStrategy-TMRNXFSL.js +1 -0
- package/dist/cli.cjs +63 -63
- package/dist/cli.js +1 -1
- package/dist/contractTestRunnerPlaywright-CHCVW7VO.js +46 -0
- package/dist/contractTestRunnerPlaywright-FECB4HSX.js +46 -0
- package/dist/index.cjs +36 -36
- package/dist/index.d.cts +18 -19
- package/dist/index.d.ts +18 -19
- package/dist/index.js +10 -10
- package/dist/src/{Types.d-D96FYkCN.d.cts → Types.d-BjBTlIzl.d.cts} +18 -8
- package/dist/src/{Types.d-D96FYkCN.d.ts → Types.d-BjBTlIzl.d.ts} +18 -8
- package/dist/src/accordion/index.cjs +1 -1
- package/dist/src/accordion/index.d.cts +1 -1
- package/dist/src/accordion/index.d.ts +1 -1
- package/dist/src/accordion/index.js +1 -1
- package/dist/src/block/index.d.cts +1 -1
- package/dist/src/block/index.d.ts +1 -1
- package/dist/src/checkbox/index.cjs +1 -1
- package/dist/src/checkbox/index.d.cts +1 -1
- package/dist/src/checkbox/index.d.ts +1 -1
- package/dist/src/checkbox/index.js +1 -1
- package/dist/src/combobox/index.cjs +1 -1
- package/dist/src/combobox/index.d.cts +1 -1
- package/dist/src/combobox/index.d.ts +1 -1
- package/dist/src/combobox/index.js +1 -1
- package/dist/src/menu/index.cjs +1 -1
- package/dist/src/menu/index.d.cts +1 -1
- package/dist/src/menu/index.d.ts +1 -1
- package/dist/src/menu/index.js +1 -1
- package/dist/src/radio/index.cjs +1 -1
- package/dist/src/radio/index.d.cts +1 -1
- package/dist/src/radio/index.d.ts +1 -1
- package/dist/src/radio/index.js +1 -1
- package/dist/src/tabs/index.cjs +1 -1
- package/dist/src/tabs/index.d.cts +1 -2
- package/dist/src/tabs/index.d.ts +1 -2
- package/dist/src/tabs/index.js +1 -1
- package/dist/src/toggle/index.cjs +1 -1
- package/dist/src/toggle/index.d.cts +2 -7
- package/dist/src/toggle/index.d.ts +2 -7
- package/dist/src/toggle/index.js +1 -1
- package/dist/src/utils/test/ToggleComponentStrategy-UOGYK2U4.js +1 -0
- package/dist/src/utils/test/contractTestRunnerPlaywright-7ERFIHCM.js +46 -0
- package/dist/src/utils/test/dsl/index.cjs +1 -1
- package/dist/src/utils/test/dsl/index.d.cts +0 -5
- package/dist/src/utils/test/dsl/index.d.ts +0 -5
- package/dist/src/utils/test/dsl/index.js +1 -1
- package/dist/src/utils/test/index.cjs +29 -29
- package/dist/src/utils/test/index.d.cts +4 -3
- package/dist/src/utils/test/index.d.ts +4 -3
- package/dist/src/utils/test/index.js +1 -1
- package/dist/{test-FURQN5KO.js → test-CMD6E5YF.js} +1 -1
- package/package.json +1 -1
- package/dist/contractTestRunnerPlaywright-75NI6SN7.js +0 -46
- package/dist/contractTestRunnerPlaywright-VLOD5IB3.js +0 -46
- package/dist/src/utils/test/contractTestRunnerPlaywright-FSZDW7IR.js +0 -46
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var or=Object.create;var Ee=Object.defineProperty;var ar=Object.getOwnPropertyDescriptor;var cr=Object.getOwnPropertyNames;var lr=Object.getPrototypeOf,ur=Object.prototype.hasOwnProperty;var Q=(t,e)=>()=>(t&&(e=t(t=0)),e);var se=(t,e)=>{for(var r in e)Ee(t,r,{get:e[r],enumerable:!0})},Ae=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of cr(e))!ur.call(t,i)&&i!==r&&Ee(t,i,{get:()=>e[i],enumerable:!(s=ar(e,i))||s.enumerable});return t},Me=(t,e,r)=>(Ae(t,e,"default"),r&&Ae(r,e,"default")),ne=(t,e,r)=>(r=t!=null?or(lr(t)):{},Ae(e||!t||!t.__esModule?Ee(r,"default",{value:t,enumerable:!0}):r,t)),pr=t=>Ae(Ee({},"__esModule",{value:!0}),t);async function ls(){return me||(me=await kt.chromium.launch({headless:!0,args:["--disable-extensions","--disable-blink-features=AutomationControlled"]})),me}async function us(){return he||(he=await(await ls()).newContext({permissions:[],ignoreHTTPSErrors:!0})),he}async function At(){return await(await us()).newPage()}async function Et(){he&&(await he.close(),he=null),me&&(await me.close(),me=null)}var kt,me,he,Ke=Q(()=>{"use strict";kt=require("playwright"),me=null,he=null});function be(t){return t==="required"||t==="recommended"||t==="optional"?t:ps}function we(t){return t==="minimal"||t==="balanced"||t==="strict"||t==="paranoid"?t:"balanced"}function Mt(t,e){return{minimal:{required:"error",recommended:"ignore",optional:"ignore"},balanced:{required:"error",recommended:"warning",optional:"ignore"},strict:{required:"error",recommended:"error",optional:"warning"},paranoid:{required:"error",recommended:"error",optional:"error"}}[e][t]}var ps,We=Q(()=>{"use strict";ps="required"});var St={};se(St,{loadConfig:()=>gs});function ds(t){let e=[];if(!t||typeof t!="object")return e.push("Config must be an object"),{valid:!1,errors:e};let r=t;if(r.audit!==void 0){if(typeof r.audit!="object"||r.audit===null)e.push("audit must be an object");else if(r.audit.urls!==void 0&&(Array.isArray(r.audit.urls)?r.audit.urls.some(s=>typeof s!="string")&&e.push("audit.urls must contain only strings"):e.push("audit.urls must be an array")),r.audit.output!==void 0)if(typeof r.audit.output!="object")e.push("audit.output must be an object");else{let s=r.audit.output;s.format!==void 0&&(["json","csv","html","all"].includes(s.format)||e.push("audit.output.format must be one of: json, csv, html, all")),s.out!==void 0&&typeof s.out!="string"&&e.push("audit.output.out must be a string")}}if(r.test!==void 0)if(typeof r.test!="object"||r.test===null)e.push("test must be an object");else{r.test.disableTimeouts!==void 0&&typeof r.test.disableTimeouts!="boolean"&&e.push("test.disableTimeouts must be a boolean when provided");let s=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let i of s){let n=r.test[i];n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&e.push(`test.${i} must be a non-negative number when provided`)}r.test.components!==void 0&&(Array.isArray(r.test.components)?r.test.components.forEach((i,n)=>{if(typeof i!="object"||i===null)e.push(`test.components[${n}] must be an object`);else{typeof i.name!="string"&&e.push(`test.components[${n}].name must be a string`),i.contractPath!==void 0&&typeof i.contractPath!="string"&&e.push(`test.components[${n}].contractPath must be a string when provided`),i.strategyPath!==void 0&&typeof i.strategyPath!="string"&&e.push(`test.components[${n}].strategyPath must be a string when provided`),i.strictness!==void 0&&!["minimal","balanced","strict","paranoid"].includes(i.strictness)&&e.push(`test.components[${n}].strictness must be one of: minimal, balanced, strict, paranoid`),i.disableTimeouts!==void 0&&typeof i.disableTimeouts!="boolean"&&e.push(`test.components[${n}].disableTimeouts must be a boolean when provided`);let a=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let o of a){let l=i[o];l!==void 0&&(typeof l!="number"||!Number.isFinite(l)||l<0)&&e.push(`test.components[${n}].${o} must be a non-negative number when provided`)}}}):e.push("test.components must be an array")),r.test.strictness!==void 0&&(["minimal","balanced","strict","paranoid"].includes(r.test.strictness)||e.push("test.strictness must be one of: minimal, balanced, strict, paranoid"))}return r.contracts!==void 0&&(Array.isArray(r.contracts)?r.contracts.forEach((s,i)=>{typeof s!="object"||s===null?e.push(`contracts[${i}] must be an object`):(typeof s.src!="string"&&e.push(`contracts[${i}].src is required and must be a string`),s.out!==void 0&&typeof s.out!="string"&&e.push(`contracts[${i}].out must be a string`))}):e.push("contracts must be an array")),{valid:e.length===0,errors:e}}async function fs(t){try{let e=ze.default.extname(t);if(e===".json"){let r=await Je.default.readFile(t,"utf-8");return JSON.parse(r)}else if([".js",".mjs",".cjs",".ts"].includes(e)){let r=await import(t);return r.default||r}return null}catch{return null}}async function gs(t=process.cwd()){let e=["ariaease.config.js","ariaease.config.mjs","ariaease.config.cjs","ariaease.config.json","ariaease.config.ts"],r=null,s=null,i=[];for(let n of e){let a=ze.default.resolve(t,n);if(await Je.default.pathExists(a)){if(s=a,r=await fs(a),r===null){i.push(`Found config at ${n} but failed to load it. Check for syntax errors.`);continue}let o=ds(r);if(!o.valid){i.push(`Config validation failed in ${n}:`),i.push(...o.errors.map(l=>` - ${l}`)),r=null;continue}break}}return{config:r||{},configPath:r?s:null,errors:i}}var ze,Je,xt=Q(()=>{"use strict";ze=ne(require("path"),1),Je=ne(require("fs-extra"),1)});var z={};se(z,{default:()=>Ct.default});var Ct,de=Q(()=>{"use strict";Me(z,require("playwright/test"));Ct=ne(require("playwright/test"),1)});var $t={};se($t,{MenuComponentStrategy:()=>Ge});var Ge,Lt=Q(()=>{"use strict";de();Ge=class{constructor(e,r,s=400,i=400){this.mainSelector=e;this.selectors=r;this.actionTimeoutMs=s;this.assertionTimeoutMs=i}async resetState(e){if(!this.selectors.popup)return;let r=this.selectors.popup,s=e.locator(r).first();if(!await s.isVisible().catch(()=>!1))return;let n=!1,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await(0,z.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!n&&this.selectors.main&&(await e.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),n=await(0,z.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),n||(await e.mouse.click(10,10),n=await(0,z.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!n)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
|
|
2
2
|
1. Escape key
|
|
3
3
|
2. Clicking trigger
|
|
4
4
|
3. Clicking outside
|
|
5
|
-
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus()}async shouldSkipTest(e,r){if(!(e.action.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")||e.assertions.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")))return!1;let
|
|
5
|
+
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus()}async shouldSkipTest(e,r){if(!(e.action.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")||e.assertions.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")))return!1;let i=this.selectors.submenuTrigger;return i?await r.locator(i).count()===0:!0}getMainSelector(){return this.mainSelector}}});var Rt={};se(Rt,{AccordionComponentStrategy:()=>Xe});var Xe,Ht=Q(()=>{"use strict";de();Xe=class{constructor(e,r,s=400,i=400){this.mainSelector=e;this.selectors=r;this.actionTimeoutMs=s;this.assertionTimeoutMs=i}async resetState(e){if(!this.selectors.panel||!this.selectors.trigger)return;let r=this.selectors.trigger,s=this.selectors.panel;if(!r||!s)return;let i=await e.locator(r).all();for(let n of i){let a=await n.getAttribute("aria-expanded")==="true",o=await n.getAttribute("aria-controls");if(a&&o){await n.click({timeout:this.actionTimeoutMs});let l=e.locator(`#${o}`);await(0,z.expect)(l).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{})}}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Pt={};se(Pt,{ComboboxComponentStrategy:()=>Ye});var Ye,It=Q(()=>{"use strict";de();Ye=class{constructor(e,r,s=400,i=400){this.mainSelector=e;this.selectors=r;this.actionTimeoutMs=s;this.assertionTimeoutMs=i}async resetState(e){if(!this.selectors.popup)return;let r=this.selectors.popup,s=e.locator(r).first();if(!await s.isVisible().catch(()=>!1))return;let n=!1,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await(0,z.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!n&&this.selectors.button&&(await e.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),n=await(0,z.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),n||(await e.mouse.click(10,10),n=await(0,z.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!n)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
|
|
6
6
|
1. Escape key
|
|
7
7
|
2. Clicking button
|
|
8
8
|
3. Clicking outside
|
|
9
|
-
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear()}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var
|
|
10
|
-
`)}start(e,r,s){this.startTime=Date.now(),this.componentName=e,this.totalTests=r,this.hasPrintedStaticSection=!1,this.hasPrintedDynamicSection=!1,s&&(this.apgUrl=s);let
|
|
11
|
-
${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${e.charAt(0).toUpperCase()+e.slice(1)} Component - ${
|
|
12
|
-
`)}reportStatic(e,r,s=0){this.staticPasses=e,this.staticFailures=r,this.staticWarnings=s}reportStaticTest(e,r,s,
|
|
9
|
+
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear()}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Dt={};se(Dt,{TabsComponentStrategy:()=>Qe});var Qe,Bt=Q(()=>{"use strict";Qe=class{constructor(e,r){this.mainSelector=e;this.selectors=r}async resetState(){}async shouldSkipTest(e,r){if(e.orientation!==void 0&&this.selectors.tablist){let s=this.selectors.tablist,n=await r.locator(s).first().getAttribute("aria-orientation");if(e.orientation!==n)return!0}return!1}getMainSelector(){return this.mainSelector}}});var Vt={};se(Vt,{RadioComponentStrategy:()=>Ze});var Ze,Ft=Q(()=>{"use strict";de();Ze=class{constructor(e,r,s=400,i=400){this.mainSelector=e;this.selectors=r;this.actionTimeoutMs=s;this.assertionTimeoutMs=i}async resetState(e){if(!this.selectors.radio||!this.selectors.relative)return;let r=this.selectors.radio;if(!r)return;let s=await e.locator(r).all();for(let i of s)if(await i.getAttribute("aria-checked")==="true"){await i.evaluate(o=>o.setAttribute("aria-checked","false"),{timeout:this.actionTimeoutMs});let a=e.locator(`#${i}`);await(0,z.expect)(a).toHaveAttribute("aria-checked","false",{timeout:this.assertionTimeoutMs}).catch(()=>{})}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var qt={};se(qt,{CheckboxComponentStrategy:()=>et});var et,Ot=Q(()=>{"use strict";de();et=class{constructor(e,r,s=400,i=400){this.mainSelector=e;this.selectors=r;this.actionTimeoutMs=s;this.assertionTimeoutMs=i}async resetState(e){if(!this.selectors.checkbox||!this.selectors.relative)return;let r=this.selectors.checkbox;if(!r)return;let s=await e.locator(r).all();for(let i of s)if(await i.getAttribute("aria-checked")==="true"){await i.click({timeout:this.actionTimeoutMs});let a=e.locator(`#${i}`);await(0,z.expect)(a).toHaveAttribute("aria-checked","false",{timeout:this.assertionTimeoutMs}).catch(()=>{})}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var _t={};se(_t,{ToggleComponentStrategy:()=>tt});var tt,Ut=Q(()=>{"use strict";de();tt=class{constructor(e,r,s=400,i=400){this.mainSelector=e;this.selectors=r;this.actionTimeoutMs=s;this.assertionTimeoutMs=i}async resetState(e){if(!this.selectors.toggle||!this.selectors.relative)return;let r=this.selectors.toggle;if(!r)return;let s=await e.locator(r).all();for(let i of s)if(await i.getAttribute("aria-pressed")==="true"){await i.click({timeout:this.actionTimeoutMs});let a=e.locator(`#${i}`);await(0,z.expect)(a).toHaveAttribute("aria-pressed","false",{timeout:this.assertionTimeoutMs}).catch(()=>{})}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var rt,jt,$e,Nt=Q(()=>{"use strict";rt=ne(require("path"),1),jt=require("url"),$e=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies()}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>Promise.resolve().then(()=>(Lt(),$t)).then(e=>e.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>Promise.resolve().then(()=>(Ht(),Rt)).then(e=>e.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>Promise.resolve().then(()=>(It(),Pt)).then(e=>e.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>Promise.resolve().then(()=>(Bt(),Dt)).then(e=>e.TabsComponentStrategy)),this.builtInStrategies.set("radio",()=>Promise.resolve().then(()=>(Ft(),Vt)).then(e=>e.RadioComponentStrategy)),this.builtInStrategies.set("checkbox",()=>Promise.resolve().then(()=>(Ot(),qt)).then(e=>e.CheckboxComponentStrategy)),this.builtInStrategies.set("toggle",()=>Promise.resolve().then(()=>(Ut(),_t)).then(e=>e.ToggleComponentStrategy))}async loadStrategy(e,r,s){try{if(r)try{let n=rt.default.isAbsolute(r)?r:rt.default.resolve(s||process.cwd(),r),a=await import((0,jt.pathToFileURL)(n).href),o=a.default||a;if(!o)throw new Error(`No default export found in ${r}`);return o}catch(n){throw new Error(`Failed to load custom strategy from ${r}: ${n instanceof Error?n.message:String(n)}`)}let i=this.builtInStrategies.get(e);return i?i():null}catch(i){throw new Error(`Strategy loading failed for ${e}: ${i instanceof Error?i.message:String(i)}`)}}has(e,r){return!!r||this.builtInStrategies.has(e)}}});var Le,Re,ms,He,Kt=Q(()=>{"use strict";Le=require("fs"),Re=ne(require("path"),1);Nt();ms={},He=class{static strategyRegistry=new $e;static isComponentConfig(e){return typeof e=="object"&&e!==null}static async detect(e,r,s=400,i=400,n){let a=this.isComponentConfig(r)?r:void 0,o=a?.contractPath;if(!o)throw new Error(`Contract path not found for component: ${e}`);let l=(()=>{if(Re.default.isAbsolute(o))return o;if(n){let B=Re.default.resolve(n,o);try{return(0,Le.readFileSync)(B,"utf-8"),B}catch{}}let D=Re.default.resolve(process.cwd(),o);try{return(0,Le.readFileSync)(D,"utf-8"),D}catch{return new URL(o,ms.url).pathname}})(),u=(0,Le.readFileSync)(l,"utf-8"),k=JSON.parse(u).selectors,A=await this.strategyRegistry.loadStrategy(e,a?.strategyPath,n);if(!A)return null;let C=k.main;return e==="tabs"?new A(C,k):new A(C,k,s,i)}}});var Pe,Wt=Q(()=>{"use strict";Pe=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=!1;isCustomContract=!1;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=!1;hasPrintedDynamicSection=!1;constructor(e=!1,r=!1){this.isPlaywright=e,this.isCustomContract=r}log(e){process.stderr.write(e+`
|
|
10
|
+
`)}start(e,r,s){this.startTime=Date.now(),this.componentName=e,this.totalTests=r,this.hasPrintedStaticSection=!1,this.hasPrintedDynamicSection=!1,s&&(this.apgUrl=s);let i="Playwright (Real Browser)";this.log(`
|
|
11
|
+
${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${e.charAt(0).toUpperCase()+e.slice(1)} Component - ${i}`),this.log(`${"\u2550".repeat(60)}
|
|
12
|
+
`)}reportStatic(e,r,s=0){this.staticPasses=e,this.staticFailures=r,this.staticWarnings=s}reportStaticTest(e,r,s,i){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=!0);let n=r==="pass"?"\u2713":r==="warn"?"\u26A0":r==="skip"?"\u25CB":"\u2717";this.log(` ${n} ${e}`),i&&this.log(` \u21B3 level=${i}`),(r==="fail"||r==="warn"||r==="skip")&&s&&this.log(` \u21B3 ${s}`)}reportTest(e,r,s){this.hasPrintedDynamicSection||(this.log(""),this.log(`${"\u2500".repeat(60)}`),this.log("\u2328\uFE0F Dynamic Interaction Tests"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedDynamicSection=!0);let i={description:e.description,status:r,failureMessage:s,level:e.level};r==="skip"&&(i.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(i);let n={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},a=e.level?`[${e.level.toUpperCase()}] `:"";this.log(` ${n[r]} ${a}${e.description}`),r==="skip"&&!this.isPlaywright&&this.log(" \u21B3 Skipped (runs only in Playwright)"),r==="fail"&&s&&this.log(` \u21B3 ${s}`),r==="warn"&&s&&this.log(` \u21B3 ${s}`),r==="skip"&&s&&this.log(` \u21B3 ${s}`)}reportFailures(e){e.length!==0&&(this.log(`
|
|
13
13
|
${"\u2500".repeat(60)}`),this.log(`\u274C Failures (${e.length}):
|
|
14
14
|
`),e.forEach((r,s)=>{this.log(`${s+1}. ${r}`),r.includes("aria-")?this.log(" \u{1F4A1} Add the missing ARIA attribute to improve screen reader support"):r.includes("focus")?this.log(" \u{1F4A1} Check keyboard event handlers and focus management"):r.includes("visible")&&this.log(" \u{1F4A1} Verify display/visibility styles and state management"),this.log("")}))}reportWarnings(){let e=this.dynamicResults.filter(r=>r.status==="warn");e.length===0&&this.staticWarnings===0||(this.log(`
|
|
15
15
|
${"\u2500".repeat(60)}`),this.log(`\u26A0\uFE0F Warnings (${this.staticWarnings+e.length}):
|
|
@@ -21,62 +21,62 @@ ${"\u2500".repeat(60)}`),this.log(`\u2139\uFE0F Skipped Tests (${this.skipped})
|
|
|
21
21
|
`),this.log("These tests use native keyboard events via addEventListener,"),this.log(`which only run in Playwright (real browser).
|
|
22
22
|
`),e.forEach((r,s)=>{this.log(`${s+1}. ${r.description}`)}),this.log(`
|
|
23
23
|
\u{1F4A1} Run with Playwright for full validation:`),this.log(` testUiComponent('${this.componentName}', null, 'http://localhost:5173/test-harness?component=component_name')
|
|
24
|
-
`)}summary(e){let r=Date.now()-this.startTime,s=this.dynamicResults.filter(
|
|
24
|
+
`)}summary(e){let r=Date.now()-this.startTime,s=this.dynamicResults.filter(g=>g.status==="pass").length,i=this.dynamicResults.filter(g=>g.status==="fail").length,n=this.dynamicResults.filter(g=>g.status==="warn").length;this.skipped=this.dynamicResults.filter(g=>g.status==="skip").length,this.warnings=this.staticWarnings+n;let a=this.staticPasses+s,o=this.staticFailures+i,l=a+o+this.warnings,u=()=>{let g=`${this.componentName.charAt(0).toUpperCase()}${this.componentName.slice(1)}`;return this.isCustomContract?`${g} component validates against your custom accessibility policy \u2713`:`${g} component meets Aria-Ease baseline WAI-ARIA expectations \u2713`};return e.length>0&&this.reportFailures(e),this.reportWarnings(),this.reportSkipped(),this.log(`
|
|
25
25
|
${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
|
|
26
26
|
`),o===0&&this.skipped===0&&this.warnings===0?(this.log(`\u2705 All ${l} tests passed!`),this.log(` ${u()}`)):o===0?(this.log(`\u2705 ${a}/${l} tests passed`),this.skipped>0&&this.log(`\u25CB ${this.skipped} tests skipped`),this.warnings>0&&this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings>1?"s":""}`),this.log(` ${u()}`)):(this.log(`\u274C ${o} test${o>1?"s":""} failed`),this.log(`\u2705 ${a} test${a>1?"s":""} passed`),this.warnings>0&&this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings>1?"s":""}`),this.skipped>0&&this.log(`\u25CB ${this.skipped} test${this.skipped>1?"s":""} skipped`)),this.log(`\u23F1\uFE0F Duration: ${r}ms`),this.log(`${"\u2550".repeat(60)}
|
|
27
27
|
`),o>0?(this.log("\u{1F527} Next Steps:"),this.log(" 1. Review the failures above"),this.log(" 2. Fix ARIA attributes and keyboard handlers"),this.log(` 3. Re-run tests to verify fixes
|
|
28
28
|
`)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
|
|
29
29
|
`),{passes:a,failures:o,skipped:this.skipped,duration:r}}error(e,r){this.log(`
|
|
30
|
-
\u274C Error: ${e}`),r&&this.log(` Context: ${r}`),this.log("")}}});var _t={};oe(_t,{RelativeTargetResolver:()=>ce});var ce,De=Y(()=>{"use strict";ce=class{static async resolve(e,r,s){let n=await e.locator(r).all();if(typeof s=="number")return n[s-1];switch(s){case"first":return n[0];case"second":return n[1];case"last":return n[n.length-1];case"next":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[r])+1)%n.length;return n[a]}case"previous":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[r])-1+n.length)%n.length;return n[a]}default:return null}}}});var be,Ut=Y(()=>{"use strict";De();be=class{constructor(e,r,s=400){this.page=e;this.selectors=r;this.timeoutMs=s}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,r,s){try{if(e==="virtual"&&s){let i=this.selectors.main;if(!i)return{success:!1,error:"Main selector not defined for virtual focus."};let a=this.page.locator(i).first();return await a.count()?(await a.evaluate((l,u)=>{l.setAttribute("aria-activedescendant",u)},s),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&r){let i=this.selectors.relative;if(!i)return{success:!1,error:"Relative selector not defined for focus action."};let a=await ce.resolve(this.page,i,r);return a?(await a.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for focus.`}}let n=this.selectors[e];return n?(await this.page.locator(n).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(n){return this.isBrowserClosedError(n)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to focus ${e}: ${n instanceof Error?n.message:String(n)}`}}}async type(e,r){try{let s=this.selectors[e];return s?(await this.page.locator(s).first().fill(r,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to type into ${e}: ${s instanceof Error?s.message:String(s)}`}}}async click(e,r){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&r){let n=this.selectors.relative;if(!n)return{success:!1,error:"Relative selector not defined for click action."};let i=await ce.resolve(this.page,n,r);return i?(await i.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for click.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to click ${e}: ${s instanceof Error?s.message:String(s)}`}}}async keypress(e,r,s){try{let i={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[r]||r;if(i==="Space"?i=" ":i.includes(" ")&&(i=i.replace(/ /g,"")),e==="relative"){if(s==null)return{success:!1,error:"relativeTarget must be provided for relative keypress."};let u=this.selectors.relative;if(!u)return{success:!1,error:"Relative selector not defined for keypress action."};let f=await ce.resolve(this.page,u,s);return f?(await f.press(i,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for keypress.`}}let a=this.selectors[e];if(!a)return{success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(a).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(i,{timeout:this.timeoutMs}),{success:!0})}catch(n){return this.isBrowserClosedError(n)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to press ${r} on ${e}: ${n instanceof Error?n.message:String(n)}`}}}async hover(e,r){try{if(e==="relative"&&r){let n=this.selectors.relative;if(!n)return{success:!1,error:"Relative selector not defined for hover action."};let i=await ce.resolve(this.page,n,r);return i?(await i.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for hover.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to hover ${e}: ${s instanceof Error?s.message:String(s)}`}}}}});var ke,Nt=Y(()=>{"use strict";de();De();ke=class{constructor(e,r,s=400){this.page=e;this.selectors=r;this.timeoutMs=s}async resolveTarget(e,r,s){try{if(e==="relative"){let i=s?this.selectors[s]:this.selectors.relative;if(!i)return{target:null,error:"Relative selector is not defined in the contract."};if(!r)return{target:null,error:"Relative target or expected value is not defined."};let a=await ce.resolve(this.page,i,r);return a?{target:a}:{target:null,error:`Target ${e} not found.`}}let n=this.selectors[e];return n?{target:this.page.locator(n).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(n){return{target:null,error:`Failed to resolve target ${e}: ${n instanceof Error?n.message:String(n)}`}}}async validateVisibility(e,r,s,n,i){try{return s?(await(0,J.expect)(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} is visible as expected. Test: "${i}".`}):(await(0,J.expect)(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} is not visible as expected. Test: "${i}".`})}catch{let a=this.selectors[r]||"",o=await this.page.evaluate(l=>{let u=l?document.querySelector(l):null;if(!u)return"element not found";let f=window.getComputedStyle(u);return`display:${f.display}, visibility:${f.visibility}, opacity:${f.opacity}`},a);return s?{success:!1,failMessage:`${n} (actual: ${o})`}:{success:!1,failMessage:`${n} ${r} is still visible (actual: ${o}).`}}}async validateAttribute(e,r,s,n,i,a){if(n==="!empty"){let u=await e.getAttribute(s);return u&&u.trim()!==""?{success:!0,passMessage:`${r} has non-empty "${s}". Test: "${a}".`}:{success:!1,failMessage:`${i} ${r} "${s}" should not be empty, found "${u}".`}}if(typeof n!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",n),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(n)}`);let o=n.split(" | ").map(u=>u.trim()),l=await e.getAttribute(s);return l!==null&&o.includes(l)?{success:!0,passMessage:`${r} has expected "${s}". Test: "${a}".`}:{success:!1,failMessage:`${i} ${r} "${s}" should be "${n}", found "${l}".`}}async validateValue(e,r,s,n,i){let a=await e.inputValue().catch(()=>"");return s==="!empty"?a&&a.trim()!==""?{success:!0,passMessage:`${r} has non-empty value. Test: "${i}".`}:{success:!1,failMessage:`${n} ${r} value should not be empty, found "${a}".`}:s===""?a===""?{success:!0,passMessage:`${r} has empty value. Test: "${i}".`}:{success:!1,failMessage:`${n} ${r} value should be empty, found "${a}".`}:a===s?{success:!0,passMessage:`${r} has expected value. Test: "${i}".`}:{success:!1,failMessage:`${n} ${r} value should be "${s}", found "${a}".`}}async validateFocus(e,r,s,n,i){try{return s?(await(0,J.expect)(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} has focus as expected. Test: "${i}".`}):(await(0,J.expect)(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} does not have focus as expected. Test: "${i}".`})}catch{let a=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return{success:!1,failMessage:`${n} (actual focus: ${a})`}}}async validateRole(e,r,s,n,i){let a=await e.getAttribute("role");return a===s?{success:!0,passMessage:`${r} has role "${s}". Test: "${i}".`}:{success:!1,failMessage:`${n} Expected role "${s}", found "${a}".`}}async validate(e,r){if(this.page.isClosed())return{success:!1,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let s=null,n;if(e.controlledBy){let i=e.controlledBy,a=this.selectors[i.target];if(!a)return{success:!1,failMessage:`Selector for controlledBy.target '${i.target}' not found.`,target:null};let o=null;if(i.relativeTarget?o=await ce.resolve(this.page,a,i.relativeTarget):o=this.page.locator(a).first(),!o)return{success:!1,failMessage:"Controlling element for controlledBy not found.",target:null};let l=i.attribute||"aria-controls",u=await o.getAttribute(l);if(!u)return{success:!1,failMessage:`Controlling element does not have attribute '${l}'.`,target:null};if(s=this.page.locator(`#${u}`),!s||await s.count()===0)return{success:!1,failMessage:`Controlled element with id '${u}' not found.`,target:null}}else{let i=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(s=i.target,n=i.error,n||!s)return{success:!1,failMessage:n||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let i=await ce.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),a=i?await i.getAttribute("id"):null,o=await s.getAttribute("aria-activedescendant");return a&&o===a?{success:!0,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${r}".`}:{success:!1,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case"toBeVisible":return this.validateVisibility(s,e.target,!0,e.failureMessage||"",r);case"notToBeVisible":return this.validateVisibility(s,e.target,!1,e.failureMessage||"",r);case"toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(s,e.target,e.attribute,e.expectedValue,e.failureMessage||"",r):{success:!1,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case"toHaveValue":return e.expectedValue!==void 0?this.validateValue(s,e.target,e.expectedValue,e.failureMessage||"",r):{success:!1,failMessage:"Missing expectedValue for toHaveValue assertion"};case"toHaveFocus":return this.validateFocus(s,e.target,!0,e.failureMessage||"",r);case"notToHaveFocus":return this.validateFocus(s,e.target,!1,e.failureMessage||"",r);case"toHaveRole":return e.expectedValue!==void 0?this.validateRole(s,e.target,e.expectedValue,e.failureMessage||"",r):{success:!1,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return{success:!1,failMessage:`Unknown assertion type: ${e.assertion}`}}}}});var jt={};oe(jt,{runContractTestsPlaywright:()=>es});async function es(t,e,r,s,n){let i=s?.test?.components?.find(p=>p.name===t),a=!!i?.contractPath,o=new Ie(!0,a),l={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},u=s?.test?.disableTimeouts===!0,y=i?.disableTimeouts===!0||u,T=(p,v,$)=>{if(y)return 0;let B=p??v;return typeof B!="number"||!Number.isFinite(B)||B<0?$:B},H=T(i?.actionTimeoutMs,s?.test?.actionTimeoutMs,l.actionTimeoutMs),q=T(i?.assertionTimeoutMs,s?.test?.assertionTimeoutMs,l.assertionTimeoutMs),U=T(i?.navigationTimeoutMs,s?.test?.navigationTimeoutMs,l.navigationTimeoutMs),G=T(i?.componentReadyTimeoutMs,s?.test?.componentReadyTimeoutMs,l.componentReadyTimeoutMs),g=we(r),d=i?.contractPath;if(!d)throw new Error(`Contract path not found for component: ${t}`);let C=(()=>{if(Ve.default.isAbsolute(d))return d;if(n){let v=Ve.default.resolve(n,d);try{return(0,Be.readFileSync)(v,"utf-8"),v}catch{}}let p=Ve.default.resolve(process.cwd(),d);try{return(0,Be.readFileSync)(p,"utf-8"),p}catch{return new URL(d,ts.url).pathname}})(),h=(0,Be.readFileSync)(C,"utf-8"),k=JSON.parse(h),F=(k.relationships?.length||0)+(k.static.length||0)+k.dynamic.length,w=k.meta?.source?.apg,x=[],L=[],m=[],A=[],b=null,D=(p,v)=>{let $=fe(v),B=kt($,g);if(B==="error")return x.push(p),{status:"fail",level:$,detail:p};if(B==="warning")return L.push(p),{status:"warn",level:$,detail:p};let X=`${p} (ignored by strictness=${g}, level=${$})`;return A.push(X),{status:"skip",level:$,detail:X}};try{if(b=await vt(),e){try{await b.goto(e,{waitUntil:"domcontentloaded",timeout:U})}catch(c){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${c instanceof Error?c.message:String(c)}`)}await b.addStyleTag({content:"* { transition: none !important; animation: none !important; }"})}let p=await Pe.detect(t,i,H,q,n);if(!p)throw new Error(`Unsupported component: ${t}`);let v=p.getMainSelector();if(!v)throw new Error(`CRITICAL: No selector found in contract for ${t}`);try{await b.locator(v).first().waitFor({state:"attached",timeout:G})}catch(c){throw new Error(`
|
|
30
|
+
\u274C Error: ${e}`),r&&this.log(` Context: ${r}`),this.log("")}}});var zt={};se(zt,{RelativeTargetResolver:()=>ae});var ae,Ie=Q(()=>{"use strict";ae=class{static async resolve(e,r,s){let i=await e.locator(r).all();if(typeof s=="number")return i[s-1];switch(s){case"first":return i[0];case"second":return i[1];case"last":return i[i.length-1];case"next":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[r])+1)%i.length;return i[a]}case"previous":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[r])-1+i.length)%i.length;return i[a]}default:return null}}}});var ve,Jt=Q(()=>{"use strict";Ie();ve=class{constructor(e,r,s=400){this.page=e;this.selectors=r;this.timeoutMs=s}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,r,s){try{if(e==="virtual"&&s){let n=this.selectors.main;if(!n)return{success:!1,error:"Main selector not defined for virtual focus."};let a=this.page.locator(n).first();return await a.count()?(await a.evaluate((l,u)=>{l.setAttribute("aria-activedescendant",u)},s),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&r){let n=this.selectors.relative;if(!n)return{success:!1,error:"Relative selector not defined for focus action."};let a=await ae.resolve(this.page,n,r);return a?(await a.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for focus.`}}let i=this.selectors[e];return i?(await this.page.locator(i).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(i){return this.isBrowserClosedError(i)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to focus ${e}: ${i instanceof Error?i.message:String(i)}`}}}async type(e,r){try{let s=this.selectors[e];return s?(await this.page.locator(s).first().fill(r,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to type into ${e}: ${s instanceof Error?s.message:String(s)}`}}}async click(e,r){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&r){let i=this.selectors.relative;if(!i)return{success:!1,error:"Relative selector not defined for click action."};let n=await ae.resolve(this.page,i,r);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for click.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to click ${e}: ${s instanceof Error?s.message:String(s)}`}}}async keypress(e,r,s){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[r]||r;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),e==="relative"){if(s==null)return{success:!1,error:"relativeTarget must be provided for relative keypress."};let u=this.selectors.relative;if(!u)return{success:!1,error:"Relative selector not defined for keypress action."};let g=await ae.resolve(this.page,u,s);return g?(await g.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for keypress.`}}let a=this.selectors[e];if(!a)return{success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(a).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(i){return this.isBrowserClosedError(i)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to press ${r} on ${e}: ${i instanceof Error?i.message:String(i)}`}}}async hover(e,r){try{if(e==="relative"&&r){let i=this.selectors.relative;if(!i)return{success:!1,error:"Relative selector not defined for hover action."};let n=await ae.resolve(this.page,i,r);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for hover.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to hover ${e}: ${s instanceof Error?s.message:String(s)}`}}}}});var Te,Gt=Q(()=>{"use strict";de();Ie();Te=class{constructor(e,r,s=400){this.page=e;this.selectors=r;this.timeoutMs=s}async resolveTarget(e,r,s){try{if(e==="relative"){let n=s?this.selectors[s]:this.selectors.relative;if(!n)return{target:null,error:"Relative selector is not defined in the contract."};if(!r)return{target:null,error:"Relative target or expected value is not defined."};let a=await ae.resolve(this.page,n,r);return a?{target:a}:{target:null,error:`Target ${e} not found.`}}let i=this.selectors[e];return i?{target:this.page.locator(i).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(i){return{target:null,error:`Failed to resolve target ${e}: ${i instanceof Error?i.message:String(i)}`}}}async validateVisibility(e,r,s,i,n){try{return s?(await(0,z.expect)(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} is visible as expected. Test: "${n}".`}):(await(0,z.expect)(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} is not visible as expected. Test: "${n}".`})}catch{let a=this.selectors[r]||"",o=await this.page.evaluate(l=>{let u=l?document.querySelector(l):null;if(!u)return"element not found";let g=window.getComputedStyle(u);return`display:${g.display}, visibility:${g.visibility}, opacity:${g.opacity}`},a);return s?{success:!1,failMessage:`${i} (actual: ${o})`}:{success:!1,failMessage:`${i} ${r} is still visible (actual: ${o}).`}}}async validateAttribute(e,r,s,i,n,a){if(i==="!empty"){let u=await e.getAttribute(s);return u&&u.trim()!==""?{success:!0,passMessage:`${r} has non-empty "${s}". Test: "${a}".`}:{success:!1,failMessage:`${n} ${r} "${s}" should not be empty, found "${u}".`}}if(typeof i!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",i),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(i)}`);let o=i.split(" | ").map(u=>u.trim()),l=await e.getAttribute(s);return l!==null&&o.includes(l)?{success:!0,passMessage:`${r} has expected "${s}". Test: "${a}".`}:{success:!1,failMessage:`${n} ${r} "${s}" should be "${i}", found "${l}".`}}async validateValue(e,r,s,i,n){let a=await e.inputValue().catch(()=>"");return s==="!empty"?a&&a.trim()!==""?{success:!0,passMessage:`${r} has non-empty value. Test: "${n}".`}:{success:!1,failMessage:`${i} ${r} value should not be empty, found "${a}".`}:s===""?a===""?{success:!0,passMessage:`${r} has empty value. Test: "${n}".`}:{success:!1,failMessage:`${i} ${r} value should be empty, found "${a}".`}:a===s?{success:!0,passMessage:`${r} has expected value. Test: "${n}".`}:{success:!1,failMessage:`${i} ${r} value should be "${s}", found "${a}".`}}async validateFocus(e,r,s,i,n){try{return s?(await(0,z.expect)(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} has focus as expected. Test: "${n}".`}):(await(0,z.expect)(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} does not have focus as expected. Test: "${n}".`})}catch{let a=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return{success:!1,failMessage:`${i} (actual focus: ${a})`}}}async validateRole(e,r,s,i,n){let a=await e.getAttribute("role");return a===s?{success:!0,passMessage:`${r} has role "${s}". Test: "${n}".`}:{success:!1,failMessage:`${i} Expected role "${s}", found "${a}".`}}async validate(e,r){if(this.page.isClosed())return{success:!1,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let s=null,i;if(e.controlledBy){let n=e.controlledBy,a=this.selectors[n.target];if(!a)return{success:!1,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let o=null;if(n.relativeTarget?o=await ae.resolve(this.page,a,n.relativeTarget):o=this.page.locator(a).first(),!o)return{success:!1,failMessage:"Controlling element for controlledBy not found.",target:null};let l=n.attribute||"aria-controls",u=await o.getAttribute(l);if(!u)return{success:!1,failMessage:`Controlling element does not have attribute '${l}'.`,target:null};if(s=this.page.locator(`#${u}`),!s||await s.count()===0)return{success:!1,failMessage:`Controlled element with id '${u}' not found.`,target:null}}else{let n=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(s=n.target,i=n.error,i||!s)return{success:!1,failMessage:i||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let n=await ae.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),a=n?await n.getAttribute("id"):null,o=await s.getAttribute("aria-activedescendant");return a&&o===a?{success:!0,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${r}".`}:{success:!1,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case"toBeVisible":return this.validateVisibility(s,e.target,!0,e.failureMessage||"",r);case"notToBeVisible":return this.validateVisibility(s,e.target,!1,e.failureMessage||"",r);case"toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(s,e.target,e.attribute,e.expectedValue,e.failureMessage||"",r):{success:!1,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case"toHaveValue":return e.expectedValue!==void 0?this.validateValue(s,e.target,e.expectedValue,e.failureMessage||"",r):{success:!1,failMessage:"Missing expectedValue for toHaveValue assertion"};case"toHaveFocus":return this.validateFocus(s,e.target,!0,e.failureMessage||"",r);case"notToHaveFocus":return this.validateFocus(s,e.target,!1,e.failureMessage||"",r);case"toHaveRole":return e.expectedValue!==void 0?this.validateRole(s,e.target,e.expectedValue,e.failureMessage||"",r):{success:!1,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return{success:!1,failMessage:`Unknown assertion type: ${e.assertion}`}}}}});var Xt={};se(Xt,{runContractTestsPlaywright:()=>hs});async function hs(t,e,r,s,i){let n=s?.test?.components?.find(d=>d.name===t),a=!!n?.contractPath,o=new Pe(!0,a),l={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},u=s?.test?.disableTimeouts===!0,k=n?.disableTimeouts===!0||u,A=(d,$,q)=>{if(k)return 0;let J=d??$;return typeof J!="number"||!Number.isFinite(J)||J<0?q:J},C=A(n?.actionTimeoutMs,s?.test?.actionTimeoutMs,l.actionTimeoutMs),D=A(n?.assertionTimeoutMs,s?.test?.assertionTimeoutMs,l.assertionTimeoutMs),B=A(n?.navigationTimeoutMs,s?.test?.navigationTimeoutMs,l.navigationTimeoutMs),G=A(n?.componentReadyTimeoutMs,s?.test?.componentReadyTimeoutMs,l.componentReadyTimeoutMs),S=we(r),p=n?.contractPath;if(!p)throw new Error(`Contract path not found for component: ${t}`);let w=(()=>{if(Be.default.isAbsolute(p))return p;if(i){let $=Be.default.resolve(i,p);try{return(0,De.readFileSync)($,"utf-8"),$}catch{}}let d=Be.default.resolve(process.cwd(),p);try{return(0,De.readFileSync)(d,"utf-8"),d}catch{return new URL(p,bs.url).pathname}})(),f=(0,De.readFileSync)(w,"utf-8"),h=JSON.parse(f),O=(h.relationships?.length||0)+(h.static.length||0)+h.dynamic.length,v=h.meta?.source?.apg,x=[],L=[],m=[],T=[],y=null,V=(d,$)=>{let q=be($),J=Mt(q,S);if(J==="error")return x.push(d),{status:"fail",level:q,detail:d};if(J==="warning")return L.push(d),{status:"warn",level:q,detail:d};let le=`${d} (ignored by strictness=${S}, level=${q})`;return T.push(le),{status:"skip",level:q,detail:le}},ie=d=>d&&typeof d=="object"&&d.success===!0;try{if(y=await At(),e){try{await y.goto(e,{waitUntil:"domcontentloaded",timeout:B})}catch(c){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${c instanceof Error?c.message:String(c)}`)}await y.addStyleTag({content:"* { transition: none !important; animation: none !important; }"})}let d=await He.detect(t,n,C,D,i);if(!d)throw new Error(`Unsupported component: ${t}`);let $=d.getMainSelector();if(!$)throw new Error(`CRITICAL: No selector found in contract for ${t}`);try{await y.locator($).first().waitFor({state:"attached",timeout:G})}catch(c){throw new Error(`
|
|
31
31
|
\u274C CRITICAL: Component not found on page!
|
|
32
32
|
This usually means:
|
|
33
33
|
- The component didn't render
|
|
34
34
|
- The URL is incorrect
|
|
35
|
-
- The component selector '${
|
|
36
|
-
- Original error: ${c}`)}o.start(t,F,w),t==="menu"&&k.selectors.main&&await b.locator(k.selectors.main).first().waitFor({state:"visible",timeout:G}).catch(()=>{});let $=t==="menu"&&k.selectors.submenuTrigger?await b.locator(k.selectors.submenuTrigger).count()>0:!1,B=c=>c.type==="aria-reference"&&[c.from,c.to].some(R=>["submenu","submenuTrigger","submenuItems"].includes(R||""))||c.type==="contains"&&[c.parent,c.child].some(R=>["submenu","submenuTrigger","submenuItems"].includes(R||"")),X=0,ee=0,te=0;for(let c of k.relationships||[]){if(p&&typeof p.resetState=="function")try{await p.resetState(b)}catch(I){L.push(`Warning: resetState failed before relationship test: ${I instanceof Error?I.message:String(I)}`)}let R=fe(c.level);if(Array.isArray(c.setup)&&c.setup.length>0){let N=function(M){return V.includes(M)};var Z=N;let I=new be(b,k.selectors,H),W=c.type==="aria-reference"?`${c.from}.${c.attribute} references ${c.to}`:`${c.parent} contains ${c.child}`,V=["focus","type","click","keypress","hover"],O=M=>({...M,type:N(M.type)?M.type:"click"}),j=c.setup.map(O),z=await Fe(j,I,p,b,W,["submenu","submenuTrigger","submenuItems"]);if(z.skip){A.push(z.message||"Setup action skipped"),o.reportStaticTest(W,"skip",z.message,R);continue}if(!z.success){let M=`Relationship setup failed: ${z.error}`,S=D(M,c.level);S.status==="fail"&&(ee+=1),S.status==="warn"&&(te+=1),o.reportStaticTest(W,S.status,S.detail,S.level);continue}}if(t==="menu"&&!$&&B(c)){let W=c.type==="aria-reference"?`${c.from}.${c.attribute} references ${c.to}`:`${c.parent} contains ${c.child}`,V="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";A.push(V),o.reportStaticTest(W,"skip",V,R);continue}if(c.type==="aria-reference"){let I=`${c.from}.${c.attribute} references ${c.to}`,W=k.selectors[c.from],V=k.selectors[c.to];if(!W||!V){let P=D(`Relationship selector missing: from="${c.from}" or to="${c.to}" not found in selectors.`,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}let N=b.locator(W).first(),O=b.locator(V).first(),j=await N.count()>0,z=await O.count()>0;if(!j||!z){if(t==="menu"&&B(c)){let re="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";A.push(re),o.reportStaticTest(I,"skip",re,R);continue}let P=D(`Relationship target not found: ${j?c.to:c.from}.`,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}let M=await N.getAttribute(c.attribute),S=await O.getAttribute("id");if(!S){let P=D(`Relationship target "${c.to}" must have an id for ${c.attribute} validation.`,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}if(!(M||"").split(/\s+/).filter(Boolean).includes(S)){let P=D(`Expected ${c.from} ${c.attribute} to reference id "${S}", found "${M||""}".`,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}m.push(`Relationship valid: ${c.from}.${c.attribute} -> ${c.to} (id=${S}).`),X+=1,o.reportStaticTest(I,"pass",void 0,R);continue}if(c.type==="contains"){let I=`${c.parent} contains ${c.child}`,W=k.selectors[c.parent],V=k.selectors[c.child];if(!W||!V){let M=D(`Relationship selector missing: parent="${c.parent}" or child="${c.child}" not found in selectors.`,c.level);M.status==="fail"&&(ee+=1),M.status==="warn"&&(te+=1),o.reportStaticTest(I,M.status,M.detail,M.level);continue}let N=b.locator(W).first();if(!(await N.count()>0)){if(t==="menu"&&B(c)){let S="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";A.push(S),o.reportStaticTest(I,"skip",S,R);continue}let M=D(`Relationship parent target not found: ${c.parent}.`,c.level);M.status==="fail"&&(ee+=1),M.status==="warn"&&(te+=1),o.reportStaticTest(I,M.status,M.detail,M.level);continue}if(await N.locator(V).count()<1){if(t==="menu"&&B(c)){let S="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";A.push(S),o.reportStaticTest(I,"skip",S,R);continue}let M=D(`Expected ${c.parent} to contain descendant matching selector for ${c.child}.`,c.level);M.status==="fail"&&(ee+=1),M.status==="warn"&&(te+=1),o.reportStaticTest(I,M.status,M.detail,M.level);continue}m.push(`Relationship valid: ${c.parent} contains ${c.child}.`),X+=1,o.reportStaticTest(I,"pass",void 0,R)}}async function nt(c,R,I,W={}){if(!c||typeof c!="object"||!("ref"in c))return c;let V;if(c.ref==="relative"){if(!c.relativeTarget||!W.relativeBaseSelector)return;let N=I.locator(W.relativeBaseSelector),O=await N.count(),j=0;if(c.relativeTarget==="first"?j=0:c.relativeTarget==="second"?j=1:c.relativeTarget==="last"?j=O-1:isNaN(Number(c.relativeTarget))?j=0:j=Number(c.relativeTarget),j<0||j>=O)return;let z=N.nth(j);return await it(z,c.property||c.attribute)}else{if(V=R[c.ref],!V)throw new Error(`Selector for ref '${c.ref}' not found in contract selectors.`);let N=I.locator(V).first();return await it(N,c.property||c.attribute)}}async function it(c,R){if(c)return!R||R==="id"?await c.getAttribute("id")??void 0:R==="class"?await c.getAttribute("class")??void 0:R==="textContent"?await c.evaluate(I=>I.textContent??void 0):R.startsWith("aria-")?await c.getAttribute(R)??void 0:R.endsWith("*")?await c.evaluate(W=>{let V=[];for(let N of Array.from(W.attributes))N.name.startsWith("aria-")&&V.push(`${N.name}=${N.value}`);return V.join(";")}):await c.getAttribute(R)??void 0}let Qt=new ke(b,k.selectors,q);async function Fe(c,R,I,W,V,N=[]){if(!Array.isArray(c)||c.length===0)return{success:!0};I&&typeof I.resetState=="function"&&await I.resetState(W);for(let O of c){let j={success:!0};try{if(O.type==="focus")O.target==="relative"&&O.relativeTarget?j=await R.focus("relative",O.relativeTarget):j=await R.focus(O.target);else if(O.type==="type"&&O.value)j=await R.type(O.target,O.value);else if(O.type==="click")j=await R.click(O.target,O.relativeTarget);else if(O.type==="keypress"&&O.key)j=await R.keypress(O.target,O.key,O.relativeTarget);else if(O.type==="hover")j=await R.hover(O.target,O.relativeTarget);else continue}catch(z){j={success:!1,error:z instanceof Error?z.message:String(z)}}if(!j.success){let z=j.error||"Setup action failed";return N.some(S=>V.includes(S)||z.includes(S))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${z}`}:{success:!1,error:z}}}return{success:!0}}for(let c of k.static||[]){if(p&&typeof p.resetState=="function")try{await p.resetState(b)}catch(M){L.push(`Warning: resetState failed before static test: ${M instanceof Error?M.message:String(M)}`)}if(c.target==="relative")continue;let R=`${c.target}${c.attribute?` (${c.attribute})`:""}`,I=fe(c.level);if(t==="menu"&&c.target==="submenuTrigger"&&!$){let M=`Skipping submenu static assertion for ${c.target}: no submenu capability detected in rendered component.`;A.push(M),o.reportStaticTest(R,"skip",M,I);continue}let W=[];if(c.target||W.push("target"),c.attribute||W.push("attribute"),typeof c.expectedValue>"u"&&W.push("expectedValue"),W.length>0){let M=`${c.target||""}${c.attribute?` (${c.attribute})`:""}`,S=`Static assertion missing required field(s): ${W.join(", ")}`,_=D(S,c.level);_.status==="fail"&&(ee+=1),_.status==="warn"&&(te+=1),o.reportStaticTest(M,_.status,_.detail,_.level);continue}if(Array.isArray(c.setup)&&c.setup.length>0){let _=function(E){return S.includes(E)};var Z=_;let M=new be(b,k.selectors,H),S=["focus","type","click","keypress","hover"],ie=E=>({...E,type:_(E.type)?E.type:"click"}),P=c.setup.map(ie),re=await Fe(P,M,p,b,R,["submenu","submenuTrigger","submenuItems"]);if(re.skip){A.push(re.message||"Setup action skipped"),o.reportStaticTest(R,"skip",re.message,I);continue}if(!re.success){let E=`Static setup failed: ${re.error}`,K=D(E,c.level);K.status==="fail"&&(ee+=1),K.status==="warn"&&(te+=1),o.reportStaticTest(R,K.status,K.detail,K.level);continue}}let V=k.selectors[c.target];if(!V){let M=`Selector for target ${c.target} not found.`,S=D(M,c.level);S.status==="fail"&&(ee+=1),S.status==="warn"&&(te+=1),o.reportStaticTest(R,S.status,S.detail,S.level);continue}let N=b.locator(V).first();if(!(await N.count()>0)){let M=`Target ${c.target} not found.`,S=D(M,c.level);S.status==="fail"&&(ee+=1),S.status==="warn"&&(te+=1),o.reportStaticTest(R,S.status,S.detail,S.level);continue}let j=(M,S,_)=>{let ie=new RegExp(`\\[${S}(?:=["']?([^\\]"']+)["']?)?\\]`),P=M.match(ie);if(!P)return!1;if(!_)return!0;let re=P[1];return re?_.split(" | ").includes(re):!1},z=c.expectedValue;if(c.expectedValue&&typeof c.expectedValue=="object"&&"ref"in c.expectedValue){let M={},S=c.relativeTarget;if(c.expectedValue.ref==="relative"&&c.target==="relative"&&S){let _=k.selectors[S];if(!_)throw new Error(`Selector for relativeTarget '${S}' not found in contract selectors.`);M.relativeBaseSelector=_}else if(c.expectedValue.ref==="relative"&&S){let _=k.selectors[S];if(!_)throw new Error(`Selector for relativeTarget '${S}' not found in contract selectors.`);M.relativeBaseSelector=_}z=await nt(c.expectedValue,k.selectors,b,M)}if(c.expectedValue)if(j(V,c.attribute,typeof z=="string"?z:void 0))m.push(`${c.attribute}="${z}" on ${c.target} verified by selector (already present in: ${V}).`),X+=1,o.reportStaticTest(R,"pass",void 0,I);else{let M=z??"",S=await Qt.validateAttribute(N,c.target,c.attribute,M,c.failureMessage,"Static ARIA Test");if(S.success&&S.passMessage)m.push(S.passMessage),X+=1,o.reportStaticTest(R,"pass",void 0,I);else if(!S.success&&S.failMessage){let _=D(S.failMessage,c.level);_.status==="fail"&&(ee+=1),_.status==="warn"&&(te+=1),o.reportStaticTest(R,_.status,_.detail,_.level)}}else{let M=c.attribute.split(" | "),S=!1,_=!0;for(let ie of M){let P=ie.trim();if(j(V,P)){m.push(`${P} on ${c.target} verified by selector (already present in: ${V}).`),S=!0;continue}if(_=!1,await N.getAttribute(P)!==null){S=!0;break}}if(!S&&!_){let ie=c.failureMessage+` None of the attributes "${c.attribute}" are present.`,P=D(ie,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(R,P.status,P.detail,P.level)}else!_&&S?(m.push(`At least one of the attributes "${c.attribute}" exists on the element.`),X+=1,o.reportStaticTest(R,"pass",void 0,I)):(X+=1,o.reportStaticTest(R,"pass",void 0,I))}}for(let c of k.dynamic||[]){if(!c.assertions||c.assertions.length===0){let E="Skipping test - no assertions found for this dynamic test.";A.push(E),o.reportTest({description:c.description,level:fe(c.level)},"skip",E);continue}if(!b||b.isClosed()){console.warn(`
|
|
37
|
-
\u26A0\uFE0F Browser closed - skipping remaining ${
|
|
38
|
-
`),x.push(`CRITICAL: Browser/page closed before completing all tests. ${
|
|
35
|
+
- The component selector '${$}' in the contract is wrong
|
|
36
|
+
- Original error: ${c}`)}o.start(t,O,v),t==="menu"&&h.selectors.main&&await y.locator(h.selectors.main).first().waitFor({state:"visible",timeout:G}).catch(()=>{});let q=t==="menu"&&h.selectors.submenuTrigger?await y.locator(h.selectors.submenuTrigger).count()>0:!1,J=c=>c.type==="aria-reference"&&[c.from,c.to].some(R=>["submenu","submenuTrigger","submenuItems"].includes(R||""))||c.type==="contains"&&[c.parent,c.child].some(R=>["submenu","submenuTrigger","submenuItems"].includes(R||"")),le=0,ee=0,te=0;for(let c of h.relationships||[]){if(d&&typeof d.resetState=="function")try{await d.resetState(y)}catch(I){L.push(`Warning: resetState failed before relationship test: ${I instanceof Error?I.message:String(I)}`)}let R=be(c.level);if(Array.isArray(c.setup)&&c.setup.length>0){let j=function(M){return F.includes(M)};var b=j;let I=new ve(y,h.selectors,C),K=c.type==="aria-reference"?`${c.from}.${c.attribute} references ${c.to}`:`${c.parent} contains ${c.child}`,F=["focus","type","click","keypress","hover"],_=M=>({...M,type:j(M.type)?M.type:"click"}),N=c.setup.map(_),W=await Fe(N,I,d,y,K,["submenu","submenuTrigger","submenuItems"]);if(W.skip){T.push(W.message||"Setup action skipped"),o.reportStaticTest(K,"skip",W.message,R);continue}if(!W.success){let M=`Relationship setup failed: ${W.error}`,E=V(M,c.level);E.status==="fail"&&(ee+=1),E.status==="warn"&&(te+=1),o.reportStaticTest(K,E.status,E.detail,E.level);continue}}if(t==="menu"&&!q&&J(c)){let K=c.type==="aria-reference"?`${c.from}.${c.attribute} references ${c.to}`:`${c.parent} contains ${c.child}`,F="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";T.push(F),o.reportStaticTest(K,"skip",F,R);continue}if(c.type==="aria-reference"){let I=`${c.from}.${c.attribute} references ${c.to}`,K=h.selectors[c.from],F=h.selectors[c.to];if(!K||!F){let P=V(`Relationship selector missing: from="${c.from}" or to="${c.to}" not found in selectors.`,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}let j=y.locator(K).first(),_=y.locator(F).first(),N=await j.count()>0,W=await _.count()>0;if(!N||!W){if(t==="menu"&&J(c)){let re="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";T.push(re),o.reportStaticTest(I,"skip",re,R);continue}let P=V(`Relationship target not found: ${N?c.to:c.from}.`,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}let M=await j.getAttribute(c.attribute),E=await _.getAttribute("id");if(!E){let P=V(`Relationship target "${c.to}" must have an id for ${c.attribute} validation.`,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}if(!(M||"").split(/\s+/).filter(Boolean).includes(E)){let P=V(`Expected ${c.from} ${c.attribute} to reference id "${E}", found "${M||""}".`,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}m.push(`Relationship valid: ${c.from}.${c.attribute} -> ${c.to} (id=${E}).`),le+=1,o.reportStaticTest(I,"pass",void 0,R);continue}if(c.type==="contains"){let I=`${c.parent} contains ${c.child}`,K=h.selectors[c.parent],F=h.selectors[c.child];if(!K||!F){let M=V(`Relationship selector missing: parent="${c.parent}" or child="${c.child}" not found in selectors.`,c.level);M.status==="fail"&&(ee+=1),M.status==="warn"&&(te+=1),o.reportStaticTest(I,M.status,M.detail,M.level);continue}let j=y.locator(K).first();if(!(await j.count()>0)){if(t==="menu"&&J(c)){let E="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";T.push(E),o.reportStaticTest(I,"skip",E,R);continue}let M=V(`Relationship parent target not found: ${c.parent}.`,c.level);M.status==="fail"&&(ee+=1),M.status==="warn"&&(te+=1),o.reportStaticTest(I,M.status,M.detail,M.level);continue}if(await j.locator(F).count()<1){if(t==="menu"&&J(c)){let E="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";T.push(E),o.reportStaticTest(I,"skip",E,R);continue}let M=V(`Expected ${c.parent} to contain descendant matching selector for ${c.child}.`,c.level);M.status==="fail"&&(ee+=1),M.status==="warn"&&(te+=1),o.reportStaticTest(I,M.status,M.detail,M.level);continue}m.push(`Relationship valid: ${c.parent} contains ${c.child}.`),le+=1,o.reportStaticTest(I,"pass",void 0,R)}}async function ot(c,R,I,K={}){if(!c||typeof c!="object"||!("ref"in c))return c;let F;if(c.ref==="relative"){if(!c.relativeTarget||!K.relativeBaseSelector)return;let j=I.locator(K.relativeBaseSelector),_=await j.count(),N=0;if(c.relativeTarget==="first"?N=0:c.relativeTarget==="second"?N=1:c.relativeTarget==="last"?N=_-1:isNaN(Number(c.relativeTarget))?N=0:N=Number(c.relativeTarget),N<0||N>=_)return;let W=j.nth(N);return await at(W,c.property||c.attribute)}else{if(F=R[c.ref],!F)throw new Error(`Selector for ref '${c.ref}' not found in contract selectors.`);let j=I.locator(F).first();return await at(j,c.property||c.attribute)}}async function at(c,R){if(c)return!R||R==="id"?await c.getAttribute("id")??void 0:R==="class"?await c.getAttribute("class")??void 0:R==="textContent"?await c.evaluate(I=>I.textContent??void 0):R.startsWith("aria-")?await c.getAttribute(R)??void 0:R.endsWith("*")?await c.evaluate(K=>{let F=[];for(let j of Array.from(K.attributes))j.name.startsWith("aria-")&&F.push(`${j.name}=${j.value}`);return F.join(";")}):await c.getAttribute(R)??void 0}let nr=new Te(y,h.selectors,D);async function Fe(c,R,I,K,F,j=[]){if(!Array.isArray(c)||c.length===0)return{success:!0};I&&typeof I.resetState=="function"&&await I.resetState(K);for(let _ of c){let N={success:!0};try{if(_.type==="focus")_.target==="relative"&&_.relativeTarget?N=await R.focus("relative",_.relativeTarget):N=await R.focus(_.target);else if(_.type==="type"&&_.value)N=await R.type(_.target,_.value);else if(_.type==="click")N=await R.click(_.target,_.relativeTarget);else if(_.type==="keypress"&&_.key)N=await R.keypress(_.target,_.key,_.relativeTarget);else if(_.type==="hover")N=await R.hover(_.target,_.relativeTarget);else continue}catch(W){N={success:!1,error:W instanceof Error?W.message:String(W)}}if(!N.success){let W=N.error||"Setup action failed";return j.some(E=>F.includes(E)||W.includes(E))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${W}`}:{success:!1,error:W}}}return{success:!0}}for(let c of h.static||[]){if(d&&typeof d.resetState=="function")try{await d.resetState(y)}catch(M){L.push(`Warning: resetState failed before static test: ${M instanceof Error?M.message:String(M)}`)}if(c.target==="relative")continue;let R=`${c.target}${c.attribute?` (${c.attribute})`:""}`,I=be(c.level);if(t==="menu"&&c.target==="submenuTrigger"&&!q){let M=`Skipping submenu static assertion for ${c.target}: no submenu capability detected in rendered component.`;T.push(M),o.reportStaticTest(R,"skip",M,I);continue}let K=[];if(c.target||K.push("target"),c.attribute||K.push("attribute"),typeof c.expectedValue>"u"&&K.push("expectedValue"),K.length>0){let M=`${c.target||""}${c.attribute?` (${c.attribute})`:""}`,E=`Static assertion missing required field(s): ${K.join(", ")}`,U=V(E,c.level);U.status==="fail"&&(ee+=1),U.status==="warn"&&(te+=1),o.reportStaticTest(M,U.status,U.detail,U.level);continue}if(Array.isArray(c.setup)&&c.setup.length>0){let U=function(ue){return E.includes(ue)};var b=U;let M=new ve(y,h.selectors,C),E=["focus","type","click","keypress","hover"],oe=ue=>({...ue,type:U(ue.type)?ue.type:"click"}),P=c.setup.map(oe),re=await Fe(P,M,d,y,R,["submenu","submenuTrigger","submenuItems"]);if(re.skip){T.push(re.message||"Setup action skipped"),o.reportStaticTest(R,"skip",re.message,I);continue}if(!re.success){let ue=`Static setup failed: ${re.error}`,fe=V(ue,c.level);fe.status==="fail"&&(ee+=1),fe.status==="warn"&&(te+=1),o.reportStaticTest(R,fe.status,fe.detail,fe.level);continue}}let F=h.selectors[c.target];if(!F){let M=`Selector for target ${c.target} not found.`,E=V(M,c.level);E.status==="fail"&&(ee+=1),E.status==="warn"&&(te+=1),o.reportStaticTest(R,E.status,E.detail,E.level);continue}let j=y.locator(F).first();if(!(await j.count()>0)){let M=`Target ${c.target} not found.`,E=V(M,c.level);E.status==="fail"&&(ee+=1),E.status==="warn"&&(te+=1),o.reportStaticTest(R,E.status,E.detail,E.level);continue}let N=(M,E,U)=>{let oe=new RegExp(`\\[${E}(?:=["']?([^\\]"']+)["']?)?\\]`),P=M.match(oe);if(!P)return!1;if(!U)return!0;let re=P[1];return re?U.split(" | ").includes(re):!1},W=c.expectedValue;if(c.expectedValue&&typeof c.expectedValue=="object"&&"ref"in c.expectedValue){let M={},E=c.relativeTarget;if(c.expectedValue.ref==="relative"&&c.target==="relative"&&E){let U=h.selectors[E];if(!U)throw new Error(`Selector for relativeTarget '${E}' not found in contract selectors.`);M.relativeBaseSelector=U}else if(c.expectedValue.ref==="relative"&&E){let U=h.selectors[E];if(!U)throw new Error(`Selector for relativeTarget '${E}' not found in contract selectors.`);M.relativeBaseSelector=U}W=await ot(c.expectedValue,h.selectors,y,M)}if(c.expectedValue)if(N(F,c.attribute,typeof W=="string"?W:void 0))m.push(`${c.attribute}="${W}" on ${c.target} verified by selector (already present in: ${F}).`),le+=1,o.reportStaticTest(R,"pass",void 0,I);else{let M=W??"",E=await nr.validateAttribute(j,c.target,c.attribute,M,c.failureMessage,"Static ARIA Test");if(E.success&&E.passMessage)m.push(E.passMessage),le+=1,o.reportStaticTest(R,"pass",void 0,I);else if(!E.success&&E.failMessage){let U=V(E.failMessage,c.level);U.status==="fail"&&(ee+=1),U.status==="warn"&&(te+=1),o.reportStaticTest(R,U.status,U.detail,U.level)}}else{let M=c.attribute.split(" | "),E=!1,U=!0;for(let oe of M){let P=oe.trim();if(N(F,P)){m.push(`${P} on ${c.target} verified by selector (already present in: ${F}).`),E=!0;continue}if(U=!1,await j.getAttribute(P)!==null){E=!0;break}}if(!E&&!U){let oe=c.failureMessage+` None of the attributes "${c.attribute}" are present.`,P=V(oe,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(R,P.status,P.detail,P.level)}else!U&&E?(m.push(`At least one of the attributes "${c.attribute}" exists on the element.`),le+=1,o.reportStaticTest(R,"pass",void 0,I)):(le+=1,o.reportStaticTest(R,"pass",void 0,I))}}for(let c of h.dynamic||[]){if(!c.assertions||c.assertions.length===0){let H="Skipping test - no assertions found for this dynamic test.";T.push(H),o.reportTest({description:c.description,level:be(c.level)},"skip",H);continue}if(!y||y.isClosed()){console.warn(`
|
|
37
|
+
\u26A0\uFE0F Browser closed - skipping remaining ${h.dynamic.length-h.dynamic.indexOf(c)} tests
|
|
38
|
+
`),x.push(`CRITICAL: Browser/page closed before completing all tests. ${h.dynamic.length-h.dynamic.indexOf(c)} tests skipped.`);break}try{await d.resetState(y)}catch(H){let X=H instanceof Error?H.message:String(H);throw o.error(X),H}let{setup:R=[],action:I,assertions:K}=c,F=be(c.level),j=new ve(y,h.selectors,C);if(Array.isArray(R)&&R.length>0){let X=function(ce){return H.includes(ce)};var b=X;let H=["focus","type","click","keypress","hover"],ge=ce=>({...ce,type:X(ce.type)?ce.type:"click"}),qe=R.map(ge),pe=await Fe(qe,j,d,y,c.description,["submenu","submenuTrigger","submenuItems"]);if(pe.skip){T.push(pe.message||"Setup action skipped"),o.reportTest({description:c.description,level:F},"skip",pe.message);continue}if(!pe.success){let ce=V(`Setup failed: ${pe.error}`,c.level);o.reportTest({description:c.description,level:F},ce.status,ce.detail);continue}}let _=x.length,N=L.length,W=T.length;if(await d.shouldSkipTest(c,y)){let H="Skipping test - component-specific conditions not met";T.push(H),o.reportTest({description:c.description,level:F},"skip",H);continue}let E=new Te(y,h.selectors,D),U=!1,oe=null;for(let H of I){if(!y||y.isClosed()){x.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),U=!0;break}let X;if(H.type==="focus")H.target==="relative"&&H.relativeTarget?X=await j.focus("relative",H.relativeTarget):X=await j.focus(H.target);else if(H.type==="type"&&H.value)X=await j.type(H.target,H.value);else if(H.type==="click")X=await j.click(H.target,H.relativeTarget);else if(H.type==="keypress"&&H.key)X=await j.keypress(H.target,H.key,H.relativeTarget);else if(H.type==="hover")X=await j.hover(H.target,H.relativeTarget);else continue;if(!X.success){if(X.error){let ge=V(X.error,c.level);oe={status:ge.status,detail:ge.detail}}U=!0;break}}if(U){o.reportTest({description:c.description,level:F},oe?.status||"fail",oe?.detail||x[x.length-1]);continue}let P=!1,re="";for(let H of K){let X;if(H.expectedValue&&typeof H.expectedValue=="object"&&"ref"in H.expectedValue)if(H.expectedValue.ref==="relative"){let{RelativeTargetResolver:ir}=await Promise.resolve().then(()=>(Ie(),zt)),ce=h.selectors.relative;if(!ce)throw new Error("Relative selector not defined in contract selectors.");let lt=H.relativeTarget||"first",Oe=await ir.resolve(y,ce,lt);if(!Oe)throw new Error(`Could not resolve relative target '${lt}' for expectedValue.`);let ut=H.expectedValue.property||H.expectedValue.attribute||"id";if(ut==="textContent")X=await Oe.evaluate(ke=>ke.textContent??void 0);else{let ke=await Oe.getAttribute(ut);X=ke===null?void 0:ke}}else X=await ot(H.expectedValue,h.selectors,y,{});else typeof H.expectedValue=="string"||typeof H.expectedValue>"u"?X=H.expectedValue:X="";let ge={...H,expectedValue:X},qe=X??"",pe=await E.validate({...ge,expectedValue:qe},c.description);ie(pe)?m.push(pe.passMessage):(P=!0,re=pe.failMessage||"Assertion failed.")}if(P){o.reportTest({description:c.description,level:F},"fail",re);continue}let ct=x.length,ue=L.length,fe=T.length;ct>_?o.reportTest({description:c.description,level:F},"fail",x[x.length-1]):ue>N?o.reportTest({description:c.description,level:F},"warn",L[L.length-1]):fe>W?o.reportTest({description:c.description,level:F},"skip",T[T.length-1]):o.reportTest({description:c.description,level:F},"pass")}o.reportStatic(le,ee,te),o.summary(x)}catch(d){if(d instanceof Error)throw d.message.includes("Executable doesn't exist")||d.message.includes("browserType.launch")?new Error(`
|
|
39
39
|
\u274C CRITICAL: Playwright browsers not found!
|
|
40
|
-
\u{1F4E6} Run: npx playwright install chromium`):
|
|
40
|
+
\u{1F4E6} Run: npx playwright install chromium`):d.message.includes("net::ERR_CONNECTION_REFUSED")||d.message.includes("NS_ERROR_CONNECTION_REFUSED")?new Error(`
|
|
41
41
|
\u274C CRITICAL: Cannot connect to dev server!
|
|
42
|
-
Make sure your dev server is running at ${e}`):
|
|
42
|
+
Make sure your dev server is running at ${e}`):d.message.includes("Timeout")&&d.message.includes("waitFor")?new Error(`
|
|
43
43
|
\u274C CRITICAL: Component not found on page!
|
|
44
44
|
The component selector could not be found within ${G}ms.
|
|
45
45
|
This usually means:
|
|
46
46
|
- The component didn't render
|
|
47
47
|
- The URL is incorrect
|
|
48
48
|
- The component selector was not provided to the component utility, or a wrong selector was used
|
|
49
|
-
`):
|
|
49
|
+
`):d.message.includes("Target page, context or browser has been closed")?new Error(`
|
|
50
50
|
\u274C CRITICAL: Browser/page was closed unexpectedly!
|
|
51
51
|
This usually means:
|
|
52
52
|
- The test timeout was too short
|
|
53
53
|
- The browser crashed
|
|
54
|
-
- An external process killed the browser`):
|
|
55
|
-
\u{1F3C5} Show your accessibility commitment!`)),console.log(
|
|
56
|
-
`)),console.log(
|
|
54
|
+
- An external process killed the browser`):d}finally{y&&await y.close()}return{passes:m,failures:x,skipped:T,warnings:L}}var De,Be,bs,Yt=Q(()=>{"use strict";De=require("fs"),Be=ne(require("path"),1);Ke();Kt();Wt();Jt();Gt();We();bs={}});var er={};se(er,{BADGE_CONFIGS:()=>st,displayAllBadges:()=>Ts,displayBadgeInfo:()=>vs,getBadgeMarkdown:()=>ye,promptAddBadge:()=>ys});function ye(t){let e=st[t];return`[](https://github.com/aria-ease/aria-ease)`}function vs(t){let e=ye(t);console.log(Z.default.cyan(`
|
|
55
|
+
\u{1F3C5} Show your accessibility commitment!`)),console.log(Z.default.white(` Add this badge to your README.md:
|
|
56
|
+
`)),console.log(Z.default.green(" "+e)),console.log(Z.default.dim(`
|
|
57
57
|
This helps others discover accessibility tools and shows you care!
|
|
58
|
-
`))}async function
|
|
59
|
-
`),
|
|
60
|
-
`),"utf-8")}function
|
|
61
|
-
\u{1F4CD} Available badges:`)),console.log(
|
|
62
|
-
For audits:`)),console.log(
|
|
63
|
-
For component testing:`)),console.log(
|
|
64
|
-
For both (verified):`)),console.log(Q.default.green(" "+ye("verified"))),console.log("")}var qe,Wt,Q,zt,tt,Xt=Y(()=>{"use strict";qe=ne(require("fs-extra"),1),Wt=ne(require("path"),1),Q=ne(require("chalk"),1),zt=ne(require("readline"),1),tt={audit:{type:"audit",fileName:"audited-by-aria-ease.svg",label:"Audited by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/audited-by-aria-ease.svg"},component:{type:"component",fileName:"components-tested-aria-ease.svg",label:"Components tested: aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/components-tested-aria-ease.svg"},verified:{type:"verified",fileName:"verified-by-aria-ease.svg",label:"Verified by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/verified-by-aria-ease.svg"}}});var os={};oe(os,{cleanupTests:()=>st,createContract:()=>Wr,makeAccordionAccessible:()=>ir,makeBlockAccessible:()=>cr,makeCheckboxAccessible:()=>lr,makeComboboxAccessible:()=>fr,makeMenuAccessible:()=>ut,makeRadioAccessible:()=>ur,makeTabsAccessible:()=>dr,makeToggleAccessible:()=>pr,testUiComponent:()=>rt});module.exports=nr(os);function ir({accordionId:t,triggersClass:e,panelsClass:r,allowMultipleOpen:s=!1,callback:n}){if(t==="")return console.error("[aria-ease] 'accordionId' should not be an empty string. Provide an id to the accordion container element that exists before calling makeAccordionAccessible."),{cleanup:()=>{}};let i=document.querySelector(`#${t}`);if(!i)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'triggersClass' should not be an empty string. Provide a class name that exists on the accordion trigger elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let a=Array.from(i.querySelectorAll(`.${e}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(r==="")return console.error("[aria-ease] 'panelsClass' should not be an empty string. Provide a class name that exists on the accordion panel elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let o=Array.from(i.querySelectorAll(`.${r}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${r}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(a.length!==o.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${a.length} triggers but ${o.length} panels.`),{cleanup:()=>{}};let l=new WeakMap,u=new WeakMap;function f(){a.forEach((h,k)=>{let F=o[k];h.id||(h.id=`${t}-trigger-${k}`),F.id||(F.id=`${t}-panel-${k}`),h.setAttribute("aria-controls",F.id),h.setAttribute("aria-expanded","false"),(!s||a.length<=6)&&F.setAttribute("role","region"),F.setAttribute("aria-labelledby",h.id),F.style.display="none"})}function y(h){if(h<0||h>=a.length){console.error(`[aria-ease] Invalid accordion index: ${h}`);return}let k=a[h],F=o[h];if(k.setAttribute("aria-expanded","true"),F.style.display="block",n?.onExpand)try{n.onExpand(h)}catch(w){console.error("[aria-ease] Error in accordion onExpand callback:",w)}}function T(h){if(h<0||h>=a.length){console.error(`[aria-ease] Invalid accordion index: ${h}`);return}let k=a[h],F=o[h];if(k.setAttribute("aria-expanded","false"),F.style.display="none",n?.onCollapse)try{n.onCollapse(h)}catch(w){console.error("[aria-ease] Error in accordion onCollapse callback:",w)}}function H(h){a[h].getAttribute("aria-expanded")==="true"?T(h):(s||a.forEach((w,x)=>{x!==h&&T(x)}),y(h))}function q(h){return()=>{H(h)}}function U(h){return k=>{let{key:F}=k;switch(F){case"Enter":case" ":k.preventDefault(),H(h);break;case"ArrowDown":k.preventDefault();{let w=(h+1)%a.length;a[w].focus()}break;case"ArrowUp":k.preventDefault();{let w=(h-1+a.length)%a.length;a[w].focus()}break;case"Home":k.preventDefault(),a[0].focus();break;case"End":k.preventDefault(),a[a.length-1].focus();break}}}function G(){a.forEach((h,k)=>{let F=q(k),w=U(k);h.addEventListener("click",F),h.addEventListener("keydown",w),l.set(h,w),u.set(h,F)})}function g(){a.forEach(h=>{let k=l.get(h),F=u.get(h);k&&(h.removeEventListener("keydown",k),l.delete(h)),F&&(h.removeEventListener("click",F),u.delete(h))})}function d(){g(),a.forEach((h,k)=>{T(k)})}function C(){g();let h=Array.from(i.querySelectorAll(`.${e}`)),k=Array.from(i.querySelectorAll(`.${r}`));a.length=0,a.push(...h),o.length=0,o.push(...k),f(),G()}return f(),G(),{expandItem:y,collapseItem:T,toggleItem:H,cleanup:d,refresh:C}}function Me(t){if(t.tagName!=="INPUT")return!1;let e=t.type;return["text","email","password","tel","number"].includes(e)}function xe(t){return t.tagName==="TEXTAREA"}function ct(t){return t.tagName==="BUTTON"||t.tagName==="INPUT"&&["button","submit","reset"].includes(t.type)}function or(t){return t.tagName==="A"}function Ce(t,e,r){let s=t.length,n=(e+r+s)%s;t.item(n).focus()}function ar(t){return t.getAttribute("data-custom-click")!==null&&t.getAttribute("data-custom-click")!==void 0}function lt(t,e,r){let s=e.item(r);switch(t.key){case"ArrowUp":case"ArrowLeft":{(!Me(s)&&!xe(s)||(Me(s)||xe(s))&&s.selectionStart===0)&&(t.preventDefault(),Ce(e,r,-1));break}case"ArrowDown":case"ArrowRight":{if(!Me(s)&&!xe(s))t.preventDefault(),Ce(e,r,1);else if(Me(s)||xe(s)){let n=s.value;s.selectionStart===n.length&&(t.preventDefault(),Ce(e,r,1))}break}case"Escape":{t.preventDefault();break}case"Enter":case" ":{(!ct(s)&&!or(s)&&ar(s)||ct(s))&&(t.preventDefault(),s.click());break}case"Tab":break;default:break}}function cr({blockId:t,blockItemsClass:e}){if(t==="")return console.error("[aria-ease] 'blockId' should not be an empty string. Provide an id to the block container element that exists before calling makeBlockAccessible."),{cleanup:()=>{}};let r=document.querySelector(`#${t}`);if(!r)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'blockItemsClass' should not be an empty string. Provide a class name that exists on the block item elements before calling makeBlockAccessible."),{cleanup:()=>{}};let s=null;function n(){return s||(s=r.querySelectorAll(`.${e}`)),s}let i=n();if(!i||i.length===0)return console.error(`[aria-ease] Element with class="${e}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let a=new Map;i.forEach(u=>{if(!a.has(u)){let f=y=>{let T=r.querySelectorAll(`.${e}`),H=Array.prototype.indexOf.call(T,u);lt(y,T,H)};u.addEventListener("keydown",f),a.set(u,f)}});function o(){i.forEach(u=>{let f=a.get(u);f&&(u.removeEventListener("keydown",f),a.delete(u))})}function l(){s=null}return{cleanup:o,refresh:l}}function lr({checkboxGroupId:t,checkboxesClass:e,callback:r}){if(t==="")return console.error("[aria-ease] 'checkboxGroupId' should not be an empty string. Provide an id to the checkbox group container element that exists before calling makeCheckboxAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${t}`);if(!s)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let n=Array.from(s.querySelectorAll(`.${e}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let i=new WeakMap,a=new WeakMap;function o(){s.getAttribute("role")||s.setAttribute("role","group"),n.forEach(d=>{d.setAttribute("role","checkbox"),d.hasAttribute("aria-checked")||d.setAttribute("aria-checked","false"),d.hasAttribute("tabindex")||d.setAttribute("tabindex","0")})}function l(d,C){if(r?.onCheck)try{r.onCheck(d,C)}catch(h){console.error("[aria-ease] Error in checkbox onCheck callback:",h)}}function u(d){if(d<0||d>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${d}`);return}let C=n[d],h=C.getAttribute("aria-checked")==="true";C.setAttribute("aria-checked",h?"false":"true"),l(d,h)}function f(d,C){if(d<0||d>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${d}`);return}n[d].setAttribute("aria-checked",C?"true":"false"),l(d,C)}function y(d){return()=>{u(d)}}function T(d){return C=>{let{key:h}=C;switch(h){case" ":C.preventDefault(),u(d);break}}}function H(){n.forEach((d,C)=>{let h=y(C),k=T(C);d.addEventListener("click",h),d.addEventListener("keydown",k),i.set(d,k),a.set(d,h)})}function q(){n.forEach(d=>{let C=i.get(d),h=a.get(d);C&&(d.removeEventListener("keydown",C),i.delete(d)),h&&(d.removeEventListener("click",h),a.delete(d))})}function U(){q()}function G(){return n.map(d=>d.getAttribute("aria-checked")==="true")}function g(){return n.map((d,C)=>d.getAttribute("aria-checked")==="true"?C:-1).filter(d=>d!==-1)}return o(),H(),{toggleCheckbox:u,setCheckboxState:f,getCheckedStates:G,getCheckedIndices:g,cleanup:U}}function ut({menuId:t,menuItemsClass:e,triggerId:r,callback:s}){if(t==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let n=document.querySelector(`#${t}`);if(!n)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(r==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let i=document.querySelector(`#${r}`);if(!i)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'menuItemsClass' should not be an empty string. Provide a class name to at least a menu item that exists before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(t))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-controls",t),i.setAttribute("aria-expanded","false"),n.setAttribute("role","menu"),n.setAttribute("aria-labelledby",r);let a=new WeakMap,o=new Map,l=null,u=null;function f(){return l||(l=n.querySelectorAll(`.${e}`)),l}function y(){if(!u){let p=f();u=[];for(let v=0;v<p.length;v++){let $=p.item(v),B=C($),X=$.getAttribute("aria-disabled")==="true";B||($.hasAttribute("tabindex")||$.setAttribute("tabindex","-1"),X||u.push($))}}return u}function T(p){return{length:p.length,item:$=>p[$],forEach:$=>{p.forEach($)},[Symbol.iterator]:function*(){for(let $ of p)yield $}}}function H(){f().forEach(v=>{v.setAttribute("role","menuitem");let $=v.getAttribute("data-submenu-id")??v.getAttribute("aria-controls"),B=v.hasAttribute("aria-haspopup")&&$;$&&(v.hasAttribute("data-submenu-id")||B)&&(v.setAttribute("aria-haspopup","menu"),v.setAttribute("aria-controls",$),v.hasAttribute("aria-expanded")||v.setAttribute("aria-expanded","false"))})}function q(p,v,$){let B=p.length,X=(v+$+B)%B;p.item(X).focus()}function U(p,v){p.length!==0&&p[v]?.focus()}function G(p){return p.hasAttribute("aria-controls")&&p.hasAttribute("aria-haspopup")&&p.getAttribute("role")==="menuitem"}function g(p){let v=p;for(;v&&v.getAttribute("role")==="menuitem";){let $=v.closest('[role="menu"]');if(!$)break;$.style.display="none",v.setAttribute("aria-expanded","false");let B=$.getAttribute("aria-labelledby");if(!B)break;let X=document.getElementById(B);if(!X)break;v=X}}H();function d(p,v,$){switch(p.key){case"ArrowLeft":{if(p.key==="ArrowLeft"&&i.getAttribute("role")==="menuitem"){p.preventDefault(),m();return}break}case"ArrowUp":{p.preventDefault(),q(T(y()),$,-1);break}case"ArrowRight":{if(p.key==="ArrowRight"&&G(v)){p.preventDefault();let B=v.getAttribute("aria-controls");if(B){k(B);return}}break}case"ArrowDown":{p.preventDefault(),q(T(y()),$,1);break}case"Home":{p.preventDefault(),U(y(),0);break}case"End":{p.preventDefault();let B=y();U(B,B.length-1);break}case"Escape":{p.preventDefault(),m(),i.focus(),F&&F(!1);break}case"Enter":case" ":{if(p.preventDefault(),G(v)){let B=v.getAttribute("aria-controls");if(B){k(B);return}}v.click(),m(),F&&F(!1);break}case"Tab":{m(),g(i),F&&F(!1);break}default:break}}function C(p){let v=p.parentElement;for(;v&&v!==n;){if(v.getAttribute("role")==="menu"||v.id&&n.querySelector(`[aria-controls="${v.id}"]`))return!0;v=v.parentElement}return!1}function h(p){i.setAttribute("aria-expanded",p?"true":"false")}function k(p){let v=o.get(p);if(!v){let $=n.querySelector(`[aria-controls="${p}"]`);if(!$){console.error(`[aria-ease] Submenu trigger with aria-controls="${p}" not found in menu "${t}".`);return}if(!$.id){let X=`trigger-${p}`;$.id=X,console.warn(`[aria-ease] Submenu trigger for "${p}" had no ID. Auto-generated ID: "${X}".`)}if(!document.querySelector(`#${p}`)){console.error(`[aria-ease] Submenu element with id="${p}" not found. Cannot create submenu instance.`);return}v=ut({menuId:p,menuItemsClass:e,triggerId:$.id,callback:s}),o.set(p,v)}v.openMenu()}function F(p){if(s?.onOpenChange)try{s.onOpenChange(p)}catch(v){console.error("[aria-ease] Error in menu onOpenChange callback:",v)}}function w(){y().forEach((v,$)=>{if(!a.has(v)){let B=X=>d(X,v,$);v.addEventListener("keydown",B),a.set(v,B)}})}function x(){y().forEach(v=>{let $=a.get(v);$&&(v.removeEventListener("keydown",$),a.delete(v))})}function L(){h(!0),n.style.display="block";let p=y();if(w(),p&&p.length>0&&p[0].focus(),s?.onOpenChange)try{s.onOpenChange(!0)}catch(v){console.error("[aria-ease] Error in menu onOpenChange callback:",v)}}function m(){if(o.forEach(p=>p.closeMenu()),h(!1),n.style.display="none",x(),i.focus(),s?.onOpenChange)try{s.onOpenChange(!1)}catch(p){console.error("[aria-ease] Error in menu onOpenChange callback:",p)}}function A(){i.getAttribute("aria-expanded")==="true"?m():L()}function b(p){if(!(i.getAttribute("aria-expanded")==="true"))return;let $=i.contains(p.target),B=n.contains(p.target);!$&&!B&&m()}i.addEventListener("click",A),document.addEventListener("click",b);function D(){x(),i.removeEventListener("click",A),document.removeEventListener("click",b),n.style.display="none",h(!1),o.forEach(p=>p.cleanup()),o.clear()}function Z(){l=null,u=null}return{openMenu:L,closeMenu:m,cleanup:D,refresh:Z}}function ur({radioGroupId:t,radiosClass:e,defaultSelectedIndex:r,callback:s}){if(t==="")return console.error("[aria-ease] 'radioGroupId' should not be an empty string. Provide an id to the radio group container element that exists before calling makeRadioAccessible."),{cleanup:()=>{}};let n=document.querySelector(`#${t}`);if(!n)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'radiosClass' should not be an empty string. Provide a class name that exists on the radio button elements before calling makeRadioAccessible."),{cleanup:()=>{}};let i=Array.from(n.querySelectorAll(`.${e}`));if(i.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let a=new WeakMap,o=new WeakMap,l;r&&(l=r);function u(){n.getAttribute("role")||n.setAttribute("role","radiogroup"),i.forEach((g,d)=>{g.setAttribute("role","radio"),g.setAttribute("tabindex","0"),d===l?g.setAttribute("aria-checked","true"):g.setAttribute("aria-checked","false")})}function f(g){if(g<0||g>=i.length){console.error(`[aria-ease] Invalid radio index: ${g}`);return}if(l>=0&&l<i.length&&i[l].setAttribute("aria-checked","false"),i[g].setAttribute("aria-checked","true"),i[g].focus(),s?.onCheck)try{s.onCheck(g)}catch(d){console.error("[aria-ease] Error in radio onCheck callback:",d)}l=g}function y(g){return()=>{f(g)}}function T(g){return d=>{let{key:C}=d,h=g;switch(C){case"ArrowDown":case"ArrowRight":d.preventDefault(),h=(g+1)%i.length,f(h);break;case"ArrowUp":case"ArrowLeft":d.preventDefault(),h=(g-1+i.length)%i.length,f(h);break;case" ":case"Enter":d.preventDefault(),f(g);break}}}function H(){i.forEach((g,d)=>{let C=y(d),h=T(d);g.addEventListener("click",C),g.addEventListener("keydown",h),a.set(g,h),o.set(g,C)})}function q(){i.forEach(g=>{let d=a.get(g),C=o.get(g);d&&(g.removeEventListener("keydown",d),a.delete(g)),C&&(g.removeEventListener("click",C),o.delete(g))})}function U(){q()}function G(){return l}return u(),H(),{selectRadio:f,getSelectedIndex:G,cleanup:U}}function pr({toggleId:t,togglesClass:e,isSingleToggle:r=!0}){if(t==="")return console.error("[aria-ease] 'toggleId' should not be an empty string. Provide an id to the toggle element or toggle container before calling makeToggleAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${t}`);if(!s)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let n;if(r)n=[s];else{if(!e)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(n=Array.from(s.querySelectorAll(`.${e}`)),n.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let i=new WeakMap,a=new WeakMap;function o(){n.forEach(g=>{g.tagName.toLowerCase()!=="button"&&!g.getAttribute("role")&&g.setAttribute("role","button"),g.hasAttribute("aria-pressed")||g.setAttribute("aria-pressed","false"),g.hasAttribute("tabindex")||g.setAttribute("tabindex","0")})}function l(g){if(g<0||g>=n.length){console.error(`[aria-ease] Invalid toggle index: ${g}`);return}let d=n[g],C=d.getAttribute("aria-pressed")==="true";d.setAttribute("aria-pressed",C?"false":"true")}function u(g,d){if(g<0||g>=n.length){console.error(`[aria-ease] Invalid toggle index: ${g}`);return}n[g].setAttribute("aria-pressed",d?"true":"false")}function f(g){return()=>{l(g)}}function y(g){return d=>{let{key:C}=d;switch(C){case"Enter":case" ":d.preventDefault(),l(g);break}}}function T(){n.forEach((g,d)=>{let C=f(d),h=y(d);g.addEventListener("click",C),g.addEventListener("keydown",h),i.set(g,h),a.set(g,C)})}function H(){n.forEach(g=>{let d=i.get(g),C=a.get(g);d&&(g.removeEventListener("keydown",d),i.delete(g)),C&&(g.removeEventListener("click",C),a.delete(g))})}function q(){H()}function U(){return n.map(g=>g.getAttribute("aria-pressed")==="true")}function G(){return n.map((g,d)=>g.getAttribute("aria-pressed")==="true"?d:-1).filter(g=>g!==-1)}return o(),T(),{toggleButton:l,setPressed:u,getPressedStates:U,getPressedIndices:G,cleanup:q}}function fr({comboboxInputId:t,comboboxButtonId:e,listBoxId:r,listBoxItemsClass:s,callback:n}){if(t==="")return console.error("[aria-ease] 'comboboxInputId' should not be an empty string. Provide an id to the combobox input element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let i=document.getElementById(`${t}`);if(!i)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(r==="")return console.error("[aria-ease] 'listBoxId' should not be an empty string. Provide an id to the combobox listbox element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let a=document.getElementById(`${r}`);if(!a)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(s==="")return console.error("[aria-ease] 'listboxItemsClass' class should not be an empty string. Provide a class name to at least a listbox option that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};if(!document.querySelectorAll(s))return console.error(`[aria-ease] Listbox option(s) with class="${s}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let l=e?document.getElementById(`${e}`):null,u=-1;i.setAttribute("role","combobox"),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-controls",r),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-haspopup","listbox"),a.setAttribute("role","listbox");let f=null;function y(){return f||(f=a.querySelectorAll(`.${s}`)),Array.from(f).filter(m=>!m.hidden&&m.style.display!=="none")}function T(){return i.getAttribute("aria-expanded")==="true"}function H(m){let A=y();if(m>=0&&m<A.length){let b=A[m],D=b.id||`${r}-option-${m}`;if(b.id||(b.id=D),i.setAttribute("aria-activedescendant",D),typeof b.scrollIntoView=="function"&&b.scrollIntoView({block:"nearest",behavior:"smooth"}),n?.onActiveDescendantChange)try{n.onActiveDescendantChange(D,b)}catch(Z){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",Z)}}else i.setAttribute("aria-activedescendant","");u=m}function q(){if(i.setAttribute("aria-expanded","true"),a.style.display="block",n?.onOpenChange)try{n.onOpenChange(!0)}catch(m){console.error("[aria-ease] Error in combobox onOpenChange callback:",m)}}function U(){if(i.setAttribute("aria-expanded","false"),i.setAttribute("aria-activedescendant",""),a.style.display="none",u=-1,n?.onOpenChange)try{n.onOpenChange(!1)}catch(m){console.error("[aria-ease] Error in combobox onOpenChange callback:",m)}}function G(m){let A=m.textContent?.trim()||"";if(i.value=A,m.setAttribute("aria-selected","true"),U(),n?.onSelect)try{n.onSelect(m)}catch(b){console.error("[aria-ease] Error in combobox onSelect callback:",b)}}function g(m){let A=y(),b=T();switch(m.key){case"ArrowDown":if(m.preventDefault(),!b){q();return}if(A.length===0)return;{let D=u>=A.length-1?0:u+1;H(D)}break;case"ArrowUp":if(m.preventDefault(),!b)return;if(A.length>0){let D=u<=0?A.length-1:u-1;H(D)}break;case"Enter":b&&u>=0&&u<A.length&&(m.preventDefault(),G(A[u]));break;case"Escape":if(b)m.preventDefault(),U();else if(i.value&&(m.preventDefault(),i.value="",i.setAttribute("aria-activedescendant",""),y().forEach(Z=>{Z.getAttribute("aria-selected")==="true"&&Z.setAttribute("aria-selected","false")}),n?.onClear))try{n.onClear()}catch(Z){console.error("[aria-ease] Error in combobox onClear callback:",Z)}break;case"Home":b&&A.length>0&&(m.preventDefault(),H(0));break;case"End":b&&A.length>0&&(m.preventDefault(),H(A.length-1));break;case"Tab":b&&u>=0&&u<A.length&&G(A[u]),b&&U();break}}function d(m){let A=m.target;if(A.classList.contains(s)){let D=y().indexOf(A);D>=0&&H(D)}}function C(m){let A=m.target;A.classList.contains(s)&&(m.preventDefault(),G(A))}function h(m){let A=m.target;!i.contains(A)&&!a.contains(A)&&(!l||!l.contains(A))&&U()}function k(){T()?U():(q(),i.focus())}function F(m){(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),k())}i.addEventListener("keydown",g),a.addEventListener("mousemove",d),a.addEventListener("mousedown",C),document.addEventListener("mousedown",h),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",k),l.addEventListener("keydown",F));function w(){let m=a.querySelectorAll(`.${s}`);if(m.length===0)return;let A=null;for(let b of m)if(b.getAttribute("aria-selected")==="true"){A=b.textContent?.trim()||null;break}!A&&i.value&&(A=i.value.trim()),m.forEach((b,D)=>{b.setAttribute("role","option");let Z=b.textContent?.trim()||"";A&&Z===A?b.setAttribute("aria-selected","true"):b.setAttribute("aria-selected","false");let p=b.getAttribute("id");if(!p||p===""){let v=`${r}-option-${D}`;b.id=v,b.setAttribute("id",v)}})}w();function x(){i.removeEventListener("keydown",g),a.removeEventListener("mousemove",d),a.removeEventListener("mousedown",C),document.removeEventListener("mousedown",h),l&&(l.removeEventListener("click",k),l.removeEventListener("keydown",F))}function L(){f=null,w(),u=-1,H(-1)}return{cleanup:x,refresh:L,openListbox:q,closeListbox:U}}function dr({tabListId:t,tabsClass:e,tabPanelsClass:r,orientation:s="horizontal",activateOnFocus:n=!0,callback:i}){if(t==="")return console.error("[aria-ease] 'tabListId' should not be an empty string. Provide an id to the tab list container element that exists before calling makeTabsAccessible."),{cleanup:()=>{}};let a=document.querySelector(`#${t}`);if(!a)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'tabsClass' should not be an empty string. Provide a class name that exists on the tab button elements before calling makeTabsAccessible."),{cleanup:()=>{}};let o=Array.from(a.querySelectorAll(`.${e}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(r==="")return console.error("[aria-ease] 'tabPanelsClass' should not be an empty string. Provide a class name that exists on the tab panel elements before calling makeTabsAccessible."),{cleanup:()=>{}};let l=Array.from(document.querySelectorAll(`.${r}`));if(l.length===0)return console.error(`[aria-ease] No elements with class="${r}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(o.length!==l.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${o.length} tabs but ${l.length} panels.`),{cleanup:()=>{}};let u=new WeakMap,f=new WeakMap,y=new WeakMap,T=0;function H(){a.setAttribute("role","tablist"),a.setAttribute("aria-orientation",s),o.forEach((w,x)=>{let L=l[x];w.id||(w.id=`${t}-tab-${x}`),L.id||(L.id=`${t}-panel-${x}`),w.setAttribute("role","tab"),w.setAttribute("aria-controls",L.id),w.setAttribute("aria-selected","false"),w.setAttribute("tabindex","-1"),L.setAttribute("role","tabpanel"),L.setAttribute("aria-labelledby",w.id),L.hidden=!0,L.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||L.setAttribute("tabindex","0")}),q(0,!1)}function q(w,x=!0){if(w<0||w>=o.length){console.error(`[aria-ease] Invalid tab index: ${w}`);return}let L=T;o.forEach((b,D)=>{let Z=l[D];b.setAttribute("aria-selected","false"),b.setAttribute("tabindex","-1"),Z.hidden=!0});let m=o[w],A=l[w];if(m.setAttribute("aria-selected","true"),m.setAttribute("tabindex","0"),A.hidden=!1,x&&m.focus(),T=w,i?.onTabChange&&L!==w)try{i.onTabChange(w,L)}catch(b){console.error("[aria-ease] Error in tabs onTabChange callback:",b)}}function U(w){let x=o.findIndex(A=>A===document.activeElement),L=x!==-1?x:T,m=L;switch(w){case"first":m=0;break;case"last":m=o.length-1;break;case"next":m=(L+1)%o.length;break;case"prev":m=(L-1+o.length)%o.length;break}if(o[m].focus(),o[m].setAttribute("tabindex","0"),o[T].setAttribute("tabindex","-1"),n)q(m,!1);else{let A=T;o.forEach((b,D)=>{D===m?b.setAttribute("tabindex","0"):D!==A&&b.setAttribute("tabindex","-1")})}}function G(w){return()=>{q(w)}}function g(w){return x=>{let{key:L}=x,m=!1;if(s==="horizontal")switch(L){case"ArrowLeft":x.preventDefault(),U("prev"),m=!0;break;case"ArrowRight":x.preventDefault(),U("next"),m=!0;break}else switch(L){case"ArrowUp":x.preventDefault(),U("prev"),m=!0;break;case"ArrowDown":x.preventDefault(),U("next"),m=!0;break}if(!m)switch(L){case"Home":x.preventDefault(),U("first");break;case"End":x.preventDefault(),U("last");break;case" ":case"Enter":n||(x.preventDefault(),q(w));break;case"F10":if(x.shiftKey&&i?.onContextMenu){x.preventDefault();try{i.onContextMenu(w,o[w])}catch(A){console.error("[aria-ease] Error in tabs onContextMenu callback:",A)}}break}}}function d(w){return x=>{if(i?.onContextMenu){x.preventDefault();try{i.onContextMenu(w,o[w])}catch(L){console.error("[aria-ease] Error in tabs onContextMenu callback:",L)}}}}function C(){o.forEach((w,x)=>{let L=G(x),m=g(x),A=d(x);w.addEventListener("click",L),w.addEventListener("keydown",m),i?.onContextMenu&&(w.addEventListener("contextmenu",A),y.set(w,A)),u.set(w,m),f.set(w,L)})}function h(){o.forEach(w=>{let x=u.get(w),L=f.get(w),m=y.get(w);x&&(w.removeEventListener("keydown",x),u.delete(w)),L&&(w.removeEventListener("click",L),f.delete(w)),m&&(w.removeEventListener("contextmenu",m),y.delete(w))})}function k(){h(),o.forEach((w,x)=>{let L=l[x];w.removeAttribute("role"),w.removeAttribute("aria-selected"),w.removeAttribute("aria-controls"),w.removeAttribute("tabindex"),L.removeAttribute("role"),L.removeAttribute("aria-labelledby"),L.removeAttribute("tabindex"),L.hidden=!1}),a.removeAttribute("role"),a.removeAttribute("aria-orientation")}function F(){h();let w=Array.from(a.querySelectorAll(`.${e}`)),x=Array.from(document.querySelectorAll(`.${r}`));o.length=0,o.push(...w),l.length=0,l.push(...x),H(),C()}return H(),C(),{activateTab:q,cleanup:k,refresh:F}}function ae(t,e){return e==="first"?`first ${t}`:e==="last"?`last ${t}`:e==="next"?`next ${t}`:e==="previous"?`previous ${t}`:typeof e=="number"?`${t} at index ${e}`:`${e} ${t}`}var ft={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:gr},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...mr(),...pt()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:vr},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:wr},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:kr},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:Tr},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(t={})=>typeof t.relativeTarget=="number"?Array.from({length:t.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):t.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:t.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(t={})=>hr(t.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:br},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:pt},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(t={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTarget:t.relativeTarget}]},{when:["pointer"],steps:(t={})=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>yr(t.relativeTarget)}};function gr(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function mr(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function hr(t){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:t,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function br(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function pt(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function yr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${ae("option",t)} to have aria-selected='true'.`}]}function vr(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function wr(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function kr(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function Tr(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var dt={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:Ar},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Er},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:Sr},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Mr},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(t={})=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>xr(t.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:Cr},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:$r},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Lr},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Rr},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(t={})=>{let e=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof t.relativeTarget=="number"&&(e=e.concat(Array.from({length:t.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),t.relativeTarget==="first"&&(e=e.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),t.relativeTarget==="last"&&(e=e.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),e}},{when:["pointer"],steps:(t={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Hr(t.relativeTarget)}};function Ar(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function Er(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function Sr(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function Mr(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function xr(t){return[{target:"relative",assertion:"toHaveFocus",expectedValue:t,failureMessage:`${t} menu item should have focus.`}]}function Cr(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function $r(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function Lr(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Rr(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function Hr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${t} to have focus.`}]}var gt={"tab.active":{setup:[{when:["keyboard"],steps:(t={})=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(t={})=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Dr(t.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(t={})=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Pr(t.relativeTarget)}};function Pr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${ae("tab",t)} to have focus.`}]}function Ir(t){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:t,failureMessage:`Expected ${ae("tab",t)} to have tabindex='0'.`}]}function Dr(t){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:t,failureMessage:`Expected ${ae("tab",t)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:t},failureMessage:`Expected panel controlled by the ${ae("tab",t)} to be visible.`},Ir(t)]}var mt={"panel.expanded":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:t=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Br(t.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Vr(t.relativeTarget)}};function Br(t){return[{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:t},failureMessage:`Expected panel controlled by the ${t} trigger to be visible.`},{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected trigger to have aria-expanded='true' when panel expands."}]}function Vr(t){return[{target:"panel",assertion:"notToBeVisible",controlledBy:{target:"relative",relativeTarget:t},failureMessage:`Expected panel controlled by the ${t} trigger not to be visible.`},{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected trigger to have aria-expanded='false' when panel collapses."}]}var ht={"radio.checked":{setup:[{when:["keyboard"],steps:t=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"Space"}]},{when:["pointer"],steps:t=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>qr(t.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Fr(t.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Or(t.relativeTarget)}};function qr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function Fr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function Or(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${ae("radio",t)} to have focus.`}]}var bt={"checkbox.checked":{setup:[{when:["keyboard"],steps:t=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"Space"}]},{when:["pointer"],steps:t=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>_r(t.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Ur(t.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Nr(t.relativeTarget)}};function _r(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function Ur(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function Nr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${ae("checkbox",t)} to have focus.`}]}function jr(t,e){return e.some(r=>t.capabilities.includes(r))}function $e(t,e){Array.isArray(t)&&t.length&&!t[0].when&&(t=[{when:["keyboard"],steps:()=>t}]);for(let r of t)if(jr(e,r.when))return r.steps(e);throw new Error(`No setup strategy matches capabilities: ${e.capabilities.join(", ")}`)}var Kr={combobox:ft,menu:dt,tabs:gt,accordion:mt,radio:ht,checkbox:bt},_e=class{constructor(e){this.jsonContract=e}toJSON(){return this.jsonContract}},Ue=class{constructor(e){this.componentName=e;this.statePack=Kr[e]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(e){return this.metaValue=e,this}selectors(e){return this.selectorsValue=e,this}relationships(e){let r=this.statePack,s={capabilities:["keyboard"]},n=(a,o=new Set)=>{if(o.has(a))return[];o.add(a);let l=r[a];if(!l)return[];let u=[];if(Array.isArray(l.requires))for(let f of l.requires)u=u.concat(n(f,o));return l.setup&&(u=u.concat($e(l.setup,s))),u};return e({ariaReference:(a,o,l)=>({requires:u=>{let f=n(u,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"required",setup:f}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"optional",setup:f}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"recommended",setup:f})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"recommended"})}),contains:(a,o)=>({requires:l=>{let u=n(l,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"required",setup:u}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"optional",setup:u}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"recommended",setup:u})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"recommended"})})}),this}static(e){return e({target:s=>{let n=o=>{let l=this.statePack,u={capabilities:["keyboard"]},f=(y,T=new Set)=>{if(T.has(y))return[];T.add(y);let H=l[y];if(!H)return[];let q=[];if(Array.isArray(H.requires))for(let U of H.requires)q=q.concat(f(U,T));return H.setup&&(q=q.concat($e(H.setup,u))),q};return f(o,new Set)},i=o=>o==="role"?"toHaveRole":"toHaveAttribute",a=(o,l,u)=>{let f=i(o);return{required:()=>this.staticAssertions.push({target:s,assertion:f,attribute:o,expectedValue:l,failureMessage:"",level:"required",setup:u}),optional:()=>this.staticAssertions.push({target:s,assertion:f,attribute:o,expectedValue:l,failureMessage:"",level:"optional",setup:u}),recommended:()=>this.staticAssertions.push({target:s,assertion:f,attribute:o,expectedValue:l,failureMessage:"",level:"recommended",setup:u})}};return{has:(o,l)=>({...a(o,l),requires:f=>{let y=n(f);return a(o,l,y)}})}}}),this}when(e){return new Ne(this,this.statePack,e)}addDynamicTest(e){this.dynamicTests.push(e)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?this.staticAssertions:[],dynamic:this.dynamicTests}}},Ne=class{constructor(e,r,s){this.parent=e;this.statePack=r;this.event=s}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(e){return this._as=e,this}on(e,r){return this._onTarget=e,this._onRelativeTarget=r,this}given(e){return this._given=this._normalizeStates(e),this}then(e){return this._then=this._normalizeStates(e),this}orientation(e){return this._orientation=e,this}_normalizeStates(e){return(Array.isArray(e)?e:[e]).flatMap(s=>typeof s=="string"?[s]:typeof s=="object"&&s!==null&&"type"in s&&"ref"in s?this._findStateKeyByTypeAndRef(s.type)?[{type:s.type,ref:s.ref}]:[]:[s])}_findStateKeyByTypeAndRef(e){if(Object.keys(this.statePack).includes(e))return e}describe(e){return this._desc=e,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let s={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},n=(u,f=new Set)=>{if(f.has(u))return[];f.add(u);let y=this.statePack[u];if(!y)return[];let T=[];if(Array.isArray(y.requires))for(let H of y.requires)T=T.concat(n(H,f));return y.setup&&(T=T.concat($e(y.setup,s))),T},i=[];for(let u of this._given)if(typeof u=="string")i.push(...n(u));else if(typeof u=="object"&&u!==null&&"type"in u&&"ref"in u){let f=this._findStateKeyByTypeAndRef(u.type);if(f){let y=this.statePack[f];if(y&&y.setup)for(let T of y.setup)typeof T.steps=="function"?i.push(...T.steps({relativeTarget:u.ref})):Array.isArray(T.steps)&&i.push(...T.steps)}}let a=new Set;i=i.filter(u=>{let f=JSON.stringify(u);return a.has(f)?!1:(a.add(f),!0)});let o=[];for(let u of this._then)if(typeof u=="string"){let f=this.statePack[u];if(f&&f.assertion!==void 0){let y=f.assertion;if(typeof y=="function")try{y=y()}catch(T){throw new Error(`Error calling assertion function for state '${u}': ${T.message}`)}Array.isArray(y)?o.push(...y):o.push(y)}}else if(typeof u=="object"&&u!==null&&"type"in u&&"ref"in u){let f=this._findStateKeyByTypeAndRef(u.type);if(f){let y=this.statePack[f];if(y&&y.assertion!==void 0){let T=y.assertion;if(typeof T=="function")try{T=T({relativeTarget:u.ref})}catch(H){throw new Error(`Error calling assertion function for state '${f}': ${H.message}`)}Array.isArray(T)?o.push(...T):o.push(T)}}}let l=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:l,assertions:o,...i.length?{setup:i}:{}})}};function Wr(t,e){let r=new Ue(t);return e(r),new _e(r.build())}je();Ke();var Gt=ne(require("path"),1);async function rt(t,e,r={}){if(!t||typeof t!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let s={violations:[]};async function n(f){try{let y=await fetch(f,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(y.ok||y.status===304)return f}catch{return null}return null}let i=we(r.strictness),a={},o=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:f}=await Promise.resolve().then(()=>(At(),Tt)),y=await f(process.cwd());if(a=y.config,y.configPath&&(o=Gt.default.dirname(y.configPath)),r.strictness===void 0){let T=a.test?.components?.find(H=>H?.name===t)?.strictness;i=we(T??a.test?.strictness)}}catch{r.strictness===void 0&&(i="balanced")}let l;try{if(e){let f=await n(e);if(f){console.log(`\u{1F3AD} Running Playwright tests on ${f}`);let{runContractTestsPlaywright:y}=await Promise.resolve().then(()=>(Kt(),jt));l=await y(t,f,i,a,o)}else throw new Error(`\u274C Dev server not running at ${e}
|
|
65
|
-
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(
|
|
58
|
+
`))}async function ys(t,e=process.cwd()){let r=Qt.default.join(e,"README.md");if(!await Ve.default.pathExists(r)){console.log(Z.default.yellow(" \u2139\uFE0F No README.md found in current directory"));return}let i=await Ve.default.readFile(r,"utf-8"),n=ye(t);if(i.includes(n)||i.includes(st[t].fileName)){console.log(Z.default.gray(" \u2713 Badge already in README.md"));return}let a=Zt.default.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(l=>{a.question(Z.default.cyan(" Add badge to README.md now? (y/n): "),u=>{a.close(),l(u.toLowerCase().trim())})});o==="y"||o==="yes"?(await ws(r,i,n),console.log(Z.default.green(" \u2713 Badge added to README.md!"))):console.log(Z.default.gray(" Skipped. You can add it manually anytime."))}async function ws(t,e,r){let s=e.split(`
|
|
59
|
+
`),i=0;for(let n=0;n<s.length;n++){let a=s[n].trim();if(a.startsWith("[![")||a.startsWith("[!")){i=n+1;continue}if(i>0&&!a.startsWith("[![")&&!a.startsWith("[!")&&a.length>0)break;if(i===0&&a.startsWith("#")){i=n+2;break}}i===0&&(i=1),s.splice(i,0,r),await Ve.default.writeFile(t,s.join(`
|
|
60
|
+
`),"utf-8")}function Ts(){console.log(Z.default.cyan(`
|
|
61
|
+
\u{1F4CD} Available badges:`)),console.log(Z.default.white(`
|
|
62
|
+
For audits:`)),console.log(Z.default.green(" "+ye("audit"))),console.log(Z.default.white(`
|
|
63
|
+
For component testing:`)),console.log(Z.default.green(" "+ye("component"))),console.log(Z.default.white(`
|
|
64
|
+
For both (verified):`)),console.log(Z.default.green(" "+ye("verified"))),console.log("")}var Ve,Qt,Z,Zt,st,tr=Q(()=>{"use strict";Ve=ne(require("fs-extra"),1),Qt=ne(require("path"),1),Z=ne(require("chalk"),1),Zt=ne(require("readline"),1),st={audit:{type:"audit",fileName:"audited-by-aria-ease.svg",label:"Audited by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/audited-by-aria-ease.svg"},component:{type:"component",fileName:"components-tested-aria-ease.svg",label:"Components tested: aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/components-tested-aria-ease.svg"},verified:{type:"verified",fileName:"verified-by-aria-ease.svg",label:"Verified by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/verified-by-aria-ease.svg"}}});var ks={};se(ks,{cleanupTests:()=>it,createContract:()=>cs,makeAccordionAccessible:()=>dr,makeBlockAccessible:()=>mr,makeCheckboxAccessible:()=>hr,makeComboboxAccessible:()=>yr,makeMenuAccessible:()=>ft,makeRadioAccessible:()=>br,makeTabsAccessible:()=>wr,makeToggleAccessible:()=>vr,testUiComponent:()=>nt});module.exports=pr(ks);function dr({accordionId:t,triggersClass:e,panelsClass:r,allowMultipleOpen:s=!1,callback:i}){if(t==="")return console.error("[aria-ease] 'accordionId' should not be an empty string. Provide an id to the accordion container element that exists before calling makeAccordionAccessible."),{cleanup:()=>{}};let n=document.querySelector(`#${t}`);if(!n)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'triggersClass' should not be an empty string. Provide a class name that exists on the accordion trigger elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let a=Array.from(n.querySelectorAll(`.${e}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(r==="")return console.error("[aria-ease] 'panelsClass' should not be an empty string. Provide a class name that exists on the accordion panel elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let o=Array.from(n.querySelectorAll(`.${r}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${r}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(a.length!==o.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${a.length} triggers but ${o.length} panels.`),{cleanup:()=>{}};let l=new WeakMap,u=new WeakMap;function g(){a.forEach((f,h)=>{let O=o[h];f.id||(f.id=`${t}-trigger-${h}`),O.id||(O.id=`${t}-panel-${h}`),f.setAttribute("aria-controls",O.id),f.setAttribute("aria-expanded","false"),(!s||a.length<=6)&&O.setAttribute("role","region"),O.setAttribute("aria-labelledby",f.id),O.style.display="none"})}function k(f){if(f<0||f>=a.length){console.error(`[aria-ease] Invalid accordion index: ${f}`);return}let h=a[f],O=o[f];if(h.setAttribute("aria-expanded","true"),O.style.display="block",i?.onExpandedChange)try{i.onExpandedChange(f,!0)}catch(v){console.error("[aria-ease] Error in accordion onExpandedChange callback:",v)}}function A(f){if(f<0||f>=a.length){console.error(`[aria-ease] Invalid accordion index: ${f}`);return}let h=a[f],O=o[f];if(h.setAttribute("aria-expanded","false"),O.style.display="none",i?.onExpandedChange)try{i.onExpandedChange(f,!1)}catch(v){console.error("[aria-ease] Error in accordion onExpandedChange callback:",v)}}function C(f){a[f].getAttribute("aria-expanded")==="true"?A(f):(s||a.forEach((v,x)=>{x!==f&&A(x)}),k(f))}function D(f){return()=>{C(f)}}function B(f){return h=>{let{key:O}=h;switch(O){case"Enter":case" ":h.preventDefault(),C(f);break;case"ArrowDown":h.preventDefault();{let v=(f+1)%a.length;a[v].focus()}break;case"ArrowUp":h.preventDefault();{let v=(f-1+a.length)%a.length;a[v].focus()}break;case"Home":h.preventDefault(),a[0].focus();break;case"End":h.preventDefault(),a[a.length-1].focus();break}}}function G(){a.forEach((f,h)=>{let O=D(h),v=B(h);f.addEventListener("click",O),f.addEventListener("keydown",v),l.set(f,v),u.set(f,O)})}function S(){a.forEach(f=>{let h=l.get(f),O=u.get(f);h&&(f.removeEventListener("keydown",h),l.delete(f)),O&&(f.removeEventListener("click",O),u.delete(f))})}function p(){S(),a.forEach((f,h)=>{A(h)})}function w(){S();let f=Array.from(n.querySelectorAll(`.${e}`)),h=Array.from(n.querySelectorAll(`.${r}`));a.length=0,a.push(...f),o.length=0,o.push(...h),g(),G()}return g(),G(),{expandItem:k,collapseItem:A,toggleItem:C,cleanup:p,refresh:w}}function Se(t){if(t.tagName!=="INPUT")return!1;let e=t.type;return["text","email","password","tel","number"].includes(e)}function xe(t){return t.tagName==="TEXTAREA"}function pt(t){return t.tagName==="BUTTON"||t.tagName==="INPUT"&&["button","submit","reset"].includes(t.type)}function fr(t){return t.tagName==="A"}function Ce(t,e,r){let s=t.length,i=(e+r+s)%s;t.item(i).focus()}function gr(t){return t.getAttribute("data-custom-click")!==null&&t.getAttribute("data-custom-click")!==void 0}function dt(t,e,r){let s=e.item(r);switch(t.key){case"ArrowUp":case"ArrowLeft":{(!Se(s)&&!xe(s)||(Se(s)||xe(s))&&s.selectionStart===0)&&(t.preventDefault(),Ce(e,r,-1));break}case"ArrowDown":case"ArrowRight":{if(!Se(s)&&!xe(s))t.preventDefault(),Ce(e,r,1);else if(Se(s)||xe(s)){let i=s.value;s.selectionStart===i.length&&(t.preventDefault(),Ce(e,r,1))}break}case"Escape":{t.preventDefault();break}case"Enter":case" ":{(!pt(s)&&!fr(s)&&gr(s)||pt(s))&&(t.preventDefault(),s.click());break}case"Tab":break;default:break}}function mr({blockId:t,blockItemsClass:e}){if(t==="")return console.error("[aria-ease] 'blockId' should not be an empty string. Provide an id to the block container element that exists before calling makeBlockAccessible."),{cleanup:()=>{}};let r=document.querySelector(`#${t}`);if(!r)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'blockItemsClass' should not be an empty string. Provide a class name that exists on the block item elements before calling makeBlockAccessible."),{cleanup:()=>{}};let s=null;function i(){return s||(s=r.querySelectorAll(`.${e}`)),s}let n=i();if(!n||n.length===0)return console.error(`[aria-ease] Element with class="${e}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let a=new Map;n.forEach(u=>{if(!a.has(u)){let g=k=>{let A=r.querySelectorAll(`.${e}`),C=Array.prototype.indexOf.call(A,u);dt(k,A,C)};u.addEventListener("keydown",g),a.set(u,g)}});function o(){n.forEach(u=>{let g=a.get(u);g&&(u.removeEventListener("keydown",g),a.delete(u))})}function l(){s=null}return{cleanup:o,refresh:l}}function hr({checkboxGroupId:t,checkboxesClass:e,callback:r}){if(t==="")return console.error("[aria-ease] 'checkboxGroupId' should not be an empty string. Provide an id to the checkbox group container element that exists before calling makeCheckboxAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${t}`);if(!s)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let i=Array.from(s.querySelectorAll(`.${e}`));if(i.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let n=new WeakMap,a=new WeakMap;function o(){s.getAttribute("role")||s.setAttribute("role","group"),i.forEach(p=>{p.setAttribute("role","checkbox");let w=p.checked;p.setAttribute("aria-checked",w?"true":"false"),p.hasAttribute("tabindex")||p.setAttribute("tabindex","0")})}function l(p,w){if(r?.onCheckedChange)try{r.onCheckedChange(p,w)}catch(f){console.error("[aria-ease] Error in checkbox onCheckedChange callback:",f)}}function u(p){if(p<0||p>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${p}`);return}let w=i[p],f=!w.checked;w.checked=f,w.setAttribute("aria-checked",f?"true":"false"),l(p,f)}function g(p,w){if(p<0||p>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${p}`);return}let f=i[p];f.checked=w,f.setAttribute("aria-checked",w?"true":"false"),l(p,w)}function k(p){return()=>{let w=i[p];if("checked"in w&&typeof w.checked=="boolean")setTimeout(()=>{let f=w.checked;w.setAttribute("aria-checked",f?"true":"false"),l(p,f)},0);else{let f=w.getAttribute("aria-checked")==="true";w.setAttribute("aria-checked",f?"false":"true"),l(p,!f)}}}function A(p){return w=>{let{key:f}=w;switch(f){case" ":case"Spacebar":w.preventDefault(),u(p);break}}}function C(){i.forEach((p,w)=>{let f=k(w),h=A(w);p.addEventListener("click",f),p.addEventListener("keydown",h),n.set(p,h),a.set(p,f)})}function D(){i.forEach(p=>{let w=n.get(p),f=a.get(p);w&&(p.removeEventListener("keydown",w),n.delete(p)),f&&(p.removeEventListener("click",f),a.delete(p))})}function B(){D()}function G(){return i.map(p=>p.getAttribute("aria-checked")==="true")}function S(){return i.map((p,w)=>p.getAttribute("aria-checked")==="true"?w:-1).filter(p=>p!==-1)}return o(),C(),{toggleCheckbox:u,setCheckboxState:g,getCheckedStates:G,getCheckedIndices:S,cleanup:B}}function ft({menuId:t,menuItemsClass:e,triggerId:r,callback:s}){if(t==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let i=document.querySelector(`#${t}`);if(!i)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(r==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let n=document.querySelector(`#${r}`);if(!n)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'menuItemsClass' should not be an empty string. Provide a class name to at least a menu item that exists before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(t))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};n.setAttribute("aria-haspopup","true"),n.setAttribute("aria-controls",t),n.setAttribute("aria-expanded","false"),i.setAttribute("role","menu"),i.setAttribute("aria-labelledby",r);let a=new WeakMap,o=new Map,l=null,u=null;function g(){return l||(l=i.querySelectorAll(`.${e}`)),l}function k(){if(!u){let b=g();u=[];for(let d=0;d<b.length;d++){let $=b.item(d),q=w($),J=$.getAttribute("aria-disabled")==="true";q||($.hasAttribute("tabindex")||$.setAttribute("tabindex","-1"),J||u.push($))}}return u}function A(b){return{length:b.length,item:$=>b[$],forEach:$=>{b.forEach($)},[Symbol.iterator]:function*(){for(let $ of b)yield $}}}function C(){g().forEach(d=>{d.setAttribute("role","menuitem");let $=d.getAttribute("data-submenu-id")??d.getAttribute("aria-controls"),q=d.hasAttribute("aria-haspopup")&&$;$&&(d.hasAttribute("data-submenu-id")||q)&&(d.setAttribute("aria-haspopup","menu"),d.setAttribute("aria-controls",$),d.hasAttribute("aria-expanded")||d.setAttribute("aria-expanded","false"))})}function D(b,d,$){let q=b.length,J=(d+$+q)%q;b.item(J).focus()}function B(b,d){b.length!==0&&b[d]?.focus()}function G(b){return b.hasAttribute("aria-controls")&&b.hasAttribute("aria-haspopup")&&b.getAttribute("role")==="menuitem"}function S(b){let d=b;for(;d&&d.getAttribute("role")==="menuitem";){let $=d.closest('[role="menu"]');if(!$)break;$.style.display="none",d.setAttribute("aria-expanded","false");let q=$.getAttribute("aria-labelledby");if(!q)break;let J=document.getElementById(q);if(!J)break;d=J}}C();function p(b,d,$){switch(b.key){case"ArrowLeft":{if(b.key==="ArrowLeft"&&n.getAttribute("role")==="menuitem"){b.preventDefault(),m();return}break}case"ArrowUp":{b.preventDefault(),D(A(k()),$,-1);break}case"ArrowRight":{if(b.key==="ArrowRight"&&G(d)){b.preventDefault();let q=d.getAttribute("aria-controls");if(q){h(q);return}}break}case"ArrowDown":{b.preventDefault(),D(A(k()),$,1);break}case"Home":{b.preventDefault(),B(k(),0);break}case"End":{b.preventDefault();let q=k();B(q,q.length-1);break}case"Escape":{b.preventDefault(),m(),n.focus(),O&&O(!1);break}case"Enter":case" ":{if(b.preventDefault(),G(d)){let q=d.getAttribute("aria-controls");if(q){h(q);return}}d.click(),m(),O&&O(!1);break}case"Tab":{m(),S(n),O&&O(!1);break}default:break}}function w(b){let d=b.parentElement;for(;d&&d!==i;){if(d.getAttribute("role")==="menu"||d.id&&i.querySelector(`[aria-controls="${d.id}"]`))return!0;d=d.parentElement}return!1}function f(b){n.setAttribute("aria-expanded",b?"true":"false")}function h(b){let d=o.get(b);if(!d){let $=i.querySelector(`[aria-controls="${b}"]`);if(!$){console.error(`[aria-ease] Submenu trigger with aria-controls="${b}" not found in menu "${t}".`);return}if(!$.id){let J=`trigger-${b}`;$.id=J,console.warn(`[aria-ease] Submenu trigger for "${b}" had no ID. Auto-generated ID: "${J}".`)}if(!document.querySelector(`#${b}`)){console.error(`[aria-ease] Submenu element with id="${b}" not found. Cannot create submenu instance.`);return}d=ft({menuId:b,menuItemsClass:e,triggerId:$.id,callback:s}),o.set(b,d)}d.openMenu()}function O(b){if(s?.onExpandedChange)try{s.onExpandedChange(b)}catch(d){console.error("[aria-ease] Error in menu onExpandedChange callback:",d)}}function v(){k().forEach((d,$)=>{if(!a.has(d)){let q=J=>p(J,d,$);d.addEventListener("keydown",q),a.set(d,q)}})}function x(){k().forEach(d=>{let $=a.get(d);$&&(d.removeEventListener("keydown",$),a.delete(d))})}function L(){f(!0),i.style.display="block";let b=k();if(v(),b&&b.length>0&&b[0].focus(),s?.onExpandedChange)try{s.onExpandedChange(!0)}catch(d){console.error("[aria-ease] Error in menu onExpandedChange callback:",d)}}function m(){if(o.forEach(b=>b.closeMenu()),f(!1),i.style.display="none",x(),n.focus(),s?.onExpandedChange)try{s.onExpandedChange(!1)}catch(b){console.error("[aria-ease] Error in menu onExpandedChange callback:",b)}}function T(){n.getAttribute("aria-expanded")==="true"?m():L()}function y(b){if(!(n.getAttribute("aria-expanded")==="true"))return;let $=n.contains(b.target),q=i.contains(b.target);!$&&!q&&m()}n.addEventListener("click",T),document.addEventListener("click",y);function V(){x(),n.removeEventListener("click",T),document.removeEventListener("click",y),i.style.display="none",f(!1),o.forEach(b=>b.cleanup()),o.clear()}function ie(){l=null,u=null}return{openMenu:L,closeMenu:m,cleanup:V,refresh:ie}}function br({radioGroupId:t,radiosClass:e,defaultSelectedIndex:r,callback:s}){if(t==="")return console.error("[aria-ease] 'radioGroupId' should not be an empty string. Provide an id to the radio group container element that exists before calling makeRadioAccessible."),{cleanup:()=>{}};let i=document.querySelector(`#${t}`);if(!i)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'radiosClass' should not be an empty string. Provide a class name that exists on the radio button elements before calling makeRadioAccessible."),{cleanup:()=>{}};let n=Array.from(i.querySelectorAll(`.${e}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let a=new WeakMap,o=new WeakMap,l;r&&(l=r);function u(){i.getAttribute("role")||i.setAttribute("role","radiogroup"),n.forEach((S,p)=>{S.setAttribute("role","radio"),S.setAttribute("tabindex","0");let w=p===l;S.setAttribute("aria-checked",w?"true":"false"),S.checked!==void 0&&(S.checked=w)})}function g(S){if(S<0||S>=n.length){console.error(`[aria-ease] Invalid radio index: ${S}`);return}if(l>=0&&l<n.length&&(n[l].setAttribute("aria-checked","false"),n[l].checked!==void 0&&(n[l].checked=!1)),n[S].setAttribute("aria-checked","true"),n[S].checked!==void 0&&(n[S].checked=!0),n[S].focus(),s?.onValueChange)try{s.onValueChange(S,n[S].getAttribute("value"))}catch(p){console.error("[aria-ease] Error in radio onValueChange callback:",p)}l=S}function k(S){return()=>{let p=n[S];"checked"in p&&typeof p.checked=="boolean"?setTimeout(()=>{g(S)},0):g(S)}}function A(S){return p=>{let{key:w}=p,f=S;switch(w){case"ArrowDown":case"ArrowRight":p.preventDefault(),f=(S+1)%n.length,g(f);break;case"ArrowUp":case"ArrowLeft":p.preventDefault(),f=(S-1+n.length)%n.length,g(f);break;case" ":case"Enter":p.preventDefault(),g(S);break}}}function C(){n.forEach((S,p)=>{let w=k(p),f=A(p);S.addEventListener("click",w),S.addEventListener("keydown",f),a.set(S,f),o.set(S,w)})}function D(){n.forEach(S=>{let p=a.get(S),w=o.get(S);p&&(S.removeEventListener("keydown",p),a.delete(S)),w&&(S.removeEventListener("click",w),o.delete(S))})}function B(){D()}function G(){return l}return u(),C(),{selectRadio:g,getSelectedIndex:G,cleanup:B}}function vr({toggleId:t,togglesClass:e,isSingleToggle:r=!0,callback:s}){if(t==="")return console.error("[aria-ease] 'toggleId' should not be an empty string. Provide an id to the toggle element or toggle container before calling makeToggleAccessible."),{cleanup:()=>{}};let i=document.querySelector(`#${t}`);if(!i)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let n;if(r)n=[i];else{if(!e)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(n=Array.from(i.querySelectorAll(`.${e}`)),n.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let a=new WeakMap,o=new WeakMap;function l(){n.forEach(p=>{p.tagName.toLowerCase()!=="button"&&!p.getAttribute("role")&&p.setAttribute("role","button"),p.hasAttribute("aria-pressed")||p.setAttribute("aria-pressed","false"),p.hasAttribute("tabindex")||p.setAttribute("tabindex","0")})}function u(p){if(p<0||p>=n.length){console.error(`[aria-ease] Invalid toggle index: ${p}`);return}let f=n[p].getAttribute("aria-pressed")==="true";g(p,!f)}function g(p,w){if(p<0||p>=n.length){console.error(`[aria-ease] Invalid toggle index: ${p}`);return}if(n[p].setAttribute("aria-pressed",w?"true":"false"),s?.onPressedChange)try{s.onPressedChange(p,w)}catch(f){console.error("[aria-ease] Error in checkbox onPressedChange callback:",f)}}function k(p){return()=>{u(p)}}function A(p){return w=>{let{key:f}=w;switch(f){case"Enter":case" ":w.preventDefault(),u(p);break}}}function C(){n.forEach((p,w)=>{let f=k(w),h=A(w);p.addEventListener("click",f),p.addEventListener("keydown",h),a.set(p,h),o.set(p,f)})}function D(){n.forEach(p=>{let w=a.get(p),f=o.get(p);w&&(p.removeEventListener("keydown",w),a.delete(p)),f&&(p.removeEventListener("click",f),o.delete(p))})}function B(){D()}function G(){return n.map(p=>p.getAttribute("aria-pressed")==="true")}function S(){return n.map((p,w)=>p.getAttribute("aria-pressed")==="true"?w:-1).filter(p=>p!==-1)}return l(),C(),{toggleButton:u,setPressed:g,getPressedStates:G,getPressedIndices:S,cleanup:B}}function yr({comboboxInputId:t,comboboxButtonId:e,listBoxId:r,listBoxItemsClass:s,callback:i}){if(t==="")return console.error("[aria-ease] 'comboboxInputId' should not be an empty string. Provide an id to the combobox input element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let n=document.getElementById(`${t}`);if(!n)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(r==="")return console.error("[aria-ease] 'listBoxId' should not be an empty string. Provide an id to the combobox listbox element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let a=document.getElementById(`${r}`);if(!a)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(s==="")return console.error("[aria-ease] 'listboxItemsClass' class should not be an empty string. Provide a class name to at least a listbox option that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};if(!document.querySelectorAll(s))return console.error(`[aria-ease] Listbox option(s) with class="${s}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let l=e?document.getElementById(`${e}`):null,u=-1;n.setAttribute("role","combobox"),n.setAttribute("aria-autocomplete","list"),n.setAttribute("aria-controls",r),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-haspopup","listbox"),a.setAttribute("role","listbox");let g=null;function k(){return g||(g=a.querySelectorAll(`.${s}`)),Array.from(g).filter(m=>!m.hidden&&m.style.display!=="none")}function A(){return n.getAttribute("aria-expanded")==="true"}function C(m){let T=k();if(m>=0&&m<T.length){let y=T[m],V=y.id||`${r}-option-${m}`;if(y.id||(y.id=V),n.setAttribute("aria-activedescendant",V),typeof y.scrollIntoView=="function"&&y.scrollIntoView({block:"nearest",behavior:"smooth"}),i?.onActiveDescendantChange)try{i.onActiveDescendantChange(V,y)}catch(ie){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",ie)}}else n.setAttribute("aria-activedescendant","");u=m}function D(){if(n.setAttribute("aria-expanded","true"),a.style.display="block",i?.onExpandedChange)try{i.onExpandedChange(!0)}catch(m){console.error("[aria-ease] Error in combobox onExpandedChange callback:",m)}}function B(){if(n.setAttribute("aria-expanded","false"),n.setAttribute("aria-activedescendant",""),a.style.display="none",u=-1,i?.onExpandedChange)try{i.onExpandedChange(!1)}catch(m){console.error("[aria-ease] Error in combobox onExpandedChange callback:",m)}}function G(m){let T=m.textContent?.trim()||"";if(n.value=T,m.setAttribute("aria-selected","true"),B(),i?.onSelect)try{i.onSelect(m)}catch(y){console.error("[aria-ease] Error in combobox onSelect callback:",y)}}function S(m){let T=k(),y=A();switch(m.key){case"ArrowDown":if(m.preventDefault(),!y){D();return}if(T.length===0)return;{let V=u>=T.length-1?0:u+1;C(V)}break;case"ArrowUp":if(m.preventDefault(),!y)return;if(T.length>0){let V=u<=0?T.length-1:u-1;C(V)}break;case"Enter":y&&u>=0&&u<T.length&&(m.preventDefault(),G(T[u]));break;case"Escape":if(y)m.preventDefault(),B();else if(n.value&&(m.preventDefault(),n.value="",n.setAttribute("aria-activedescendant",""),k().forEach(ie=>{ie.getAttribute("aria-selected")==="true"&&ie.setAttribute("aria-selected","false")}),i?.onClear))try{i.onClear()}catch(ie){console.error("[aria-ease] Error in combobox onClear callback:",ie)}break;case"Home":y&&T.length>0&&(m.preventDefault(),C(0));break;case"End":y&&T.length>0&&(m.preventDefault(),C(T.length-1));break;case"Tab":y&&u>=0&&u<T.length&&G(T[u]),y&&B();break}}function p(m){let T=m.target;if(T.classList.contains(s)){let V=k().indexOf(T);V>=0&&C(V)}}function w(m){let T=m.target;T.classList.contains(s)&&(m.preventDefault(),G(T))}function f(m){let T=m.target;!n.contains(T)&&!a.contains(T)&&(!l||!l.contains(T))&&B()}function h(){A()?B():(D(),n.focus())}function O(m){(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),h())}n.addEventListener("keydown",S),a.addEventListener("mousemove",p),a.addEventListener("mousedown",w),document.addEventListener("mousedown",f),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",h),l.addEventListener("keydown",O));function v(){let m=a.querySelectorAll(`.${s}`);if(m.length===0)return;let T=null;for(let y of m)if(y.getAttribute("aria-selected")==="true"){T=y.textContent?.trim()||null;break}!T&&n.value&&(T=n.value.trim()),m.forEach((y,V)=>{y.setAttribute("role","option");let ie=y.textContent?.trim()||"";T&&ie===T?y.setAttribute("aria-selected","true"):y.setAttribute("aria-selected","false");let b=y.getAttribute("id");if(!b||b===""){let d=`${r}-option-${V}`;y.id=d,y.setAttribute("id",d)}})}v();function x(){n.removeEventListener("keydown",S),a.removeEventListener("mousemove",p),a.removeEventListener("mousedown",w),document.removeEventListener("mousedown",f),l&&(l.removeEventListener("click",h),l.removeEventListener("keydown",O))}function L(){g=null,v(),u=-1,C(-1)}return{cleanup:x,refresh:L,openListbox:D,closeListbox:B}}function wr({tabListId:t,tabsClass:e,tabPanelsClass:r,orientation:s="horizontal",activateOnFocus:i=!0,callback:n}){if(t==="")return console.error("[aria-ease] 'tabListId' should not be an empty string. Provide an id to the tab list container element that exists before calling makeTabsAccessible."),{cleanup:()=>{}};let a=document.querySelector(`#${t}`);if(!a)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'tabsClass' should not be an empty string. Provide a class name that exists on the tab button elements before calling makeTabsAccessible."),{cleanup:()=>{}};let o=Array.from(a.querySelectorAll(`.${e}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(r==="")return console.error("[aria-ease] 'tabPanelsClass' should not be an empty string. Provide a class name that exists on the tab panel elements before calling makeTabsAccessible."),{cleanup:()=>{}};let l=Array.from(document.querySelectorAll(`.${r}`));if(l.length===0)return console.error(`[aria-ease] No elements with class="${r}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(o.length!==l.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${o.length} tabs but ${l.length} panels.`),{cleanup:()=>{}};let u=new WeakMap,g=new WeakMap,k=new WeakMap,A=0;function C(){a.setAttribute("role","tablist"),a.setAttribute("aria-orientation",s),o.forEach((v,x)=>{let L=l[x];v.id||(v.id=`${t}-tab-${x}`),L.id||(L.id=`${t}-panel-${x}`),v.setAttribute("role","tab"),v.setAttribute("aria-controls",L.id),v.setAttribute("aria-selected","false"),v.setAttribute("tabindex","-1"),L.setAttribute("role","tabpanel"),L.setAttribute("aria-labelledby",v.id),L.hidden=!0,L.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||L.setAttribute("tabindex","0")}),D(0,!1)}function D(v,x=!0){if(v<0||v>=o.length){console.error(`[aria-ease] Invalid tab index: ${v}`);return}o.forEach((T,y)=>{let V=l[y];T.setAttribute("aria-selected","false"),T.setAttribute("tabindex","-1"),V.hidden=!0});let L=o[v],m=l[v];if(L.setAttribute("aria-selected","true"),L.setAttribute("tabindex","0"),m.hidden=!1,x&&L.focus(),A=v,n?.onSelectedChange)try{n.onSelectedChange(v,!0)}catch(T){console.error("[aria-ease] Error in tabs onSelectedChange callback:",T)}}function B(v){let x=o.findIndex(T=>T===document.activeElement),L=x!==-1?x:A,m=L;switch(v){case"first":m=0;break;case"last":m=o.length-1;break;case"next":m=(L+1)%o.length;break;case"prev":m=(L-1+o.length)%o.length;break}if(o[m].focus(),o[m].setAttribute("tabindex","0"),o[A].setAttribute("tabindex","-1"),i)D(m,!1);else{let T=A;o.forEach((y,V)=>{V===m?y.setAttribute("tabindex","0"):V!==T&&y.setAttribute("tabindex","-1")})}}function G(v){return()=>{D(v)}}function S(v){return x=>{let{key:L}=x,m=!1;if(s==="horizontal")switch(L){case"ArrowLeft":x.preventDefault(),B("prev"),m=!0;break;case"ArrowRight":x.preventDefault(),B("next"),m=!0;break}else switch(L){case"ArrowUp":x.preventDefault(),B("prev"),m=!0;break;case"ArrowDown":x.preventDefault(),B("next"),m=!0;break}if(!m)switch(L){case"Home":x.preventDefault(),B("first");break;case"End":x.preventDefault(),B("last");break;case" ":case"Enter":i||(x.preventDefault(),D(v));break;case"F10":if(x.shiftKey&&n?.onContextMenu){x.preventDefault();try{n.onContextMenu(v,o[v])}catch(T){console.error("[aria-ease] Error in tabs onContextMenu callback:",T)}}break}}}function p(v){return x=>{if(n?.onContextMenu){x.preventDefault();try{n.onContextMenu(v,o[v])}catch(L){console.error("[aria-ease] Error in tabs onContextMenu callback:",L)}}}}function w(){o.forEach((v,x)=>{let L=G(x),m=S(x),T=p(x);v.addEventListener("click",L),v.addEventListener("keydown",m),n?.onContextMenu&&(v.addEventListener("contextmenu",T),k.set(v,T)),u.set(v,m),g.set(v,L)})}function f(){o.forEach(v=>{let x=u.get(v),L=g.get(v),m=k.get(v);x&&(v.removeEventListener("keydown",x),u.delete(v)),L&&(v.removeEventListener("click",L),g.delete(v)),m&&(v.removeEventListener("contextmenu",m),k.delete(v))})}function h(){f(),o.forEach((v,x)=>{let L=l[x];v.removeAttribute("role"),v.removeAttribute("aria-selected"),v.removeAttribute("aria-controls"),v.removeAttribute("tabindex"),L.removeAttribute("role"),L.removeAttribute("aria-labelledby"),L.removeAttribute("tabindex"),L.hidden=!1}),a.removeAttribute("role"),a.removeAttribute("aria-orientation")}function O(){f();let v=Array.from(a.querySelectorAll(`.${e}`)),x=Array.from(document.querySelectorAll(`.${r}`));o.length=0,o.push(...v),l.length=0,l.push(...x),C(),w()}return C(),w(),{activateTab:D,cleanup:h,refresh:O}}function Y(t,e){return e==="first"?`first ${t}`:e==="last"?`last ${t}`:e==="next"?`next ${t}`:e==="previous"?`previous ${t}`:typeof e=="number"?`${t} at index ${e}`:`${e} ${t}`}var mt={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:Tr},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...kr(),...gt()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:Sr},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:xr},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:Cr},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:$r},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(t={})=>typeof t.relativeTarget=="number"?Array.from({length:t.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):t.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:t.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(t={})=>Ar(t.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Er},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:gt},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(t={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTarget:t.relativeTarget}]},{when:["pointer"],steps:(t={})=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Mr(t.relativeTarget)}};function Tr(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function kr(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function Ar(t){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:t,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function Er(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function gt(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function Mr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${Y("option",t)} to have aria-selected='true'.`}]}function Sr(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function xr(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function Cr(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function $r(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var ht={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:Lr},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Rr},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:Hr},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Pr},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(t={})=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Ir(t.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:Dr},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Br},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Vr},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Fr},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(t={})=>{let e=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof t.relativeTarget=="number"&&(e=e.concat(Array.from({length:t.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),t.relativeTarget==="first"&&(e=e.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),t.relativeTarget==="last"&&(e=e.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),e}},{when:["pointer"],steps:(t={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>qr(t.relativeTarget)}};function Lr(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function Rr(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function Hr(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function Pr(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function Ir(t){return[{target:"relative",assertion:"toHaveFocus",expectedValue:t,failureMessage:`${t} menu item should have focus.`}]}function Dr(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function Br(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function Vr(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Fr(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function qr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${t} to have focus.`}]}var bt={"tab.active":{setup:[{when:["keyboard"],steps:(t={})=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(t={})=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>jr(t.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(t={})=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Or(t.relativeTarget)},"tab.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>_r(t.relativeTarget)}};function Or(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("tab",t)} to have focus.`}]}function _r(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("tab",t)} not to have focus.`}]}function Ur(t){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:t,failureMessage:`Expected ${Y("tab",t)} to have tabindex='0'.`}]}function jr(t){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:t,failureMessage:`Expected ${Y("tab",t)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:t},failureMessage:`Expected panel controlled by the ${Y("tab",t)} to be visible.`},Ur(t)]}var vt={"panel.expanded":{setup:[{when:["keyboard"],steps:t=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:t=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Nr(t.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Kr(t.relativeTarget)},"trigger.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Wr(t.relativeTarget)},"trigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>zr(t.relativeTarget)}};function Nr(t){return[{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:t},failureMessage:`Expected panel controlled by the ${t} trigger to be visible.`},{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected trigger to have aria-expanded='true' when panel expands."}]}function Kr(t){return[{target:"panel",assertion:"notToBeVisible",controlledBy:{target:"relative",relativeTarget:t},failureMessage:`Expected panel controlled by the ${t} trigger not to be visible.`},{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected trigger to have aria-expanded='false' when panel collapses."}]}function Wr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("trigger",t)} to have focus.`}]}function zr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("trigger",t)} not to have focus.`}]}var yt={"radio.checked":{setup:[{when:["keyboard"],steps:t=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"Space"}]},{when:["pointer"],steps:t=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Jr(t.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Gr(t.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Xr(t.relativeTarget)},"radio.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Yr(t.relativeTarget)}};function Jr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function Gr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function Xr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("radio",t)} to have focus.`}]}function Yr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("radio",t)} not to have focus.`}]}var wt={"checkbox.checked":{setup:[{when:["keyboard"],steps:t=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"Space"}]},{when:["pointer"],steps:t=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Qr(t.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Zr(t.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>es(t.relativeTarget)},"checkbox.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>ts(t.relativeTarget)}};function Qr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function Zr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function es(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("checkbox",t)} to have focus.`}]}function ts(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("checkbox",t)} not to have focus.`}]}var Tt={"toggle.pressed":{setup:[{when:["keyboard"],steps:t=>[{type:"keypress",target:"relative",relativeTarget:t.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:t=>[{type:"click",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>rs(t.relativeTarget)},"toggle.unpressed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>ss(t.relativeTarget)},"toggle.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>ns(t.relativeTarget)},"toggle.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>is(t.relativeTarget)}};function rs(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"true",failureMessage:"Expected toggle to have aria-pressed='true' when pressed."}]}function ss(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"false",failureMessage:"Expected toggle to have aria-pressed='false' when unpressed."}]}function ns(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("toggle",t)} to have focus.`}]}function is(t){return[{target:"relative",assertion:"notToHaveFocus",relativeTarget:t,failureMessage:`Expected ${Y("toggle",t)} not to have focus.`}]}function os(t,e){return e.some(r=>t.capabilities.includes(r))}function _e(t,e){Array.isArray(t)&&t.length&&!t[0].when&&(t=[{when:["keyboard"],steps:()=>t}]);for(let r of t)if(os(e,r.when))return r.steps(e);throw new Error(`No setup strategy matches capabilities: ${e.capabilities.join(", ")}`)}var as={combobox:mt,menu:ht,tabs:bt,accordion:vt,radio:yt,checkbox:wt,toggle:Tt},Ue=class{constructor(e){this.jsonContract=e}toJSON(){return this.jsonContract}},je=class{constructor(e){this.componentName=e;this.statePack=as[e]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(e){return this.metaValue=e,this}selectors(e){return this.selectorsValue=e,this}relationships(e){let r=this.statePack,s={capabilities:["keyboard"]},i=(a,o=new Set)=>{if(o.has(a))return[];o.add(a);let l=r[a];if(!l)return[];let u=[];if(Array.isArray(l.requires))for(let g of l.requires)u=u.concat(i(g,o));return l.setup&&(u=u.concat(_e(l.setup,s))),u};return e({ariaReference:(a,o,l)=>({requires:u=>{let g=i(u,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"required",setup:g}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"optional",setup:g}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"recommended",setup:g})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"recommended"})}),contains:(a,o)=>({requires:l=>{let u=i(l,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"required",setup:u}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"optional",setup:u}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"recommended",setup:u})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"recommended"})})}),this}static(e){return e({target:s=>{let i=o=>{let l=this.statePack,u={capabilities:["keyboard"]},g=(k,A=new Set)=>{if(A.has(k))return[];A.add(k);let C=l[k];if(!C)return[];let D=[];if(Array.isArray(C.requires))for(let B of C.requires)D=D.concat(g(B,A));return C.setup&&(D=D.concat(_e(C.setup,u))),D};return g(o,new Set)},n=o=>o==="role"?"toHaveRole":"toHaveAttribute",a=(o,l,u)=>{let g=n(o);return{required:()=>this.staticAssertions.push({target:s,assertion:g,attribute:o,expectedValue:l,failureMessage:"",level:"required",setup:u}),optional:()=>this.staticAssertions.push({target:s,assertion:g,attribute:o,expectedValue:l,failureMessage:"",level:"optional",setup:u}),recommended:()=>this.staticAssertions.push({target:s,assertion:g,attribute:o,expectedValue:l,failureMessage:"",level:"recommended",setup:u})}};return{has:(o,l)=>({...a(o,l),requires:g=>{let k=i(g);return a(o,l,k)}})}}}),this}when(e){return new Ne(this,this.statePack,e)}addDynamicTest(e){this.dynamicTests.push(e)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?this.staticAssertions:[],dynamic:this.dynamicTests}}},Ne=class{constructor(e,r,s){this.parent=e;this.statePack=r;this.event=s}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(e){return this._as=e,this}on(e,r){return this._onTarget=e,this._onRelativeTarget=r,this}given(e){return this._given=this._normalizeStates(e),this}then(e){return this._then=this._normalizeStates(e),this}orientation(e){return this._orientation=e,this}_normalizeStates(e){return(Array.isArray(e)?e:[e]).flatMap(s=>typeof s=="string"?[s]:typeof s=="object"&&s!==null&&"type"in s&&"ref"in s?this._findStateKeyByTypeAndRef(s.type)?[{type:s.type,ref:s.ref}]:[]:[s])}_findStateKeyByTypeAndRef(e){if(Object.keys(this.statePack).includes(e))return e}describe(e){return this._desc=e,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let s={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},i=(u,g=new Set,k)=>{if(g.has(u))return[];g.add(u);let A=this.statePack[u];if(!A)return[];let C=[];if(Array.isArray(A.requires))for(let D of A.requires)C=C.concat(i(D,g,k));if(A.setup){let D=A.setup.filter(B=>B.when.some(G=>s.capabilities.includes(G)));for(let B of D)typeof B.steps=="function"?C=C.concat(B.steps({relativeTarget:k})):C=C.concat(B.steps)}return C},n=[];for(let u of this._given)typeof u=="string"?n=n.concat(i(u,new Set)):typeof u=="object"&&u.type&&(n=n.concat(i(u.type,new Set,u.ref)));let a=new Set;n=n.filter(u=>{let g=[u.type,u.target,u.relativeTarget].join(":");return a.has(g)?!1:(a.add(g),!0)});let o=[];for(let u of this._then)if(typeof u=="string"){let g=this.statePack[u];if(g&&g.assertion!==void 0){let k=g.assertion;if(typeof k=="function")try{k=k()}catch(A){throw new Error(`Error calling assertion function for state '${u}': ${A.message}`)}Array.isArray(k)?o.push(...k):o.push(k)}}else if(typeof u=="object"&&u!==null&&"type"in u&&"ref"in u){let g=this._findStateKeyByTypeAndRef(u.type);if(g){let k=this.statePack[g];if(k&&k.assertion!==void 0){let A=k.assertion;if(typeof A=="function")try{A=A({relativeTarget:u.ref})}catch(C){throw new Error(`Error calling assertion function for state '${g}': ${C.message}`)}Array.isArray(A)?o.push(...A):o.push(A)}}}let l=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:l,assertions:o,...n.length?{setup:n}:{}})}};function cs(t,e){let r=new je(t);return e(r),new Ue(r.build())}Ke();We();var rr=ne(require("path"),1);async function nt(t,e,r={}){if(!t||typeof t!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let s={violations:[]};async function i(g){try{let k=await fetch(g,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(k.ok||k.status===304)return g}catch{return null}return null}let n=we(r.strictness),a={},o=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:g}=await Promise.resolve().then(()=>(xt(),St)),k=await g(process.cwd());if(a=k.config,k.configPath&&(o=rr.default.dirname(k.configPath)),r.strictness===void 0){let A=a.test?.components?.find(C=>C?.name===t)?.strictness;n=we(A??a.test?.strictness)}}catch{r.strictness===void 0&&(n="balanced")}let l;try{if(e){let g=await i(e);if(g){console.log(`\u{1F3AD} Running Playwright tests on ${g}`);let{runContractTestsPlaywright:k}=await Promise.resolve().then(()=>(Yt(),Xt));l=await k(t,g,n,a,o)}else throw new Error(`\u274C Dev server not running at ${e}
|
|
65
|
+
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(g){throw g instanceof Error?g:new Error(`\u274C Contract test execution failed: ${String(g)}`)}let u={violations:s.violations,raw:s,contract:l};if(l.failures.length>0&&e==="Playwright")throw new Error(`
|
|
66
66
|
\u274C ${l.failures.length} accessibility contract test${l.failures.length>1?"s":""} failed (Playwright mode)
|
|
67
67
|
\u2705 ${l.passes.length} test${l.passes.length>1?"s":""} passed
|
|
68
68
|
|
|
69
69
|
\u{1F4CB} Review the detailed test report above for specific failures.
|
|
70
|
-
\u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(s.violations.length>0){let
|
|
71
|
-
- ${
|
|
72
|
-
Impact: ${
|
|
73
|
-
Affected elements: ${
|
|
74
|
-
Help: ${
|
|
70
|
+
\u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(s.violations.length>0){let g=s.violations.length,k=s.violations.map(A=>`
|
|
71
|
+
- ${A.id}: ${A.description}
|
|
72
|
+
Impact: ${A.impact}
|
|
73
|
+
Affected elements: ${A.nodes.length}
|
|
74
|
+
Help: ${A.helpUrl}`).join(`
|
|
75
75
|
`);throw new Error(`
|
|
76
|
-
\u274C ${
|
|
77
|
-
${
|
|
76
|
+
\u274C ${g} axe accessibility violation${g>1?"s":""} detected
|
|
77
|
+
${k}
|
|
78
78
|
|
|
79
|
-
\u{1F4CB} Full details available in result.violations`)}return u}var
|
|
80
|
-
`);let{exec:t}=await import("child_process"),e=(await import("chalk")).default;return new Promise((r,s)=>{t("npx vitest --run --reporter verbose",async(n,
|
|
79
|
+
\u{1F4CB} Full details available in result.violations`)}return u}var sr=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(sr=async()=>{console.log(`\u{1F680} Running component accessibility tests...
|
|
80
|
+
`);let{exec:t}=await import("child_process"),e=(await import("chalk")).default;return new Promise((r,s)=>{t("npx vitest --run --reporter verbose",async(i,n,a)=>{if(console.log(n),a&&console.error(a),!i||i.code===0){try{let{displayBadgeInfo:l,promptAddBadge:u}=await Promise.resolve().then(()=>(tr(),er));l("component"),await u("component",process.cwd()),console.log(e.dim(`
|
|
81
81
|
`+"\u2500".repeat(60))),console.log(e.cyan("\u{1F499} Found aria-ease helpful?")),console.log(e.white(" \u2022 Star us on GitHub: ")+e.blue.underline("https://github.com/aria-ease/aria-ease")),console.log(e.white(" \u2022 Share feedback: ")+e.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log(e.dim("\u2500".repeat(60)+`
|
|
82
|
-
`))}catch(l){console.error("Warning: Could not display badge prompt:",l)}r({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let l=
|
|
82
|
+
`))}catch(l){console.error("Warning: Could not display badge prompt:",l)}r({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let l=i?.code||1;s(new Error(`Tests failed with code ${l}`)),process.exit(l)}})})});async function it(){await Et()}0&&(module.exports={cleanupTests,createContract,makeAccordionAccessible,makeBlockAccessible,makeCheckboxAccessible,makeComboboxAccessible,makeMenuAccessible,makeRadioAccessible,makeTabsAccessible,makeToggleAccessible,testUiComponent});
|