aria-ease 7.8.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/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
- "use strict";var sr=Object.create;var Ee=Object.defineProperty;var nr=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var Y=(t,e)=>()=>(t&&(e=t(t=0)),e);var ie=(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 ir(e))!ar.call(t,i)&&i!==r&&Ee(t,i,{get:()=>e[i],enumerable:!(s=nr(e,i))||s.enumerable});return t},Me=(t,e,r)=>(Ae(t,e,"default"),r&&Ae(r,e,"default")),oe=(t,e,r)=>(r=t!=null?sr(or(t)):{},Ae(e||!t||!t.__esModule?Ee(r,"default",{value:t,enumerable:!0}):r,t)),cr=t=>Ae(Ee({},"__esModule",{value:!0}),t);async function es(){return me||(me=await wt.chromium.launch({headless:!0,args:["--disable-extensions","--disable-blink-features=AutomationControlled"]})),me}async function ts(){return he||(he=await(await es()).newContext({permissions:[],ignoreHTTPSErrors:!0})),he}async function kt(){return await(await ts()).newPage()}async function Tt(){he&&(await he.close(),he=null),me&&(await me.close(),me=null)}var wt,me,he,je=Y(()=>{"use strict";wt=require("playwright"),me=null,he=null});function de(t){return t==="required"||t==="recommended"||t==="optional"?t:rs}function we(t){return t==="minimal"||t==="balanced"||t==="strict"||t==="paranoid"?t:"balanced"}function At(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 rs,Ke=Y(()=>{"use strict";rs="required"});var Et={};ie(Et,{loadConfig:()=>is});function ss(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 ns(t){try{let e=We.default.extname(t);if(e===".json"){let r=await ze.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 is(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=We.default.resolve(t,n);if(await ze.default.pathExists(a)){if(s=a,r=await ns(a),r===null){i.push(`Found config at ${n} but failed to load it. Check for syntax errors.`);continue}let o=ss(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 We,ze,Mt=Y(()=>{"use strict";We=oe(require("path"),1),ze=oe(require("fs-extra"),1)});var J={};ie(J,{default:()=>St.default});var St,pe=Y(()=>{"use strict";Me(J,require("playwright/test"));St=oe(require("playwright/test"),1)});var xt={};ie(xt,{MenuComponentStrategy:()=>Je});var Je,Ct=Y(()=>{"use strict";pe();Je=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,J.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,J.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),n||(await e.mouse.click(10,10),n=await(0,J.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:
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 i=this.selectors.submenuTrigger;return i?await r.locator(i).count()===0:!0}getMainSelector(){return this.mainSelector}}});var $t={};ie($t,{AccordionComponentStrategy:()=>Ge});var Ge,Lt=Y(()=>{"use strict";pe();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.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,J.expect)(l).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{})}}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Rt={};ie(Rt,{ComboboxComponentStrategy:()=>Xe});var Xe,Ht=Y(()=>{"use strict";pe();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.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,J.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,J.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),n||(await e.mouse.click(10,10),n=await(0,J.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:
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 Pt={};ie(Pt,{TabsComponentStrategy:()=>Ye});var Ye,It=Y(()=>{"use strict";Ye=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 Dt={};ie(Dt,{RadioComponentStrategy:()=>Qe});var Qe,Bt=Y(()=>{"use strict";pe();Qe=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,J.expect)(a).toHaveAttribute("aria-checked","false",{timeout:this.assertionTimeoutMs}).catch(()=>{})}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Vt={};ie(Vt,{CheckboxComponentStrategy:()=>Ze});var Ze,qt=Y(()=>{"use strict";pe();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.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,J.expect)(a).toHaveAttribute("aria-checked","false",{timeout:this.assertionTimeoutMs}).catch(()=>{})}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Ft={};ie(Ft,{ToggleComponentStrategy:()=>et});var et,Ot=Y(()=>{"use strict";pe();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.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,J.expect)(a).toHaveAttribute("aria-pressed","false",{timeout:this.assertionTimeoutMs}).catch(()=>{})}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var tt,_t,Le,Ut=Y(()=>{"use strict";tt=oe(require("path"),1),_t=require("url"),Le=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies()}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>Promise.resolve().then(()=>(Ct(),xt)).then(e=>e.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>Promise.resolve().then(()=>(Lt(),$t)).then(e=>e.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>Promise.resolve().then(()=>(Ht(),Rt)).then(e=>e.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>Promise.resolve().then(()=>(It(),Pt)).then(e=>e.TabsComponentStrategy)),this.builtInStrategies.set("radio",()=>Promise.resolve().then(()=>(Bt(),Dt)).then(e=>e.RadioComponentStrategy)),this.builtInStrategies.set("checkbox",()=>Promise.resolve().then(()=>(qt(),Vt)).then(e=>e.CheckboxComponentStrategy)),this.builtInStrategies.set("toggle",()=>Promise.resolve().then(()=>(Ot(),Ft)).then(e=>e.ToggleComponentStrategy))}async loadStrategy(e,r,s){try{if(r)try{let n=tt.default.isAbsolute(r)?r:tt.default.resolve(s||process.cwd(),r),a=await import((0,_t.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 Re,He,os,Pe,Nt=Y(()=>{"use strict";Re=require("fs"),He=oe(require("path"),1);Ut();os={},Pe=class{static strategyRegistry=new Le;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(He.default.isAbsolute(o))return o;if(n){let U=He.default.resolve(n,o);try{return(0,Re.readFileSync)(U,"utf-8"),U}catch{}}let q=He.default.resolve(process.cwd(),o);try{return(0,Re.readFileSync)(q,"utf-8"),q}catch{return new URL(o,os.url).pathname}})(),u=(0,Re.readFileSync)(l,"utf-8"),h=JSON.parse(u).selectors,A=await this.strategyRegistry.loadStrategy(e,a?.strategyPath,n);if(!A)return null;let H=h.main;return e==="tabs"?new A(H,h):new A(H,h,s,i)}}});var Ie,jt=Y(()=>{"use strict";Ie=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+`
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
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
11
  ${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${e.charAt(0).toUpperCase()+e.slice(1)} Component - ${i}`),this.log(`${"\u2550".repeat(60)}
12
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(`
@@ -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(d=>d.status==="pass").length,i=this.dynamicResults.filter(d=>d.status==="fail").length,n=this.dynamicResults.filter(d=>d.status==="warn").length;this.skipped=this.dynamicResults.filter(d=>d.status==="skip").length,this.warnings=this.staticWarnings+n;let a=this.staticPasses+s,o=this.staticFailures+i,l=a+o+this.warnings,u=()=>{let d=`${this.componentName.charAt(0).toUpperCase()}${this.componentName.slice(1)}`;return this.isCustomContract?`${d} component validates against your custom accessibility policy \u2713`:`${d} component meets Aria-Ease baseline WAI-ARIA expectations \u2713`};return e.length>0&&this.reportFailures(e),this.reportWarnings(),this.reportSkipped(),this.log(`
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 Kt={};ie(Kt,{RelativeTargetResolver:()=>ce});var ce,De=Y(()=>{"use strict";ce=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 be,Wt=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 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 ce.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 ce.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 d=await ce.resolve(this.page,u,s);return d?(await d.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 ce.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 ke,zt=Y(()=>{"use strict";pe();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 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 ce.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,J.expect)(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} is visible as expected. Test: "${n}".`}):(await(0,J.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 d=window.getComputedStyle(u);return`display:${d.display}, visibility:${d.visibility}, opacity:${d.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,J.expect)(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${r} has focus as expected. Test: "${n}".`}):(await(0,J.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 ce.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 ce.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 Jt={};ie(Jt,{runContractTestsPlaywright:()=>as});async function as(t,e,r,s,i){let n=s?.test?.components?.find(f=>f.name===t),a=!!n?.contractPath,o=new Ie(!0,a),l={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},u=s?.test?.disableTimeouts===!0,h=n?.disableTimeouts===!0||u,A=(f,v,$)=>{if(h)return 0;let B=f??v;return typeof B!="number"||!Number.isFinite(B)||B<0?$:B},H=A(n?.actionTimeoutMs,s?.test?.actionTimeoutMs,l.actionTimeoutMs),q=A(n?.assertionTimeoutMs,s?.test?.assertionTimeoutMs,l.assertionTimeoutMs),U=A(n?.navigationTimeoutMs,s?.test?.navigationTimeoutMs,l.navigationTimeoutMs),X=A(n?.componentReadyTimeoutMs,s?.test?.componentReadyTimeoutMs,l.componentReadyTimeoutMs),x=we(r),p=n?.contractPath;if(!p)throw new Error(`Contract path not found for component: ${t}`);let k=(()=>{if(Ve.default.isAbsolute(p))return p;if(i){let v=Ve.default.resolve(i,p);try{return(0,Be.readFileSync)(v,"utf-8"),v}catch{}}let f=Ve.default.resolve(process.cwd(),p);try{return(0,Be.readFileSync)(f,"utf-8"),f}catch{return new URL(p,cs.url).pathname}})(),g=(0,Be.readFileSync)(k,"utf-8"),b=JSON.parse(g),F=(b.relationships?.length||0)+(b.static.length||0)+b.dynamic.length,y=b.meta?.source?.apg,C=[],L=[],m=[],T=[],w=null,D=(f,v)=>{let $=de(v),B=At($,x);if(B==="error")return C.push(f),{status:"fail",level:$,detail:f};if(B==="warning")return L.push(f),{status:"warn",level:$,detail:f};let G=`${f} (ignored by strictness=${x}, level=${$})`;return T.push(G),{status:"skip",level:$,detail:G}};try{if(w=await kt(),e){try{await w.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 w.addStyleTag({content:"* { transition: none !important; animation: none !important; }"})}let f=await Pe.detect(t,n,H,q,i);if(!f)throw new Error(`Unsupported component: ${t}`);let v=f.getMainSelector();if(!v)throw new Error(`CRITICAL: No selector found in contract for ${t}`);try{await w.locator(v).first().waitFor({state:"attached",timeout:X})}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 '${v}' in the contract is wrong
36
- - Original error: ${c}`)}o.start(t,F,y),t==="menu"&&b.selectors.main&&await w.locator(b.selectors.main).first().waitFor({state:"visible",timeout:X}).catch(()=>{});let $=t==="menu"&&b.selectors.submenuTrigger?await w.locator(b.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||"")),G=0,Z=0,ee=0;for(let c of b.relationships||[]){if(f&&typeof f.resetState=="function")try{await f.resetState(w)}catch(I){L.push(`Warning: resetState failed before relationship test: ${I instanceof Error?I.message:String(I)}`)}let R=de(c.level);if(Array.isArray(c.setup)&&c.setup.length>0){let N=function(S){return V.includes(S)};var ne=N;let I=new be(w,b.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=S=>({...S,type:N(S.type)?S.type:"click"}),j=c.setup.map(O),z=await Fe(j,I,f,w,W,["submenu","submenuTrigger","submenuItems"]);if(z.skip){T.push(z.message||"Setup action skipped"),o.reportStaticTest(W,"skip",z.message,R);continue}if(!z.success){let S=`Relationship setup failed: ${z.error}`,M=D(S,c.level);M.status==="fail"&&(Z+=1),M.status==="warn"&&(ee+=1),o.reportStaticTest(W,M.status,M.detail,M.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.";T.push(V),o.reportStaticTest(W,"skip",V,R);continue}if(c.type==="aria-reference"){let I=`${c.from}.${c.attribute} references ${c.to}`,W=b.selectors[c.from],V=b.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"&&(Z+=1),P.status==="warn"&&(ee+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}let N=w.locator(W).first(),O=w.locator(V).first(),j=await N.count()>0,z=await O.count()>0;if(!j||!z){if(t==="menu"&&B(c)){let te="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";T.push(te),o.reportStaticTest(I,"skip",te,R);continue}let P=D(`Relationship target not found: ${j?c.to:c.from}.`,c.level);P.status==="fail"&&(Z+=1),P.status==="warn"&&(ee+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}let S=await N.getAttribute(c.attribute),M=await O.getAttribute("id");if(!M){let P=D(`Relationship target "${c.to}" must have an id for ${c.attribute} validation.`,c.level);P.status==="fail"&&(Z+=1),P.status==="warn"&&(ee+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}if(!(S||"").split(/\s+/).filter(Boolean).includes(M)){let P=D(`Expected ${c.from} ${c.attribute} to reference id "${M}", found "${S||""}".`,c.level);P.status==="fail"&&(Z+=1),P.status==="warn"&&(ee+=1),o.reportStaticTest(I,P.status,P.detail,P.level);continue}m.push(`Relationship valid: ${c.from}.${c.attribute} -> ${c.to} (id=${M}).`),G+=1,o.reportStaticTest(I,"pass",void 0,R);continue}if(c.type==="contains"){let I=`${c.parent} contains ${c.child}`,W=b.selectors[c.parent],V=b.selectors[c.child];if(!W||!V){let S=D(`Relationship selector missing: parent="${c.parent}" or child="${c.child}" not found in selectors.`,c.level);S.status==="fail"&&(Z+=1),S.status==="warn"&&(ee+=1),o.reportStaticTest(I,S.status,S.detail,S.level);continue}let N=w.locator(W).first();if(!(await N.count()>0)){if(t==="menu"&&B(c)){let M="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";T.push(M),o.reportStaticTest(I,"skip",M,R);continue}let S=D(`Relationship parent target not found: ${c.parent}.`,c.level);S.status==="fail"&&(Z+=1),S.status==="warn"&&(ee+=1),o.reportStaticTest(I,S.status,S.detail,S.level);continue}if(await N.locator(V).count()<1){if(t==="menu"&&B(c)){let M="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";T.push(M),o.reportStaticTest(I,"skip",M,R);continue}let S=D(`Expected ${c.parent} to contain descendant matching selector for ${c.child}.`,c.level);S.status==="fail"&&(Z+=1),S.status==="warn"&&(ee+=1),o.reportStaticTest(I,S.status,S.detail,S.level);continue}m.push(`Relationship valid: ${c.parent} contains ${c.child}.`),G+=1,o.reportStaticTest(I,"pass",void 0,R)}}async function it(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 ot(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 ot(N,c.property||c.attribute)}}async function ot(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 rr=new ke(w,b.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(M=>V.includes(M)||z.includes(M))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${z}`}:{success:!1,error:z}}}return{success:!0}}for(let c of b.static||[]){if(f&&typeof f.resetState=="function")try{await f.resetState(w)}catch(S){L.push(`Warning: resetState failed before static test: ${S instanceof Error?S.message:String(S)}`)}if(c.target==="relative")continue;let R=`${c.target}${c.attribute?` (${c.attribute})`:""}`,I=de(c.level);if(t==="menu"&&c.target==="submenuTrigger"&&!$){let S=`Skipping submenu static assertion for ${c.target}: no submenu capability detected in rendered component.`;T.push(S),o.reportStaticTest(R,"skip",S,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 S=`${c.target||""}${c.attribute?` (${c.attribute})`:""}`,M=`Static assertion missing required field(s): ${W.join(", ")}`,_=D(M,c.level);_.status==="fail"&&(Z+=1),_.status==="warn"&&(ee+=1),o.reportStaticTest(S,_.status,_.detail,_.level);continue}if(Array.isArray(c.setup)&&c.setup.length>0){let _=function(E){return M.includes(E)};var ne=_;let S=new be(w,b.selectors,H),M=["focus","type","click","keypress","hover"],ae=E=>({...E,type:_(E.type)?E.type:"click"}),P=c.setup.map(ae),te=await Fe(P,S,f,w,R,["submenu","submenuTrigger","submenuItems"]);if(te.skip){T.push(te.message||"Setup action skipped"),o.reportStaticTest(R,"skip",te.message,I);continue}if(!te.success){let E=`Static setup failed: ${te.error}`,K=D(E,c.level);K.status==="fail"&&(Z+=1),K.status==="warn"&&(ee+=1),o.reportStaticTest(R,K.status,K.detail,K.level);continue}}let V=b.selectors[c.target];if(!V){let S=`Selector for target ${c.target} not found.`,M=D(S,c.level);M.status==="fail"&&(Z+=1),M.status==="warn"&&(ee+=1),o.reportStaticTest(R,M.status,M.detail,M.level);continue}let N=w.locator(V).first();if(!(await N.count()>0)){let S=`Target ${c.target} not found.`,M=D(S,c.level);M.status==="fail"&&(Z+=1),M.status==="warn"&&(ee+=1),o.reportStaticTest(R,M.status,M.detail,M.level);continue}let j=(S,M,_)=>{let ae=new RegExp(`\\[${M}(?:=["']?([^\\]"']+)["']?)?\\]`),P=S.match(ae);if(!P)return!1;if(!_)return!0;let te=P[1];return te?_.split(" | ").includes(te):!1},z=c.expectedValue;if(c.expectedValue&&typeof c.expectedValue=="object"&&"ref"in c.expectedValue){let S={},M=c.relativeTarget;if(c.expectedValue.ref==="relative"&&c.target==="relative"&&M){let _=b.selectors[M];if(!_)throw new Error(`Selector for relativeTarget '${M}' not found in contract selectors.`);S.relativeBaseSelector=_}else if(c.expectedValue.ref==="relative"&&M){let _=b.selectors[M];if(!_)throw new Error(`Selector for relativeTarget '${M}' not found in contract selectors.`);S.relativeBaseSelector=_}z=await it(c.expectedValue,b.selectors,w,S)}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}).`),G+=1,o.reportStaticTest(R,"pass",void 0,I);else{let S=z??"",M=await rr.validateAttribute(N,c.target,c.attribute,S,c.failureMessage,"Static ARIA Test");if(M.success&&M.passMessage)m.push(M.passMessage),G+=1,o.reportStaticTest(R,"pass",void 0,I);else if(!M.success&&M.failMessage){let _=D(M.failMessage,c.level);_.status==="fail"&&(Z+=1),_.status==="warn"&&(ee+=1),o.reportStaticTest(R,_.status,_.detail,_.level)}}else{let S=c.attribute.split(" | "),M=!1,_=!0;for(let ae of S){let P=ae.trim();if(j(V,P)){m.push(`${P} on ${c.target} verified by selector (already present in: ${V}).`),M=!0;continue}if(_=!1,await N.getAttribute(P)!==null){M=!0;break}}if(!M&&!_){let ae=c.failureMessage+` None of the attributes "${c.attribute}" are present.`,P=D(ae,c.level);P.status==="fail"&&(Z+=1),P.status==="warn"&&(ee+=1),o.reportStaticTest(R,P.status,P.detail,P.level)}else!_&&M?(m.push(`At least one of the attributes "${c.attribute}" exists on the element.`),G+=1,o.reportStaticTest(R,"pass",void 0,I)):(G+=1,o.reportStaticTest(R,"pass",void 0,I))}}for(let c of b.dynamic||[]){if(!c.assertions||c.assertions.length===0){let E="Skipping test - no assertions found for this dynamic test.";T.push(E),o.reportTest({description:c.description,level:de(c.level)},"skip",E);continue}if(!w||w.isClosed()){console.warn(`
37
- \u26A0\uFE0F Browser closed - skipping remaining ${b.dynamic.length-b.dynamic.indexOf(c)} tests
38
- `),C.push(`CRITICAL: Browser/page closed before completing all tests. ${b.dynamic.length-b.dynamic.indexOf(c)} tests skipped.`);break}try{await f.resetState(w)}catch(E){let K=E instanceof Error?E.message:String(E);throw o.error(K),E}let{setup:R=[],action:I,assertions:W}=c,V=de(c.level),N=new be(w,b.selectors,H);if(Array.isArray(R)&&R.length>0){let K=function(re){return E.includes(re)};var ne=K;let E=["focus","type","click","keypress","hover"],ge=re=>({...re,type:K(re.type)?re.type:"click"}),Oe=R.map(ge),le=await Fe(Oe,N,f,w,c.description,["submenu","submenuTrigger","submenuItems"]);if(le.skip){T.push(le.message||"Setup action skipped"),o.reportTest({description:c.description,level:V},"skip",le.message);continue}if(!le.success){let re=D(`Setup failed: ${le.error}`,c.level);o.reportTest({description:c.description,level:V},re.status,re.detail);continue}}let O=C.length,j=L.length,z=T.length;if(await f.shouldSkipTest(c,w)){let E="Skipping test - component-specific conditions not met";T.push(E),o.reportTest({description:c.description,level:V},"skip",E);continue}let M=new ke(w,b.selectors,q),_=!1,ae=null;for(let E of I){if(!w||w.isClosed()){C.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),_=!0;break}let K;if(E.type==="focus")E.target==="relative"&&E.relativeTarget?K=await N.focus("relative",E.relativeTarget):K=await N.focus(E.target);else if(E.type==="type"&&E.value)K=await N.type(E.target,E.value);else if(E.type==="click")K=await N.click(E.target,E.relativeTarget);else if(E.type==="keypress"&&E.key)K=await N.keypress(E.target,E.key,E.relativeTarget);else if(E.type==="hover")K=await N.hover(E.target,E.relativeTarget);else continue;if(!K.success){if(K.error){let ge=D(K.error,c.level);ae={status:ge.status,detail:ge.detail}}_=!0;break}}if(_){o.reportTest({description:c.description,level:V},ae?.status||"fail",ae?.detail||C[C.length-1]);continue}for(let E of W){let K;if(E.expectedValue&&typeof E.expectedValue=="object"&&"ref"in E.expectedValue)if(E.expectedValue.ref==="relative"){let{RelativeTargetResolver:ue}=await Promise.resolve().then(()=>(De(),Kt)),re=b.selectors.relative;if(!re)throw new Error("Relative selector not defined in contract selectors.");let ye=E.relativeTarget||"first",fe=await ue.resolve(w,re,ye);if(!fe)throw new Error(`Could not resolve relative target '${ye}' for expectedValue.`);let ct=E.expectedValue.property||E.expectedValue.attribute||"id";if(ct==="textContent")K=await fe.evaluate(Te=>Te.textContent??void 0);else{let Te=await fe.getAttribute(ct);K=Te===null?void 0:Te}}else K=await it(E.expectedValue,b.selectors,w,{});else typeof E.expectedValue=="string"||typeof E.expectedValue>"u"?K=E.expectedValue:K="";let ge={...E,expectedValue:K},Oe=K??"",le=await M.validate({...ge,expectedValue:Oe},c.description);if(le.success&&le.passMessage)m.push(le.passMessage);else if(!le.success&&le.failMessage){let ue=[];if(E.target||ue.push("target"),E.assertion||ue.push("assertion"),["toHaveAttribute","toHaveValue","toHaveRole"].includes(E.assertion)&&(typeof E.attribute>"u"&&E.assertion==="toHaveAttribute"&&ue.push("attribute"),typeof E.expectedValue>"u"&&ue.push("expectedValue")),ue.length>0){let re=de(E.level||c.level),ye=`Dynamic assertion missing required field(s): ${ue.join(", ")}`,fe=D(ye,re);if(fe.status==="skip")continue;C.push(ye),o.reportTest({description:c.description,level:re},fe.status,fe.detail);continue}}}let P=C.length,te=L.length,at=T.length;P>O?o.reportTest({description:c.description,level:V},"fail",C[C.length-1]):te>j?o.reportTest({description:c.description,level:V},"warn",L[L.length-1]):at>z?o.reportTest({description:c.description,level:V},"skip",T[T.length-1]):o.reportTest({description:c.description,level:V},"pass")}o.reportStatic(G,Z,ee),o.summary(C)}catch(f){if(f instanceof Error)throw f.message.includes("Executable doesn't exist")||f.message.includes("browserType.launch")?new Error(`
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`):f.message.includes("net::ERR_CONNECTION_REFUSED")||f.message.includes("NS_ERROR_CONNECTION_REFUSED")?new Error(`
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}`):f.message.includes("Timeout")&&f.message.includes("waitFor")?new Error(`
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
- The component selector could not be found within ${X}ms.
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
- `):f.message.includes("Target page, context or browser has been closed")?new Error(`
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`):f}finally{w&&await w.close()}return{passes:m,failures:C,skipped:T,warnings:L}}var Be,Ve,cs,Gt=Y(()=>{"use strict";Be=require("fs"),Ve=oe(require("path"),1);je();Nt();jt();Wt();zt();Ke();cs={}});var Qt={};ie(Qt,{BADGE_CONFIGS:()=>rt,displayAllBadges:()=>fs,displayBadgeInfo:()=>ls,getBadgeMarkdown:()=>ve,promptAddBadge:()=>us});function ve(t){let e=rt[t];return`[![${e.label}](${e.markdownUrl})](https://github.com/aria-ease/aria-ease)`}function ls(t){let e=ve(t);console.log(Q.default.cyan(`
55
- \u{1F3C5} Show your accessibility commitment!`)),console.log(Q.default.white(` Add this badge to your README.md:
56
- `)),console.log(Q.default.green(" "+e)),console.log(Q.default.dim(`
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`[![${e.label}](${e.markdownUrl})](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 us(t,e=process.cwd()){let r=Xt.default.join(e,"README.md");if(!await qe.default.pathExists(r)){console.log(Q.default.yellow(" \u2139\uFE0F No README.md found in current directory"));return}let i=await qe.default.readFile(r,"utf-8"),n=ve(t);if(i.includes(n)||i.includes(rt[t].fileName)){console.log(Q.default.gray(" \u2713 Badge already in README.md"));return}let a=Yt.default.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(l=>{a.question(Q.default.cyan(" Add badge to README.md now? (y/n): "),u=>{a.close(),l(u.toLowerCase().trim())})});o==="y"||o==="yes"?(await ps(r,i,n),console.log(Q.default.green(" \u2713 Badge added to README.md!"))):console.log(Q.default.gray(" Skipped. You can add it manually anytime."))}async function ps(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 qe.default.writeFile(t,s.join(`
60
- `),"utf-8")}function fs(){console.log(Q.default.cyan(`
61
- \u{1F4CD} Available badges:`)),console.log(Q.default.white(`
62
- For audits:`)),console.log(Q.default.green(" "+ve("audit"))),console.log(Q.default.white(`
63
- For component testing:`)),console.log(Q.default.green(" "+ve("component"))),console.log(Q.default.white(`
64
- For both (verified):`)),console.log(Q.default.green(" "+ve("verified"))),console.log("")}var qe,Xt,Q,Yt,rt,Zt=Y(()=>{"use strict";qe=oe(require("fs-extra"),1),Xt=oe(require("path"),1),Q=oe(require("chalk"),1),Yt=oe(require("readline"),1),rt={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 ds={};ie(ds,{cleanupTests:()=>nt,createContract:()=>Zr,makeAccordionAccessible:()=>lr,makeBlockAccessible:()=>fr,makeCheckboxAccessible:()=>dr,makeComboboxAccessible:()=>hr,makeMenuAccessible:()=>pt,makeRadioAccessible:()=>gr,makeTabsAccessible:()=>br,makeToggleAccessible:()=>mr,testUiComponent:()=>st});module.exports=cr(ds);function lr({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 d(){a.forEach((g,b)=>{let F=o[b];g.id||(g.id=`${t}-trigger-${b}`),F.id||(F.id=`${t}-panel-${b}`),g.setAttribute("aria-controls",F.id),g.setAttribute("aria-expanded","false"),(!s||a.length<=6)&&F.setAttribute("role","region"),F.setAttribute("aria-labelledby",g.id),F.style.display="none"})}function h(g){if(g<0||g>=a.length){console.error(`[aria-ease] Invalid accordion index: ${g}`);return}let b=a[g],F=o[g];if(b.setAttribute("aria-expanded","true"),F.style.display="block",i?.onExpandedChange)try{i.onExpandedChange(g,!0)}catch(y){console.error("[aria-ease] Error in accordion onExpandedChange callback:",y)}}function A(g){if(g<0||g>=a.length){console.error(`[aria-ease] Invalid accordion index: ${g}`);return}let b=a[g],F=o[g];if(b.setAttribute("aria-expanded","false"),F.style.display="none",i?.onExpandedChange)try{i.onExpandedChange(g,!1)}catch(y){console.error("[aria-ease] Error in accordion onExpandedChange callback:",y)}}function H(g){a[g].getAttribute("aria-expanded")==="true"?A(g):(s||a.forEach((y,C)=>{C!==g&&A(C)}),h(g))}function q(g){return()=>{H(g)}}function U(g){return b=>{let{key:F}=b;switch(F){case"Enter":case" ":b.preventDefault(),H(g);break;case"ArrowDown":b.preventDefault();{let y=(g+1)%a.length;a[y].focus()}break;case"ArrowUp":b.preventDefault();{let y=(g-1+a.length)%a.length;a[y].focus()}break;case"Home":b.preventDefault(),a[0].focus();break;case"End":b.preventDefault(),a[a.length-1].focus();break}}}function X(){a.forEach((g,b)=>{let F=q(b),y=U(b);g.addEventListener("click",F),g.addEventListener("keydown",y),l.set(g,y),u.set(g,F)})}function x(){a.forEach(g=>{let b=l.get(g),F=u.get(g);b&&(g.removeEventListener("keydown",b),l.delete(g)),F&&(g.removeEventListener("click",F),u.delete(g))})}function p(){x(),a.forEach((g,b)=>{A(b)})}function k(){x();let g=Array.from(n.querySelectorAll(`.${e}`)),b=Array.from(n.querySelectorAll(`.${r}`));a.length=0,a.push(...g),o.length=0,o.push(...b),d(),X()}return d(),X(),{expandItem:h,collapseItem:A,toggleItem:H,cleanup:p,refresh:k}}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 lt(t){return t.tagName==="BUTTON"||t.tagName==="INPUT"&&["button","submit","reset"].includes(t.type)}function ur(t){return t.tagName==="A"}function Ce(t,e,r){let s=t.length,i=(e+r+s)%s;t.item(i).focus()}function pr(t){return t.getAttribute("data-custom-click")!==null&&t.getAttribute("data-custom-click")!==void 0}function ut(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" ":{(!lt(s)&&!ur(s)&&pr(s)||lt(s))&&(t.preventDefault(),s.click());break}case"Tab":break;default:break}}function fr({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 d=h=>{let A=r.querySelectorAll(`.${e}`),H=Array.prototype.indexOf.call(A,u);ut(h,A,H)};u.addEventListener("keydown",d),a.set(u,d)}});function o(){n.forEach(u=>{let d=a.get(u);d&&(u.removeEventListener("keydown",d),a.delete(u))})}function l(){s=null}return{cleanup:o,refresh:l}}function dr({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 k=p.checked;p.setAttribute("aria-checked",k?"true":"false"),p.hasAttribute("tabindex")||p.setAttribute("tabindex","0")})}function l(p,k){if(r?.onCheckedChange)try{r.onCheckedChange(p,k)}catch(g){console.error("[aria-ease] Error in checkbox onCheckedChange callback:",g)}}function u(p){if(p<0||p>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${p}`);return}let k=i[p],g=!k.checked;k.checked=g,k.setAttribute("aria-checked",g?"true":"false"),l(p,g)}function d(p,k){if(p<0||p>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${p}`);return}let g=i[p];g.checked=k,g.setAttribute("aria-checked",k?"true":"false"),l(p,k)}function h(p){return()=>{let k=i[p];if("checked"in k&&typeof k.checked=="boolean")setTimeout(()=>{let g=k.checked;k.setAttribute("aria-checked",g?"true":"false"),l(p,g)},0);else{let g=k.getAttribute("aria-checked")==="true";k.setAttribute("aria-checked",g?"false":"true"),l(p,!g)}}}function A(p){return k=>{let{key:g}=k;switch(g){case" ":case"Spacebar":k.preventDefault(),u(p);break}}}function H(){i.forEach((p,k)=>{let g=h(k),b=A(k);p.addEventListener("click",g),p.addEventListener("keydown",b),n.set(p,b),a.set(p,g)})}function q(){i.forEach(p=>{let k=n.get(p),g=a.get(p);k&&(p.removeEventListener("keydown",k),n.delete(p)),g&&(p.removeEventListener("click",g),a.delete(p))})}function U(){q()}function X(){return i.map(p=>p.getAttribute("aria-checked")==="true")}function x(){return i.map((p,k)=>p.getAttribute("aria-checked")==="true"?k:-1).filter(p=>p!==-1)}return o(),H(),{toggleCheckbox:u,setCheckboxState:d,getCheckedStates:X,getCheckedIndices:x,cleanup:U}}function pt({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 d(){return l||(l=i.querySelectorAll(`.${e}`)),l}function h(){if(!u){let f=d();u=[];for(let v=0;v<f.length;v++){let $=f.item(v),B=k($),G=$.getAttribute("aria-disabled")==="true";B||($.hasAttribute("tabindex")||$.setAttribute("tabindex","-1"),G||u.push($))}}return u}function A(f){return{length:f.length,item:$=>f[$],forEach:$=>{f.forEach($)},[Symbol.iterator]:function*(){for(let $ of f)yield $}}}function H(){d().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(f,v,$){let B=f.length,G=(v+$+B)%B;f.item(G).focus()}function U(f,v){f.length!==0&&f[v]?.focus()}function X(f){return f.hasAttribute("aria-controls")&&f.hasAttribute("aria-haspopup")&&f.getAttribute("role")==="menuitem"}function x(f){let v=f;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 G=document.getElementById(B);if(!G)break;v=G}}H();function p(f,v,$){switch(f.key){case"ArrowLeft":{if(f.key==="ArrowLeft"&&n.getAttribute("role")==="menuitem"){f.preventDefault(),m();return}break}case"ArrowUp":{f.preventDefault(),q(A(h()),$,-1);break}case"ArrowRight":{if(f.key==="ArrowRight"&&X(v)){f.preventDefault();let B=v.getAttribute("aria-controls");if(B){b(B);return}}break}case"ArrowDown":{f.preventDefault(),q(A(h()),$,1);break}case"Home":{f.preventDefault(),U(h(),0);break}case"End":{f.preventDefault();let B=h();U(B,B.length-1);break}case"Escape":{f.preventDefault(),m(),n.focus(),F&&F(!1);break}case"Enter":case" ":{if(f.preventDefault(),X(v)){let B=v.getAttribute("aria-controls");if(B){b(B);return}}v.click(),m(),F&&F(!1);break}case"Tab":{m(),x(n),F&&F(!1);break}default:break}}function k(f){let v=f.parentElement;for(;v&&v!==i;){if(v.getAttribute("role")==="menu"||v.id&&i.querySelector(`[aria-controls="${v.id}"]`))return!0;v=v.parentElement}return!1}function g(f){n.setAttribute("aria-expanded",f?"true":"false")}function b(f){let v=o.get(f);if(!v){let $=i.querySelector(`[aria-controls="${f}"]`);if(!$){console.error(`[aria-ease] Submenu trigger with aria-controls="${f}" not found in menu "${t}".`);return}if(!$.id){let G=`trigger-${f}`;$.id=G,console.warn(`[aria-ease] Submenu trigger for "${f}" had no ID. Auto-generated ID: "${G}".`)}if(!document.querySelector(`#${f}`)){console.error(`[aria-ease] Submenu element with id="${f}" not found. Cannot create submenu instance.`);return}v=pt({menuId:f,menuItemsClass:e,triggerId:$.id,callback:s}),o.set(f,v)}v.openMenu()}function F(f){if(s?.onExpandedChange)try{s.onExpandedChange(f)}catch(v){console.error("[aria-ease] Error in menu onExpandedChange callback:",v)}}function y(){h().forEach((v,$)=>{if(!a.has(v)){let B=G=>p(G,v,$);v.addEventListener("keydown",B),a.set(v,B)}})}function C(){h().forEach(v=>{let $=a.get(v);$&&(v.removeEventListener("keydown",$),a.delete(v))})}function L(){g(!0),i.style.display="block";let f=h();if(y(),f&&f.length>0&&f[0].focus(),s?.onExpandedChange)try{s.onExpandedChange(!0)}catch(v){console.error("[aria-ease] Error in menu onExpandedChange callback:",v)}}function m(){if(o.forEach(f=>f.closeMenu()),g(!1),i.style.display="none",C(),n.focus(),s?.onExpandedChange)try{s.onExpandedChange(!1)}catch(f){console.error("[aria-ease] Error in menu onExpandedChange callback:",f)}}function T(){n.getAttribute("aria-expanded")==="true"?m():L()}function w(f){if(!(n.getAttribute("aria-expanded")==="true"))return;let $=n.contains(f.target),B=i.contains(f.target);!$&&!B&&m()}n.addEventListener("click",T),document.addEventListener("click",w);function D(){C(),n.removeEventListener("click",T),document.removeEventListener("click",w),i.style.display="none",g(!1),o.forEach(f=>f.cleanup()),o.clear()}function ne(){l=null,u=null}return{openMenu:L,closeMenu:m,cleanup:D,refresh:ne}}function gr({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((x,p)=>{x.setAttribute("role","radio"),x.setAttribute("tabindex","0");let k=p===l;x.setAttribute("aria-checked",k?"true":"false"),x.checked!==void 0&&(x.checked=k)})}function d(x){if(x<0||x>=n.length){console.error(`[aria-ease] Invalid radio index: ${x}`);return}if(l>=0&&l<n.length&&(n[l].setAttribute("aria-checked","false"),n[l].checked!==void 0&&(n[l].checked=!1)),n[x].setAttribute("aria-checked","true"),n[x].checked!==void 0&&(n[x].checked=!0),n[x].focus(),s?.onValueChange)try{s.onValueChange(x,n[x].getAttribute("value"))}catch(p){console.error("[aria-ease] Error in radio onValueChange callback:",p)}l=x}function h(x){return()=>{let p=n[x];"checked"in p&&typeof p.checked=="boolean"?setTimeout(()=>{d(x)},0):d(x)}}function A(x){return p=>{let{key:k}=p,g=x;switch(k){case"ArrowDown":case"ArrowRight":p.preventDefault(),g=(x+1)%n.length,d(g);break;case"ArrowUp":case"ArrowLeft":p.preventDefault(),g=(x-1+n.length)%n.length,d(g);break;case" ":case"Enter":p.preventDefault(),d(x);break}}}function H(){n.forEach((x,p)=>{let k=h(p),g=A(p);x.addEventListener("click",k),x.addEventListener("keydown",g),a.set(x,g),o.set(x,k)})}function q(){n.forEach(x=>{let p=a.get(x),k=o.get(x);p&&(x.removeEventListener("keydown",p),a.delete(x)),k&&(x.removeEventListener("click",k),o.delete(x))})}function U(){q()}function X(){return l}return u(),H(),{selectRadio:d,getSelectedIndex:X,cleanup:U}}function mr({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 g=n[p].getAttribute("aria-pressed")==="true";d(p,!g)}function d(p,k){if(p<0||p>=n.length){console.error(`[aria-ease] Invalid toggle index: ${p}`);return}if(n[p].setAttribute("aria-pressed",k?"true":"false"),s?.onPressedChange)try{s.onPressedChange(p,k)}catch(g){console.error("[aria-ease] Error in checkbox onPressedChange callback:",g)}}function h(p){return()=>{u(p)}}function A(p){return k=>{let{key:g}=k;switch(g){case"Enter":case" ":k.preventDefault(),u(p);break}}}function H(){n.forEach((p,k)=>{let g=h(k),b=A(k);p.addEventListener("click",g),p.addEventListener("keydown",b),a.set(p,b),o.set(p,g)})}function q(){n.forEach(p=>{let k=a.get(p),g=o.get(p);k&&(p.removeEventListener("keydown",k),a.delete(p)),g&&(p.removeEventListener("click",g),o.delete(p))})}function U(){q()}function X(){return n.map(p=>p.getAttribute("aria-pressed")==="true")}function x(){return n.map((p,k)=>p.getAttribute("aria-pressed")==="true"?k:-1).filter(p=>p!==-1)}return l(),H(),{toggleButton:u,setPressed:d,getPressedStates:X,getPressedIndices:x,cleanup:U}}function hr({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 d=null;function h(){return d||(d=a.querySelectorAll(`.${s}`)),Array.from(d).filter(m=>!m.hidden&&m.style.display!=="none")}function A(){return n.getAttribute("aria-expanded")==="true"}function H(m){let T=h();if(m>=0&&m<T.length){let w=T[m],D=w.id||`${r}-option-${m}`;if(w.id||(w.id=D),n.setAttribute("aria-activedescendant",D),typeof w.scrollIntoView=="function"&&w.scrollIntoView({block:"nearest",behavior:"smooth"}),i?.onActiveDescendantChange)try{i.onActiveDescendantChange(D,w)}catch(ne){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",ne)}}else n.setAttribute("aria-activedescendant","");u=m}function q(){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 U(){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 X(m){let T=m.textContent?.trim()||"";if(n.value=T,m.setAttribute("aria-selected","true"),U(),i?.onSelect)try{i.onSelect(m)}catch(w){console.error("[aria-ease] Error in combobox onSelect callback:",w)}}function x(m){let T=h(),w=A();switch(m.key){case"ArrowDown":if(m.preventDefault(),!w){q();return}if(T.length===0)return;{let D=u>=T.length-1?0:u+1;H(D)}break;case"ArrowUp":if(m.preventDefault(),!w)return;if(T.length>0){let D=u<=0?T.length-1:u-1;H(D)}break;case"Enter":w&&u>=0&&u<T.length&&(m.preventDefault(),X(T[u]));break;case"Escape":if(w)m.preventDefault(),U();else if(n.value&&(m.preventDefault(),n.value="",n.setAttribute("aria-activedescendant",""),h().forEach(ne=>{ne.getAttribute("aria-selected")==="true"&&ne.setAttribute("aria-selected","false")}),i?.onClear))try{i.onClear()}catch(ne){console.error("[aria-ease] Error in combobox onClear callback:",ne)}break;case"Home":w&&T.length>0&&(m.preventDefault(),H(0));break;case"End":w&&T.length>0&&(m.preventDefault(),H(T.length-1));break;case"Tab":w&&u>=0&&u<T.length&&X(T[u]),w&&U();break}}function p(m){let T=m.target;if(T.classList.contains(s)){let D=h().indexOf(T);D>=0&&H(D)}}function k(m){let T=m.target;T.classList.contains(s)&&(m.preventDefault(),X(T))}function g(m){let T=m.target;!n.contains(T)&&!a.contains(T)&&(!l||!l.contains(T))&&U()}function b(){A()?U():(q(),n.focus())}function F(m){(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),b())}n.addEventListener("keydown",x),a.addEventListener("mousemove",p),a.addEventListener("mousedown",k),document.addEventListener("mousedown",g),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",b),l.addEventListener("keydown",F));function y(){let m=a.querySelectorAll(`.${s}`);if(m.length===0)return;let T=null;for(let w of m)if(w.getAttribute("aria-selected")==="true"){T=w.textContent?.trim()||null;break}!T&&n.value&&(T=n.value.trim()),m.forEach((w,D)=>{w.setAttribute("role","option");let ne=w.textContent?.trim()||"";T&&ne===T?w.setAttribute("aria-selected","true"):w.setAttribute("aria-selected","false");let f=w.getAttribute("id");if(!f||f===""){let v=`${r}-option-${D}`;w.id=v,w.setAttribute("id",v)}})}y();function C(){n.removeEventListener("keydown",x),a.removeEventListener("mousemove",p),a.removeEventListener("mousedown",k),document.removeEventListener("mousedown",g),l&&(l.removeEventListener("click",b),l.removeEventListener("keydown",F))}function L(){d=null,y(),u=-1,H(-1)}return{cleanup:C,refresh:L,openListbox:q,closeListbox:U}}function br({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,d=new WeakMap,h=new WeakMap,A=0;function H(){a.setAttribute("role","tablist"),a.setAttribute("aria-orientation",s),o.forEach((y,C)=>{let L=l[C];y.id||(y.id=`${t}-tab-${C}`),L.id||(L.id=`${t}-panel-${C}`),y.setAttribute("role","tab"),y.setAttribute("aria-controls",L.id),y.setAttribute("aria-selected","false"),y.setAttribute("tabindex","-1"),L.setAttribute("role","tabpanel"),L.setAttribute("aria-labelledby",y.id),L.hidden=!0,L.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||L.setAttribute("tabindex","0")}),q(0,!1)}function q(y,C=!0){if(y<0||y>=o.length){console.error(`[aria-ease] Invalid tab index: ${y}`);return}o.forEach((T,w)=>{let D=l[w];T.setAttribute("aria-selected","false"),T.setAttribute("tabindex","-1"),D.hidden=!0});let L=o[y],m=l[y];if(L.setAttribute("aria-selected","true"),L.setAttribute("tabindex","0"),m.hidden=!1,C&&L.focus(),A=y,n?.onSelectedChange)try{n.onSelectedChange(y,!0)}catch(T){console.error("[aria-ease] Error in tabs onSelectedChange callback:",T)}}function U(y){let C=o.findIndex(T=>T===document.activeElement),L=C!==-1?C:A,m=L;switch(y){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)q(m,!1);else{let T=A;o.forEach((w,D)=>{D===m?w.setAttribute("tabindex","0"):D!==T&&w.setAttribute("tabindex","-1")})}}function X(y){return()=>{q(y)}}function x(y){return C=>{let{key:L}=C,m=!1;if(s==="horizontal")switch(L){case"ArrowLeft":C.preventDefault(),U("prev"),m=!0;break;case"ArrowRight":C.preventDefault(),U("next"),m=!0;break}else switch(L){case"ArrowUp":C.preventDefault(),U("prev"),m=!0;break;case"ArrowDown":C.preventDefault(),U("next"),m=!0;break}if(!m)switch(L){case"Home":C.preventDefault(),U("first");break;case"End":C.preventDefault(),U("last");break;case" ":case"Enter":i||(C.preventDefault(),q(y));break;case"F10":if(C.shiftKey&&n?.onContextMenu){C.preventDefault();try{n.onContextMenu(y,o[y])}catch(T){console.error("[aria-ease] Error in tabs onContextMenu callback:",T)}}break}}}function p(y){return C=>{if(n?.onContextMenu){C.preventDefault();try{n.onContextMenu(y,o[y])}catch(L){console.error("[aria-ease] Error in tabs onContextMenu callback:",L)}}}}function k(){o.forEach((y,C)=>{let L=X(C),m=x(C),T=p(C);y.addEventListener("click",L),y.addEventListener("keydown",m),n?.onContextMenu&&(y.addEventListener("contextmenu",T),h.set(y,T)),u.set(y,m),d.set(y,L)})}function g(){o.forEach(y=>{let C=u.get(y),L=d.get(y),m=h.get(y);C&&(y.removeEventListener("keydown",C),u.delete(y)),L&&(y.removeEventListener("click",L),d.delete(y)),m&&(y.removeEventListener("contextmenu",m),h.delete(y))})}function b(){g(),o.forEach((y,C)=>{let L=l[C];y.removeAttribute("role"),y.removeAttribute("aria-selected"),y.removeAttribute("aria-controls"),y.removeAttribute("tabindex"),L.removeAttribute("role"),L.removeAttribute("aria-labelledby"),L.removeAttribute("tabindex"),L.hidden=!1}),a.removeAttribute("role"),a.removeAttribute("aria-orientation")}function F(){g();let y=Array.from(a.querySelectorAll(`.${e}`)),C=Array.from(document.querySelectorAll(`.${r}`));o.length=0,o.push(...y),l.length=0,l.push(...C),H(),k()}return H(),k(),{activateTab:q,cleanup:b,refresh:F}}function se(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 dt={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:vr},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...yr(),...ft()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:Ar},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Er},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:Mr},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:Sr},"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={})=>wr(t.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:kr},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ft},"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={})=>Tr(t.relativeTarget)}};function vr(){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 yr(){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 wr(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 kr(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function ft(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function Tr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${se("option",t)} to have aria-selected='true'.`}]}function Ar(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function Er(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function Mr(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function Sr(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var gt={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:xr},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Cr},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:$r},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Lr},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(t={})=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Rr(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:Hr},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Pr},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Ir},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Dr},"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={})=>Br(t.relativeTarget)}};function xr(){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 Cr(){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 $r(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function Lr(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function Rr(t){return[{target:"relative",assertion:"toHaveFocus",expectedValue:t,failureMessage:`${t} menu item should have focus.`}]}function Hr(){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 Pr(){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 Ir(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Dr(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function Br(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${t} to have focus.`}]}var mt={"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={})=>Fr(t.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(t={})=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Vr(t.relativeTarget)}};function Vr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${se("tab",t)} to have focus.`}]}function qr(t){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:t,failureMessage:`Expected ${se("tab",t)} to have tabindex='0'.`}]}function Fr(t){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:t,failureMessage:`Expected ${se("tab",t)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:t},failureMessage:`Expected panel controlled by the ${se("tab",t)} to be visible.`},qr(t)]}var ht={"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={})=>Or(t.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>_r(t.relativeTarget)}};function Or(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 _r(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 bt={"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={})=>Ur(t.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Nr(t.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>jr(t.relativeTarget)}};function Ur(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function Nr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function jr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${se("radio",t)} to have focus.`}]}var vt={"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={})=>Kr(t.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Wr(t.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>zr(t.relativeTarget)}};function Kr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function Wr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function zr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${se("checkbox",t)} to have focus.`}]}var yt={"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={})=>Jr(t.relativeTarget)},"toggle.unpressed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(t={})=>Gr(t.relativeTarget)},"toggle.focused":{setup:[{when:["keyboard","pointer"],steps:t=>[{type:"focus",target:"relative",relativeTarget:t.relativeTarget}]}],assertion:(t={})=>Xr(t.relativeTarget)}};function Jr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"true",failureMessage:"Expected toggle to have aria-pressed='true' when pressed."}]}function Gr(t){return[{target:"relative",relativeTarget:t,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"false",failureMessage:"Expected toggle to have aria-pressed='false' when unpressed."}]}function Xr(t){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:t,failureMessage:`Expected ${se("toggle",t)} to have focus.`}]}function Yr(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(Yr(e,r.when))return r.steps(e);throw new Error(`No setup strategy matches capabilities: ${e.capabilities.join(", ")}`)}var Qr={combobox:dt,menu:gt,tabs:mt,accordion:ht,radio:bt,checkbox:vt,toggle:yt},_e=class{constructor(e){this.jsonContract=e}toJSON(){return this.jsonContract}},Ue=class{constructor(e){this.componentName=e;this.statePack=Qr[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 d of l.requires)u=u.concat(i(d,o));return l.setup&&(u=u.concat($e(l.setup,s))),u};return e({ariaReference:(a,o,l)=>({requires:u=>{let d=i(u,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"required",setup:d}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"optional",setup:d}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:l,level:"recommended",setup:d})}},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"]},d=(h,A=new Set)=>{if(A.has(h))return[];A.add(h);let H=l[h];if(!H)return[];let q=[];if(Array.isArray(H.requires))for(let U of H.requires)q=q.concat(d(U,A));return H.setup&&(q=q.concat($e(H.setup,u))),q};return d(o,new Set)},n=o=>o==="role"?"toHaveRole":"toHaveAttribute",a=(o,l,u)=>{let d=n(o);return{required:()=>this.staticAssertions.push({target:s,assertion:d,attribute:o,expectedValue:l,failureMessage:"",level:"required",setup:u}),optional:()=>this.staticAssertions.push({target:s,assertion:d,attribute:o,expectedValue:l,failureMessage:"",level:"optional",setup:u}),recommended:()=>this.staticAssertions.push({target:s,assertion:d,attribute:o,expectedValue:l,failureMessage:"",level:"recommended",setup:u})}};return{has:(o,l)=>({...a(o,l),requires:d=>{let h=i(d);return a(o,l,h)}})}}}),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,d=new Set)=>{if(d.has(u))return[];d.add(u);let h=this.statePack[u];if(!h)return[];let A=[];if(Array.isArray(h.requires))for(let H of h.requires)A=A.concat(i(H,d));return h.setup&&(A=A.concat($e(h.setup,s))),A},n=[];for(let u of this._given)if(typeof u=="string")n.push(...i(u));else if(typeof u=="object"&&u!==null&&"type"in u&&"ref"in u){let d=this._findStateKeyByTypeAndRef(u.type);if(d){let h=this.statePack[d];if(h&&h.setup)for(let A of h.setup)typeof A.steps=="function"?n.push(...A.steps({relativeTarget:u.ref})):Array.isArray(A.steps)&&n.push(...A.steps)}}let a=new Set;n=n.filter(u=>{let d=JSON.stringify(u);return a.has(d)?!1:(a.add(d),!0)});let o=[];for(let u of this._then)if(typeof u=="string"){let d=this.statePack[u];if(d&&d.assertion!==void 0){let h=d.assertion;if(typeof h=="function")try{h=h()}catch(A){throw new Error(`Error calling assertion function for state '${u}': ${A.message}`)}Array.isArray(h)?o.push(...h):o.push(h)}}else if(typeof u=="object"&&u!==null&&"type"in u&&"ref"in u){let d=this._findStateKeyByTypeAndRef(u.type);if(d){let h=this.statePack[d];if(h&&h.assertion!==void 0){let A=h.assertion;if(typeof A=="function")try{A=A({relativeTarget:u.ref})}catch(H){throw new Error(`Error calling assertion function for state '${d}': ${H.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 Zr(t,e){let r=new Ue(t);return e(r),new _e(r.build())}je();Ke();var er=oe(require("path"),1);async function st(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(d){try{let h=await fetch(d,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(h.ok||h.status===304)return d}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:d}=await Promise.resolve().then(()=>(Mt(),Et)),h=await d(process.cwd());if(a=h.config,h.configPath&&(o=er.default.dirname(h.configPath)),r.strictness===void 0){let A=a.test?.components?.find(H=>H?.name===t)?.strictness;n=we(A??a.test?.strictness)}}catch{r.strictness===void 0&&(n="balanced")}let l;try{if(e){let d=await i(e);if(d){console.log(`\u{1F3AD} Running Playwright tests on ${d}`);let{runContractTestsPlaywright:h}=await Promise.resolve().then(()=>(Gt(),Jt));l=await h(t,d,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(d){throw d instanceof Error?d:new Error(`\u274C Contract test execution failed: ${String(d)}`)}let u={violations:s.violations,raw:s,contract:l};if(l.failures.length>0&&e==="Playwright")throw new Error(`
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 d=s.violations.length,h=s.violations.map(A=>`
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
71
  - ${A.id}: ${A.description}
72
72
  Impact: ${A.impact}
73
73
  Affected elements: ${A.nodes.length}
74
74
  Help: ${A.helpUrl}`).join(`
75
75
  `);throw new Error(`
76
- \u274C ${d} axe accessibility violation${d>1?"s":""} detected
77
- ${h}
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 tr=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(tr=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(()=>(Zt(),Qt));l("component"),await u("component",process.cwd()),console.log(e.dim(`
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=i?.code||1;s(new Error(`Tests failed with code ${l}`)),process.exit(l)}})})});async function nt(){await Tt()}0&&(module.exports={cleanupTests,createContract,makeAccordionAccessible,makeBlockAccessible,makeCheckboxAccessible,makeComboboxAccessible,makeMenuAccessible,makeRadioAccessible,makeTabsAccessible,makeToggleAccessible,testUiComponent});
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});