aria-ease 7.0.1 → 7.1.0

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.
Files changed (32) hide show
  1. package/dist/RelativeTargetResolver-PDJM3ZJI.js +1 -0
  2. package/dist/TabsComponentStrategy-LKV6D2B7.js +1 -0
  3. package/dist/chunk-WIWSYIGK.js +1 -0
  4. package/dist/cli.cjs +61 -61
  5. package/dist/cli.js +1 -1
  6. package/dist/contractTestRunnerPlaywright-44QPA5JG.js +46 -0
  7. package/dist/contractTestRunnerPlaywright-IUUAGMXP.js +46 -0
  8. package/dist/index.cjs +41 -41
  9. package/dist/index.d.cts +35 -11
  10. package/dist/index.d.ts +35 -11
  11. package/dist/index.js +14 -14
  12. package/dist/src/utils/test/RelativeTargetResolver-5SIQLWPN.js +1 -0
  13. package/dist/src/utils/test/TabsComponentStrategy-DTQQUCK2.js +1 -0
  14. package/dist/src/utils/test/chunk-WIWSYIGK.js +1 -0
  15. package/dist/src/utils/test/contractTestRunnerPlaywright-VALOFEZZ.js +46 -0
  16. package/dist/src/utils/test/dsl/index.cjs +1 -1
  17. package/dist/src/utils/test/dsl/index.d.cts +35 -11
  18. package/dist/src/utils/test/dsl/index.d.ts +35 -11
  19. package/dist/src/utils/test/dsl/index.js +1 -1
  20. package/dist/src/utils/test/index.cjs +36 -36
  21. package/dist/src/utils/test/index.js +1 -1
  22. package/dist/{test-VXSCSKV5.js → test-MWX7KH44.js} +1 -1
  23. package/package.json +2 -2
  24. package/dist/RelativeTargetResolver-T4P25J2M.js +0 -1
  25. package/dist/TabsComponentStrategy-ADEEFJXM.js +0 -1
  26. package/dist/chunk-BHNO4ZI3.js +0 -1
  27. package/dist/contractTestRunnerPlaywright-FOCQTM4L.js +0 -46
  28. package/dist/contractTestRunnerPlaywright-QPU6HZXG.js +0 -46
  29. package/dist/src/utils/test/RelativeTargetResolver-UQQMZHI6.js +0 -1
  30. package/dist/src/utils/test/TabsComponentStrategy-L2PYNEW6.js +0 -1
  31. package/dist/src/utils/test/chunk-BHNO4ZI3.js +0 -1
  32. package/dist/src/utils/test/contractTestRunnerPlaywright-YZCMF64Q.js +0 -46
package/dist/index.d.cts CHANGED
@@ -195,10 +195,21 @@ declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, lis
195
195
  declare function makeTabsAccessible({ tabListId, tabsClass, tabPanelsClass, orientation, activateOnFocus, callback }: TabsConfig): AccessibilityInstance;
196
196
 
197
197
  type StatePack = Record<string, {
198
- setup?: DynamicAction[];
199
- assertion?: DynamicAssertion[] | DynamicAssertion;
198
+ setup?: Array<{
199
+ when: string[];
200
+ steps: ((arg?: {
201
+ relativeTarget?: string | number;
202
+ }) => DynamicAction[]) | DynamicAction[];
203
+ }>;
204
+ assertion?: ((arg?: {
205
+ relativeTarget?: string | number;
206
+ }) => DynamicAssertion[] | DynamicAssertion) | DynamicAssertion[] | DynamicAssertion;
200
207
  requires?: string[];
201
208
  }>;
209
+ type RelativeState = {
210
+ type: string;
211
+ ref: string | number;
212
+ };
202
213
  type Level = "required" | "recommended" | "optional";
203
214
  type ContractMeta = {
204
215
  id?: string;
@@ -229,9 +240,10 @@ type RelationshipInvariant = {
229
240
  };
230
241
  type StaticAssertion = {
231
242
  target: string;
243
+ assertion: "toBeVisible" | "notToBeVisible" | "toHaveAttribute" | "toHaveValue" | "toHaveFocus" | "notToHaveFocus" | "toHaveRole";
232
244
  attribute: string;
233
245
  expectedValue?: string;
234
- failureMessage: string;
246
+ failureMessage?: string;
235
247
  level: Level;
236
248
  requires?: string;
237
249
  setup?: DynamicAction[];
@@ -242,7 +254,7 @@ type DynamicAssertion = {
242
254
  attribute?: string;
243
255
  expectedValue?: string;
244
256
  failureMessage?: string;
245
- relativeTarget?: string;
257
+ relativeTarget?: string | number;
246
258
  virtualId?: string;
247
259
  selectorKey?: string;
248
260
  level?: Level;
@@ -250,17 +262,18 @@ type DynamicAssertion = {
250
262
  type DynamicAction = {
251
263
  type: "focus";
252
264
  target: string;
253
- relativeTarget?: "first" | "last" | "next" | "previous";
265
+ relativeTarget?: "first" | "last" | "next" | "previous" | number;
254
266
  virtualId?: string;
255
267
  } | {
256
- type: "click" | "keypress" | "type" | "hover";
268
+ type: "click" | "keypress" | "type" | "hover" | "focus";
257
269
  target: string;
258
270
  key?: string;
259
271
  value?: string;
260
- relativeTarget?: string;
272
+ relativeTarget?: string | number;
261
273
  };
262
274
  type DynamicTest = {
263
275
  description: string;
276
+ orientation?: "vertical" | "horizontal";
264
277
  level?: Level;
265
278
  action: DynamicAction[];
266
279
  assertions: DynamicAssertion[];
@@ -335,16 +348,27 @@ declare class DynamicTestBuilder {
335
348
  private statePack;
336
349
  private event;
337
350
  private _as;
338
- private _on;
351
+ private _onTarget;
352
+ private _onRelativeTarget;
339
353
  private _given;
340
354
  private _then;
341
355
  private _desc;
342
356
  private _level;
357
+ private _orientation;
343
358
  constructor(parent: ContractBuilder, statePack: StatePack, event: string);
344
359
  as(actionType: string): this;
345
- on(target: string): this;
346
- given(states: string | string[]): this;
347
- then(states: string | string[]): this;
360
+ on(target: string, relativeTarget?: string | number): this;
361
+ given(states: string | string[] | RelativeState | RelativeState[]): this;
362
+ then(states: string | string[] | RelativeState | RelativeState[]): this;
363
+ orientation(orientation: "vertical" | "horizontal"): this;
364
+ /**
365
+ * Normalize states to an array of string or resolved state keys from relative state objects.
366
+ */
367
+ private _normalizeStates;
368
+ /**
369
+ * Find a generic state key in the state pack by type.
370
+ */
371
+ private _findStateKeyByTypeAndRef;
348
372
  describe(desc: string): this;
349
373
  required(): ContractBuilder;
350
374
  optional(): ContractBuilder;
package/dist/index.d.ts CHANGED
@@ -195,10 +195,21 @@ declare function makeComboboxAccessible({ comboboxInputId, comboboxButtonId, lis
195
195
  declare function makeTabsAccessible({ tabListId, tabsClass, tabPanelsClass, orientation, activateOnFocus, callback }: TabsConfig): AccessibilityInstance;
196
196
 
197
197
  type StatePack = Record<string, {
198
- setup?: DynamicAction[];
199
- assertion?: DynamicAssertion[] | DynamicAssertion;
198
+ setup?: Array<{
199
+ when: string[];
200
+ steps: ((arg?: {
201
+ relativeTarget?: string | number;
202
+ }) => DynamicAction[]) | DynamicAction[];
203
+ }>;
204
+ assertion?: ((arg?: {
205
+ relativeTarget?: string | number;
206
+ }) => DynamicAssertion[] | DynamicAssertion) | DynamicAssertion[] | DynamicAssertion;
200
207
  requires?: string[];
201
208
  }>;
209
+ type RelativeState = {
210
+ type: string;
211
+ ref: string | number;
212
+ };
202
213
  type Level = "required" | "recommended" | "optional";
203
214
  type ContractMeta = {
204
215
  id?: string;
@@ -229,9 +240,10 @@ type RelationshipInvariant = {
229
240
  };
230
241
  type StaticAssertion = {
231
242
  target: string;
243
+ assertion: "toBeVisible" | "notToBeVisible" | "toHaveAttribute" | "toHaveValue" | "toHaveFocus" | "notToHaveFocus" | "toHaveRole";
232
244
  attribute: string;
233
245
  expectedValue?: string;
234
- failureMessage: string;
246
+ failureMessage?: string;
235
247
  level: Level;
236
248
  requires?: string;
237
249
  setup?: DynamicAction[];
@@ -242,7 +254,7 @@ type DynamicAssertion = {
242
254
  attribute?: string;
243
255
  expectedValue?: string;
244
256
  failureMessage?: string;
245
- relativeTarget?: string;
257
+ relativeTarget?: string | number;
246
258
  virtualId?: string;
247
259
  selectorKey?: string;
248
260
  level?: Level;
@@ -250,17 +262,18 @@ type DynamicAssertion = {
250
262
  type DynamicAction = {
251
263
  type: "focus";
252
264
  target: string;
253
- relativeTarget?: "first" | "last" | "next" | "previous";
265
+ relativeTarget?: "first" | "last" | "next" | "previous" | number;
254
266
  virtualId?: string;
255
267
  } | {
256
- type: "click" | "keypress" | "type" | "hover";
268
+ type: "click" | "keypress" | "type" | "hover" | "focus";
257
269
  target: string;
258
270
  key?: string;
259
271
  value?: string;
260
- relativeTarget?: string;
272
+ relativeTarget?: string | number;
261
273
  };
262
274
  type DynamicTest = {
263
275
  description: string;
276
+ orientation?: "vertical" | "horizontal";
264
277
  level?: Level;
265
278
  action: DynamicAction[];
266
279
  assertions: DynamicAssertion[];
@@ -335,16 +348,27 @@ declare class DynamicTestBuilder {
335
348
  private statePack;
336
349
  private event;
337
350
  private _as;
338
- private _on;
351
+ private _onTarget;
352
+ private _onRelativeTarget;
339
353
  private _given;
340
354
  private _then;
341
355
  private _desc;
342
356
  private _level;
357
+ private _orientation;
343
358
  constructor(parent: ContractBuilder, statePack: StatePack, event: string);
344
359
  as(actionType: string): this;
345
- on(target: string): this;
346
- given(states: string | string[]): this;
347
- then(states: string | string[]): this;
360
+ on(target: string, relativeTarget?: string | number): this;
361
+ given(states: string | string[] | RelativeState | RelativeState[]): this;
362
+ then(states: string | string[] | RelativeState | RelativeState[]): this;
363
+ orientation(orientation: "vertical" | "horizontal"): this;
364
+ /**
365
+ * Normalize states to an array of string or resolved state keys from relative state objects.
366
+ */
367
+ private _normalizeStates;
368
+ /**
369
+ * Find a generic state key in the state pack by type.
370
+ */
371
+ private _findStateKeyByTypeAndRef;
348
372
  describe(desc: string): this;
349
373
  required(): ContractBuilder;
350
374
  optional(): ContractBuilder;
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import{b as U,d as V}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function Te({accordionId:r,triggersClass:t,panelsClass:m,allowMultipleOpen:i=!1,callback:a}){if(r==="")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 o=document.querySelector(`#${r}`);if(!o)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(t==="")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 e=Array.from(o.querySelectorAll(`.${t}`));if(e.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(m==="")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 n=Array.from(o.querySelectorAll(`.${m}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${m}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(e.length!==n.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${e.length} triggers but ${n.length} panels.`),{cleanup:()=>{}};let s=new WeakMap,u=new WeakMap;function f(){e.forEach((h,T)=>{let H=n[T];h.id||(h.id=`${r}-trigger-${T}`),H.id||(H.id=`${r}-panel-${T}`),h.setAttribute("aria-controls",H.id),h.setAttribute("aria-expanded","false"),(!i||e.length<=6)&&H.setAttribute("role","region"),H.setAttribute("aria-labelledby",h.id),H.style.display="none"})}function y(h){if(h<0||h>=e.length){console.error(`[aria-ease] Invalid accordion index: ${h}`);return}let T=e[h],H=n[h];if(T.setAttribute("aria-expanded","true"),H.style.display="block",a?.onExpand)try{a.onExpand(h)}catch(d){console.error("[aria-ease] Error in accordion onExpand callback:",d)}}function k(h){if(h<0||h>=e.length){console.error(`[aria-ease] Invalid accordion index: ${h}`);return}let T=e[h],H=n[h];if(T.setAttribute("aria-expanded","false"),H.style.display="none",a?.onCollapse)try{a.onCollapse(h)}catch(d){console.error("[aria-ease] Error in accordion onCollapse callback:",d)}}function L(h){e[h].getAttribute("aria-expanded")==="true"?k(h):(i||e.forEach((d,E)=>{E!==h&&k(E)}),y(h))}function $(h){return()=>{L(h)}}function S(h){return T=>{let{key:H}=T;switch(H){case"Enter":case" ":T.preventDefault(),L(h);break;case"ArrowDown":T.preventDefault();{let d=(h+1)%e.length;e[d].focus()}break;case"ArrowUp":T.preventDefault();{let d=(h-1+e.length)%e.length;e[d].focus()}break;case"Home":T.preventDefault(),e[0].focus();break;case"End":T.preventDefault(),e[e.length-1].focus();break}}}function c(){e.forEach((h,T)=>{let H=$(T),d=S(T);h.addEventListener("click",H),h.addEventListener("keydown",d),s.set(h,d),u.set(h,H)})}function l(){e.forEach(h=>{let T=s.get(h),H=u.get(h);T&&(h.removeEventListener("keydown",T),s.delete(h)),H&&(h.removeEventListener("click",H),u.delete(h))})}function A(){l(),e.forEach((h,T)=>{k(T)})}function C(){l();let h=Array.from(o.querySelectorAll(`.${t}`)),T=Array.from(o.querySelectorAll(`.${m}`));e.length=0,e.push(...h),n.length=0,n.push(...T),f(),c()}return f(),c(),{expandItem:y,collapseItem:k,toggleItem:L,cleanup:A,refresh:C}}function O(r){if(r.tagName!=="INPUT")return!1;let t=r.type;return["text","email","password","tel","number"].includes(t)}function N(r){return r.tagName==="TEXTAREA"}function z(r){return r.tagName==="BUTTON"||r.tagName==="INPUT"&&["button","submit","reset"].includes(r.type)}function ee(r){return r.tagName==="A"}function R(r,t,m){let i=r.length,a=(t+m+i)%i;r.item(a).focus()}function te(r){return r.getAttribute("data-custom-click")!==null&&r.getAttribute("data-custom-click")!==void 0}function W(r,t,m){let i=t.item(m);switch(r.key){case"ArrowUp":case"ArrowLeft":{(!O(i)&&!N(i)||(O(i)||N(i))&&i.selectionStart===0)&&(r.preventDefault(),R(t,m,-1));break}case"ArrowDown":case"ArrowRight":{if(!O(i)&&!N(i))r.preventDefault(),R(t,m,1);else if(O(i)||N(i)){let a=i.value;i.selectionStart===a.length&&(r.preventDefault(),R(t,m,1))}break}case"Escape":{r.preventDefault();break}case"Enter":case" ":{(!z(i)&&!ee(i)&&te(i)||z(i))&&(r.preventDefault(),i.click());break}case"Tab":break;default:break}}function Se({blockId:r,blockItemsClass:t}){if(r==="")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 m=document.querySelector(`#${r}`);if(!m)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(t==="")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 i=null;function a(){return i||(i=m.querySelectorAll(`.${t}`)),i}let o=a();if(!o||o.length===0)return console.error(`[aria-ease] Element with class="${t}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let e=new Map;o.forEach(u=>{if(!e.has(u)){let f=y=>{let k=m.querySelectorAll(`.${t}`),L=Array.prototype.indexOf.call(k,u);W(y,k,L)};u.addEventListener("keydown",f),e.set(u,f)}});function n(){o.forEach(u=>{let f=e.get(u);f&&(u.removeEventListener("keydown",f),e.delete(u))})}function s(){i=null}return{cleanup:n,refresh:s}}function $e({checkboxGroupId:r,checkboxesClass:t}){if(r==="")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 m=document.querySelector(`#${r}`);if(!m)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(t==="")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(m.querySelectorAll(`.${t}`));if(i.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let a=new WeakMap,o=new WeakMap;function e(){m.getAttribute("role")||m.setAttribute("role","group"),i.forEach(c=>{c.setAttribute("role","checkbox"),c.hasAttribute("aria-checked")||c.setAttribute("aria-checked","false"),c.hasAttribute("tabindex")||c.setAttribute("tabindex","0")})}function n(c){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}let l=i[c],A=l.getAttribute("aria-checked")==="true";l.setAttribute("aria-checked",A?"false":"true")}function s(c,l){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}i[c].setAttribute("aria-checked",l?"true":"false")}function u(c){return()=>{n(c)}}function f(c){return l=>{let{key:A}=l;switch(A){case" ":l.preventDefault(),n(c);break}}}function y(){i.forEach((c,l)=>{let A=u(l),C=f(l);c.addEventListener("click",A),c.addEventListener("keydown",C),a.set(c,C),o.set(c,A)})}function k(){i.forEach(c=>{let l=a.get(c),A=o.get(c);l&&(c.removeEventListener("keydown",l),a.delete(c)),A&&(c.removeEventListener("click",A),o.delete(c))})}function L(){k()}function $(){return i.map(c=>c.getAttribute("aria-checked")==="true")}function S(){return i.map((c,l)=>c.getAttribute("aria-checked")==="true"?l:-1).filter(c=>c!==-1)}return e(),y(),{toggleCheckbox:n,setCheckboxState:s,getCheckedStates:$,getCheckedIndices:S,cleanup:L}}function ne({menuId:r,menuItemsClass:t,triggerId:m,callback:i}){if(r==="")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 a=document.querySelector(`#${r}`);if(!a)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(m==="")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 o=document.querySelector(`#${m}`);if(!o)return console.error(`[aria-ease] Element with id="${m}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(t==="")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(r))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-controls",r),o.setAttribute("aria-expanded","false"),a.setAttribute("role","menu"),a.setAttribute("aria-labelledby",m);let e=new WeakMap,n=new Map,s=null,u=null;function f(){return s||(s=a.querySelectorAll(`.${t}`)),s}function y(){if(!u){let b=f();u=[];for(let g=0;g<b.length;g++){let x=b.item(g),D=C(x),P=x.getAttribute("aria-disabled")==="true";D||(x.hasAttribute("tabindex")||x.setAttribute("tabindex","-1"),P||u.push(x))}}return u}function k(b){return{length:b.length,item:x=>b[x],forEach:x=>{b.forEach(x)},[Symbol.iterator]:function*(){for(let x of b)yield x}}}function L(){f().forEach(g=>{g.setAttribute("role","menuitem");let x=g.getAttribute("data-submenu-id")??g.getAttribute("aria-controls"),D=g.hasAttribute("aria-haspopup")&&x;x&&(g.hasAttribute("data-submenu-id")||D)&&(g.setAttribute("aria-haspopup","menu"),g.setAttribute("aria-controls",x),g.hasAttribute("aria-expanded")||g.setAttribute("aria-expanded","false"))})}function $(b,g,x){let D=b.length,P=(g+x+D)%D;b.item(P).focus()}function S(b,g){b.length!==0&&b[g]?.focus()}function c(b){return b.hasAttribute("aria-controls")&&b.hasAttribute("aria-haspopup")&&b.getAttribute("role")==="menuitem"}function l(b){let g=b;for(;g&&g.getAttribute("role")==="menuitem";){let x=g.closest('[role="menu"]');if(!x)break;x.style.display="none",g.setAttribute("aria-expanded","false");let D=x.getAttribute("aria-labelledby");if(!D)break;let P=document.getElementById(D);if(!P)break;g=P}}L();function A(b,g,x){switch(b.key){case"ArrowLeft":{if(b.key==="ArrowLeft"&&o.getAttribute("role")==="menuitem"){b.preventDefault(),p();return}break}case"ArrowUp":{b.preventDefault(),$(k(y()),x,-1);break}case"ArrowRight":{if(b.key==="ArrowRight"&&c(g)){b.preventDefault();let D=g.getAttribute("aria-controls");if(D){T(D);return}}break}case"ArrowDown":{b.preventDefault(),$(k(y()),x,1);break}case"Home":{b.preventDefault(),S(y(),0);break}case"End":{b.preventDefault();let D=y();S(D,D.length-1);break}case"Escape":{b.preventDefault(),p(),o.focus(),H&&H(!1);break}case"Enter":case" ":{if(b.preventDefault(),c(g)){let D=g.getAttribute("aria-controls");if(D){T(D);return}}g.click(),p(),H&&H(!1);break}case"Tab":{p(),l(o),H&&H(!1);break}default:break}}function C(b){let g=b.parentElement;for(;g&&g!==a;){if(g.getAttribute("role")==="menu"||g.id&&a.querySelector(`[aria-controls="${g.id}"]`))return!0;g=g.parentElement}return!1}function h(b){o.setAttribute("aria-expanded",b?"true":"false")}function T(b){let g=n.get(b);if(!g){let x=a.querySelector(`[aria-controls="${b}"]`);if(!x){console.error(`[aria-ease] Submenu trigger with aria-controls="${b}" not found in menu "${r}".`);return}if(!x.id){let P=`trigger-${b}`;x.id=P,console.warn(`[aria-ease] Submenu trigger for "${b}" had no ID. Auto-generated ID: "${P}".`)}if(!document.querySelector(`#${b}`)){console.error(`[aria-ease] Submenu element with id="${b}" not found. Cannot create submenu instance.`);return}g=ne({menuId:b,menuItemsClass:t,triggerId:x.id,callback:i}),n.set(b,g)}g.openMenu()}function H(b){if(i?.onOpenChange)try{i.onOpenChange(b)}catch(g){console.error("[aria-ease] Error in menu onOpenChange callback:",g)}}function d(){y().forEach((g,x)=>{if(!e.has(g)){let D=P=>A(P,g,x);g.addEventListener("keydown",D),e.set(g,D)}})}function E(){y().forEach(g=>{let x=e.get(g);x&&(g.removeEventListener("keydown",x),e.delete(g))})}function w(){h(!0),a.style.display="block";let b=y();if(d(),b&&b.length>0&&b[0].focus(),i?.onOpenChange)try{i.onOpenChange(!0)}catch(g){console.error("[aria-ease] Error in menu onOpenChange callback:",g)}}function p(){if(n.forEach(b=>b.closeMenu()),h(!1),a.style.display="none",E(),o.focus(),i?.onOpenChange)try{i.onOpenChange(!1)}catch(b){console.error("[aria-ease] Error in menu onOpenChange callback:",b)}}function v(){o.getAttribute("aria-expanded")==="true"?p():w()}function M(b){if(!(o.getAttribute("aria-expanded")==="true"))return;let x=o.contains(b.target),D=a.contains(b.target);!x&&!D&&p()}o.addEventListener("click",v),document.addEventListener("click",M);function q(){E(),o.removeEventListener("click",v),document.removeEventListener("click",M),a.style.display="none",h(!1),n.forEach(b=>b.cleanup()),n.clear()}function I(){s=null,u=null}return{openMenu:w,closeMenu:p,cleanup:q,refresh:I}}function Pe({radioGroupId:r,radiosClass:t,defaultSelectedIndex:m=0}){if(r==="")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(`#${r}`);if(!i)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(t==="")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 a=Array.from(i.querySelectorAll(`.${t}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let o=new WeakMap,e=new WeakMap,n=m;function s(){i.getAttribute("role")||i.setAttribute("role","radiogroup"),a.forEach((c,l)=>{c.setAttribute("role","radio"),c.setAttribute("tabindex",l===n?"0":"-1"),l===n?c.setAttribute("aria-checked","true"):c.setAttribute("aria-checked","false")})}function u(c){if(c<0||c>=a.length){console.error(`[aria-ease] Invalid radio index: ${c}`);return}n>=0&&n<a.length&&(a[n].setAttribute("aria-checked","false"),a[n].setAttribute("tabindex","-1")),a[c].setAttribute("aria-checked","true"),a[c].setAttribute("tabindex","0"),a[c].focus(),n=c}function f(c){return()=>{u(c)}}function y(c){return l=>{let{key:A}=l,C=c;switch(A){case"ArrowDown":case"ArrowRight":l.preventDefault(),C=(c+1)%a.length,u(C);break;case"ArrowUp":case"ArrowLeft":l.preventDefault(),C=(c-1+a.length)%a.length,u(C);break;case" ":case"Enter":l.preventDefault(),u(c);break}}}function k(){a.forEach((c,l)=>{let A=f(l),C=y(l);c.addEventListener("click",A),c.addEventListener("keydown",C),o.set(c,C),e.set(c,A)})}function L(){a.forEach(c=>{let l=o.get(c),A=e.get(c);l&&(c.removeEventListener("keydown",l),o.delete(c)),A&&(c.removeEventListener("click",A),e.delete(c))})}function $(){L()}function S(){return n}return s(),k(),{selectRadio:u,getSelectedIndex:S,cleanup:$}}function Ne({toggleId:r,togglesClass:t,isSingleToggle:m=!0}){if(r==="")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(`#${r}`);if(!i)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let a;if(m)a=[i];else{if(!t)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(a=Array.from(i.querySelectorAll(`.${t}`)),a.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let o=new WeakMap,e=new WeakMap;function n(){a.forEach(l=>{l.tagName.toLowerCase()!=="button"&&!l.getAttribute("role")&&l.setAttribute("role","button"),l.hasAttribute("aria-pressed")||l.setAttribute("aria-pressed","false"),l.hasAttribute("tabindex")||l.setAttribute("tabindex","0")})}function s(l){if(l<0||l>=a.length){console.error(`[aria-ease] Invalid toggle index: ${l}`);return}let A=a[l],C=A.getAttribute("aria-pressed")==="true";A.setAttribute("aria-pressed",C?"false":"true")}function u(l,A){if(l<0||l>=a.length){console.error(`[aria-ease] Invalid toggle index: ${l}`);return}a[l].setAttribute("aria-pressed",A?"true":"false")}function f(l){return()=>{s(l)}}function y(l){return A=>{let{key:C}=A;switch(C){case"Enter":case" ":A.preventDefault(),s(l);break}}}function k(){a.forEach((l,A)=>{let C=f(A),h=y(A);l.addEventListener("click",C),l.addEventListener("keydown",h),o.set(l,h),e.set(l,C)})}function L(){a.forEach(l=>{let A=o.get(l),C=e.get(l);A&&(l.removeEventListener("keydown",A),o.delete(l)),C&&(l.removeEventListener("click",C),e.delete(l))})}function $(){L()}function S(){return a.map(l=>l.getAttribute("aria-pressed")==="true")}function c(){return a.map((l,A)=>l.getAttribute("aria-pressed")==="true"?A:-1).filter(l=>l!==-1)}return n(),k(),{toggleButton:s,setPressed:u,getPressedStates:S,getPressedIndices:c,cleanup:$}}function Fe({comboboxInputId:r,comboboxButtonId:t,listBoxId:m,listBoxItemsClass:i,callback:a}){if(r==="")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 o=document.getElementById(`${r}`);if(!o)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(m==="")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 e=document.getElementById(`${m}`);if(!e)return console.error(`[aria-ease] Element with id="${m}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(i==="")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(i))return console.error(`[aria-ease] Listbox option(s) with class="${i}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let s=t?document.getElementById(`${t}`):null,u=-1;o.setAttribute("role","combobox"),o.setAttribute("aria-autocomplete","list"),o.setAttribute("aria-controls",m),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-haspopup","listbox"),e.setAttribute("role","listbox");let f=null;function y(){return f||(f=e.querySelectorAll(`.${i}`)),Array.from(f).filter(p=>!p.hidden&&p.style.display!=="none")}function k(){return o.getAttribute("aria-expanded")==="true"}function L(p){let v=y();if(p>=0&&p<v.length){let M=v[p],q=M.id||`${m}-option-${p}`;if(M.id||(M.id=q),o.setAttribute("aria-activedescendant",q),typeof M.scrollIntoView=="function"&&M.scrollIntoView({block:"nearest",behavior:"smooth"}),a?.onActiveDescendantChange)try{a.onActiveDescendantChange(q,M)}catch(I){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",I)}}else o.setAttribute("aria-activedescendant","");u=p}function $(){if(o.setAttribute("aria-expanded","true"),e.style.display="block",a?.onOpenChange)try{a.onOpenChange(!0)}catch(p){console.error("[aria-ease] Error in combobox onOpenChange callback:",p)}}function S(){if(o.setAttribute("aria-expanded","false"),o.setAttribute("aria-activedescendant",""),e.style.display="none",u=-1,a?.onOpenChange)try{a.onOpenChange(!1)}catch(p){console.error("[aria-ease] Error in combobox onOpenChange callback:",p)}}function c(p){let v=p.textContent?.trim()||"";if(o.value=v,p.setAttribute("aria-selected","true"),S(),a?.onSelect)try{a.onSelect(p)}catch(M){console.error("[aria-ease] Error in combobox onSelect callback:",M)}}function l(p){let v=y(),M=k();switch(p.key){case"ArrowDown":if(p.preventDefault(),!M){$();return}if(v.length===0)return;{let q=u>=v.length-1?0:u+1;L(q)}break;case"ArrowUp":if(p.preventDefault(),!M)return;if(v.length>0){let q=u<=0?v.length-1:u-1;L(q)}break;case"Enter":M&&u>=0&&u<v.length&&(p.preventDefault(),c(v[u]));break;case"Escape":if(M)p.preventDefault(),S();else if(o.value&&(p.preventDefault(),o.value="",o.setAttribute("aria-activedescendant",""),y().forEach(I=>{I.getAttribute("aria-selected")==="true"&&I.setAttribute("aria-selected","false")}),a?.onClear))try{a.onClear()}catch(I){console.error("[aria-ease] Error in combobox onClear callback:",I)}break;case"Home":M&&v.length>0&&(p.preventDefault(),L(0));break;case"End":M&&v.length>0&&(p.preventDefault(),L(v.length-1));break;case"Tab":M&&u>=0&&u<v.length&&c(v[u]),M&&S();break}}function A(p){let v=p.target;if(v.classList.contains(i)){let q=y().indexOf(v);q>=0&&L(q)}}function C(p){let v=p.target;v.classList.contains(i)&&(p.preventDefault(),c(v))}function h(p){let v=p.target;!o.contains(v)&&!e.contains(v)&&(!s||!s.contains(v))&&S()}function T(){k()?S():($(),o.focus())}function H(p){(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),T())}o.addEventListener("keydown",l),e.addEventListener("mousemove",A),e.addEventListener("mousedown",C),document.addEventListener("mousedown",h),s&&(s.setAttribute("tabindex","-1"),s.setAttribute("aria-label","Toggle options"),s.addEventListener("click",T),s.addEventListener("keydown",H));function d(){let p=e.querySelectorAll(`.${i}`);if(p.length===0)return;let v=null;for(let M of p)if(M.getAttribute("aria-selected")==="true"){v=M.textContent?.trim()||null;break}!v&&o.value&&(v=o.value.trim()),p.forEach((M,q)=>{M.setAttribute("role","option");let I=M.textContent?.trim()||"";v&&I===v?M.setAttribute("aria-selected","true"):M.setAttribute("aria-selected","false");let b=M.getAttribute("id");if(!b||b===""){let g=`${m}-option-${q}`;M.id=g,M.setAttribute("id",g)}})}d();function E(){o.removeEventListener("keydown",l),e.removeEventListener("mousemove",A),e.removeEventListener("mousedown",C),document.removeEventListener("mousedown",h),s&&(s.removeEventListener("click",T),s.removeEventListener("keydown",H))}function w(){f=null,d(),u=-1,L(-1)}return{cleanup:E,refresh:w,openListbox:$,closeListbox:S}}function _e({tabListId:r,tabsClass:t,tabPanelsClass:m,orientation:i="horizontal",activateOnFocus:a=!0,callback:o}){if(r==="")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 e=document.querySelector(`#${r}`);if(!e)return console.error(`[aria-ease] Element with id="${r}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};if(t==="")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 n=Array.from(e.querySelectorAll(`.${t}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(m==="")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 s=Array.from(document.querySelectorAll(`.${m}`));if(s.length===0)return console.error(`[aria-ease] No elements with class="${m}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(n.length!==s.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${n.length} tabs but ${s.length} panels.`),{cleanup:()=>{}};let u=new WeakMap,f=new WeakMap,y=new WeakMap,k=0;function L(){e.setAttribute("role","tablist"),e.setAttribute("aria-orientation",i),n.forEach((d,E)=>{let w=s[E];d.id||(d.id=`${r}-tab-${E}`),w.id||(w.id=`${r}-panel-${E}`),d.setAttribute("role","tab"),d.setAttribute("aria-controls",w.id),d.setAttribute("aria-selected","false"),d.setAttribute("tabindex","-1"),w.setAttribute("role","tabpanel"),w.setAttribute("aria-labelledby",d.id),w.hidden=!0,w.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||w.setAttribute("tabindex","0")}),$(0,!1)}function $(d,E=!0){if(d<0||d>=n.length){console.error(`[aria-ease] Invalid tab index: ${d}`);return}let w=k;n.forEach((M,q)=>{let I=s[q];M.setAttribute("aria-selected","false"),M.setAttribute("tabindex","-1"),I.hidden=!0});let p=n[d],v=s[d];if(p.setAttribute("aria-selected","true"),p.setAttribute("tabindex","0"),v.hidden=!1,E&&p.focus(),k=d,o?.onTabChange&&w!==d)try{o.onTabChange(d,w)}catch(M){console.error("[aria-ease] Error in tabs onTabChange callback:",M)}}function S(d){let E=n.findIndex(v=>v===document.activeElement),w=E!==-1?E:k,p=w;switch(d){case"first":p=0;break;case"last":p=n.length-1;break;case"next":p=(w+1)%n.length;break;case"prev":p=(w-1+n.length)%n.length;break}if(n[p].focus(),n[p].setAttribute("tabindex","0"),n[k].setAttribute("tabindex","-1"),a)$(p,!1);else{let v=k;n.forEach((M,q)=>{q===p?M.setAttribute("tabindex","0"):q!==v&&M.setAttribute("tabindex","-1")})}}function c(d){return()=>{$(d)}}function l(d){return E=>{let{key:w}=E,p=!1;if(i==="horizontal")switch(w){case"ArrowLeft":E.preventDefault(),S("prev"),p=!0;break;case"ArrowRight":E.preventDefault(),S("next"),p=!0;break}else switch(w){case"ArrowUp":E.preventDefault(),S("prev"),p=!0;break;case"ArrowDown":E.preventDefault(),S("next"),p=!0;break}if(!p)switch(w){case"Home":E.preventDefault(),S("first");break;case"End":E.preventDefault(),S("last");break;case" ":case"Enter":a||(E.preventDefault(),$(d));break;case"F10":if(E.shiftKey&&o?.onContextMenu){E.preventDefault();try{o.onContextMenu(d,n[d])}catch(v){console.error("[aria-ease] Error in tabs onContextMenu callback:",v)}}break}}}function A(d){return E=>{if(o?.onContextMenu){E.preventDefault();try{o.onContextMenu(d,n[d])}catch(w){console.error("[aria-ease] Error in tabs onContextMenu callback:",w)}}}}function C(){n.forEach((d,E)=>{let w=c(E),p=l(E),v=A(E);d.addEventListener("click",w),d.addEventListener("keydown",p),o?.onContextMenu&&(d.addEventListener("contextmenu",v),y.set(d,v)),u.set(d,p),f.set(d,w)})}function h(){n.forEach(d=>{let E=u.get(d),w=f.get(d),p=y.get(d);E&&(d.removeEventListener("keydown",E),u.delete(d)),w&&(d.removeEventListener("click",w),f.delete(d)),p&&(d.removeEventListener("contextmenu",p),y.delete(d))})}function T(){h(),n.forEach((d,E)=>{let w=s[E];d.removeAttribute("role"),d.removeAttribute("aria-selected"),d.removeAttribute("aria-controls"),d.removeAttribute("tabindex"),w.removeAttribute("role"),w.removeAttribute("aria-labelledby"),w.removeAttribute("tabindex"),w.hidden=!1}),e.removeAttribute("role"),e.removeAttribute("aria-orientation")}function H(){h();let d=Array.from(e.querySelectorAll(`.${t}`)),E=Array.from(document.querySelectorAll(`.${m}`));n.length=0,n.push(...d),s.length=0,s.push(...E),L(),C()}return L(),C(),{activateTab:$,cleanup:T,refresh:H}}var G={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:re},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...se(),...J()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ce},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:le},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:ue},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:pe},"activeOption.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]}],assertion:ie},"activeOption.last":{requires:["activeOption.first"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowUp"}]}],assertion:ae},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:oe},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:J},"selectedOption.first":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"first"}]}],assertion:()=>j("first")},"selectedOption.last":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"last"}]}],assertion:()=>j("last")}};function re(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect combobox main to have aria-expanded='true'."}]}function se(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect combobox main to have aria-expanded='false'."}]}function ie(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"first",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function ae(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"last",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the last option."}]}function oe(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function J(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function j(r){return[{target:"relative",relativeTarget:r,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${r} option to have aria-selected='true'.`}]}function ce(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function le(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function ue(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function pe(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var X={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:de},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:fe},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:be},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:me},"activeItem.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[]}],assertion:ge},"activeItem.last":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"ArrowUp"}]}],assertion:he},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ye},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ve},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Ae},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:ke},"submenuActiveItem.first":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:Ee}};function de(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect menu main to have aria-expanded='true'."}]}function fe(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect menu main to have aria-expanded='false'."}]}function be(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function me(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function ge(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"first",failureMessage:"First menu item should have focus."}]}function he(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"last",failureMessage:"Last menu item should have focus."}]}function ye(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect submenu trigger to have aria-expanded='true'."}]}function ve(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect submenu trigger to have aria-expanded='false'."}]}function Ae(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function ke(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function Ee(){return[{target:"submenuItems",assertion:"toHaveFocus",failureMessage:"First interactive item in the submenu should have focus after Right Arrow open the submenu."}]}function Me(r,t){return t.some(m=>r.capabilities.includes(m))}function F(r,t){Array.isArray(r)&&r.length&&!r[0].when&&(r=[{when:["keyboard"],steps:()=>r}]);for(let m of r)if(Me(t,m.when))return m.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var we={combobox:G,menu:X},_=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},K=class{constructor(t){this.componentName=t;this.statePack=we[t]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let m=this.statePack,i={capabilities:["keyboard"]},a=(e,n=new Set)=>{if(n.has(e))return[];n.add(e);let s=m[e];if(!s)return[];let u=[];if(Array.isArray(s.requires))for(let f of s.requires)u=u.concat(a(f,n));return s.setup&&(u=u.concat(F(s.setup,i))),u};return t({ariaReference:(e,n,s)=>({requires:u=>{let f=a(u,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"required",setup:f}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"optional",setup:f}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"recommended",setup:f})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:e,attribute:n,to:s,level:"recommended"})}),contains:(e,n)=>({requires:s=>{let u=a(s,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"required",setup:u}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"optional",setup:u}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"recommended",setup:u})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:e,child:n,level:"recommended"})})}),this}static(t){return t({target:i=>{let a=e=>{let n=this.statePack,s={capabilities:["keyboard"]},u=(f,y=new Set)=>{if(y.has(f))return[];y.add(f);let k=n[f];if(!k)return[];let L=[];if(Array.isArray(k.requires))for(let $ of k.requires)L=L.concat(u($,y));return k.setup&&(L=L.concat(F(k.setup,s))),L};return u(e,new Set)},o=(e,n,s)=>({required:()=>this.staticAssertions.push({target:i,attribute:e,expectedValue:n,failureMessage:"",level:"required",setup:s}),optional:()=>this.staticAssertions.push({target:i,attribute:e,expectedValue:n,failureMessage:"",level:"optional",setup:s}),recommended:()=>this.staticAssertions.push({target:i,attribute:e,expectedValue:n,failureMessage:"",level:"recommended",setup:s})});return{has:(e,n)=>({...o(e,n),requires:u=>{let f=a(u);return o(e,n,f)}})}}}),this}when(t){return new B(this,this.statePack,t)}addDynamicTest(t){this.dynamicTests.push(t)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?[{assertions:this.staticAssertions}]:[],dynamic:this.dynamicTests}}},B=class{constructor(t,m,i){this.parent=t;this.statePack=m;this.event=i}_as;_on;_given=[];_then=[];_desc="";_level="required";as(t){return this._as=t,this}on(t){return this._on=t,this}given(t){return this._given=Array.isArray(t)?t:[t],this}then(t){return this._then=Array.isArray(t)?t:[t],this}describe(t){return this._desc=t,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 i={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},a=(s,u=new Set)=>{if(u.has(s))return[];u.add(s);let f=this.statePack[s];if(!f)return[];let y=[];if(Array.isArray(f.requires))for(let k of f.requires)y=y.concat(a(k,u));return f.setup&&(y=y.concat(F(f.setup,i))),y},o=[];for(let s of this._given)o.push(...a(s));let e=[];for(let s of this._then){let u=this.statePack[s];if(u&&u.assertion!==void 0){let f=u.assertion;if(typeof f=="function")try{f=f()}catch(y){throw new Error(`Error calling assertion function for state '${s}': ${y.message}`)}Array.isArray(f)?e.push(...f):e.push(f)}}let n=[{type:this._as,target:this._on,key:this._as==="keypress"?this.event:void 0}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,action:n,assertions:e,...o.length?{setup:o}:{}})}};function Xe(r,t){let m=new K(r);return t(m),new _(m.build())}import xe from"path";async function Q(r,t,m={}){if(!r||typeof r!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!t)throw new Error("\u274C testUiComponent requires a URL");if(t&&typeof t!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function a(f){try{let y=await fetch(f,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(y.ok||y.status===304)return f}catch{return null}return null}let o=V(m.strictness),e={},n=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:f}=await import("./configLoader-ZEJVXLX7.js"),y=await f(process.cwd());if(e=y.config,y.configPath&&(n=xe.dirname(y.configPath)),m.strictness===void 0){let k=e.test?.components?.find(L=>L?.name===r)?.strictness;o=V(k??e.test?.strictness)}}catch{m.strictness===void 0&&(o="balanced")}let s;try{if(t){let f=await a(t);if(f){console.log(`\u{1F3AD} Running Playwright tests on ${f}`);let{runContractTestsPlaywright:y}=await import("./contractTestRunnerPlaywright-QPU6HZXG.js");s=await y(r,f,o,e,n)}else throw new Error(`\u274C Dev server not running at ${t}
2
- 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(f){throw f instanceof Error?f:new Error(`\u274C Contract test execution failed: ${String(f)}`)}let u={violations:i.violations,raw:i,contract:s};if(s.failures.length>0&&t==="Playwright")throw new Error(`
3
- \u274C ${s.failures.length} accessibility contract test${s.failures.length>1?"s":""} failed (Playwright mode)
4
- \u2705 ${s.passes.length} test${s.passes.length>1?"s":""} passed
1
+ import{b as U,d as V}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function He({accordionId:e,triggersClass:t,panelsClass:g,allowMultipleOpen:i=!1,callback:o}){if(e==="")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 a=document.querySelector(`#${e}`);if(!a)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(t==="")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 n=Array.from(a.querySelectorAll(`.${t}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(g==="")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 r=Array.from(a.querySelectorAll(`.${g}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${g}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(n.length!==r.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${n.length} triggers but ${r.length} panels.`),{cleanup:()=>{}};let l=new WeakMap,s=new WeakMap;function p(){n.forEach((v,L)=>{let H=r[L];v.id||(v.id=`${e}-trigger-${L}`),H.id||(H.id=`${e}-panel-${L}`),v.setAttribute("aria-controls",H.id),v.setAttribute("aria-expanded","false"),(!i||n.length<=6)&&H.setAttribute("role","region"),H.setAttribute("aria-labelledby",v.id),H.style.display="none"})}function m(v){if(v<0||v>=n.length){console.error(`[aria-ease] Invalid accordion index: ${v}`);return}let L=n[v],H=r[v];if(L.setAttribute("aria-expanded","true"),H.style.display="block",o?.onExpand)try{o.onExpand(v)}catch(f){console.error("[aria-ease] Error in accordion onExpand callback:",f)}}function y(v){if(v<0||v>=n.length){console.error(`[aria-ease] Invalid accordion index: ${v}`);return}let L=n[v],H=r[v];if(L.setAttribute("aria-expanded","false"),H.style.display="none",o?.onCollapse)try{o.onCollapse(v)}catch(f){console.error("[aria-ease] Error in accordion onCollapse callback:",f)}}function x(v){n[v].getAttribute("aria-expanded")==="true"?y(v):(i||n.forEach((f,E)=>{E!==v&&y(E)}),m(v))}function C(v){return()=>{x(v)}}function D(v){return L=>{let{key:H}=L;switch(H){case"Enter":case" ":L.preventDefault(),x(v);break;case"ArrowDown":L.preventDefault();{let f=(v+1)%n.length;n[f].focus()}break;case"ArrowUp":L.preventDefault();{let f=(v-1+n.length)%n.length;n[f].focus()}break;case"Home":L.preventDefault(),n[0].focus();break;case"End":L.preventDefault(),n[n.length-1].focus();break}}}function c(){n.forEach((v,L)=>{let H=C(L),f=D(L);v.addEventListener("click",H),v.addEventListener("keydown",f),l.set(v,f),s.set(v,H)})}function u(){n.forEach(v=>{let L=l.get(v),H=s.get(v);L&&(v.removeEventListener("keydown",L),l.delete(v)),H&&(v.removeEventListener("click",H),s.delete(v))})}function k(){u(),n.forEach((v,L)=>{y(L)})}function S(){u();let v=Array.from(a.querySelectorAll(`.${t}`)),L=Array.from(a.querySelectorAll(`.${g}`));n.length=0,n.push(...v),r.length=0,r.push(...L),p(),c()}return p(),c(),{expandItem:m,collapseItem:y,toggleItem:x,cleanup:k,refresh:S}}function O(e){if(e.tagName!=="INPUT")return!1;let t=e.type;return["text","email","password","tel","number"].includes(t)}function R(e){return e.tagName==="TEXTAREA"}function z(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function ee(e){return e.tagName==="A"}function _(e,t,g){let i=e.length,o=(t+g+i)%i;e.item(o).focus()}function te(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function W(e,t,g){let i=t.item(g);switch(e.key){case"ArrowUp":case"ArrowLeft":{(!O(i)&&!R(i)||(O(i)||R(i))&&i.selectionStart===0)&&(e.preventDefault(),_(t,g,-1));break}case"ArrowDown":case"ArrowRight":{if(!O(i)&&!R(i))e.preventDefault(),_(t,g,1);else if(O(i)||R(i)){let o=i.value;i.selectionStart===o.length&&(e.preventDefault(),_(t,g,1))}break}case"Escape":{e.preventDefault();break}case"Enter":case" ":{(!z(i)&&!ee(i)&&te(i)||z(i))&&(e.preventDefault(),i.click());break}case"Tab":break;default:break}}function $e({blockId:e,blockItemsClass:t}){if(e==="")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 g=document.querySelector(`#${e}`);if(!g)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(t==="")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 i=null;function o(){return i||(i=g.querySelectorAll(`.${t}`)),i}let a=o();if(!a||a.length===0)return console.error(`[aria-ease] Element with class="${t}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let n=new Map;a.forEach(s=>{if(!n.has(s)){let p=m=>{let y=g.querySelectorAll(`.${t}`),x=Array.prototype.indexOf.call(y,s);W(m,y,x)};s.addEventListener("keydown",p),n.set(s,p)}});function r(){a.forEach(s=>{let p=n.get(s);p&&(s.removeEventListener("keydown",p),n.delete(s))})}function l(){i=null}return{cleanup:r,refresh:l}}function Ie({checkboxGroupId:e,checkboxesClass:t}){if(e==="")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 g=document.querySelector(`#${e}`);if(!g)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(t==="")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(g.querySelectorAll(`.${t}`));if(i.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let o=new WeakMap,a=new WeakMap;function n(){g.getAttribute("role")||g.setAttribute("role","group"),i.forEach(c=>{c.setAttribute("role","checkbox"),c.hasAttribute("aria-checked")||c.setAttribute("aria-checked","false"),c.hasAttribute("tabindex")||c.setAttribute("tabindex","0")})}function r(c){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}let u=i[c],k=u.getAttribute("aria-checked")==="true";u.setAttribute("aria-checked",k?"false":"true")}function l(c,u){if(c<0||c>=i.length){console.error(`[aria-ease] Invalid checkbox index: ${c}`);return}i[c].setAttribute("aria-checked",u?"true":"false")}function s(c){return()=>{r(c)}}function p(c){return u=>{let{key:k}=u;switch(k){case" ":u.preventDefault(),r(c);break}}}function m(){i.forEach((c,u)=>{let k=s(u),S=p(u);c.addEventListener("click",k),c.addEventListener("keydown",S),o.set(c,S),a.set(c,k)})}function y(){i.forEach(c=>{let u=o.get(c),k=a.get(c);u&&(c.removeEventListener("keydown",u),o.delete(c)),k&&(c.removeEventListener("click",k),a.delete(c))})}function x(){y()}function C(){return i.map(c=>c.getAttribute("aria-checked")==="true")}function D(){return i.map((c,u)=>c.getAttribute("aria-checked")==="true"?u:-1).filter(c=>c!==-1)}return n(),m(),{toggleCheckbox:r,setCheckboxState:l,getCheckedStates:C,getCheckedIndices:D,cleanup:x}}function ne({menuId:e,menuItemsClass:t,triggerId:g,callback:i}){if(e==="")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 o=document.querySelector(`#${e}`);if(!o)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(g==="")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 a=document.querySelector(`#${g}`);if(!a)return console.error(`[aria-ease] Element with id="${g}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(t==="")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(e))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-controls",e),a.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-labelledby",g);let n=new WeakMap,r=new Map,l=null,s=null;function p(){return l||(l=o.querySelectorAll(`.${t}`)),l}function m(){if(!s){let b=p();s=[];for(let h=0;h<b.length;h++){let w=b.item(h),$=S(w),P=w.getAttribute("aria-disabled")==="true";$||(w.hasAttribute("tabindex")||w.setAttribute("tabindex","-1"),P||s.push(w))}}return s}function y(b){return{length:b.length,item:w=>b[w],forEach:w=>{b.forEach(w)},[Symbol.iterator]:function*(){for(let w of b)yield w}}}function x(){p().forEach(h=>{h.setAttribute("role","menuitem");let w=h.getAttribute("data-submenu-id")??h.getAttribute("aria-controls"),$=h.hasAttribute("aria-haspopup")&&w;w&&(h.hasAttribute("data-submenu-id")||$)&&(h.setAttribute("aria-haspopup","menu"),h.setAttribute("aria-controls",w),h.hasAttribute("aria-expanded")||h.setAttribute("aria-expanded","false"))})}function C(b,h,w){let $=b.length,P=(h+w+$)%$;b.item(P).focus()}function D(b,h){b.length!==0&&b[h]?.focus()}function c(b){return b.hasAttribute("aria-controls")&&b.hasAttribute("aria-haspopup")&&b.getAttribute("role")==="menuitem"}function u(b){let h=b;for(;h&&h.getAttribute("role")==="menuitem";){let w=h.closest('[role="menu"]');if(!w)break;w.style.display="none",h.setAttribute("aria-expanded","false");let $=w.getAttribute("aria-labelledby");if(!$)break;let P=document.getElementById($);if(!P)break;h=P}}x();function k(b,h,w){switch(b.key){case"ArrowLeft":{if(b.key==="ArrowLeft"&&a.getAttribute("role")==="menuitem"){b.preventDefault(),d();return}break}case"ArrowUp":{b.preventDefault(),C(y(m()),w,-1);break}case"ArrowRight":{if(b.key==="ArrowRight"&&c(h)){b.preventDefault();let $=h.getAttribute("aria-controls");if($){L($);return}}break}case"ArrowDown":{b.preventDefault(),C(y(m()),w,1);break}case"Home":{b.preventDefault(),D(m(),0);break}case"End":{b.preventDefault();let $=m();D($,$.length-1);break}case"Escape":{b.preventDefault(),d(),a.focus(),H&&H(!1);break}case"Enter":case" ":{if(b.preventDefault(),c(h)){let $=h.getAttribute("aria-controls");if($){L($);return}}h.click(),d(),H&&H(!1);break}case"Tab":{d(),u(a),H&&H(!1);break}default:break}}function S(b){let h=b.parentElement;for(;h&&h!==o;){if(h.getAttribute("role")==="menu"||h.id&&o.querySelector(`[aria-controls="${h.id}"]`))return!0;h=h.parentElement}return!1}function v(b){a.setAttribute("aria-expanded",b?"true":"false")}function L(b){let h=r.get(b);if(!h){let w=o.querySelector(`[aria-controls="${b}"]`);if(!w){console.error(`[aria-ease] Submenu trigger with aria-controls="${b}" not found in menu "${e}".`);return}if(!w.id){let P=`trigger-${b}`;w.id=P,console.warn(`[aria-ease] Submenu trigger for "${b}" had no ID. Auto-generated ID: "${P}".`)}if(!document.querySelector(`#${b}`)){console.error(`[aria-ease] Submenu element with id="${b}" not found. Cannot create submenu instance.`);return}h=ne({menuId:b,menuItemsClass:t,triggerId:w.id,callback:i}),r.set(b,h)}h.openMenu()}function H(b){if(i?.onOpenChange)try{i.onOpenChange(b)}catch(h){console.error("[aria-ease] Error in menu onOpenChange callback:",h)}}function f(){m().forEach((h,w)=>{if(!n.has(h)){let $=P=>k(P,h,w);h.addEventListener("keydown",$),n.set(h,$)}})}function E(){m().forEach(h=>{let w=n.get(h);w&&(h.removeEventListener("keydown",w),n.delete(h))})}function M(){v(!0),o.style.display="block";let b=m();if(f(),b&&b.length>0&&b[0].focus(),i?.onOpenChange)try{i.onOpenChange(!0)}catch(h){console.error("[aria-ease] Error in menu onOpenChange callback:",h)}}function d(){if(r.forEach(b=>b.closeMenu()),v(!1),o.style.display="none",E(),a.focus(),i?.onOpenChange)try{i.onOpenChange(!1)}catch(b){console.error("[aria-ease] Error in menu onOpenChange callback:",b)}}function A(){a.getAttribute("aria-expanded")==="true"?d():M()}function T(b){if(!(a.getAttribute("aria-expanded")==="true"))return;let w=a.contains(b.target),$=o.contains(b.target);!w&&!$&&d()}a.addEventListener("click",A),document.addEventListener("click",T);function q(){E(),a.removeEventListener("click",A),document.removeEventListener("click",T),o.style.display="none",v(!1),r.forEach(b=>b.cleanup()),r.clear()}function I(){l=null,s=null}return{openMenu:M,closeMenu:d,cleanup:q,refresh:I}}function Re({radioGroupId:e,radiosClass:t,defaultSelectedIndex:g=0}){if(e==="")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(`#${e}`);if(!i)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(t==="")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 o=Array.from(i.querySelectorAll(`.${t}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let a=new WeakMap,n=new WeakMap,r=g;function l(){i.getAttribute("role")||i.setAttribute("role","radiogroup"),o.forEach((c,u)=>{c.setAttribute("role","radio"),c.setAttribute("tabindex",u===r?"0":"-1"),u===r?c.setAttribute("aria-checked","true"):c.setAttribute("aria-checked","false")})}function s(c){if(c<0||c>=o.length){console.error(`[aria-ease] Invalid radio index: ${c}`);return}r>=0&&r<o.length&&(o[r].setAttribute("aria-checked","false"),o[r].setAttribute("tabindex","-1")),o[c].setAttribute("aria-checked","true"),o[c].setAttribute("tabindex","0"),o[c].focus(),r=c}function p(c){return()=>{s(c)}}function m(c){return u=>{let{key:k}=u,S=c;switch(k){case"ArrowDown":case"ArrowRight":u.preventDefault(),S=(c+1)%o.length,s(S);break;case"ArrowUp":case"ArrowLeft":u.preventDefault(),S=(c-1+o.length)%o.length,s(S);break;case" ":case"Enter":u.preventDefault(),s(c);break}}}function y(){o.forEach((c,u)=>{let k=p(u),S=m(u);c.addEventListener("click",k),c.addEventListener("keydown",S),a.set(c,S),n.set(c,k)})}function x(){o.forEach(c=>{let u=a.get(c),k=n.get(c);u&&(c.removeEventListener("keydown",u),a.delete(c)),k&&(c.removeEventListener("click",k),n.delete(c))})}function C(){x()}function D(){return r}return l(),y(),{selectRadio:s,getSelectedIndex:D,cleanup:C}}function Ne({toggleId:e,togglesClass:t,isSingleToggle:g=!0}){if(e==="")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(`#${e}`);if(!i)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let o;if(g)o=[i];else{if(!t)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(o=Array.from(i.querySelectorAll(`.${t}`)),o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let a=new WeakMap,n=new WeakMap;function r(){o.forEach(u=>{u.tagName.toLowerCase()!=="button"&&!u.getAttribute("role")&&u.setAttribute("role","button"),u.hasAttribute("aria-pressed")||u.setAttribute("aria-pressed","false"),u.hasAttribute("tabindex")||u.setAttribute("tabindex","0")})}function l(u){if(u<0||u>=o.length){console.error(`[aria-ease] Invalid toggle index: ${u}`);return}let k=o[u],S=k.getAttribute("aria-pressed")==="true";k.setAttribute("aria-pressed",S?"false":"true")}function s(u,k){if(u<0||u>=o.length){console.error(`[aria-ease] Invalid toggle index: ${u}`);return}o[u].setAttribute("aria-pressed",k?"true":"false")}function p(u){return()=>{l(u)}}function m(u){return k=>{let{key:S}=k;switch(S){case"Enter":case" ":k.preventDefault(),l(u);break}}}function y(){o.forEach((u,k)=>{let S=p(k),v=m(k);u.addEventListener("click",S),u.addEventListener("keydown",v),a.set(u,v),n.set(u,S)})}function x(){o.forEach(u=>{let k=a.get(u),S=n.get(u);k&&(u.removeEventListener("keydown",k),a.delete(u)),S&&(u.removeEventListener("click",S),n.delete(u))})}function C(){x()}function D(){return o.map(u=>u.getAttribute("aria-pressed")==="true")}function c(){return o.map((u,k)=>u.getAttribute("aria-pressed")==="true"?k:-1).filter(u=>u!==-1)}return r(),y(),{toggleButton:l,setPressed:s,getPressedStates:D,getPressedIndices:c,cleanup:C}}function Be({comboboxInputId:e,comboboxButtonId:t,listBoxId:g,listBoxItemsClass:i,callback:o}){if(e==="")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 a=document.getElementById(`${e}`);if(!a)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(g==="")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 n=document.getElementById(`${g}`);if(!n)return console.error(`[aria-ease] Element with id="${g}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(i==="")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(i))return console.error(`[aria-ease] Listbox option(s) with class="${i}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let l=t?document.getElementById(`${t}`):null,s=-1;a.setAttribute("role","combobox"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-controls",g),a.setAttribute("aria-expanded","false"),a.setAttribute("aria-haspopup","listbox"),n.setAttribute("role","listbox");let p=null;function m(){return p||(p=n.querySelectorAll(`.${i}`)),Array.from(p).filter(d=>!d.hidden&&d.style.display!=="none")}function y(){return a.getAttribute("aria-expanded")==="true"}function x(d){let A=m();if(d>=0&&d<A.length){let T=A[d],q=T.id||`${g}-option-${d}`;if(T.id||(T.id=q),a.setAttribute("aria-activedescendant",q),typeof T.scrollIntoView=="function"&&T.scrollIntoView({block:"nearest",behavior:"smooth"}),o?.onActiveDescendantChange)try{o.onActiveDescendantChange(q,T)}catch(I){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",I)}}else a.setAttribute("aria-activedescendant","");s=d}function C(){if(a.setAttribute("aria-expanded","true"),n.style.display="block",o?.onOpenChange)try{o.onOpenChange(!0)}catch(d){console.error("[aria-ease] Error in combobox onOpenChange callback:",d)}}function D(){if(a.setAttribute("aria-expanded","false"),a.setAttribute("aria-activedescendant",""),n.style.display="none",s=-1,o?.onOpenChange)try{o.onOpenChange(!1)}catch(d){console.error("[aria-ease] Error in combobox onOpenChange callback:",d)}}function c(d){let A=d.textContent?.trim()||"";if(a.value=A,d.setAttribute("aria-selected","true"),D(),o?.onSelect)try{o.onSelect(d)}catch(T){console.error("[aria-ease] Error in combobox onSelect callback:",T)}}function u(d){let A=m(),T=y();switch(d.key){case"ArrowDown":if(d.preventDefault(),!T){C();return}if(A.length===0)return;{let q=s>=A.length-1?0:s+1;x(q)}break;case"ArrowUp":if(d.preventDefault(),!T)return;if(A.length>0){let q=s<=0?A.length-1:s-1;x(q)}break;case"Enter":T&&s>=0&&s<A.length&&(d.preventDefault(),c(A[s]));break;case"Escape":if(T)d.preventDefault(),D();else if(a.value&&(d.preventDefault(),a.value="",a.setAttribute("aria-activedescendant",""),m().forEach(I=>{I.getAttribute("aria-selected")==="true"&&I.setAttribute("aria-selected","false")}),o?.onClear))try{o.onClear()}catch(I){console.error("[aria-ease] Error in combobox onClear callback:",I)}break;case"Home":T&&A.length>0&&(d.preventDefault(),x(0));break;case"End":T&&A.length>0&&(d.preventDefault(),x(A.length-1));break;case"Tab":T&&s>=0&&s<A.length&&c(A[s]),T&&D();break}}function k(d){let A=d.target;if(A.classList.contains(i)){let q=m().indexOf(A);q>=0&&x(q)}}function S(d){let A=d.target;A.classList.contains(i)&&(d.preventDefault(),c(A))}function v(d){let A=d.target;!a.contains(A)&&!n.contains(A)&&(!l||!l.contains(A))&&D()}function L(){y()?D():(C(),a.focus())}function H(d){(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),L())}a.addEventListener("keydown",u),n.addEventListener("mousemove",k),n.addEventListener("mousedown",S),document.addEventListener("mousedown",v),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",L),l.addEventListener("keydown",H));function f(){let d=n.querySelectorAll(`.${i}`);if(d.length===0)return;let A=null;for(let T of d)if(T.getAttribute("aria-selected")==="true"){A=T.textContent?.trim()||null;break}!A&&a.value&&(A=a.value.trim()),d.forEach((T,q)=>{T.setAttribute("role","option");let I=T.textContent?.trim()||"";A&&I===A?T.setAttribute("aria-selected","true"):T.setAttribute("aria-selected","false");let b=T.getAttribute("id");if(!b||b===""){let h=`${g}-option-${q}`;T.id=h,T.setAttribute("id",h)}})}f();function E(){a.removeEventListener("keydown",u),n.removeEventListener("mousemove",k),n.removeEventListener("mousedown",S),document.removeEventListener("mousedown",v),l&&(l.removeEventListener("click",L),l.removeEventListener("keydown",H))}function M(){p=null,f(),s=-1,x(-1)}return{cleanup:E,refresh:M,openListbox:C,closeListbox:D}}function Ke({tabListId:e,tabsClass:t,tabPanelsClass:g,orientation:i="horizontal",activateOnFocus:o=!0,callback:a}){if(e==="")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 n=document.querySelector(`#${e}`);if(!n)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};if(t==="")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 r=Array.from(n.querySelectorAll(`.${t}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(g==="")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(`.${g}`));if(l.length===0)return console.error(`[aria-ease] No elements with class="${g}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(r.length!==l.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${r.length} tabs but ${l.length} panels.`),{cleanup:()=>{}};let s=new WeakMap,p=new WeakMap,m=new WeakMap,y=0;function x(){n.setAttribute("role","tablist"),n.setAttribute("aria-orientation",i),r.forEach((f,E)=>{let M=l[E];f.id||(f.id=`${e}-tab-${E}`),M.id||(M.id=`${e}-panel-${E}`),f.setAttribute("role","tab"),f.setAttribute("aria-controls",M.id),f.setAttribute("aria-selected","false"),f.setAttribute("tabindex","-1"),M.setAttribute("role","tabpanel"),M.setAttribute("aria-labelledby",f.id),M.hidden=!0,M.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||M.setAttribute("tabindex","0")}),C(0,!1)}function C(f,E=!0){if(f<0||f>=r.length){console.error(`[aria-ease] Invalid tab index: ${f}`);return}let M=y;r.forEach((T,q)=>{let I=l[q];T.setAttribute("aria-selected","false"),T.setAttribute("tabindex","-1"),I.hidden=!0});let d=r[f],A=l[f];if(d.setAttribute("aria-selected","true"),d.setAttribute("tabindex","0"),A.hidden=!1,E&&d.focus(),y=f,a?.onTabChange&&M!==f)try{a.onTabChange(f,M)}catch(T){console.error("[aria-ease] Error in tabs onTabChange callback:",T)}}function D(f){let E=r.findIndex(A=>A===document.activeElement),M=E!==-1?E:y,d=M;switch(f){case"first":d=0;break;case"last":d=r.length-1;break;case"next":d=(M+1)%r.length;break;case"prev":d=(M-1+r.length)%r.length;break}if(r[d].focus(),r[d].setAttribute("tabindex","0"),r[y].setAttribute("tabindex","-1"),o)C(d,!1);else{let A=y;r.forEach((T,q)=>{q===d?T.setAttribute("tabindex","0"):q!==A&&T.setAttribute("tabindex","-1")})}}function c(f){return()=>{C(f)}}function u(f){return E=>{let{key:M}=E,d=!1;if(i==="horizontal")switch(M){case"ArrowLeft":E.preventDefault(),D("prev"),d=!0;break;case"ArrowRight":E.preventDefault(),D("next"),d=!0;break}else switch(M){case"ArrowUp":E.preventDefault(),D("prev"),d=!0;break;case"ArrowDown":E.preventDefault(),D("next"),d=!0;break}if(!d)switch(M){case"Home":E.preventDefault(),D("first");break;case"End":E.preventDefault(),D("last");break;case" ":case"Enter":o||(E.preventDefault(),C(f));break;case"F10":if(E.shiftKey&&a?.onContextMenu){E.preventDefault();try{a.onContextMenu(f,r[f])}catch(A){console.error("[aria-ease] Error in tabs onContextMenu callback:",A)}}break}}}function k(f){return E=>{if(a?.onContextMenu){E.preventDefault();try{a.onContextMenu(f,r[f])}catch(M){console.error("[aria-ease] Error in tabs onContextMenu callback:",M)}}}}function S(){r.forEach((f,E)=>{let M=c(E),d=u(E),A=k(E);f.addEventListener("click",M),f.addEventListener("keydown",d),a?.onContextMenu&&(f.addEventListener("contextmenu",A),m.set(f,A)),s.set(f,d),p.set(f,M)})}function v(){r.forEach(f=>{let E=s.get(f),M=p.get(f),d=m.get(f);E&&(f.removeEventListener("keydown",E),s.delete(f)),M&&(f.removeEventListener("click",M),p.delete(f)),d&&(f.removeEventListener("contextmenu",d),m.delete(f))})}function L(){v(),r.forEach((f,E)=>{let M=l[E];f.removeAttribute("role"),f.removeAttribute("aria-selected"),f.removeAttribute("aria-controls"),f.removeAttribute("tabindex"),M.removeAttribute("role"),M.removeAttribute("aria-labelledby"),M.removeAttribute("tabindex"),M.hidden=!1}),n.removeAttribute("role"),n.removeAttribute("aria-orientation")}function H(){v();let f=Array.from(n.querySelectorAll(`.${t}`)),E=Array.from(document.querySelectorAll(`.${g}`));r.length=0,r.push(...f),l.length=0,l.push(...E),x(),S()}return x(),S(),{activateTab:C,cleanup:L,refresh:H}}var j={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:re},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...ie(),...J()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ce},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:le},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:ue},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:pe},activeOption:{requires:["popup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"input",key:"ArrowDown"})):e.relativeTarget==="first"?[]:e.relativeTarget==="last"?[{type:"keypress",target:"input",key:"ArrowUp"}]:[]}],assertion:(e={})=>se(e.relativeTarget)},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:ae},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:J},selectedOption:{requires:["popup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTargeta:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTargeta:e.relativeTarget}]}],assertion:(e={})=>oe(e.relativeTarget)}};function re(){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 ie(){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 se(e){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function ae(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function J(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function oe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${e} option to have aria-selected='true'.`}]}function ce(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function le(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function ue(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function pe(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var G={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:de},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:fe},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:be},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:ge},activeItem:{requires:["popup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>me(e.relativeTarget)},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:he},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ve},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:ye},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:Ae},activeSubmenuItem:{requires:["submenu.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ke(e.relativeTarget)}};function de(){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 fe(){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 be(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function ge(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function me(e){return[{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function he(){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 ve(){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 ye(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Ae(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function ke(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var X={activeTab:{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Me(e.relativeTarget)},focusedTab:{setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ee(e.relativeTarget)}};function Ee(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:"Expected first tab to have focus."}]}function Te(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have tabindex='0'.`}]}function Me(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${e} tab to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} tab to be visible.`},Te(e)]}function we(e,t){return t.some(g=>e.capabilities.includes(g))}function N(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let g of e)if(we(t,g.when))return g.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var xe={combobox:j,menu:G,tabs:X},B=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},F=class{constructor(t){this.componentName=t;this.statePack=xe[t]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let g=this.statePack,i={capabilities:["keyboard"]},o=(n,r=new Set)=>{if(r.has(n))return[];r.add(n);let l=g[n];if(!l)return[];let s=[];if(Array.isArray(l.requires))for(let p of l.requires)s=s.concat(o(p,r));return l.setup&&(s=s.concat(N(l.setup,i))),s};return t({ariaReference:(n,r,l)=>({requires:s=>{let p=o(s,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"required",setup:p}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"optional",setup:p}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"recommended",setup:p})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:r,to:l,level:"recommended"})}),contains:(n,r)=>({requires:l=>{let s=o(l,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"recommended"})})}),this}static(t){return t({target:i=>{let o=r=>{let l=this.statePack,s={capabilities:["keyboard"]},p=(m,y=new Set)=>{if(y.has(m))return[];y.add(m);let x=l[m];if(!x)return[];let C=[];if(Array.isArray(x.requires))for(let D of x.requires)C=C.concat(p(D,y));return x.setup&&(C=C.concat(N(x.setup,s))),C};return p(r,new Set)},a=r=>r==="role"?"toHaveRole":"toHaveAttribute",n=(r,l,s)=>{let p=a(r);return{required:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"required",setup:s}),optional:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"optional",setup:s}),recommended:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"recommended",setup:s})}};return{has:(r,l)=>({...n(r,l),requires:p=>{let m=o(p);return n(r,l,m)}})}}}),this}when(t){return new K(this,this.statePack,t)}addDynamicTest(t){this.dynamicTests.push(t)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?[{assertions:this.staticAssertions}]:[],dynamic:this.dynamicTests}}},K=class{constructor(t,g,i){this.parent=t;this.statePack=g;this.event=i}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,g){return this._onTarget=t,this._onRelativeTarget=g,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return(Array.isArray(t)?t:[t]).flatMap(i=>typeof i=="string"?[i]:typeof i=="object"&&i!==null&&"type"in i&&"ref"in i?this._findStateKeyByTypeAndRef(i.type)?[{type:i.type,ref:i.ref}]:[]:[i])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}describe(t){return this._desc=t,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 i={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},o=(s,p=new Set)=>{if(p.has(s))return[];p.add(s);let m=this.statePack[s];if(!m)return[];let y=[];if(Array.isArray(m.requires))for(let x of m.requires)y=y.concat(o(x,p));return m.setup&&(y=y.concat(N(m.setup,i))),y},a=[];for(let s of this._given)if(typeof s=="string")a.push(...o(s));else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let p=this._findStateKeyByTypeAndRef(s.type);if(p){let m=this.statePack[p];if(m&&m.setup)for(let y of m.setup)typeof y.steps=="function"?a.push(...y.steps({relativeTarget:s.ref})):Array.isArray(y.steps)&&a.push(...y.steps)}}let n=new Set;a=a.filter(s=>{let p=JSON.stringify(s);return n.has(p)?!1:(n.add(p),!0)});let r=[];for(let s of this._then)if(typeof s=="string"){let p=this.statePack[s];if(p&&p.assertion!==void 0){let m=p.assertion;if(typeof m=="function")try{m=m()}catch(y){throw new Error(`Error calling assertion function for state '${s}': ${y.message}`)}Array.isArray(m)?r.push(...m):r.push(m)}}else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let p=this._findStateKeyByTypeAndRef(s.type);if(p){let m=this.statePack[p];if(m&&m.assertion!==void 0){let y=m.assertion;if(typeof y=="function")try{y=y({relativeTarget:s.ref})}catch(x){throw new Error(`Error calling assertion function for state '${p}': ${x.message}`)}Array.isArray(y)?r.push(...y):r.push(y)}}}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:r,...a.length?{setup:a}:{}})}};function et(e,t){let g=new F(e);return t(g),new B(g.build())}import Le from"path";async function Q(e,t,g={}){if(!e||typeof e!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!t)throw new Error("\u274C testUiComponent requires a URL");if(t&&typeof t!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function o(p){try{let m=await fetch(p,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(m.ok||m.status===304)return p}catch{return null}return null}let a=V(g.strictness),n={},r=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:p}=await import("./configLoader-ZEJVXLX7.js"),m=await p(process.cwd());if(n=m.config,m.configPath&&(r=Le.dirname(m.configPath)),g.strictness===void 0){let y=n.test?.components?.find(x=>x?.name===e)?.strictness;a=V(y??n.test?.strictness)}}catch{g.strictness===void 0&&(a="balanced")}let l;try{if(t){let p=await o(t);if(p){console.log(`\u{1F3AD} Running Playwright tests on ${p}`);let{runContractTestsPlaywright:m}=await import("./contractTestRunnerPlaywright-44QPA5JG.js");l=await m(e,p,a,n,r)}else throw new Error(`\u274C Dev server not running at ${t}
2
+ 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(p){throw p instanceof Error?p:new Error(`\u274C Contract test execution failed: ${String(p)}`)}let s={violations:i.violations,raw:i,contract:l};if(l.failures.length>0&&t==="Playwright")throw new Error(`
3
+ \u274C ${l.failures.length} accessibility contract test${l.failures.length>1?"s":""} failed (Playwright mode)
4
+ \u2705 ${l.passes.length} test${l.passes.length>1?"s":""} passed
5
5
 
6
6
  \u{1F4CB} Review the detailed test report above for specific failures.
7
- \u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(i.violations.length>0){let f=i.violations.length,y=i.violations.map(k=>`
8
- - ${k.id}: ${k.description}
9
- Impact: ${k.impact}
10
- Affected elements: ${k.nodes.length}
11
- Help: ${k.helpUrl}`).join(`
7
+ \u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(i.violations.length>0){let p=i.violations.length,m=i.violations.map(y=>`
8
+ - ${y.id}: ${y.description}
9
+ Impact: ${y.impact}
10
+ Affected elements: ${y.nodes.length}
11
+ Help: ${y.helpUrl}`).join(`
12
12
  `);throw new Error(`
13
- \u274C ${f} axe accessibility violation${f>1?"s":""} detected
14
- ${y}
13
+ \u274C ${p} axe accessibility violation${p>1?"s":""} detected
14
+ ${m}
15
15
 
16
- \u{1F4CB} Full details available in result.violations`)}return u}var Y=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(Y=async()=>{console.log(`\u{1F680} Running component accessibility tests...
17
- `);let{exec:r}=await import("child_process"),t=(await import("chalk")).default;return new Promise((m,i)=>{r("npx vitest --run --reporter verbose",async(a,o,e)=>{if(console.log(o),e&&console.error(e),!a||a.code===0){try{let{displayBadgeInfo:s,promptAddBadge:u}=await import("./badgeHelper-IB5RTMAG.js");s("component"),await u("component",process.cwd()),console.log(t.dim(`
16
+ \u{1F4CB} Full details available in result.violations`)}return s}var Y=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(Y=async()=>{console.log(`\u{1F680} Running component accessibility tests...
17
+ `);let{exec:e}=await import("child_process"),t=(await import("chalk")).default;return new Promise((g,i)=>{e("npx vitest --run --reporter verbose",async(o,a,n)=>{if(console.log(a),n&&console.error(n),!o||o.code===0){try{let{displayBadgeInfo:l,promptAddBadge:s}=await import("./badgeHelper-IB5RTMAG.js");l("component"),await s("component",process.cwd()),console.log(t.dim(`
18
18
  `+"\u2500".repeat(60))),console.log(t.cyan("\u{1F499} Found aria-ease helpful?")),console.log(t.white(" \u2022 Star us on GitHub: ")+t.blue.underline("https://github.com/aria-ease/aria-ease")),console.log(t.white(" \u2022 Share feedback: ")+t.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log(t.dim("\u2500".repeat(60)+`
19
- `))}catch(s){console.error("Warning: Could not display badge prompt:",s)}m({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let s=a?.code||1;i(new Error(`Tests failed with code ${s}`)),process.exit(s)}})})});async function Z(){await U()}export{Z as cleanupTests,Xe as createContract,Te as makeAccordionAccessible,Se as makeBlockAccessible,$e as makeCheckboxAccessible,Fe as makeComboboxAccessible,ne as makeMenuAccessible,Pe as makeRadioAccessible,_e as makeTabsAccessible,Ne as makeToggleAccessible,Q as testUiComponent};
19
+ `))}catch(l){console.error("Warning: Could not display badge prompt:",l)}g({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let l=o?.code||1;i(new Error(`Tests failed with code ${l}`)),process.exit(l)}})})});async function Z(){await U()}export{Z as cleanupTests,et as createContract,He as makeAccordionAccessible,$e as makeBlockAccessible,Ie as makeCheckboxAccessible,Be as makeComboboxAccessible,ne as makeMenuAccessible,Re as makeRadioAccessible,Ke as makeTabsAccessible,Ne as makeToggleAccessible,Q as testUiComponent};
@@ -0,0 +1 @@
1
+ export{a as RelativeTargetResolver}from'./chunk-WIWSYIGK.js';
@@ -0,0 +1 @@
1
+ var o=class{constructor(t,e){this.mainSelector=t;this.selectors=e;}async resetState(){}async shouldSkipTest(t,e){if(t.orientation!==void 0&&this.selectors.tablist){let r=this.selectors.tablist,i=await e.locator(r).first().getAttribute("aria-orientation");if(t.orientation!==i)return true}return false}getMainSelector(){return this.mainSelector}};export{o as TabsComponentStrategy};
@@ -0,0 +1 @@
1
+ var a=class{static async resolve(t,n,r){let e=await t.locator(n).all();if(typeof r=="number")return e[r-1];switch(r){case "first":return e[0];case "second":return e[1];case "last":return e[e.length-1];case "next":{let s=(await t.evaluate(([c])=>Array.from(document.querySelectorAll(c)).indexOf(document.activeElement),[n])+1)%e.length;return e[s]}case "previous":{let s=(await t.evaluate(([c])=>Array.from(document.querySelectorAll(c)).indexOf(document.activeElement),[n])-1+e.length)%e.length;return e[s]}default:return null}}};export{a};
@@ -0,0 +1,46 @@
1
+ import {d,a,c,e}from'./chunk-APUMBDOT.js';import {a as a$1}from'./chunk-WIWSYIGK.js';import {readFileSync}from'fs';import ge from'path';import {pathToFileURL}from'url';import {expect}from'@playwright/test';var ne=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies();}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>import('./MenuComponentStrategy-R4VPAHDE.js').then(t=>t.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>import('./AccordionComponentStrategy-X2GSQ5KT.js').then(t=>t.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>import('./ComboboxComponentStrategy-SICWLI27.js').then(t=>t.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>import('./TabsComponentStrategy-DTQQUCK2.js').then(t=>t.TabsComponentStrategy));}async loadStrategy(t,s,r){try{if(s)try{let n=ge.isAbsolute(s)?s:ge.resolve(r||process.cwd(),s),u=await import(pathToFileURL(n).href),i=u.default||u;if(!i)throw new Error(`No default export found in ${s}`);return i}catch(n){throw new Error(`Failed to load custom strategy from ${s}: ${n instanceof Error?n.message:String(n)}`)}let o=this.builtInStrategies.get(t);return o?o():null}catch(o){throw new Error(`Strategy loading failed for ${t}: ${o instanceof Error?o.message:String(o)}`)}}has(t,s){return !!s||this.builtInStrategies.has(t)}};var oe=class{static strategyRegistry=new ne;static isComponentConfig(t){return typeof t=="object"&&t!==null}static async detect(t,s,r=400,o=400,n){let u=this.isComponentConfig(s)?s:void 0,i=u?.contractPath;if(!i)throw new Error(`Contract path not found for component: ${t}`);let R=(()=>{if(ge.isAbsolute(i))return i;if(n){let re=ge.resolve(n,i);try{return readFileSync(re,"utf-8"),re}catch{}}let X=ge.resolve(process.cwd(),i);try{return readFileSync(X,"utf-8"),X}catch{return new URL(i,import.meta.url).pathname}})(),C=readFileSync(R,"utf-8"),ee=JSON.parse(C).selectors,_=await this.strategyRegistry.loadStrategy(t,u?.strategyPath,n);if(!_)return null;let z=ee.main;return t==="tabs"?new _(z,ee):new _(z,ee,r,o)}};var ae=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=false;isCustomContract=false;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=false;hasPrintedDynamicSection=false;constructor(t=false,s=false){this.isPlaywright=t,this.isCustomContract=s;}log(t){process.stderr.write(t+`
2
+ `);}start(t,s,r){this.startTime=Date.now(),this.componentName=t,this.totalTests=s,this.hasPrintedStaticSection=false,this.hasPrintedDynamicSection=false,r&&(this.apgUrl=r);let o="Playwright (Real Browser)";this.log(`
3
+ ${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${t.charAt(0).toUpperCase()+t.slice(1)} Component - ${o}`),this.log(`${"\u2550".repeat(60)}
4
+ `);}reportStatic(t,s,r=0){this.staticPasses=t,this.staticFailures=s,this.staticWarnings=r;}reportStaticTest(t,s,r,o){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=true);let n=s==="pass"?"\u2713":s==="warn"?"\u26A0":s==="skip"?"\u25CB":"\u2717";this.log(` ${n} ${t}`),o&&this.log(` \u21B3 level=${o}`),(s==="fail"||s==="warn"||s==="skip")&&r&&this.log(` \u21B3 ${r}`);}reportTest(t,s,r){this.hasPrintedDynamicSection||(this.log(""),this.log(`${"\u2500".repeat(60)}`),this.log("\u2328\uFE0F Dynamic Interaction Tests"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedDynamicSection=true);let o={description:t.description,status:s,failureMessage:r,level:t.level};s==="skip"&&(o.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(o);let n={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},u=t.level?`[${t.level.toUpperCase()}] `:"";this.log(` ${n[s]} ${u}${t.description}`),s==="skip"&&!this.isPlaywright&&this.log(" \u21B3 Skipped (runs only in Playwright)"),s==="fail"&&r&&this.log(` \u21B3 ${r}`),s==="warn"&&r&&this.log(` \u21B3 ${r}`),s==="skip"&&r&&this.log(` \u21B3 ${r}`);}reportFailures(t){t.length!==0&&(this.log(`
5
+ ${"\u2500".repeat(60)}`),this.log(`\u274C Failures (${t.length}):
6
+ `),t.forEach((s,r)=>{this.log(`${r+1}. ${s}`),s.includes("aria-")?this.log(" \u{1F4A1} Add the missing ARIA attribute to improve screen reader support"):s.includes("focus")?this.log(" \u{1F4A1} Check keyboard event handlers and focus management"):s.includes("visible")&&this.log(" \u{1F4A1} Verify display/visibility styles and state management"),this.log("");}));}reportWarnings(){let t=this.dynamicResults.filter(s=>s.status==="warn");t.length===0&&this.staticWarnings===0||(this.log(`
7
+ ${"\u2500".repeat(60)}`),this.log(`\u26A0\uFE0F Warnings (${this.staticWarnings+t.length}):
8
+ `),this.log(`These checks are failing but treated as warnings under the active strictness mode.
9
+ `),t.forEach((s,r)=>{this.log(`${r+1}. ${s.description}`),s.failureMessage&&this.log(` \u21B3 ${s.failureMessage}`),s.level&&this.log(` \u21B3 level=${s.level}`);}),this.apgUrl&&this.log(`
10
+ Reference: ${this.apgUrl}
11
+ `));}reportSkipped(){if(this.skipped===0||this.isPlaywright)return;let t=this.dynamicResults.filter(s=>s.status==="skip");this.log(`
12
+ ${"\u2500".repeat(60)}`),this.log(`\u2139\uFE0F Skipped Tests (${this.skipped}):
13
+ `),this.log("These tests use native keyboard events via addEventListener,"),this.log(`which only run in Playwright (real browser).
14
+ `),t.forEach((s,r)=>{this.log(`${r+1}. ${s.description}`);}),this.log(`
15
+ \u{1F4A1} Run with Playwright for full validation:`),this.log(` testUiComponent('${this.componentName}', null, 'http://localhost:5173/test-harness?component=component_name')
16
+ `);}summary(t){let s=Date.now()-this.startTime,r=this.dynamicResults.filter(A=>A.status==="pass").length,o=this.dynamicResults.filter(A=>A.status==="fail").length,n=this.dynamicResults.filter(A=>A.status==="warn").length;this.skipped=this.dynamicResults.filter(A=>A.status==="skip").length,this.warnings=this.staticWarnings+n;let u=this.staticPasses+r,i=this.staticFailures+o,R=u+i+this.warnings,C=()=>{let A=`${this.componentName.charAt(0).toUpperCase()}${this.componentName.slice(1)}`;return this.isCustomContract?`${A} component validates against your custom accessibility policy \u2713`:`${A} component meets Aria-Ease baseline WAI-ARIA expectations \u2713`};return t.length>0&&this.reportFailures(t),this.reportWarnings(),this.reportSkipped(),this.log(`
17
+ ${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
18
+ `),i===0&&this.skipped===0&&this.warnings===0?(this.log(`\u2705 All ${R} tests passed!`),this.log(` ${C()}`)):i===0?(this.log(`\u2705 ${u}/${R} 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(` ${C()}`)):(this.log(`\u274C ${i} test${i>1?"s":""} failed`),this.log(`\u2705 ${u} test${u>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: ${s}ms`),this.log(`${"\u2550".repeat(60)}
19
+ `),i>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
20
+ `)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
21
+ `),{passes:u,failures:i,skipped:this.skipped,duration:s}}error(t,s){this.log(`
22
+ \u274C Error: ${t}`),s&&this.log(` Context: ${s}`),this.log("");}};var N=class{constructor(t,s,r=400){this.page=t;this.selectors=s;this.timeoutMs=r;}isBrowserClosedError(t){return t instanceof Error&&t.message.includes("Target page, context or browser has been closed")}async focus(t,s,r){try{if(t==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let u=this.page.locator(n).first();return await u.count()?(await u.evaluate((R,C)=>{R.setAttribute("aria-activedescendant",C);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(t==="relative"&&s){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let u=await a$1.resolve(this.page,n,s);return u?(await u.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for focus.`}}let o=this.selectors[t];return o?(await this.page.locator(o).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${t} not found.`}}catch(o){return this.isBrowserClosedError(o)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${t}: ${o instanceof Error?o.message:String(o)}`}}}async type(t,s){try{let r=this.selectors[t];return r?(await this.page.locator(r).first().fill(s,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${t}: ${r instanceof Error?r.message:String(r)}`}}}async click(t,s){try{if(t==="document")return await this.page.mouse.click(10,10),{success:!0};if(t==="relative"&&s){let o=this.selectors.relative;if(!o)return {success:!1,error:"Relative selector not defined for click action."};let n=await a$1.resolve(this.page,o,s);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for click.`}}let r=this.selectors[t];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${t}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(t,s,r){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"}[s]||s;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),t==="focusable"&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Home","End","Tab","Shift+Tab"].includes(n))return await this.page.keyboard.press(n),{success:!0};if(t==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let C=this.selectors.relative;if(!C)return {success:!1,error:"Relative selector not defined for keypress action."};let A=await a$1.resolve(this.page,C,r);return A?(await A.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let u=this.selectors[t];if(!u)return {success:!1,error:`Selector for keypress target ${t} not found.`};let i=this.page.locator(u).first();return await i.count()===0?{success:!1,error:`${t} element not found.`,shouldBreak:!0}:(await i.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(o){return this.isBrowserClosedError(o)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${s} on ${t}: ${o instanceof Error?o.message:String(o)}`}}}async hover(t,s){try{if(t==="relative"&&s){let o=this.selectors.relative;if(!o)return {success:!1,error:"Relative selector not defined for hover action."};let n=await a$1.resolve(this.page,o,s);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for hover.`}}let r=this.selectors[t];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${t}: ${r instanceof Error?r.message:String(r)}`}}}};var se=class{constructor(t,s,r=400){this.page=t;this.selectors=s;this.timeoutMs=r;}async resolveTarget(t,s,r){try{if(t==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!s)return {target:null,error:"Relative target or expected value is not defined."};let u=await a$1.resolve(this.page,n,s);return u?{target:u}:{target:null,error:`Target ${t} not found.`}}let o=this.selectors[t];return o?{target:this.page.locator(o).first()}:{target:null,error:`Selector for assertion target ${t} not found.`}}catch(o){return {target:null,error:`Failed to resolve target ${t}: ${o instanceof Error?o.message:String(o)}`}}}async validateVisibility(t,s,r,o,n){try{return r?(await expect(t).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} is visible as expected. Test: "${n}".`}):(await expect(t).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} is not visible as expected. Test: "${n}".`})}catch{let u=this.selectors[s]||"",i=await this.page.evaluate(R=>{let C=R?document.querySelector(R):null;if(!C)return "element not found";let A=window.getComputedStyle(C);return `display:${A.display}, visibility:${A.visibility}, opacity:${A.opacity}`},u);return r?{success:false,failMessage:`${o} (actual: ${i})`}:{success:false,failMessage:`${o} ${s} is still visible (actual: ${i}).`}}}async validateAttribute(t,s,r,o,n,u){if(o==="!empty"){let C=await t.getAttribute(r);return C&&C.trim()!==""?{success:true,passMessage:`${s} has non-empty "${r}". Test: "${u}".`}:{success:false,failMessage:`${n} ${s} "${r}" should not be empty, found "${C}".`}}if(typeof o!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",o),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(o)}`);let i=o.split(" | ").map(C=>C.trim()),R=await t.getAttribute(r);return R!==null&&i.includes(R)?{success:true,passMessage:`${s} has expected "${r}". Test: "${u}".`}:{success:false,failMessage:`${n} ${s} "${r}" should be "${o}", found "${R}".`}}async validateValue(t,s,r,o,n){let u=await t.inputValue().catch(()=>"");return r==="!empty"?u&&u.trim()!==""?{success:true,passMessage:`${s} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should not be empty, found "${u}".`}:r===""?u===""?{success:true,passMessage:`${s} has empty value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should be empty, found "${u}".`}:u===r?{success:true,passMessage:`${s} has expected value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should be "${r}", found "${u}".`}}async validateFocus(t,s,r,o,n){try{return r?(await expect(t).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} has focus as expected. Test: "${n}".`}):(await expect(t).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} does not have focus as expected. Test: "${n}".`})}catch{let u=await this.page.evaluate(()=>{let i=document.activeElement;return i?`${i.tagName}#${i.id||"no-id"}.${i.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${o} (actual focus: ${u})`}}}async validateRole(t,s,r,o,n){let u=await t.getAttribute("role");return u===r?{success:true,passMessage:`${s} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${o} Expected role "${r}", found "${u}".`}}async validate(t,s){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,o;if(t.controlledBy){let n=t.controlledBy,u=this.selectors[n.target];if(!u)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let i=null;if(n.relativeTarget?i=await a$1.resolve(this.page,u,n.relativeTarget):i=this.page.locator(u).first(),!i)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let R=n.attribute||"aria-controls",C=await i.getAttribute(R);if(!C)return {success:false,failMessage:`Controlling element does not have attribute '${R}'.`,target:null};if(r=this.page.locator(`#${C}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${C}' not found.`,target:null}}else {let n=await this.resolveTarget(t.target,t.relativeTarget||t.expectedValue,t.selectorKey);if(r=n.target,o=n.error,o||!r)return {success:false,failMessage:o||`Target ${t.target} not found.`,target:null}}if(t.target==="input"&&t.attribute==="aria-activedescendant"&&t.expectedValue==="!empty"&&t.relativeTarget&&t.selectorKey){let n=await a$1.resolve(this.page,this.selectors[t.selectorKey],t.relativeTarget),u=n?await n.getAttribute("id"):null,i=await r.getAttribute("aria-activedescendant");return u&&i===u?{success:true,passMessage:`input[aria-activedescendant] matches id of ${t.relativeTarget}(${t.selectorKey}). Test: "${s}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${t.relativeTarget}(${t.selectorKey}), found "${i}".`}}switch(t.assertion){case "toBeVisible":return this.validateVisibility(r,t.target,true,t.failureMessage||"",s);case "notToBeVisible":return this.validateVisibility(r,t.target,false,t.failureMessage||"",s);case "toHaveAttribute":return t.attribute&&t.expectedValue!==void 0?this.validateAttribute(r,t.target,t.attribute,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return t.expectedValue!==void 0?this.validateValue(r,t.target,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,t.target,true,t.failureMessage||"",s);case "notToHaveFocus":return this.validateFocus(r,t.target,false,t.failureMessage||"",s);case "toHaveRole":return t.expectedValue!==void 0?this.validateRole(r,t.target,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${t.assertion}`}}}};async function tt(M,t,s,r,o){let n=r?.test?.components?.find(d=>d.name===M),u=!!n?.contractPath,i=new ae(true,u),R={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},C=r?.test?.disableTimeouts===true,ee=n?.disableTimeouts===true||C,_=(d,H,O)=>{if(ee)return 0;let F=d??H;return typeof F!="number"||!Number.isFinite(F)||F<0?O:F},z=_(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,R.actionTimeoutMs),X=_(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,R.assertionTimeoutMs),re=_(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,R.navigationTimeoutMs),le=_(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,R.componentReadyTimeoutMs),me=d(s),Y=n?.contractPath;if(!Y)throw new Error(`Contract path not found for component: ${M}`);let Re=(()=>{if(ge.isAbsolute(Y))return Y;if(o){let H=ge.resolve(o,Y);try{return readFileSync(H,"utf-8"),H}catch{}}let d=ge.resolve(process.cwd(),Y);try{return readFileSync(d,"utf-8"),d}catch{return new URL(Y,import.meta.url).pathname}})(),Ae=readFileSync(Re,"utf-8"),b=JSON.parse(Ae),Me=(b.relationships?.length||0)+(b.static[0]?.assertions.length||0)+b.dynamic.length,Ee=b.meta?.source?.apg,V=[],K=[],q=[],x=[],y=null,E=(d,H)=>{let O=c(H),F=e(O,me);if(F==="error")return V.push(d),{status:"fail",level:O,detail:d};if(F==="warning")return K.push(d),{status:"warn",level:O,detail:d};let D=`${d} (ignored by strictness=${me}, level=${O})`;return x.push(D),{status:"skip",level:O,detail:D}};try{if(y=await a(),t){try{await y.goto(t,{waitUntil:"domcontentloaded",timeout:re});}catch(e){throw new Error(`Failed to navigate to ${t}. Ensure dev server is running and accessible. Original error: ${e instanceof Error?e.message:String(e)}`)}await y.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let d=await oe.detect(M,n,z,X,o);if(!d)throw new Error(`Unsupported component: ${M}`);let H=d.getMainSelector();if(!H)throw new Error(`CRITICAL: No selector found in contract for ${M}`);try{await y.locator(H).first().waitFor({state:"attached",timeout:le});}catch(e){throw new Error(`
23
+ \u274C CRITICAL: Component not found on page!
24
+ This usually means:
25
+ - The component didn't render
26
+ - The URL is incorrect
27
+ - The component selector '${H}' in the contract is wrong
28
+ - Original error: ${e}`)}i.start(M,Me,Ee),M==="menu"&&b.selectors.main&&await y.locator(b.selectors.main).first().waitFor({state:"visible",timeout:le}).catch(()=>{});let O=M==="menu"&&b.selectors.submenuTrigger?await y.locator(b.selectors.submenuTrigger).count()>0:!1,F=e=>e.type==="aria-reference"&&[e.from,e.to].some(p=>["submenu","submenuTrigger","submenuItems"].includes(p||""))||e.type==="contains"&&[e.parent,e.child].some(p=>["submenu","submenuTrigger","submenuItems"].includes(p||"")),D=0,P=0,I=0;for(let e of b.relationships||[]){if(d&&typeof d.resetState=="function")try{await d.resetState(y);}catch(g){K.push(`Warning: resetState failed before relationship test: ${g instanceof Error?g.message:String(g)}`);}let p=c(e.level);if(Array.isArray(e.setup)&&e.setup.length>0){let w=function(l){return h.includes(l)};var ve=w;let g=new N(y,b.selectors,z),S=e.type==="aria-reference"?`${e.from}.${e.attribute} references ${e.to}`:`${e.parent} contains ${e.child}`,h=["focus","type","click","keypress","hover"],m=l=>({...l,type:w(l.type)?l.type:"click"}),$=e.setup.map(m),k=await ue($,g,d,y,S,["submenu","submenuTrigger","submenuItems"]);if(k.skip){x.push(k.message||"Setup action skipped"),i.reportStaticTest(S,"skip",k.message,p);continue}if(!k.success){let l=`Relationship setup failed: ${k.error}`,c=E(l,e.level);c.status==="fail"&&(P+=1),c.status==="warn"&&(I+=1),i.reportStaticTest(S,c.status,c.detail,c.level);continue}}if(M==="menu"&&!O&&F(e)){let S=e.type==="aria-reference"?`${e.from}.${e.attribute} references ${e.to}`:`${e.parent} contains ${e.child}`,h="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";x.push(h),i.reportStaticTest(S,"skip",h,p);continue}if(e.type==="aria-reference"){let g=`${e.from}.${e.attribute} references ${e.to}`,S=b.selectors[e.from],h=b.selectors[e.to];if(!S||!h){let f=E(`Relationship selector missing: from="${e.from}" or to="${e.to}" not found in selectors.`,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(g,f.status,f.detail,f.level);continue}let w=y.locator(S).first(),m=y.locator(h).first(),$=await w.count()>0,k=await m.count()>0;if(!$||!k){if(M==="menu"&&F(e)){let B="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";x.push(B),i.reportStaticTest(g,"skip",B,p);continue}let f=E(`Relationship target not found: ${$?e.to:e.from}.`,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(g,f.status,f.detail,f.level);continue}let l=await w.getAttribute(e.attribute),c=await m.getAttribute("id");if(!c){let f=E(`Relationship target "${e.to}" must have an id for ${e.attribute} validation.`,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(g,f.status,f.detail,f.level);continue}if(!(l||"").split(/\s+/).filter(Boolean).includes(c)){let f=E(`Expected ${e.from} ${e.attribute} to reference id "${c}", found "${l||""}".`,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(g,f.status,f.detail,f.level);continue}q.push(`Relationship valid: ${e.from}.${e.attribute} -> ${e.to} (id=${c}).`),D+=1,i.reportStaticTest(g,"pass",void 0,p);continue}if(e.type==="contains"){let g=`${e.parent} contains ${e.child}`,S=b.selectors[e.parent],h=b.selectors[e.child];if(!S||!h){let l=E(`Relationship selector missing: parent="${e.parent}" or child="${e.child}" not found in selectors.`,e.level);l.status==="fail"&&(P+=1),l.status==="warn"&&(I+=1),i.reportStaticTest(g,l.status,l.detail,l.level);continue}let w=y.locator(S).first();if(!(await w.count()>0)){if(M==="menu"&&F(e)){let c="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";x.push(c),i.reportStaticTest(g,"skip",c,p);continue}let l=E(`Relationship parent target not found: ${e.parent}.`,e.level);l.status==="fail"&&(P+=1),l.status==="warn"&&(I+=1),i.reportStaticTest(g,l.status,l.detail,l.level);continue}if(await w.locator(h).count()<1){if(M==="menu"&&F(e)){let c="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";x.push(c),i.reportStaticTest(g,"skip",c,p);continue}let l=E(`Expected ${e.parent} to contain descendant matching selector for ${e.child}.`,e.level);l.status==="fail"&&(P+=1),l.status==="warn"&&(I+=1),i.reportStaticTest(g,l.status,l.detail,l.level);continue}q.push(`Relationship valid: ${e.parent} contains ${e.child}.`),D+=1,i.reportStaticTest(g,"pass",void 0,p);}}async function ye(e,p,g,S={}){if(!e||typeof e!="object"||!("ref"in e))return e;let h;if(e.ref==="relative"){if(!e.relativeTarget||!S.relativeBaseSelector)return;let w=g.locator(S.relativeBaseSelector),m=await w.count(),$=0;if(e.relativeTarget==="first"?$=0:e.relativeTarget==="second"?$=1:e.relativeTarget==="last"?$=m-1:isNaN(Number(e.relativeTarget))?$=0:$=Number(e.relativeTarget),$<0||$>=m)return;let k=w.nth($);return await we(k,e.property||e.attribute)}else {if(h=p[e.ref],!h)throw new Error(`Selector for ref '${e.ref}' not found in contract selectors.`);let w=g.locator(h).first();return await we(w,e.property||e.attribute)}}async function we(e,p){if(e)return !p||p==="id"?await e.getAttribute("id")??void 0:p==="class"?await e.getAttribute("class")??void 0:p==="textContent"?await e.evaluate(g=>g.textContent??void 0):p.startsWith("aria-")?await e.getAttribute(p)??void 0:p.endsWith("*")?await e.evaluate(S=>{let h=[];for(let w of Array.from(S.attributes))w.name.startsWith("aria-")&&h.push(`${w.name}=${w.value}`);return h.join(";")}):await e.getAttribute(p)??void 0}let xe=new se(y,b.selectors,X);async function ue(e,p,g,S,h,w=[]){if(!Array.isArray(e)||e.length===0)return {success:!0};g&&typeof g.resetState=="function"&&await g.resetState(S);for(let m of e){let $={success:!0};try{if(m.type==="focus")m.target==="relative"&&m.relativeTarget?$=await p.focus("relative",m.relativeTarget):$=await p.focus(m.target);else if(m.type==="type"&&m.value)$=await p.type(m.target,m.value);else if(m.type==="click")$=await p.click(m.target,m.relativeTarget);else if(m.type==="keypress"&&m.key)$=await p.keypress(m.target,m.key,m.relativeTarget);else if(m.type==="hover")$=await p.hover(m.target,m.relativeTarget);else continue}catch(k){$={success:!1,error:k instanceof Error?k.message:String(k)};}if(!$.success){let k=$.error||"Setup action failed";return w.some(c=>h.includes(c)||k.includes(c))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${k}`}:{success:!1,error:k}}}return {success:!0}}for(let e of b.static[0]?.assertions||[]){if(d&&typeof d.resetState=="function")try{await d.resetState(y);}catch(l){K.push(`Warning: resetState failed before static test: ${l instanceof Error?l.message:String(l)}`);}if(e.target==="relative")continue;let p=`${e.target}${e.attribute?` (${e.attribute})`:""}`,g=c(e.level);if(M==="menu"&&e.target==="submenuTrigger"&&!O){let l=`Skipping submenu static assertion for ${e.target}: no submenu capability detected in rendered component.`;x.push(l),i.reportStaticTest(p,"skip",l,g);continue}let S=[];if(e.target||S.push("target"),e.attribute||S.push("attribute"),typeof e.expectedValue>"u"&&S.push("expectedValue"),S.length>0){let l=`${e.target||""}${e.attribute?` (${e.attribute})`:""}`,c=`Static assertion missing required field(s): ${S.join(", ")}`,v=E(c,e.level);v.status==="fail"&&(P+=1),v.status==="warn"&&(I+=1),i.reportStaticTest(l,v.status,v.detail,v.level);continue}if(Array.isArray(e.setup)&&e.setup.length>0){let v=function(a){return c.includes(a)};var ve=v;let l=new N(y,b.selectors,z),c=["focus","type","click","keypress","hover"],U=a=>({...a,type:v(a.type)?a.type:"click"}),f=e.setup.map(U),B=await ue(f,l,d,y,p,["submenu","submenuTrigger","submenuItems"]);if(B.skip){x.push(B.message||"Setup action skipped"),i.reportStaticTest(p,"skip",B.message,g);continue}if(!B.success){let a=`Static setup failed: ${B.error}`,T=E(a,e.level);T.status==="fail"&&(P+=1),T.status==="warn"&&(I+=1),i.reportStaticTest(p,T.status,T.detail,T.level);continue}}let h=b.selectors[e.target];if(!h){let l=`Selector for target ${e.target} not found.`,c=E(l,e.level);c.status==="fail"&&(P+=1),c.status==="warn"&&(I+=1),i.reportStaticTest(p,c.status,c.detail,c.level);continue}let w=y.locator(h).first();if(!(await w.count()>0)){let l=`Target ${e.target} not found.`,c=E(l,e.level);c.status==="fail"&&(P+=1),c.status==="warn"&&(I+=1),i.reportStaticTest(p,c.status,c.detail,c.level);continue}let $=(l,c,v)=>{let U=new RegExp(`\\[${c}(?:=["']?([^\\]"']+)["']?)?\\]`),f=l.match(U);if(!f)return !1;if(!v)return !0;let B=f[1];return B?v.split(" | ").includes(B):!1},k=e.expectedValue;if(e.expectedValue&&typeof e.expectedValue=="object"&&"ref"in e.expectedValue){let l={},c=e.relativeTarget;if(e.expectedValue.ref==="relative"&&e.target==="relative"&&c){let v=b.selectors[c];if(!v)throw new Error(`Selector for relativeTarget '${c}' not found in contract selectors.`);l.relativeBaseSelector=v;}else if(e.expectedValue.ref==="relative"&&c){let v=b.selectors[c];if(!v)throw new Error(`Selector for relativeTarget '${c}' not found in contract selectors.`);l.relativeBaseSelector=v;}k=await ye(e.expectedValue,b.selectors,y,l);}if(e.expectedValue)if($(h,e.attribute,typeof k=="string"?k:void 0))q.push(`${e.attribute}="${k}" on ${e.target} verified by selector (already present in: ${h}).`),D+=1,i.reportStaticTest(p,"pass",void 0,g);else {let l=k??"",c=await xe.validateAttribute(w,e.target,e.attribute,l,e.failureMessage,"Static ARIA Test");if(c.success&&c.passMessage)q.push(c.passMessage),D+=1,i.reportStaticTest(p,"pass",void 0,g);else if(!c.success&&c.failMessage){let v=E(c.failMessage,e.level);v.status==="fail"&&(P+=1),v.status==="warn"&&(I+=1),i.reportStaticTest(p,v.status,v.detail,v.level);}}else {let l=e.attribute.split(" | "),c=!1,v=!0;for(let U of l){let f=U.trim();if($(h,f)){q.push(`${f} on ${e.target} verified by selector (already present in: ${h}).`),c=!0;continue}if(v=!1,await w.getAttribute(f)!==null){c=!0;break}}if(!c&&!v){let U=e.failureMessage+` None of the attributes "${e.attribute}" are present.`,f=E(U,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(p,f.status,f.detail,f.level);}else !v&&c?(q.push(`At least one of the attributes "${e.attribute}" exists on the element.`),D+=1,i.reportStaticTest(p,"pass",void 0,g)):(D+=1,i.reportStaticTest(p,"pass",void 0,g));}}for(let e of b.dynamic||[]){if(!e.assertions||e.assertions.length===0){let a="Skipping test - no assertions found for this dynamic test.";x.push(a),i.reportTest({description:e.description,level:c(e.level)},"skip",a);continue}if(!y||y.isClosed()){console.warn(`
29
+ \u26A0\uFE0F Browser closed - skipping remaining ${b.dynamic.length-b.dynamic.indexOf(e)} tests
30
+ `),V.push(`CRITICAL: Browser/page closed before completing all tests. ${b.dynamic.length-b.dynamic.indexOf(e)} tests skipped.`);break}try{await d.resetState(y);}catch(a){let T=a instanceof Error?a.message:String(a);throw i.error(T),a}let{setup:p=[],action:g,assertions:S}=e,h=c(e.level),w=new N(y,b.selectors,z);if(Array.isArray(p)&&p.length>0){let T=function(L){return a.includes(L)};var ve=T;let a=["focus","type","click","keypress","hover"],Z=L=>({...L,type:T(L.type)?L.type:"click"}),pe=p.map(Z),W=await ue(pe,w,d,y,e.description,["submenu","submenuTrigger","submenuItems"]);if(W.skip){x.push(W.message||"Setup action skipped"),i.reportTest({description:e.description,level:h},"skip",W.message);continue}if(!W.success){let L=E(`Setup failed: ${W.error}`,e.level);i.reportTest({description:e.description,level:h},L.status,L.detail);continue}}let m=V.length,$=K.length,k=x.length;if(await d.shouldSkipTest(e,y)){let a="Skipping test - component-specific conditions not met";x.push(a),i.reportTest({description:e.description,level:h},"skip",a);continue}let c$1=new se(y,b.selectors,X),v=!1,U=null;for(let a of g){if(!y||y.isClosed()){V.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),v=!0;break}let T;if(a.type==="focus")a.target==="relative"&&a.relativeTarget?T=await w.focus("relative",a.relativeTarget):T=await w.focus(a.target);else if(a.type==="type"&&a.value)T=await w.type(a.target,a.value);else if(a.type==="click")T=await w.click(a.target,a.relativeTarget);else if(a.type==="keypress"&&a.key)T=await w.keypress(a.target,a.key,a.relativeTarget);else if(a.type==="hover")T=await w.hover(a.target,a.relativeTarget);else continue;if(!T.success){if(T.error){let Z=E(T.error,e.level);U={status:Z.status,detail:Z.detail};}v=!0;break}}if(v){i.reportTest({description:e.description,level:h},U?.status||"fail",U?.detail||V[V.length-1]);continue}for(let a of S){let T;if(a.expectedValue&&typeof a.expectedValue=="object"&&"ref"in a.expectedValue)if(a.expectedValue.ref==="relative"){let{RelativeTargetResolver:J}=await import('./RelativeTargetResolver-5SIQLWPN.js'),L=b.selectors.relative;if(!L)throw new Error("Relative selector not defined in contract selectors.");let te=a.relativeTarget||"first",G=await J.resolve(y,L,te);if(!G)throw new Error(`Could not resolve relative target '${te}' for expectedValue.`);let $e=a.expectedValue.property||a.expectedValue.attribute||"id";if($e==="textContent")T=await G.evaluate(ie=>ie.textContent??void 0);else {let ie=await G.getAttribute($e);T=ie===null?void 0:ie;}}else T=await ye(a.expectedValue,b.selectors,y,{});else typeof a.expectedValue=="string"||typeof a.expectedValue>"u"?T=a.expectedValue:T="";let Z={...a,expectedValue:T},pe=T??"",W=await c$1.validate({...Z,expectedValue:pe},e.description);if(W.success&&W.passMessage)q.push(W.passMessage);else if(!W.success&&W.failMessage){let J=[];if(a.target||J.push("target"),a.assertion||J.push("assertion"),["toHaveAttribute","toHaveValue","toHaveRole"].includes(a.assertion)&&(typeof a.attribute>"u"&&a.assertion==="toHaveAttribute"&&J.push("attribute"),typeof a.expectedValue>"u"&&J.push("expectedValue")),J.length>0){let L=c(a.level||e.level),te=`Dynamic assertion missing required field(s): ${J.join(", ")}`,G=E(te,L);if(G.status==="skip")continue;V.push(te),i.reportTest({description:e.description,level:L},G.status,G.detail);continue}}}let f=V.length,B=K.length,be=x.length;f>m?i.reportTest({description:e.description,level:h},"fail",V[V.length-1]):B>$?i.reportTest({description:e.description,level:h},"warn",K[K.length-1]):be>k?i.reportTest({description:e.description,level:h},"skip",x[x.length-1]):i.reportTest({description:e.description,level:h},"pass");}i.reportStatic(D,P,I),i.summary(V);}catch(d){if(d instanceof Error)throw d.message.includes("Executable doesn't exist")||d.message.includes("browserType.launch")?new Error(`
31
+ \u274C CRITICAL: Playwright browsers not found!
32
+ \u{1F4E6} Run: npx playwright install chromium`):d.message.includes("net::ERR_CONNECTION_REFUSED")||d.message.includes("NS_ERROR_CONNECTION_REFUSED")?new Error(`
33
+ \u274C CRITICAL: Cannot connect to dev server!
34
+ Make sure your dev server is running at ${t}`):d.message.includes("Timeout")&&d.message.includes("waitFor")?new Error(`
35
+ \u274C CRITICAL: Component not found on page!
36
+ The component selector could not be found within ${le}ms.
37
+ This usually means:
38
+ - The component didn't render
39
+ - The URL is incorrect
40
+ - The component selector was not provided to the component utility, or a wrong selector was used
41
+ `):d.message.includes("Target page, context or browser has been closed")?new Error(`
42
+ \u274C CRITICAL: Browser/page was closed unexpectedly!
43
+ This usually means:
44
+ - The test timeout was too short
45
+ - The browser crashed
46
+ - An external process killed the browser`):d}finally{y&&await y.close();}return {passes:q,failures:V,skipped:x,warnings:K}}export{tt as runContractTestsPlaywright};