aria-ease 7.3.0 → 7.5.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 (41) hide show
  1. package/dist/CheckboxComponentStrategy-AZF2Y4MN.js +1 -0
  2. package/dist/RadioComponentStrategy-GKA5KOM5.js +1 -0
  3. package/dist/cli.cjs +30 -30
  4. package/dist/cli.js +1 -1
  5. package/dist/{contractTestRunnerPlaywright-SJIHHZ3Y.js → contractTestRunnerPlaywright-75NI6SN7.js} +5 -5
  6. package/dist/{contractTestRunnerPlaywright-IFI5BPGV.js → contractTestRunnerPlaywright-VLOD5IB3.js} +5 -5
  7. package/dist/index.cjs +39 -39
  8. package/dist/index.d.cts +24 -11
  9. package/dist/index.d.ts +24 -11
  10. package/dist/index.js +8 -8
  11. package/dist/src/{Types.d-DYfYR3Vc.d.cts → Types.d-D96FYkCN.d.cts} +22 -1
  12. package/dist/src/{Types.d-DYfYR3Vc.d.ts → Types.d-D96FYkCN.d.ts} +22 -1
  13. package/dist/src/accordion/index.d.cts +1 -1
  14. package/dist/src/accordion/index.d.ts +1 -1
  15. package/dist/src/block/index.d.cts +1 -1
  16. package/dist/src/block/index.d.ts +1 -1
  17. package/dist/src/checkbox/index.cjs +1 -1
  18. package/dist/src/checkbox/index.d.cts +2 -6
  19. package/dist/src/checkbox/index.d.ts +2 -6
  20. package/dist/src/checkbox/index.js +1 -1
  21. package/dist/src/combobox/index.d.cts +1 -1
  22. package/dist/src/combobox/index.d.ts +1 -1
  23. package/dist/src/menu/index.d.cts +1 -1
  24. package/dist/src/menu/index.d.ts +1 -1
  25. package/dist/src/radio/index.cjs +1 -1
  26. package/dist/src/radio/index.d.cts +3 -7
  27. package/dist/src/radio/index.d.ts +3 -7
  28. package/dist/src/radio/index.js +1 -1
  29. package/dist/src/tabs/index.d.cts +1 -1
  30. package/dist/src/tabs/index.d.ts +1 -1
  31. package/dist/src/toggle/index.d.cts +1 -1
  32. package/dist/src/toggle/index.d.ts +1 -1
  33. package/dist/src/utils/test/CheckboxComponentStrategy-ST2DWNYT.js +1 -0
  34. package/dist/src/utils/test/RadioComponentStrategy-TWMIMSYX.js +1 -0
  35. package/dist/src/utils/test/{contractTestRunnerPlaywright-Y7N2W6AK.js → contractTestRunnerPlaywright-FSZDW7IR.js} +5 -5
  36. package/dist/src/utils/test/dsl/index.cjs +1 -1
  37. package/dist/src/utils/test/dsl/index.js +1 -1
  38. package/dist/src/utils/test/index.cjs +28 -28
  39. package/dist/src/utils/test/index.js +1 -1
  40. package/dist/{test-2XAMHIKD.js → test-FURQN5KO.js} +1 -1
  41. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -83,6 +83,27 @@ interface ComboboxCallback {
83
83
  onClear?: () => void;
84
84
  }
85
85
 
86
+ interface RadioConfig {
87
+ radioGroupId: string;
88
+ radiosClass: string;
89
+ defaultSelectedIndex?: number;
90
+ callback?: RadioCallback;
91
+ }
92
+
93
+ interface RadioCallback {
94
+ onCheck?: (index: number) => void;
95
+ }
96
+
97
+ interface CheckboxConfig {
98
+ checkboxGroupId: string;
99
+ checkboxesClass: string;
100
+ callback?: CheckboxCallback;
101
+ }
102
+
103
+ interface CheckboxCallback {
104
+ onCheck?: (index: number, checked: boolean) => void;
105
+ }
106
+
86
107
  interface MenuConfig {
87
108
  menuId: string;
88
109
  menuItemsClass: string;
@@ -125,11 +146,7 @@ declare function makeBlockAccessible({ blockId, blockItemsClass }: BlockConfig):
125
146
  * @param {string} checkboxesClass - The shared class of all checkboxes.
126
147
  */
127
148
 
128
- interface CheckboxConfig {
129
- checkboxGroupId: string;
130
- checkboxesClass: string;
131
- }
132
- declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }: CheckboxConfig): AccessibilityInstance;
149
+ declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass, callback }: CheckboxConfig): AccessibilityInstance;
133
150
 
134
151
  /**
135
152
  * Adds keyboard interaction to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first interactive item of the menu has focus when menu open.
@@ -146,14 +163,10 @@ declare function makeMenuAccessible({ menuId, menuItemsClass, triggerId, callbac
146
163
  * @param {string} radioGroupId - The id of the radio group container.
147
164
  * @param {string} radiosClass - The shared class of all radio buttons.
148
165
  * @param {number} defaultSelectedIndex - The index of the initially selected radio (default: 0).
166
+ * @param {RadioCallback} callback - Configuration options for callbacks.
149
167
  */
150
168
 
151
- interface RadioConfig {
152
- radioGroupId: string;
153
- radiosClass: string;
154
- defaultSelectedIndex?: number;
155
- }
156
- declare function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex }: RadioConfig): AccessibilityInstance;
169
+ declare function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex, callback }: RadioConfig): AccessibilityInstance;
157
170
 
158
171
  /**
159
172
  * Makes a toggle button accessible by managing ARIA attributes and keyboard interactions.
package/dist/index.d.ts CHANGED
@@ -83,6 +83,27 @@ interface ComboboxCallback {
83
83
  onClear?: () => void;
84
84
  }
85
85
 
86
+ interface RadioConfig {
87
+ radioGroupId: string;
88
+ radiosClass: string;
89
+ defaultSelectedIndex?: number;
90
+ callback?: RadioCallback;
91
+ }
92
+
93
+ interface RadioCallback {
94
+ onCheck?: (index: number) => void;
95
+ }
96
+
97
+ interface CheckboxConfig {
98
+ checkboxGroupId: string;
99
+ checkboxesClass: string;
100
+ callback?: CheckboxCallback;
101
+ }
102
+
103
+ interface CheckboxCallback {
104
+ onCheck?: (index: number, checked: boolean) => void;
105
+ }
106
+
86
107
  interface MenuConfig {
87
108
  menuId: string;
88
109
  menuItemsClass: string;
@@ -125,11 +146,7 @@ declare function makeBlockAccessible({ blockId, blockItemsClass }: BlockConfig):
125
146
  * @param {string} checkboxesClass - The shared class of all checkboxes.
126
147
  */
127
148
 
128
- interface CheckboxConfig {
129
- checkboxGroupId: string;
130
- checkboxesClass: string;
131
- }
132
- declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }: CheckboxConfig): AccessibilityInstance;
149
+ declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass, callback }: CheckboxConfig): AccessibilityInstance;
133
150
 
134
151
  /**
135
152
  * Adds keyboard interaction to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first interactive item of the menu has focus when menu open.
@@ -146,14 +163,10 @@ declare function makeMenuAccessible({ menuId, menuItemsClass, triggerId, callbac
146
163
  * @param {string} radioGroupId - The id of the radio group container.
147
164
  * @param {string} radiosClass - The shared class of all radio buttons.
148
165
  * @param {number} defaultSelectedIndex - The index of the initially selected radio (default: 0).
166
+ * @param {RadioCallback} callback - Configuration options for callbacks.
149
167
  */
150
168
 
151
- interface RadioConfig {
152
- radioGroupId: string;
153
- radiosClass: string;
154
- defaultSelectedIndex?: number;
155
- }
156
- declare function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex }: RadioConfig): AccessibilityInstance;
169
+ declare function makeRadioAccessible({ radioGroupId, radiosClass, defaultSelectedIndex, callback }: RadioConfig): AccessibilityInstance;
157
170
 
158
171
  /**
159
172
  * Makes a toggle button accessible by managing ARIA attributes and keyboard interactions.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import{b as U,d as B}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function De({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 s=document.querySelector(`#${e}`);if(!s)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(s.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(s.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,a=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),a.set(v,H)})}function u(){n.forEach(v=>{let L=l.get(v),H=a.get(v);L&&(v.removeEventListener("keydown",L),l.delete(v)),H&&(v.removeEventListener("click",H),a.delete(v))})}function k(){u(),n.forEach((v,L)=>{y(L)})}function S(){u();let v=Array.from(s.querySelectorAll(`.${t}`)),L=Array.from(s.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 te(e){return e.tagName==="A"}function _(e,t,g){let i=e.length,o=(t+g+i)%i;e.item(o).focus()}function ne(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)&&!te(i)&&ne(i)||z(i))&&(e.preventDefault(),i.click());break}case"Tab":break;default:break}}function Pe({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 s=o();if(!s||s.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;s.forEach(a=>{if(!n.has(a)){let p=m=>{let y=g.querySelectorAll(`.${t}`),x=Array.prototype.indexOf.call(y,a);W(m,y,x)};a.addEventListener("keydown",p),n.set(a,p)}});function r(){s.forEach(a=>{let p=n.get(a);p&&(a.removeEventListener("keydown",p),n.delete(a))})}function l(){i=null}return{cleanup:r,refresh:l}}function Re({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,s=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 a(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=a(u),S=p(u);c.addEventListener("click",k),c.addEventListener("keydown",S),o.set(c,S),s.set(c,k)})}function y(){i.forEach(c=>{let u=o.get(c),k=s.get(c);u&&(c.removeEventListener("keydown",u),o.delete(c)),k&&(c.removeEventListener("click",k),s.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 re({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 s=document.querySelector(`#${g}`);if(!s)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:()=>{}};s.setAttribute("aria-haspopup","true"),s.setAttribute("aria-controls",e),s.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-labelledby",g);let n=new WeakMap,r=new Map,l=null,a=null;function p(){return l||(l=o.querySelectorAll(`.${t}`)),l}function m(){if(!a){let b=p();a=[];for(let h=0;h<b.length;h++){let M=b.item(h),$=S(M),P=M.getAttribute("aria-disabled")==="true";$||(M.hasAttribute("tabindex")||M.setAttribute("tabindex","-1"),P||a.push(M))}}return a}function y(b){return{length:b.length,item:M=>b[M],forEach:M=>{b.forEach(M)},[Symbol.iterator]:function*(){for(let M of b)yield M}}}function x(){p().forEach(h=>{h.setAttribute("role","menuitem");let M=h.getAttribute("data-submenu-id")??h.getAttribute("aria-controls"),$=h.hasAttribute("aria-haspopup")&&M;M&&(h.hasAttribute("data-submenu-id")||$)&&(h.setAttribute("aria-haspopup","menu"),h.setAttribute("aria-controls",M),h.hasAttribute("aria-expanded")||h.setAttribute("aria-expanded","false"))})}function C(b,h,M){let $=b.length,P=(h+M+$)%$;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 M=h.closest('[role="menu"]');if(!M)break;M.style.display="none",h.setAttribute("aria-expanded","false");let $=M.getAttribute("aria-labelledby");if(!$)break;let P=document.getElementById($);if(!P)break;h=P}}x();function k(b,h,M){switch(b.key){case"ArrowLeft":{if(b.key==="ArrowLeft"&&s.getAttribute("role")==="menuitem"){b.preventDefault(),d();return}break}case"ArrowUp":{b.preventDefault(),C(y(m()),M,-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()),M,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(),s.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(s),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){s.setAttribute("aria-expanded",b?"true":"false")}function L(b){let h=r.get(b);if(!h){let M=o.querySelector(`[aria-controls="${b}"]`);if(!M){console.error(`[aria-ease] Submenu trigger with aria-controls="${b}" not found in menu "${e}".`);return}if(!M.id){let P=`trigger-${b}`;M.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=re({menuId:b,menuItemsClass:t,triggerId:M.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,M)=>{if(!n.has(h)){let $=P=>k(P,h,M);h.addEventListener("keydown",$),n.set(h,$)}})}function E(){m().forEach(h=>{let M=n.get(h);M&&(h.removeEventListener("keydown",M),n.delete(h))})}function w(){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(),s.focus(),i?.onOpenChange)try{i.onOpenChange(!1)}catch(b){console.error("[aria-ease] Error in menu onOpenChange callback:",b)}}function A(){s.getAttribute("aria-expanded")==="true"?d():w()}function T(b){if(!(s.getAttribute("aria-expanded")==="true"))return;let M=s.contains(b.target),$=o.contains(b.target);!M&&!$&&d()}s.addEventListener("click",A),document.addEventListener("click",T);function q(){E(),s.removeEventListener("click",A),document.removeEventListener("click",T),o.style.display="none",v(!1),r.forEach(b=>b.cleanup()),r.clear()}function I(){l=null,a=null}return{openMenu:w,closeMenu:d,cleanup:q,refresh:I}}function Be({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 s=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 a(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()=>{a(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,a(S);break;case"ArrowUp":case"ArrowLeft":u.preventDefault(),S=(c-1+o.length)%o.length,a(S);break;case" ":case"Enter":u.preventDefault(),a(c);break}}}function y(){o.forEach((c,u)=>{let k=p(u),S=m(u);c.addEventListener("click",k),c.addEventListener("keydown",S),s.set(c,S),n.set(c,k)})}function x(){o.forEach(c=>{let u=s.get(c),k=n.get(c);u&&(c.removeEventListener("keydown",u),s.delete(c)),k&&(c.removeEventListener("click",k),n.delete(c))})}function C(){x()}function D(){return r}return l(),y(),{selectRadio:a,getSelectedIndex:D,cleanup:C}}function Ke({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 s=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 a(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),s.set(u,v),n.set(u,S)})}function x(){o.forEach(u=>{let k=s.get(u),S=n.get(u);k&&(u.removeEventListener("keydown",k),s.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:a,getPressedStates:D,getPressedIndices:c,cleanup:C}}function Ue({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 s=document.getElementById(`${e}`);if(!s)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,a=-1;s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-controls",g),s.setAttribute("aria-expanded","false"),s.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 s.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),s.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 s.setAttribute("aria-activedescendant","");a=d}function C(){if(s.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(s.setAttribute("aria-expanded","false"),s.setAttribute("aria-activedescendant",""),n.style.display="none",a=-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(s.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=a>=A.length-1?0:a+1;x(q)}break;case"ArrowUp":if(d.preventDefault(),!T)return;if(A.length>0){let q=a<=0?A.length-1:a-1;x(q)}break;case"Enter":T&&a>=0&&a<A.length&&(d.preventDefault(),c(A[a]));break;case"Escape":if(T)d.preventDefault(),D();else if(s.value&&(d.preventDefault(),s.value="",s.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&&a>=0&&a<A.length&&c(A[a]),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;!s.contains(A)&&!n.contains(A)&&(!l||!l.contains(A))&&D()}function L(){y()?D():(C(),s.focus())}function H(d){(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),L())}s.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&&s.value&&(A=s.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(){s.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 w(){p=null,f(),a=-1,x(-1)}return{cleanup:E,refresh:w,openListbox:C,closeListbox:D}}function We({tabListId:e,tabsClass:t,tabPanelsClass:g,orientation:i="horizontal",activateOnFocus:o=!0,callback:s}){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 a=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 w=l[E];f.id||(f.id=`${e}-tab-${E}`),w.id||(w.id=`${e}-panel-${E}`),f.setAttribute("role","tab"),f.setAttribute("aria-controls",w.id),f.setAttribute("aria-selected","false"),f.setAttribute("tabindex","-1"),w.setAttribute("role","tabpanel"),w.setAttribute("aria-labelledby",f.id),w.hidden=!0,w.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||w.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 w=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,s?.onTabChange&&w!==f)try{s.onTabChange(f,w)}catch(T){console.error("[aria-ease] Error in tabs onTabChange callback:",T)}}function D(f){let E=r.findIndex(A=>A===document.activeElement),w=E!==-1?E:y,d=w;switch(f){case"first":d=0;break;case"last":d=r.length-1;break;case"next":d=(w+1)%r.length;break;case"prev":d=(w-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:w}=E,d=!1;if(i==="horizontal")switch(w){case"ArrowLeft":E.preventDefault(),D("prev"),d=!0;break;case"ArrowRight":E.preventDefault(),D("next"),d=!0;break}else switch(w){case"ArrowUp":E.preventDefault(),D("prev"),d=!0;break;case"ArrowDown":E.preventDefault(),D("next"),d=!0;break}if(!d)switch(w){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&&s?.onContextMenu){E.preventDefault();try{s.onContextMenu(f,r[f])}catch(A){console.error("[aria-ease] Error in tabs onContextMenu callback:",A)}}break}}}function k(f){return E=>{if(s?.onContextMenu){E.preventDefault();try{s.onContextMenu(f,r[f])}catch(w){console.error("[aria-ease] Error in tabs onContextMenu callback:",w)}}}}function S(){r.forEach((f,E)=>{let w=c(E),d=u(E),A=k(E);f.addEventListener("click",w),f.addEventListener("keydown",d),s?.onContextMenu&&(f.addEventListener("contextmenu",A),m.set(f,A)),a.set(f,d),p.set(f,w)})}function v(){r.forEach(f=>{let E=a.get(f),w=p.get(f),d=m.get(f);E&&(f.removeEventListener("keydown",E),a.delete(f)),w&&(f.removeEventListener("click",w),p.delete(f)),d&&(f.removeEventListener("contextmenu",d),m.delete(f))})}function L(){v(),r.forEach((f,E)=>{let w=l[E];f.removeAttribute("role"),f.removeAttribute("aria-selected"),f.removeAttribute("aria-controls"),f.removeAttribute("tabindex"),w.removeAttribute("role"),w.removeAttribute("aria-labelledby"),w.removeAttribute("tabindex"),w.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={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:ie},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...ae(),...J()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:le},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ue},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:pe},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:de},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>se(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:oe},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:J},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ce(e.relativeTarget)}};function ie(){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 ae(){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 relative item."}]}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 ce(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${e} item to have aria-selected='true'.`}]}function le(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function ue(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function pe(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function de(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var G={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:fe},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:be},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ge},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:me},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>he(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ve},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ye},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Ae},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ke},"submenuitem.focused":{requires:["submenupopup.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"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ee(e.relativeTarget)}};function fe(){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 be(){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 ge(){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 he(e){return[{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function ve(){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 ye(){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 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(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var X={"tab.active":{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)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Te(e.relativeTarget)}};function Te(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:"Expected first tab to have focus."}]}function we(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.`},we(e)]}var Q={"panel.expanded":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>xe(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Le(e.relativeTarget)}};function xe(e){return[{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected trigger to have aria-expanded='true' when panel expands."}]}function Le(e){return[{target:"panel",assertion:"notToBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger not to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected trigger to have aria-expanded='false' when panel collapses."}]}function He(e,t){return t.some(g=>e.capabilities.includes(g))}function V(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let g of e)if(He(t,g.when))return g.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var Se={combobox:j,menu:G,tabs:X,accordion:Q},N=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},K=class{constructor(t){this.componentName=t;this.statePack=Se[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 a=[];if(Array.isArray(l.requires))for(let p of l.requires)a=a.concat(o(p,r));return l.setup&&(a=a.concat(V(l.setup,i))),a};return t({ariaReference:(n,r,l)=>({requires:a=>{let p=o(a,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 a=o(l,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"required",setup:a}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"optional",setup:a}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:r,level:"recommended",setup:a})}},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,a={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(V(x.setup,a))),C};return p(r,new Set)},s=r=>r==="role"?"toHaveRole":"toHaveAttribute",n=(r,l,a)=>{let p=s(r);return{required:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"required",setup:a}),optional:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"optional",setup:a}),recommended:()=>this.staticAssertions.push({target:i,assertion:p,attribute:r,expectedValue:l,failureMessage:"",level:"recommended",setup:a})}};return{has:(r,l)=>({...n(r,l),requires:p=>{let m=o(p);return n(r,l,m)}})}}}),this}when(t){return new F(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?this.staticAssertions:[],dynamic:this.dynamicTests}}},F=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=(a,p=new Set)=>{if(p.has(a))return[];p.add(a);let m=this.statePack[a];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(V(m.setup,i))),y},s=[];for(let a of this._given)if(typeof a=="string")s.push(...o(a));else if(typeof a=="object"&&a!==null&&"type"in a&&"ref"in a){let p=this._findStateKeyByTypeAndRef(a.type);if(p){let m=this.statePack[p];if(m&&m.setup)for(let y of m.setup)typeof y.steps=="function"?s.push(...y.steps({relativeTarget:a.ref})):Array.isArray(y.steps)&&s.push(...y.steps)}}let n=new Set;s=s.filter(a=>{let p=JSON.stringify(a);return n.has(p)?!1:(n.add(p),!0)});let r=[];for(let a of this._then)if(typeof a=="string"){let p=this.statePack[a];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 '${a}': ${y.message}`)}Array.isArray(m)?r.push(...m):r.push(m)}}else if(typeof a=="object"&&a!==null&&"type"in a&&"ref"in a){let p=this._findStateKeyByTypeAndRef(a.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:a.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,...s.length?{setup:s}:{}})}};function at(e,t){let g=new K(e);return t(g),new N(g.build())}import Ce from"path";async function Y(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 s=B(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=Ce.dirname(m.configPath)),g.strictness===void 0){let y=n.test?.components?.find(x=>x?.name===e)?.strictness;s=B(y??n.test?.strictness)}}catch{g.strictness===void 0&&(s="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-IFI5BPGV.js");l=await m(e,p,s,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 a={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
1
+ import{b as z,d as N}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function Be({accordionId:e,triggersClass:t,panelsClass:h,allowMultipleOpen:s=!1,callback:l}){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 n=document.querySelector(`#${e}`);if(!n)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 r=Array.from(n.querySelectorAll(`.${t}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(h==="")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 a=Array.from(n.querySelectorAll(`.${h}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${h}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(r.length!==a.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${r.length} triggers but ${a.length} panels.`),{cleanup:()=>{}};let o=new WeakMap,i=new WeakMap;function p(){r.forEach((d,w)=>{let H=a[w];d.id||(d.id=`${e}-trigger-${w}`),H.id||(H.id=`${e}-panel-${w}`),d.setAttribute("aria-controls",H.id),d.setAttribute("aria-expanded","false"),(!s||r.length<=6)&&H.setAttribute("role","region"),H.setAttribute("aria-labelledby",d.id),H.style.display="none"})}function m(d){if(d<0||d>=r.length){console.error(`[aria-ease] Invalid accordion index: ${d}`);return}let w=r[d],H=a[d];if(w.setAttribute("aria-expanded","true"),H.style.display="block",l?.onExpand)try{l.onExpand(d)}catch(b){console.error("[aria-ease] Error in accordion onExpand callback:",b)}}function y(d){if(d<0||d>=r.length){console.error(`[aria-ease] Invalid accordion index: ${d}`);return}let w=r[d],H=a[d];if(w.setAttribute("aria-expanded","false"),H.style.display="none",l?.onCollapse)try{l.onCollapse(d)}catch(b){console.error("[aria-ease] Error in accordion onCollapse callback:",b)}}function L(d){r[d].getAttribute("aria-expanded")==="true"?y(d):(s||r.forEach((b,E)=>{E!==d&&y(E)}),m(d))}function C(d){return()=>{L(d)}}function S(d){return w=>{let{key:H}=w;switch(H){case"Enter":case" ":w.preventDefault(),L(d);break;case"ArrowDown":w.preventDefault();{let b=(d+1)%r.length;r[b].focus()}break;case"ArrowUp":w.preventDefault();{let b=(d-1+r.length)%r.length;r[b].focus()}break;case"Home":w.preventDefault(),r[0].focus();break;case"End":w.preventDefault(),r[r.length-1].focus();break}}}function q(){r.forEach((d,w)=>{let H=C(w),b=S(w);d.addEventListener("click",H),d.addEventListener("keydown",b),o.set(d,b),i.set(d,H)})}function c(){r.forEach(d=>{let w=o.get(d),H=i.get(d);w&&(d.removeEventListener("keydown",w),o.delete(d)),H&&(d.removeEventListener("click",H),i.delete(d))})}function u(){c(),r.forEach((d,w)=>{y(w)})}function k(){c();let d=Array.from(n.querySelectorAll(`.${t}`)),w=Array.from(n.querySelectorAll(`.${h}`));r.length=0,r.push(...d),a.length=0,a.push(...w),p(),q()}return p(),q(),{expandItem:m,collapseItem:y,toggleItem:L,cleanup:u,refresh:k}}function O(e){if(e.tagName!=="INPUT")return!1;let t=e.type;return["text","email","password","tel","number"].includes(t)}function _(e){return e.tagName==="TEXTAREA"}function W(e){return e.tagName==="BUTTON"||e.tagName==="INPUT"&&["button","submit","reset"].includes(e.type)}function ie(e){return e.tagName==="A"}function V(e,t,h){let s=e.length,l=(t+h+s)%s;e.item(l).focus()}function ae(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function J(e,t,h){let s=t.item(h);switch(e.key){case"ArrowUp":case"ArrowLeft":{(!O(s)&&!_(s)||(O(s)||_(s))&&s.selectionStart===0)&&(e.preventDefault(),V(t,h,-1));break}case"ArrowDown":case"ArrowRight":{if(!O(s)&&!_(s))e.preventDefault(),V(t,h,1);else if(O(s)||_(s)){let l=s.value;s.selectionStart===l.length&&(e.preventDefault(),V(t,h,1))}break}case"Escape":{e.preventDefault();break}case"Enter":case" ":{(!W(s)&&!ie(s)&&ae(s)||W(s))&&(e.preventDefault(),s.click());break}case"Tab":break;default:break}}function Ue({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 h=document.querySelector(`#${e}`);if(!h)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 s=null;function l(){return s||(s=h.querySelectorAll(`.${t}`)),s}let n=l();if(!n||n.length===0)return console.error(`[aria-ease] Element with class="${t}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let r=new Map;n.forEach(i=>{if(!r.has(i)){let p=m=>{let y=h.querySelectorAll(`.${t}`),L=Array.prototype.indexOf.call(y,i);J(m,y,L)};i.addEventListener("keydown",p),r.set(i,p)}});function a(){n.forEach(i=>{let p=r.get(i);p&&(i.removeEventListener("keydown",p),r.delete(i))})}function o(){s=null}return{cleanup:a,refresh:o}}function We({checkboxGroupId:e,checkboxesClass:t,callback:h}){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 s=document.querySelector(`#${e}`);if(!s)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 l=Array.from(s.querySelectorAll(`.${t}`));if(l.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let n=new WeakMap,r=new WeakMap;function a(){s.getAttribute("role")||s.setAttribute("role","group"),l.forEach(u=>{u.setAttribute("role","checkbox"),u.hasAttribute("aria-checked")||u.setAttribute("aria-checked","false"),u.hasAttribute("tabindex")||u.setAttribute("tabindex","0")})}function o(u,k){if(h?.onCheck)try{h.onCheck(u,k)}catch(d){console.error("[aria-ease] Error in checkbox onCheck callback:",d)}}function i(u){if(u<0||u>=l.length){console.error(`[aria-ease] Invalid checkbox index: ${u}`);return}let k=l[u],d=k.getAttribute("aria-checked")==="true";k.setAttribute("aria-checked",d?"false":"true"),o(u,d)}function p(u,k){if(u<0||u>=l.length){console.error(`[aria-ease] Invalid checkbox index: ${u}`);return}l[u].setAttribute("aria-checked",k?"true":"false"),o(u,k)}function m(u){return()=>{i(u)}}function y(u){return k=>{let{key:d}=k;switch(d){case" ":k.preventDefault(),i(u);break}}}function L(){l.forEach((u,k)=>{let d=m(k),w=y(k);u.addEventListener("click",d),u.addEventListener("keydown",w),n.set(u,w),r.set(u,d)})}function C(){l.forEach(u=>{let k=n.get(u),d=r.get(u);k&&(u.removeEventListener("keydown",k),n.delete(u)),d&&(u.removeEventListener("click",d),r.delete(u))})}function S(){C()}function q(){return l.map(u=>u.getAttribute("aria-checked")==="true")}function c(){return l.map((u,k)=>u.getAttribute("aria-checked")==="true"?k:-1).filter(u=>u!==-1)}return a(),L(),{toggleCheckbox:i,setCheckboxState:p,getCheckedStates:q,getCheckedIndices:c,cleanup:S}}function se({menuId:e,menuItemsClass:t,triggerId:h,callback:s}){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 l=document.querySelector(`#${e}`);if(!l)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(h==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let n=document.querySelector(`#${h}`);if(!n)return console.error(`[aria-ease] Element with id="${h}" 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:()=>{}};n.setAttribute("aria-haspopup","true"),n.setAttribute("aria-controls",e),n.setAttribute("aria-expanded","false"),l.setAttribute("role","menu"),l.setAttribute("aria-labelledby",h);let r=new WeakMap,a=new Map,o=null,i=null;function p(){return o||(o=l.querySelectorAll(`.${t}`)),o}function m(){if(!i){let g=p();i=[];for(let v=0;v<g.length;v++){let M=g.item(v),$=k(M),P=M.getAttribute("aria-disabled")==="true";$||(M.hasAttribute("tabindex")||M.setAttribute("tabindex","-1"),P||i.push(M))}}return i}function y(g){return{length:g.length,item:M=>g[M],forEach:M=>{g.forEach(M)},[Symbol.iterator]:function*(){for(let M of g)yield M}}}function L(){p().forEach(v=>{v.setAttribute("role","menuitem");let M=v.getAttribute("data-submenu-id")??v.getAttribute("aria-controls"),$=v.hasAttribute("aria-haspopup")&&M;M&&(v.hasAttribute("data-submenu-id")||$)&&(v.setAttribute("aria-haspopup","menu"),v.setAttribute("aria-controls",M),v.hasAttribute("aria-expanded")||v.setAttribute("aria-expanded","false"))})}function C(g,v,M){let $=g.length,P=(v+M+$)%$;g.item(P).focus()}function S(g,v){g.length!==0&&g[v]?.focus()}function q(g){return g.hasAttribute("aria-controls")&&g.hasAttribute("aria-haspopup")&&g.getAttribute("role")==="menuitem"}function c(g){let v=g;for(;v&&v.getAttribute("role")==="menuitem";){let M=v.closest('[role="menu"]');if(!M)break;M.style.display="none",v.setAttribute("aria-expanded","false");let $=M.getAttribute("aria-labelledby");if(!$)break;let P=document.getElementById($);if(!P)break;v=P}}L();function u(g,v,M){switch(g.key){case"ArrowLeft":{if(g.key==="ArrowLeft"&&n.getAttribute("role")==="menuitem"){g.preventDefault(),f();return}break}case"ArrowUp":{g.preventDefault(),C(y(m()),M,-1);break}case"ArrowRight":{if(g.key==="ArrowRight"&&q(v)){g.preventDefault();let $=v.getAttribute("aria-controls");if($){w($);return}}break}case"ArrowDown":{g.preventDefault(),C(y(m()),M,1);break}case"Home":{g.preventDefault(),S(m(),0);break}case"End":{g.preventDefault();let $=m();S($,$.length-1);break}case"Escape":{g.preventDefault(),f(),n.focus(),H&&H(!1);break}case"Enter":case" ":{if(g.preventDefault(),q(v)){let $=v.getAttribute("aria-controls");if($){w($);return}}v.click(),f(),H&&H(!1);break}case"Tab":{f(),c(n),H&&H(!1);break}default:break}}function k(g){let v=g.parentElement;for(;v&&v!==l;){if(v.getAttribute("role")==="menu"||v.id&&l.querySelector(`[aria-controls="${v.id}"]`))return!0;v=v.parentElement}return!1}function d(g){n.setAttribute("aria-expanded",g?"true":"false")}function w(g){let v=a.get(g);if(!v){let M=l.querySelector(`[aria-controls="${g}"]`);if(!M){console.error(`[aria-ease] Submenu trigger with aria-controls="${g}" not found in menu "${e}".`);return}if(!M.id){let P=`trigger-${g}`;M.id=P,console.warn(`[aria-ease] Submenu trigger for "${g}" had no ID. Auto-generated ID: "${P}".`)}if(!document.querySelector(`#${g}`)){console.error(`[aria-ease] Submenu element with id="${g}" not found. Cannot create submenu instance.`);return}v=se({menuId:g,menuItemsClass:t,triggerId:M.id,callback:s}),a.set(g,v)}v.openMenu()}function H(g){if(s?.onOpenChange)try{s.onOpenChange(g)}catch(v){console.error("[aria-ease] Error in menu onOpenChange callback:",v)}}function b(){m().forEach((v,M)=>{if(!r.has(v)){let $=P=>u(P,v,M);v.addEventListener("keydown",$),r.set(v,$)}})}function E(){m().forEach(v=>{let M=r.get(v);M&&(v.removeEventListener("keydown",M),r.delete(v))})}function x(){d(!0),l.style.display="block";let g=m();if(b(),g&&g.length>0&&g[0].focus(),s?.onOpenChange)try{s.onOpenChange(!0)}catch(v){console.error("[aria-ease] Error in menu onOpenChange callback:",v)}}function f(){if(a.forEach(g=>g.closeMenu()),d(!1),l.style.display="none",E(),n.focus(),s?.onOpenChange)try{s.onOpenChange(!1)}catch(g){console.error("[aria-ease] Error in menu onOpenChange callback:",g)}}function A(){n.getAttribute("aria-expanded")==="true"?f():x()}function T(g){if(!(n.getAttribute("aria-expanded")==="true"))return;let M=n.contains(g.target),$=l.contains(g.target);!M&&!$&&f()}n.addEventListener("click",A),document.addEventListener("click",T);function D(){E(),n.removeEventListener("click",A),document.removeEventListener("click",T),l.style.display="none",d(!1),a.forEach(g=>g.cleanup()),a.clear()}function I(){o=null,i=null}return{openMenu:x,closeMenu:f,cleanup:D,refresh:I}}function Xe({radioGroupId:e,radiosClass:t,defaultSelectedIndex:h,callback:s}){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 l=document.querySelector(`#${e}`);if(!l)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 n=Array.from(l.querySelectorAll(`.${t}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let r=new WeakMap,a=new WeakMap,o;h&&(o=h);function i(){l.getAttribute("role")||l.setAttribute("role","radiogroup"),n.forEach((c,u)=>{c.setAttribute("role","radio"),c.setAttribute("tabindex","0"),u===o?c.setAttribute("aria-checked","true"):c.setAttribute("aria-checked","false")})}function p(c){if(c<0||c>=n.length){console.error(`[aria-ease] Invalid radio index: ${c}`);return}if(o>=0&&o<n.length&&n[o].setAttribute("aria-checked","false"),n[c].setAttribute("aria-checked","true"),n[c].focus(),s?.onCheck)try{s.onCheck(c)}catch(u){console.error("[aria-ease] Error in radio onCheck callback:",u)}o=c}function m(c){return()=>{p(c)}}function y(c){return u=>{let{key:k}=u,d=c;switch(k){case"ArrowDown":case"ArrowRight":u.preventDefault(),d=(c+1)%n.length,p(d);break;case"ArrowUp":case"ArrowLeft":u.preventDefault(),d=(c-1+n.length)%n.length,p(d);break;case" ":case"Enter":u.preventDefault(),p(c);break}}}function L(){n.forEach((c,u)=>{let k=m(u),d=y(u);c.addEventListener("click",k),c.addEventListener("keydown",d),r.set(c,d),a.set(c,k)})}function C(){n.forEach(c=>{let u=r.get(c),k=a.get(c);u&&(c.removeEventListener("keydown",u),r.delete(c)),k&&(c.removeEventListener("click",k),a.delete(c))})}function S(){C()}function q(){return o}return i(),L(),{selectRadio:p,getSelectedIndex:q,cleanup:S}}function Qe({toggleId:e,togglesClass:t,isSingleToggle:h=!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 s=document.querySelector(`#${e}`);if(!s)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let l;if(h)l=[s];else{if(!t)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(l=Array.from(s.querySelectorAll(`.${t}`)),l.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let n=new WeakMap,r=new WeakMap;function a(){l.forEach(c=>{c.tagName.toLowerCase()!=="button"&&!c.getAttribute("role")&&c.setAttribute("role","button"),c.hasAttribute("aria-pressed")||c.setAttribute("aria-pressed","false"),c.hasAttribute("tabindex")||c.setAttribute("tabindex","0")})}function o(c){if(c<0||c>=l.length){console.error(`[aria-ease] Invalid toggle index: ${c}`);return}let u=l[c],k=u.getAttribute("aria-pressed")==="true";u.setAttribute("aria-pressed",k?"false":"true")}function i(c,u){if(c<0||c>=l.length){console.error(`[aria-ease] Invalid toggle index: ${c}`);return}l[c].setAttribute("aria-pressed",u?"true":"false")}function p(c){return()=>{o(c)}}function m(c){return u=>{let{key:k}=u;switch(k){case"Enter":case" ":u.preventDefault(),o(c);break}}}function y(){l.forEach((c,u)=>{let k=p(u),d=m(u);c.addEventListener("click",k),c.addEventListener("keydown",d),n.set(c,d),r.set(c,k)})}function L(){l.forEach(c=>{let u=n.get(c),k=r.get(c);u&&(c.removeEventListener("keydown",u),n.delete(c)),k&&(c.removeEventListener("click",k),r.delete(c))})}function C(){L()}function S(){return l.map(c=>c.getAttribute("aria-pressed")==="true")}function q(){return l.map((c,u)=>c.getAttribute("aria-pressed")==="true"?u:-1).filter(c=>c!==-1)}return a(),y(),{toggleButton:o,setPressed:i,getPressedStates:S,getPressedIndices:q,cleanup:C}}function Ze({comboboxInputId:e,comboboxButtonId:t,listBoxId:h,listBoxItemsClass:s,callback:l}){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 n=document.getElementById(`${e}`);if(!n)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(h==="")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 r=document.getElementById(`${h}`);if(!r)return console.error(`[aria-ease] Element with id="${h}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(s==="")return console.error("[aria-ease] 'listboxItemsClass' class should not be an empty string. Provide a class name to at least a listbox option that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};if(!document.querySelectorAll(s))return console.error(`[aria-ease] Listbox option(s) with class="${s}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let o=t?document.getElementById(`${t}`):null,i=-1;n.setAttribute("role","combobox"),n.setAttribute("aria-autocomplete","list"),n.setAttribute("aria-controls",h),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-haspopup","listbox"),r.setAttribute("role","listbox");let p=null;function m(){return p||(p=r.querySelectorAll(`.${s}`)),Array.from(p).filter(f=>!f.hidden&&f.style.display!=="none")}function y(){return n.getAttribute("aria-expanded")==="true"}function L(f){let A=m();if(f>=0&&f<A.length){let T=A[f],D=T.id||`${h}-option-${f}`;if(T.id||(T.id=D),n.setAttribute("aria-activedescendant",D),typeof T.scrollIntoView=="function"&&T.scrollIntoView({block:"nearest",behavior:"smooth"}),l?.onActiveDescendantChange)try{l.onActiveDescendantChange(D,T)}catch(I){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",I)}}else n.setAttribute("aria-activedescendant","");i=f}function C(){if(n.setAttribute("aria-expanded","true"),r.style.display="block",l?.onOpenChange)try{l.onOpenChange(!0)}catch(f){console.error("[aria-ease] Error in combobox onOpenChange callback:",f)}}function S(){if(n.setAttribute("aria-expanded","false"),n.setAttribute("aria-activedescendant",""),r.style.display="none",i=-1,l?.onOpenChange)try{l.onOpenChange(!1)}catch(f){console.error("[aria-ease] Error in combobox onOpenChange callback:",f)}}function q(f){let A=f.textContent?.trim()||"";if(n.value=A,f.setAttribute("aria-selected","true"),S(),l?.onSelect)try{l.onSelect(f)}catch(T){console.error("[aria-ease] Error in combobox onSelect callback:",T)}}function c(f){let A=m(),T=y();switch(f.key){case"ArrowDown":if(f.preventDefault(),!T){C();return}if(A.length===0)return;{let D=i>=A.length-1?0:i+1;L(D)}break;case"ArrowUp":if(f.preventDefault(),!T)return;if(A.length>0){let D=i<=0?A.length-1:i-1;L(D)}break;case"Enter":T&&i>=0&&i<A.length&&(f.preventDefault(),q(A[i]));break;case"Escape":if(T)f.preventDefault(),S();else if(n.value&&(f.preventDefault(),n.value="",n.setAttribute("aria-activedescendant",""),m().forEach(I=>{I.getAttribute("aria-selected")==="true"&&I.setAttribute("aria-selected","false")}),l?.onClear))try{l.onClear()}catch(I){console.error("[aria-ease] Error in combobox onClear callback:",I)}break;case"Home":T&&A.length>0&&(f.preventDefault(),L(0));break;case"End":T&&A.length>0&&(f.preventDefault(),L(A.length-1));break;case"Tab":T&&i>=0&&i<A.length&&q(A[i]),T&&S();break}}function u(f){let A=f.target;if(A.classList.contains(s)){let D=m().indexOf(A);D>=0&&L(D)}}function k(f){let A=f.target;A.classList.contains(s)&&(f.preventDefault(),q(A))}function d(f){let A=f.target;!n.contains(A)&&!r.contains(A)&&(!o||!o.contains(A))&&S()}function w(){y()?S():(C(),n.focus())}function H(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),w())}n.addEventListener("keydown",c),r.addEventListener("mousemove",u),r.addEventListener("mousedown",k),document.addEventListener("mousedown",d),o&&(o.setAttribute("tabindex","-1"),o.setAttribute("aria-label","Toggle options"),o.addEventListener("click",w),o.addEventListener("keydown",H));function b(){let f=r.querySelectorAll(`.${s}`);if(f.length===0)return;let A=null;for(let T of f)if(T.getAttribute("aria-selected")==="true"){A=T.textContent?.trim()||null;break}!A&&n.value&&(A=n.value.trim()),f.forEach((T,D)=>{T.setAttribute("role","option");let I=T.textContent?.trim()||"";A&&I===A?T.setAttribute("aria-selected","true"):T.setAttribute("aria-selected","false");let g=T.getAttribute("id");if(!g||g===""){let v=`${h}-option-${D}`;T.id=v,T.setAttribute("id",v)}})}b();function E(){n.removeEventListener("keydown",c),r.removeEventListener("mousemove",u),r.removeEventListener("mousedown",k),document.removeEventListener("mousedown",d),o&&(o.removeEventListener("click",w),o.removeEventListener("keydown",H))}function x(){p=null,b(),i=-1,L(-1)}return{cleanup:E,refresh:x,openListbox:C,closeListbox:S}}function tt({tabListId:e,tabsClass:t,tabPanelsClass:h,orientation:s="horizontal",activateOnFocus:l=!0,callback:n}){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 r=document.querySelector(`#${e}`);if(!r)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 a=Array.from(r.querySelectorAll(`.${t}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(h==="")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 o=Array.from(document.querySelectorAll(`.${h}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${h}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(a.length!==o.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${a.length} tabs but ${o.length} panels.`),{cleanup:()=>{}};let i=new WeakMap,p=new WeakMap,m=new WeakMap,y=0;function L(){r.setAttribute("role","tablist"),r.setAttribute("aria-orientation",s),a.forEach((b,E)=>{let x=o[E];b.id||(b.id=`${e}-tab-${E}`),x.id||(x.id=`${e}-panel-${E}`),b.setAttribute("role","tab"),b.setAttribute("aria-controls",x.id),b.setAttribute("aria-selected","false"),b.setAttribute("tabindex","-1"),x.setAttribute("role","tabpanel"),x.setAttribute("aria-labelledby",b.id),x.hidden=!0,x.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||x.setAttribute("tabindex","0")}),C(0,!1)}function C(b,E=!0){if(b<0||b>=a.length){console.error(`[aria-ease] Invalid tab index: ${b}`);return}let x=y;a.forEach((T,D)=>{let I=o[D];T.setAttribute("aria-selected","false"),T.setAttribute("tabindex","-1"),I.hidden=!0});let f=a[b],A=o[b];if(f.setAttribute("aria-selected","true"),f.setAttribute("tabindex","0"),A.hidden=!1,E&&f.focus(),y=b,n?.onTabChange&&x!==b)try{n.onTabChange(b,x)}catch(T){console.error("[aria-ease] Error in tabs onTabChange callback:",T)}}function S(b){let E=a.findIndex(A=>A===document.activeElement),x=E!==-1?E:y,f=x;switch(b){case"first":f=0;break;case"last":f=a.length-1;break;case"next":f=(x+1)%a.length;break;case"prev":f=(x-1+a.length)%a.length;break}if(a[f].focus(),a[f].setAttribute("tabindex","0"),a[y].setAttribute("tabindex","-1"),l)C(f,!1);else{let A=y;a.forEach((T,D)=>{D===f?T.setAttribute("tabindex","0"):D!==A&&T.setAttribute("tabindex","-1")})}}function q(b){return()=>{C(b)}}function c(b){return E=>{let{key:x}=E,f=!1;if(s==="horizontal")switch(x){case"ArrowLeft":E.preventDefault(),S("prev"),f=!0;break;case"ArrowRight":E.preventDefault(),S("next"),f=!0;break}else switch(x){case"ArrowUp":E.preventDefault(),S("prev"),f=!0;break;case"ArrowDown":E.preventDefault(),S("next"),f=!0;break}if(!f)switch(x){case"Home":E.preventDefault(),S("first");break;case"End":E.preventDefault(),S("last");break;case" ":case"Enter":l||(E.preventDefault(),C(b));break;case"F10":if(E.shiftKey&&n?.onContextMenu){E.preventDefault();try{n.onContextMenu(b,a[b])}catch(A){console.error("[aria-ease] Error in tabs onContextMenu callback:",A)}}break}}}function u(b){return E=>{if(n?.onContextMenu){E.preventDefault();try{n.onContextMenu(b,a[b])}catch(x){console.error("[aria-ease] Error in tabs onContextMenu callback:",x)}}}}function k(){a.forEach((b,E)=>{let x=q(E),f=c(E),A=u(E);b.addEventListener("click",x),b.addEventListener("keydown",f),n?.onContextMenu&&(b.addEventListener("contextmenu",A),m.set(b,A)),i.set(b,f),p.set(b,x)})}function d(){a.forEach(b=>{let E=i.get(b),x=p.get(b),f=m.get(b);E&&(b.removeEventListener("keydown",E),i.delete(b)),x&&(b.removeEventListener("click",x),p.delete(b)),f&&(b.removeEventListener("contextmenu",f),m.delete(b))})}function w(){d(),a.forEach((b,E)=>{let x=o[E];b.removeAttribute("role"),b.removeAttribute("aria-selected"),b.removeAttribute("aria-controls"),b.removeAttribute("tabindex"),x.removeAttribute("role"),x.removeAttribute("aria-labelledby"),x.removeAttribute("tabindex"),x.hidden=!1}),r.removeAttribute("role"),r.removeAttribute("aria-orientation")}function H(){d();let b=Array.from(r.querySelectorAll(`.${t}`)),E=Array.from(document.querySelectorAll(`.${h}`));a.length=0,a.push(...b),o.length=0,o.push(...E),L(),k()}return L(),k(),{activateTab:C,cleanup:w,refresh:H}}function R(e,t){return t==="first"?`first ${e}`:t==="last"?`last ${e}`:t==="next"?`next ${e}`:t==="previous"?`previous ${e}`:typeof t=="number"?`${e} at index ${t}`:`${t} ${e}`}var X={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:oe},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...ce(),...j()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:de},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:fe},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:be},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:ge},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>le(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ue},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:j},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>pe(e.relativeTarget)}};function oe(){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 ce(){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 le(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 relative item."}]}function ue(){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 pe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${R("option",e)} to have aria-selected='true'.`}]}function de(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function fe(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function be(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function ge(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var G={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:me},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:he},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ve},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ye},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ke(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:Ae},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Ee},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:Te},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:we},"submenuitem.focused":{requires:["submenupopup.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"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>xe(e.relativeTarget)}};function me(){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 he(){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 ve(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function ye(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function ke(e){return[{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function Ae(){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 Ee(){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 Te(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function we(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function xe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var Q={"tab.active":{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={})=>He(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Me(e.relativeTarget)}};function Me(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${R("tab",e)} to have focus.`}]}function Le(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${R("tab",e)} to have tabindex='0'.`}]}function He(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${R("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${R("tab",e)} to be visible.`},Le(e)]}var Y={"panel.expanded":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ce(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Se(e.relativeTarget)}};function Ce(e){return[{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected trigger to have aria-expanded='true' when panel expands."}]}function Se(e){return[{target:"panel",assertion:"notToBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger not to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected trigger to have aria-expanded='false' when panel collapses."}]}var Z={"radio.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>$e(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>De(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>qe(e.relativeTarget)}};function $e(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function De(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function qe(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${R("radio",e)} to have focus.`}]}var ee={"checkbox.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ie(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Re(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Pe(e.relativeTarget)}};function Ie(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function Re(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function Pe(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${R("checkbox",e)} to have focus.`}]}function Oe(e,t){return t.some(h=>e.capabilities.includes(h))}function B(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let h of e)if(Oe(t,h.when))return h.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var _e={combobox:X,menu:G,tabs:Q,accordion:Y,radio:Z,checkbox:ee},K=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},F=class{constructor(t){this.componentName=t;this.statePack=_e[t]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let h=this.statePack,s={capabilities:["keyboard"]},l=(r,a=new Set)=>{if(a.has(r))return[];a.add(r);let o=h[r];if(!o)return[];let i=[];if(Array.isArray(o.requires))for(let p of o.requires)i=i.concat(l(p,a));return o.setup&&(i=i.concat(B(o.setup,s))),i};return t({ariaReference:(r,a,o)=>({requires:i=>{let p=l(i,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:r,attribute:a,to:o,level:"required",setup:p}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:r,attribute:a,to:o,level:"optional",setup:p}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:r,attribute:a,to:o,level:"recommended",setup:p})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:r,attribute:a,to:o,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:r,attribute:a,to:o,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:r,attribute:a,to:o,level:"recommended"})}),contains:(r,a)=>({requires:o=>{let i=l(o,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:r,child:a,level:"required",setup:i}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:r,child:a,level:"optional",setup:i}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:r,child:a,level:"recommended",setup:i})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:r,child:a,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:r,child:a,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:r,child:a,level:"recommended"})})}),this}static(t){return t({target:s=>{let l=a=>{let o=this.statePack,i={capabilities:["keyboard"]},p=(m,y=new Set)=>{if(y.has(m))return[];y.add(m);let L=o[m];if(!L)return[];let C=[];if(Array.isArray(L.requires))for(let S of L.requires)C=C.concat(p(S,y));return L.setup&&(C=C.concat(B(L.setup,i))),C};return p(a,new Set)},n=a=>a==="role"?"toHaveRole":"toHaveAttribute",r=(a,o,i)=>{let p=n(a);return{required:()=>this.staticAssertions.push({target:s,assertion:p,attribute:a,expectedValue:o,failureMessage:"",level:"required",setup:i}),optional:()=>this.staticAssertions.push({target:s,assertion:p,attribute:a,expectedValue:o,failureMessage:"",level:"optional",setup:i}),recommended:()=>this.staticAssertions.push({target:s,assertion:p,attribute:a,expectedValue:o,failureMessage:"",level:"recommended",setup:i})}};return{has:(a,o)=>({...r(a,o),requires:p=>{let m=l(p);return r(a,o,m)}})}}}),this}when(t){return new U(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?this.staticAssertions:[],dynamic:this.dynamicTests}}},U=class{constructor(t,h,s){this.parent=t;this.statePack=h;this.event=s}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,h){return this._onTarget=t,this._onRelativeTarget=h,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(s=>typeof s=="string"?[s]:typeof s=="object"&&s!==null&&"type"in s&&"ref"in s?this._findStateKeyByTypeAndRef(s.type)?[{type:s.type,ref:s.ref}]:[]:[s])}_findStateKeyByTypeAndRef(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 s={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},l=(i,p=new Set)=>{if(p.has(i))return[];p.add(i);let m=this.statePack[i];if(!m)return[];let y=[];if(Array.isArray(m.requires))for(let L of m.requires)y=y.concat(l(L,p));return m.setup&&(y=y.concat(B(m.setup,s))),y},n=[];for(let i of this._given)if(typeof i=="string")n.push(...l(i));else if(typeof i=="object"&&i!==null&&"type"in i&&"ref"in i){let p=this._findStateKeyByTypeAndRef(i.type);if(p){let m=this.statePack[p];if(m&&m.setup)for(let y of m.setup)typeof y.steps=="function"?n.push(...y.steps({relativeTarget:i.ref})):Array.isArray(y.steps)&&n.push(...y.steps)}}let r=new Set;n=n.filter(i=>{let p=JSON.stringify(i);return r.has(p)?!1:(r.add(p),!0)});let a=[];for(let i of this._then)if(typeof i=="string"){let p=this.statePack[i];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 '${i}': ${y.message}`)}Array.isArray(m)?a.push(...m):a.push(m)}}else if(typeof i=="object"&&i!==null&&"type"in i&&"ref"in i){let p=this._findStateKeyByTypeAndRef(i.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:i.ref})}catch(L){throw new Error(`Error calling assertion function for state '${p}': ${L.message}`)}Array.isArray(y)?a.push(...y):a.push(y)}}}let o=[{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:o,assertions:a,...n.length?{setup:n}:{}})}};function Tt(e,t){let h=new F(e);return t(h),new K(h.build())}import Ve from"path";async function te(e,t,h={}){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 s={violations:[]};async function l(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 n=N(h.strictness),r={},a=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(r=m.config,m.configPath&&(a=Ve.dirname(m.configPath)),h.strictness===void 0){let y=r.test?.components?.find(L=>L?.name===e)?.strictness;n=N(y??r.test?.strictness)}}catch{h.strictness===void 0&&(n="balanced")}let o;try{if(t){let p=await l(t);if(p){console.log(`\u{1F3AD} Running Playwright tests on ${p}`);let{runContractTestsPlaywright:m}=await import("./contractTestRunnerPlaywright-75NI6SN7.js");o=await m(e,p,n,r,a)}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 i={violations:s.violations,raw:s,contract:o};if(o.failures.length>0&&t==="Playwright")throw new Error(`
3
+ \u274C ${o.failures.length} accessibility contract test${o.failures.length>1?"s":""} failed (Playwright mode)
4
+ \u2705 ${o.passes.length} test${o.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 p=i.violations.length,m=i.violations.map(y=>`
7
+ \u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(s.violations.length>0){let p=s.violations.length,m=s.violations.map(y=>`
8
8
  - ${y.id}: ${y.description}
9
9
  Impact: ${y.impact}
10
10
  Affected elements: ${y.nodes.length}
@@ -13,7 +13,7 @@ Please start your dev server and try again.`)}else throw new Error("\u274C URL i
13
13
  \u274C ${p} axe accessibility violation${p>1?"s":""} detected
14
14
  ${m}
15
15
 
16
- \u{1F4CB} Full details available in result.violations`)}return a}var Z=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(Z=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,s,n)=>{if(console.log(s),n&&console.error(n),!o||o.code===0){try{let{displayBadgeInfo:l,promptAddBadge:a}=await import("./badgeHelper-IB5RTMAG.js");l("component"),await a("component",process.cwd()),console.log(t.dim(`
16
+ \u{1F4CB} Full details available in result.violations`)}return i}var re=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(re=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((h,s)=>{e("npx vitest --run --reporter verbose",async(l,n,r)=>{if(console.log(n),r&&console.error(r),!l||l.code===0){try{let{displayBadgeInfo:o,promptAddBadge:i}=await import("./badgeHelper-IB5RTMAG.js");o("component"),await i("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(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 ee(){await U()}export{ee as cleanupTests,at as createContract,De as makeAccordionAccessible,Pe as makeBlockAccessible,Re as makeCheckboxAccessible,Ue as makeComboboxAccessible,re as makeMenuAccessible,Be as makeRadioAccessible,We as makeTabsAccessible,Ke as makeToggleAccessible,Y as testUiComponent};
19
+ `))}catch(o){console.error("Warning: Could not display badge prompt:",o)}h({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let o=l?.code||1;s(new Error(`Tests failed with code ${o}`)),process.exit(o)}})})});async function ne(){await z()}export{ne as cleanupTests,Tt as createContract,Be as makeAccordionAccessible,Ue as makeBlockAccessible,We as makeCheckboxAccessible,Ze as makeComboboxAccessible,se as makeMenuAccessible,Xe as makeRadioAccessible,tt as makeTabsAccessible,Qe as makeToggleAccessible,te as testUiComponent};
@@ -77,6 +77,27 @@ interface ComboboxCallback {
77
77
  onClear?: () => void;
78
78
  }
79
79
 
80
+ interface RadioConfig {
81
+ radioGroupId: string;
82
+ radiosClass: string;
83
+ defaultSelectedIndex?: number;
84
+ callback?: RadioCallback;
85
+ }
86
+
87
+ interface RadioCallback {
88
+ onCheck?: (index: number) => void;
89
+ }
90
+
91
+ interface CheckboxConfig {
92
+ checkboxGroupId: string;
93
+ checkboxesClass: string;
94
+ callback?: CheckboxCallback;
95
+ }
96
+
97
+ interface CheckboxCallback {
98
+ onCheck?: (index: number, checked: boolean) => void;
99
+ }
100
+
80
101
  interface MenuConfig {
81
102
  menuId: string;
82
103
  menuItemsClass: string;
@@ -88,4 +109,4 @@ interface MenuCallback {
88
109
  onOpenChange?: (isOpen: boolean) => void;
89
110
  }
90
111
 
91
- export type { AccordionConfig as A, ComboboxConfig as C, MenuConfig as M, TabsConfig as T, AccessibilityInstance as a };
112
+ export type { AccordionConfig as A, CheckboxConfig as C, MenuConfig as M, RadioConfig as R, TabsConfig as T, AccessibilityInstance as a, ComboboxConfig as b };
@@ -77,6 +77,27 @@ interface ComboboxCallback {
77
77
  onClear?: () => void;
78
78
  }
79
79
 
80
+ interface RadioConfig {
81
+ radioGroupId: string;
82
+ radiosClass: string;
83
+ defaultSelectedIndex?: number;
84
+ callback?: RadioCallback;
85
+ }
86
+
87
+ interface RadioCallback {
88
+ onCheck?: (index: number) => void;
89
+ }
90
+
91
+ interface CheckboxConfig {
92
+ checkboxGroupId: string;
93
+ checkboxesClass: string;
94
+ callback?: CheckboxCallback;
95
+ }
96
+
97
+ interface CheckboxCallback {
98
+ onCheck?: (index: number, checked: boolean) => void;
99
+ }
100
+
80
101
  interface MenuConfig {
81
102
  menuId: string;
82
103
  menuItemsClass: string;
@@ -88,4 +109,4 @@ interface MenuCallback {
88
109
  onOpenChange?: (isOpen: boolean) => void;
89
110
  }
90
111
 
91
- export type { AccordionConfig as A, ComboboxConfig as C, MenuConfig as M, TabsConfig as T, AccessibilityInstance as a };
112
+ export type { AccordionConfig as A, CheckboxConfig as C, MenuConfig as M, RadioConfig as R, TabsConfig as T, AccessibilityInstance as a, ComboboxConfig as b };
@@ -1,4 +1,4 @@
1
- import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
1
+ import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.cjs';
2
2
 
3
3
  /**
4
4
  * Makes an accordion accessible by managing ARIA attributes, keyboard interaction, and state.
@@ -1,4 +1,4 @@
1
- import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
1
+ import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.js';
2
2
 
3
3
  /**
4
4
  * Makes an accordion accessible by managing ARIA attributes, keyboard interaction, and state.
@@ -1,4 +1,4 @@
1
- import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
1
+ import { a as AccessibilityInstance } from '../Types.d-D96FYkCN.cjs';
2
2
 
3
3
  /**
4
4
  * Adds keyboard interaction to block. The block traps focus and can be interacted with using the keyboard.
@@ -1,4 +1,4 @@
1
- import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
1
+ import { a as AccessibilityInstance } from '../Types.d-D96FYkCN.js';
2
2
 
3
3
  /**
4
4
  * Adds keyboard interaction to block. The block traps focus and can be interacted with using the keyboard.
@@ -1 +1 @@
1
- 'use strict';function C({checkboxGroupId:o,checkboxesClass:i}){if(o==="")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 a=document.querySelector(`#${o}`);if(!a)return console.error(`[aria-ease] Element with id="${o}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(i==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let n=Array.from(a.querySelectorAll(`.${i}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let c=new WeakMap,s=new WeakMap;function b(){a.getAttribute("role")||a.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function l(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true");}function d(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false");}function f(e){return ()=>{l(e);}}function h(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),l(e);break}}}function k(){n.forEach((e,t)=>{let r=f(t),u=h(t);e.addEventListener("click",r),e.addEventListener("keydown",u),c.set(e,u),s.set(e,r);});}function m(){n.forEach(e=>{let t=c.get(e),r=s.get(e);t&&(e.removeEventListener("keydown",t),c.delete(e)),r&&(e.removeEventListener("click",r),s.delete(e));});}function g(){m();}function p(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function A(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return b(),k(),{toggleCheckbox:l,setCheckboxState:d,getCheckedStates:p,getCheckedIndices:A,cleanup:g}}exports.makeCheckboxAccessible=C;
1
+ 'use strict';function v({checkboxGroupId:a,checkboxesClass:c,callback:u}){if(a==="")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 o=document.querySelector(`#${a}`);if(!o)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(c==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let n=Array.from(o.querySelectorAll(`.${c}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${c}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let i=new WeakMap,s=new WeakMap;function h(){o.getAttribute("role")||o.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function b(e,t){if(u?.onCheck)try{u.onCheck(e,t);}catch(r){console.error("[aria-ease] Error in checkbox onCheck callback:",r);}}function l(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true"),b(e,r);}function k(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false"),b(e,t);}function d(e){return ()=>{l(e);}}function m(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),l(e);break}}}function g(){n.forEach((e,t)=>{let r=d(t),f=m(t);e.addEventListener("click",r),e.addEventListener("keydown",f),i.set(e,f),s.set(e,r);});}function A(){n.forEach(e=>{let t=i.get(e),r=s.get(e);t&&(e.removeEventListener("keydown",t),i.delete(e)),r&&(e.removeEventListener("click",r),s.delete(e));});}function p(){A();}function C(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function E(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return h(),g(),{toggleCheckbox:l,setCheckboxState:k,getCheckedStates:C,getCheckedIndices:E,cleanup:p}}exports.makeCheckboxAccessible=v;
@@ -1,4 +1,4 @@
1
- import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
1
+ import { C as CheckboxConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.cjs';
2
2
 
3
3
  /**
4
4
  * Makes a checkbox group accessible by managing ARIA attributes and keyboard interaction.
@@ -7,10 +7,6 @@ import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
7
7
  * @param {string} checkboxesClass - The shared class of all checkboxes.
8
8
  */
9
9
 
10
- interface CheckboxConfig {
11
- checkboxGroupId: string;
12
- checkboxesClass: string;
13
- }
14
- declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }: CheckboxConfig): AccessibilityInstance;
10
+ declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass, callback }: CheckboxConfig): AccessibilityInstance;
15
11
 
16
12
  export { makeCheckboxAccessible };
@@ -1,4 +1,4 @@
1
- import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
1
+ import { C as CheckboxConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.js';
2
2
 
3
3
  /**
4
4
  * Makes a checkbox group accessible by managing ARIA attributes and keyboard interaction.
@@ -7,10 +7,6 @@ import { a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
7
7
  * @param {string} checkboxesClass - The shared class of all checkboxes.
8
8
  */
9
9
 
10
- interface CheckboxConfig {
11
- checkboxGroupId: string;
12
- checkboxesClass: string;
13
- }
14
- declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass }: CheckboxConfig): AccessibilityInstance;
10
+ declare function makeCheckboxAccessible({ checkboxGroupId, checkboxesClass, callback }: CheckboxConfig): AccessibilityInstance;
15
11
 
16
12
  export { makeCheckboxAccessible };
@@ -1 +1 @@
1
- function C({checkboxGroupId:o,checkboxesClass:i}){if(o==="")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 a=document.querySelector(`#${o}`);if(!a)return console.error(`[aria-ease] Element with id="${o}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(i==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let n=Array.from(a.querySelectorAll(`.${i}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${i}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let c=new WeakMap,s=new WeakMap;function b(){a.getAttribute("role")||a.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function l(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true");}function d(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false");}function f(e){return ()=>{l(e);}}function h(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),l(e);break}}}function k(){n.forEach((e,t)=>{let r=f(t),u=h(t);e.addEventListener("click",r),e.addEventListener("keydown",u),c.set(e,u),s.set(e,r);});}function m(){n.forEach(e=>{let t=c.get(e),r=s.get(e);t&&(e.removeEventListener("keydown",t),c.delete(e)),r&&(e.removeEventListener("click",r),s.delete(e));});}function g(){m();}function p(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function A(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return b(),k(),{toggleCheckbox:l,setCheckboxState:d,getCheckedStates:p,getCheckedIndices:A,cleanup:g}}export{C as makeCheckboxAccessible};
1
+ function v({checkboxGroupId:a,checkboxesClass:c,callback:u}){if(a==="")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 o=document.querySelector(`#${a}`);if(!o)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(c==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let n=Array.from(o.querySelectorAll(`.${c}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${c}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let i=new WeakMap,s=new WeakMap;function h(){o.getAttribute("role")||o.setAttribute("role","group"),n.forEach(e=>{e.setAttribute("role","checkbox"),e.hasAttribute("aria-checked")||e.setAttribute("aria-checked","false"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");});}function b(e,t){if(u?.onCheck)try{u.onCheck(e,t);}catch(r){console.error("[aria-ease] Error in checkbox onCheck callback:",r);}}function l(e){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}let t=n[e],r=t.getAttribute("aria-checked")==="true";t.setAttribute("aria-checked",r?"false":"true"),b(e,r);}function k(e,t){if(e<0||e>=n.length){console.error(`[aria-ease] Invalid checkbox index: ${e}`);return}n[e].setAttribute("aria-checked",t?"true":"false"),b(e,t);}function d(e){return ()=>{l(e);}}function m(e){return t=>{let{key:r}=t;switch(r){case " ":t.preventDefault(),l(e);break}}}function g(){n.forEach((e,t)=>{let r=d(t),f=m(t);e.addEventListener("click",r),e.addEventListener("keydown",f),i.set(e,f),s.set(e,r);});}function A(){n.forEach(e=>{let t=i.get(e),r=s.get(e);t&&(e.removeEventListener("keydown",t),i.delete(e)),r&&(e.removeEventListener("click",r),s.delete(e));});}function p(){A();}function C(){return n.map(e=>e.getAttribute("aria-checked")==="true")}function E(){return n.map((e,t)=>e.getAttribute("aria-checked")==="true"?t:-1).filter(e=>e!==-1)}return h(),g(),{toggleCheckbox:l,setCheckboxState:k,getCheckedStates:C,getCheckedIndices:E,cleanup:p}}export{v as makeCheckboxAccessible};
@@ -1,4 +1,4 @@
1
- import { C as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
1
+ import { b as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.cjs';
2
2
 
3
3
  /**
4
4
  * Makes a Combobox accessible by adding appropriate ARIA attributes, keyboard interactions and focus management.
@@ -1,4 +1,4 @@
1
- import { C as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
1
+ import { b as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.js';
2
2
 
3
3
  /**
4
4
  * Makes a Combobox accessible by adding appropriate ARIA attributes, keyboard interactions and focus management.
@@ -1,4 +1,4 @@
1
- import { M as MenuConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
1
+ import { M as MenuConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.cjs';
2
2
 
3
3
  /**
4
4
  * Adds keyboard interaction to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first interactive item of the menu has focus when menu open.
@@ -1,4 +1,4 @@
1
- import { M as MenuConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
1
+ import { M as MenuConfig, a as AccessibilityInstance } from '../Types.d-D96FYkCN.js';
2
2
 
3
3
  /**
4
4
  * Adds keyboard interaction to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first interactive item of the menu has focus when menu open.