aria-ease 7.8.0 → 7.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -277,11 +277,6 @@ type DynamicAssertion = {
277
277
  level?: Level;
278
278
  };
279
279
  type DynamicAction = {
280
- type: "focus";
281
- target: string;
282
- relativeTarget?: "first" | "last" | "next" | "previous" | number;
283
- virtualId?: string;
284
- } | {
285
280
  type: "click" | "keypress" | "type" | "hover" | "focus";
286
281
  target: string;
287
282
  key?: string;
package/dist/index.d.ts CHANGED
@@ -277,11 +277,6 @@ type DynamicAssertion = {
277
277
  level?: Level;
278
278
  };
279
279
  type DynamicAction = {
280
- type: "focus";
281
- target: string;
282
- relativeTarget?: "first" | "last" | "next" | "previous" | number;
283
- virtualId?: string;
284
- } | {
285
280
  type: "click" | "keypress" | "type" | "hover" | "focus";
286
281
  target: string;
287
282
  key?: string;
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import{b as z,d as N}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function Ue({accordionId:e,triggersClass:t,panelsClass:h,allowMultipleOpen:l=!1,callback:p}){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 a=Array.from(n.querySelectorAll(`.${t}`));if(a.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 o=Array.from(n.querySelectorAll(`.${h}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${h}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(a.length!==o.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${a.length} triggers but ${o.length} panels.`),{cleanup:()=>{}};let c=new WeakMap,s=new WeakMap;function u(){a.forEach((i,E)=>{let H=o[E];i.id||(i.id=`${e}-trigger-${E}`),H.id||(H.id=`${e}-panel-${E}`),i.setAttribute("aria-controls",H.id),i.setAttribute("aria-expanded","false"),(!l||a.length<=6)&&H.setAttribute("role","region"),H.setAttribute("aria-labelledby",i.id),H.style.display="none"})}function b(i){if(i<0||i>=a.length){console.error(`[aria-ease] Invalid accordion index: ${i}`);return}let E=a[i],H=o[i];if(E.setAttribute("aria-expanded","true"),H.style.display="block",p?.onExpandedChange)try{p.onExpandedChange(i,!0)}catch(f){console.error("[aria-ease] Error in accordion onExpandedChange callback:",f)}}function y(i){if(i<0||i>=a.length){console.error(`[aria-ease] Invalid accordion index: ${i}`);return}let E=a[i],H=o[i];if(E.setAttribute("aria-expanded","false"),H.style.display="none",p?.onExpandedChange)try{p.onExpandedChange(i,!1)}catch(f){console.error("[aria-ease] Error in accordion onExpandedChange callback:",f)}}function L(i){a[i].getAttribute("aria-expanded")==="true"?y(i):(l||a.forEach((f,T)=>{T!==i&&y(T)}),b(i))}function C(i){return()=>{L(i)}}function S(i){return E=>{let{key:H}=E;switch(H){case"Enter":case" ":E.preventDefault(),L(i);break;case"ArrowDown":E.preventDefault();{let f=(i+1)%a.length;a[f].focus()}break;case"ArrowUp":E.preventDefault();{let f=(i-1+a.length)%a.length;a[f].focus()}break;case"Home":E.preventDefault(),a[0].focus();break;case"End":E.preventDefault(),a[a.length-1].focus();break}}}function I(){a.forEach((i,E)=>{let H=C(E),f=S(E);i.addEventListener("click",H),i.addEventListener("keydown",f),c.set(i,f),s.set(i,H)})}function k(){a.forEach(i=>{let E=c.get(i),H=s.get(i);E&&(i.removeEventListener("keydown",E),c.delete(i)),H&&(i.removeEventListener("click",H),s.delete(i))})}function r(){k(),a.forEach((i,E)=>{y(E)})}function m(){k();let i=Array.from(n.querySelectorAll(`.${t}`)),E=Array.from(n.querySelectorAll(`.${h}`));a.length=0,a.push(...i),o.length=0,o.push(...E),u(),I()}return u(),I(),{expandItem:b,collapseItem:y,toggleItem:L,cleanup:r,refresh:m}}function _(e){if(e.tagName!=="INPUT")return!1;let t=e.type;return["text","email","password","tel","number"].includes(t)}function V(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 O(e,t,h){let l=e.length,p=(t+h+l)%l;e.item(p).focus()}function se(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function J(e,t,h){let l=t.item(h);switch(e.key){case"ArrowUp":case"ArrowLeft":{(!_(l)&&!V(l)||(_(l)||V(l))&&l.selectionStart===0)&&(e.preventDefault(),O(t,h,-1));break}case"ArrowDown":case"ArrowRight":{if(!_(l)&&!V(l))e.preventDefault(),O(t,h,1);else if(_(l)||V(l)){let p=l.value;l.selectionStart===p.length&&(e.preventDefault(),O(t,h,1))}break}case"Escape":{e.preventDefault();break}case"Enter":case" ":{(!W(l)&&!ie(l)&&se(l)||W(l))&&(e.preventDefault(),l.click());break}case"Tab":break;default:break}}function je({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 l=null;function p(){return l||(l=h.querySelectorAll(`.${t}`)),l}let n=p();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 a=new Map;n.forEach(s=>{if(!a.has(s)){let u=b=>{let y=h.querySelectorAll(`.${t}`),L=Array.prototype.indexOf.call(y,s);J(b,y,L)};s.addEventListener("keydown",u),a.set(s,u)}});function o(){n.forEach(s=>{let u=a.get(s);u&&(s.removeEventListener("keydown",u),a.delete(s))})}function c(){l=null}return{cleanup:o,refresh:c}}function Xe({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 l=document.querySelector(`#${e}`);if(!l)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 p=Array.from(l.querySelectorAll(`.${t}`));if(p.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,a=new WeakMap;function o(){l.getAttribute("role")||l.setAttribute("role","group"),p.forEach(r=>{r.setAttribute("role","checkbox");let m=r.checked;r.setAttribute("aria-checked",m?"true":"false"),r.hasAttribute("tabindex")||r.setAttribute("tabindex","0")})}function c(r,m){if(h?.onCheckedChange)try{h.onCheckedChange(r,m)}catch(i){console.error("[aria-ease] Error in checkbox onCheckedChange callback:",i)}}function s(r){if(r<0||r>=p.length){console.error(`[aria-ease] Invalid checkbox index: ${r}`);return}let m=p[r],i=!m.checked;m.checked=i,m.setAttribute("aria-checked",i?"true":"false"),c(r,i)}function u(r,m){if(r<0||r>=p.length){console.error(`[aria-ease] Invalid checkbox index: ${r}`);return}let i=p[r];i.checked=m,i.setAttribute("aria-checked",m?"true":"false"),c(r,m)}function b(r){return()=>{let m=p[r];if("checked"in m&&typeof m.checked=="boolean")setTimeout(()=>{let i=m.checked;m.setAttribute("aria-checked",i?"true":"false"),c(r,i)},0);else{let i=m.getAttribute("aria-checked")==="true";m.setAttribute("aria-checked",i?"false":"true"),c(r,!i)}}}function y(r){return m=>{let{key:i}=m;switch(i){case" ":case"Spacebar":m.preventDefault(),s(r);break}}}function L(){p.forEach((r,m)=>{let i=b(m),E=y(m);r.addEventListener("click",i),r.addEventListener("keydown",E),n.set(r,E),a.set(r,i)})}function C(){p.forEach(r=>{let m=n.get(r),i=a.get(r);m&&(r.removeEventListener("keydown",m),n.delete(r)),i&&(r.removeEventListener("click",i),a.delete(r))})}function S(){C()}function I(){return p.map(r=>r.getAttribute("aria-checked")==="true")}function k(){return p.map((r,m)=>r.getAttribute("aria-checked")==="true"?m:-1).filter(r=>r!==-1)}return o(),L(),{toggleCheckbox:s,setCheckboxState:u,getCheckedStates:I,getCheckedIndices:k,cleanup:S}}function oe({menuId:e,menuItemsClass:t,triggerId:h,callback:l}){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 p=document.querySelector(`#${e}`);if(!p)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"),p.setAttribute("role","menu"),p.setAttribute("aria-labelledby",h);let a=new WeakMap,o=new Map,c=null,s=null;function u(){return c||(c=p.querySelectorAll(`.${t}`)),c}function b(){if(!s){let g=u();s=[];for(let v=0;v<g.length;v++){let w=g.item(v),$=m(w),R=w.getAttribute("aria-disabled")==="true";$||(w.hasAttribute("tabindex")||w.setAttribute("tabindex","-1"),R||s.push(w))}}return s}function y(g){return{length:g.length,item:w=>g[w],forEach:w=>{g.forEach(w)},[Symbol.iterator]:function*(){for(let w of g)yield w}}}function L(){u().forEach(v=>{v.setAttribute("role","menuitem");let w=v.getAttribute("data-submenu-id")??v.getAttribute("aria-controls"),$=v.hasAttribute("aria-haspopup")&&w;w&&(v.hasAttribute("data-submenu-id")||$)&&(v.setAttribute("aria-haspopup","menu"),v.setAttribute("aria-controls",w),v.hasAttribute("aria-expanded")||v.setAttribute("aria-expanded","false"))})}function C(g,v,w){let $=g.length,R=(v+w+$)%$;g.item(R).focus()}function S(g,v){g.length!==0&&g[v]?.focus()}function I(g){return g.hasAttribute("aria-controls")&&g.hasAttribute("aria-haspopup")&&g.getAttribute("role")==="menuitem"}function k(g){let v=g;for(;v&&v.getAttribute("role")==="menuitem";){let w=v.closest('[role="menu"]');if(!w)break;w.style.display="none",v.setAttribute("aria-expanded","false");let $=w.getAttribute("aria-labelledby");if(!$)break;let R=document.getElementById($);if(!R)break;v=R}}L();function r(g,v,w){switch(g.key){case"ArrowLeft":{if(g.key==="ArrowLeft"&&n.getAttribute("role")==="menuitem"){g.preventDefault(),d();return}break}case"ArrowUp":{g.preventDefault(),C(y(b()),w,-1);break}case"ArrowRight":{if(g.key==="ArrowRight"&&I(v)){g.preventDefault();let $=v.getAttribute("aria-controls");if($){E($);return}}break}case"ArrowDown":{g.preventDefault(),C(y(b()),w,1);break}case"Home":{g.preventDefault(),S(b(),0);break}case"End":{g.preventDefault();let $=b();S($,$.length-1);break}case"Escape":{g.preventDefault(),d(),n.focus(),H&&H(!1);break}case"Enter":case" ":{if(g.preventDefault(),I(v)){let $=v.getAttribute("aria-controls");if($){E($);return}}v.click(),d(),H&&H(!1);break}case"Tab":{d(),k(n),H&&H(!1);break}default:break}}function m(g){let v=g.parentElement;for(;v&&v!==p;){if(v.getAttribute("role")==="menu"||v.id&&p.querySelector(`[aria-controls="${v.id}"]`))return!0;v=v.parentElement}return!1}function i(g){n.setAttribute("aria-expanded",g?"true":"false")}function E(g){let v=o.get(g);if(!v){let w=p.querySelector(`[aria-controls="${g}"]`);if(!w){console.error(`[aria-ease] Submenu trigger with aria-controls="${g}" not found in menu "${e}".`);return}if(!w.id){let R=`trigger-${g}`;w.id=R,console.warn(`[aria-ease] Submenu trigger for "${g}" had no ID. Auto-generated ID: "${R}".`)}if(!document.querySelector(`#${g}`)){console.error(`[aria-ease] Submenu element with id="${g}" not found. Cannot create submenu instance.`);return}v=oe({menuId:g,menuItemsClass:t,triggerId:w.id,callback:l}),o.set(g,v)}v.openMenu()}function H(g){if(l?.onExpandedChange)try{l.onExpandedChange(g)}catch(v){console.error("[aria-ease] Error in menu onExpandedChange callback:",v)}}function f(){b().forEach((v,w)=>{if(!a.has(v)){let $=R=>r(R,v,w);v.addEventListener("keydown",$),a.set(v,$)}})}function T(){b().forEach(v=>{let w=a.get(v);w&&(v.removeEventListener("keydown",w),a.delete(v))})}function x(){i(!0),p.style.display="block";let g=b();if(f(),g&&g.length>0&&g[0].focus(),l?.onExpandedChange)try{l.onExpandedChange(!0)}catch(v){console.error("[aria-ease] Error in menu onExpandedChange callback:",v)}}function d(){if(o.forEach(g=>g.closeMenu()),i(!1),p.style.display="none",T(),n.focus(),l?.onExpandedChange)try{l.onExpandedChange(!1)}catch(g){console.error("[aria-ease] Error in menu onExpandedChange callback:",g)}}function A(){n.getAttribute("aria-expanded")==="true"?d():x()}function M(g){if(!(n.getAttribute("aria-expanded")==="true"))return;let w=n.contains(g.target),$=p.contains(g.target);!w&&!$&&d()}n.addEventListener("click",A),document.addEventListener("click",M);function D(){T(),n.removeEventListener("click",A),document.removeEventListener("click",M),p.style.display="none",i(!1),o.forEach(g=>g.cleanup()),o.clear()}function P(){c=null,s=null}return{openMenu:x,closeMenu:d,cleanup:D,refresh:P}}function Ze({radioGroupId:e,radiosClass:t,defaultSelectedIndex:h,callback:l}){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 p=document.querySelector(`#${e}`);if(!p)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(p.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 a=new WeakMap,o=new WeakMap,c;h&&(c=h);function s(){p.getAttribute("role")||p.setAttribute("role","radiogroup"),n.forEach((k,r)=>{k.setAttribute("role","radio"),k.setAttribute("tabindex","0");let m=r===c;k.setAttribute("aria-checked",m?"true":"false"),k.checked!==void 0&&(k.checked=m)})}function u(k){if(k<0||k>=n.length){console.error(`[aria-ease] Invalid radio index: ${k}`);return}if(c>=0&&c<n.length&&(n[c].setAttribute("aria-checked","false"),n[c].checked!==void 0&&(n[c].checked=!1)),n[k].setAttribute("aria-checked","true"),n[k].checked!==void 0&&(n[k].checked=!0),n[k].focus(),l?.onValueChange)try{l.onValueChange(k,n[k].getAttribute("value"))}catch(r){console.error("[aria-ease] Error in radio onValueChange callback:",r)}c=k}function b(k){return()=>{let r=n[k];"checked"in r&&typeof r.checked=="boolean"?setTimeout(()=>{u(k)},0):u(k)}}function y(k){return r=>{let{key:m}=r,i=k;switch(m){case"ArrowDown":case"ArrowRight":r.preventDefault(),i=(k+1)%n.length,u(i);break;case"ArrowUp":case"ArrowLeft":r.preventDefault(),i=(k-1+n.length)%n.length,u(i);break;case" ":case"Enter":r.preventDefault(),u(k);break}}}function L(){n.forEach((k,r)=>{let m=b(r),i=y(r);k.addEventListener("click",m),k.addEventListener("keydown",i),a.set(k,i),o.set(k,m)})}function C(){n.forEach(k=>{let r=a.get(k),m=o.get(k);r&&(k.removeEventListener("keydown",r),a.delete(k)),m&&(k.removeEventListener("click",m),o.delete(k))})}function S(){C()}function I(){return c}return s(),L(),{selectRadio:u,getSelectedIndex:I,cleanup:S}}function tt({toggleId:e,togglesClass:t,isSingleToggle:h=!0,callback:l}){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 p=document.querySelector(`#${e}`);if(!p)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let n;if(h)n=[p];else{if(!t)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(n=Array.from(p.querySelectorAll(`.${t}`)),n.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let a=new WeakMap,o=new WeakMap;function c(){n.forEach(r=>{r.tagName.toLowerCase()!=="button"&&!r.getAttribute("role")&&r.setAttribute("role","button"),r.hasAttribute("aria-pressed")||r.setAttribute("aria-pressed","false"),r.hasAttribute("tabindex")||r.setAttribute("tabindex","0")})}function s(r){if(r<0||r>=n.length){console.error(`[aria-ease] Invalid toggle index: ${r}`);return}let i=n[r].getAttribute("aria-pressed")==="true";u(r,!i)}function u(r,m){if(r<0||r>=n.length){console.error(`[aria-ease] Invalid toggle index: ${r}`);return}if(n[r].setAttribute("aria-pressed",m?"true":"false"),l?.onPressedChange)try{l.onPressedChange(r,m)}catch(i){console.error("[aria-ease] Error in checkbox onPressedChange callback:",i)}}function b(r){return()=>{s(r)}}function y(r){return m=>{let{key:i}=m;switch(i){case"Enter":case" ":m.preventDefault(),s(r);break}}}function L(){n.forEach((r,m)=>{let i=b(m),E=y(m);r.addEventListener("click",i),r.addEventListener("keydown",E),a.set(r,E),o.set(r,i)})}function C(){n.forEach(r=>{let m=a.get(r),i=o.get(r);m&&(r.removeEventListener("keydown",m),a.delete(r)),i&&(r.removeEventListener("click",i),o.delete(r))})}function S(){C()}function I(){return n.map(r=>r.getAttribute("aria-pressed")==="true")}function k(){return n.map((r,m)=>r.getAttribute("aria-pressed")==="true"?m:-1).filter(r=>r!==-1)}return c(),L(),{toggleButton:s,setPressed:u,getPressedStates:I,getPressedIndices:k,cleanup:S}}function nt({comboboxInputId:e,comboboxButtonId:t,listBoxId:h,listBoxItemsClass:l,callback:p}){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 a=document.getElementById(`${h}`);if(!a)return console.error(`[aria-ease] Element with id="${h}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(l==="")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(l))return console.error(`[aria-ease] Listbox option(s) with class="${l}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let c=t?document.getElementById(`${t}`):null,s=-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"),a.setAttribute("role","listbox");let u=null;function b(){return u||(u=a.querySelectorAll(`.${l}`)),Array.from(u).filter(d=>!d.hidden&&d.style.display!=="none")}function y(){return n.getAttribute("aria-expanded")==="true"}function L(d){let A=b();if(d>=0&&d<A.length){let M=A[d],D=M.id||`${h}-option-${d}`;if(M.id||(M.id=D),n.setAttribute("aria-activedescendant",D),typeof M.scrollIntoView=="function"&&M.scrollIntoView({block:"nearest",behavior:"smooth"}),p?.onActiveDescendantChange)try{p.onActiveDescendantChange(D,M)}catch(P){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",P)}}else n.setAttribute("aria-activedescendant","");s=d}function C(){if(n.setAttribute("aria-expanded","true"),a.style.display="block",p?.onExpandedChange)try{p.onExpandedChange(!0)}catch(d){console.error("[aria-ease] Error in combobox onExpandedChange callback:",d)}}function S(){if(n.setAttribute("aria-expanded","false"),n.setAttribute("aria-activedescendant",""),a.style.display="none",s=-1,p?.onExpandedChange)try{p.onExpandedChange(!1)}catch(d){console.error("[aria-ease] Error in combobox onExpandedChange callback:",d)}}function I(d){let A=d.textContent?.trim()||"";if(n.value=A,d.setAttribute("aria-selected","true"),S(),p?.onSelect)try{p.onSelect(d)}catch(M){console.error("[aria-ease] Error in combobox onSelect callback:",M)}}function k(d){let A=b(),M=y();switch(d.key){case"ArrowDown":if(d.preventDefault(),!M){C();return}if(A.length===0)return;{let D=s>=A.length-1?0:s+1;L(D)}break;case"ArrowUp":if(d.preventDefault(),!M)return;if(A.length>0){let D=s<=0?A.length-1:s-1;L(D)}break;case"Enter":M&&s>=0&&s<A.length&&(d.preventDefault(),I(A[s]));break;case"Escape":if(M)d.preventDefault(),S();else if(n.value&&(d.preventDefault(),n.value="",n.setAttribute("aria-activedescendant",""),b().forEach(P=>{P.getAttribute("aria-selected")==="true"&&P.setAttribute("aria-selected","false")}),p?.onClear))try{p.onClear()}catch(P){console.error("[aria-ease] Error in combobox onClear callback:",P)}break;case"Home":M&&A.length>0&&(d.preventDefault(),L(0));break;case"End":M&&A.length>0&&(d.preventDefault(),L(A.length-1));break;case"Tab":M&&s>=0&&s<A.length&&I(A[s]),M&&S();break}}function r(d){let A=d.target;if(A.classList.contains(l)){let D=b().indexOf(A);D>=0&&L(D)}}function m(d){let A=d.target;A.classList.contains(l)&&(d.preventDefault(),I(A))}function i(d){let A=d.target;!n.contains(A)&&!a.contains(A)&&(!c||!c.contains(A))&&S()}function E(){y()?S():(C(),n.focus())}function H(d){(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),E())}n.addEventListener("keydown",k),a.addEventListener("mousemove",r),a.addEventListener("mousedown",m),document.addEventListener("mousedown",i),c&&(c.setAttribute("tabindex","-1"),c.setAttribute("aria-label","Toggle options"),c.addEventListener("click",E),c.addEventListener("keydown",H));function f(){let d=a.querySelectorAll(`.${l}`);if(d.length===0)return;let A=null;for(let M of d)if(M.getAttribute("aria-selected")==="true"){A=M.textContent?.trim()||null;break}!A&&n.value&&(A=n.value.trim()),d.forEach((M,D)=>{M.setAttribute("role","option");let P=M.textContent?.trim()||"";A&&P===A?M.setAttribute("aria-selected","true"):M.setAttribute("aria-selected","false");let g=M.getAttribute("id");if(!g||g===""){let v=`${h}-option-${D}`;M.id=v,M.setAttribute("id",v)}})}f();function T(){n.removeEventListener("keydown",k),a.removeEventListener("mousemove",r),a.removeEventListener("mousedown",m),document.removeEventListener("mousedown",i),c&&(c.removeEventListener("click",E),c.removeEventListener("keydown",H))}function x(){u=null,f(),s=-1,L(-1)}return{cleanup:T,refresh:x,openListbox:C,closeListbox:S}}function it({tabListId:e,tabsClass:t,tabPanelsClass:h,orientation:l="horizontal",activateOnFocus:p=!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 a=document.querySelector(`#${e}`);if(!a)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 o=Array.from(a.querySelectorAll(`.${t}`));if(o.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 c=Array.from(document.querySelectorAll(`.${h}`));if(c.length===0)return console.error(`[aria-ease] No elements with class="${h}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(o.length!==c.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${o.length} tabs but ${c.length} panels.`),{cleanup:()=>{}};let s=new WeakMap,u=new WeakMap,b=new WeakMap,y=0;function L(){a.setAttribute("role","tablist"),a.setAttribute("aria-orientation",l),o.forEach((f,T)=>{let x=c[T];f.id||(f.id=`${e}-tab-${T}`),x.id||(x.id=`${e}-panel-${T}`),f.setAttribute("role","tab"),f.setAttribute("aria-controls",x.id),f.setAttribute("aria-selected","false"),f.setAttribute("tabindex","-1"),x.setAttribute("role","tabpanel"),x.setAttribute("aria-labelledby",f.id),x.hidden=!0,x.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||x.setAttribute("tabindex","0")}),C(0,!1)}function C(f,T=!0){if(f<0||f>=o.length){console.error(`[aria-ease] Invalid tab index: ${f}`);return}o.forEach((A,M)=>{let D=c[M];A.setAttribute("aria-selected","false"),A.setAttribute("tabindex","-1"),D.hidden=!0});let x=o[f],d=c[f];if(x.setAttribute("aria-selected","true"),x.setAttribute("tabindex","0"),d.hidden=!1,T&&x.focus(),y=f,n?.onSelectedChange)try{n.onSelectedChange(f,!0)}catch(A){console.error("[aria-ease] Error in tabs onSelectedChange callback:",A)}}function S(f){let T=o.findIndex(A=>A===document.activeElement),x=T!==-1?T:y,d=x;switch(f){case"first":d=0;break;case"last":d=o.length-1;break;case"next":d=(x+1)%o.length;break;case"prev":d=(x-1+o.length)%o.length;break}if(o[d].focus(),o[d].setAttribute("tabindex","0"),o[y].setAttribute("tabindex","-1"),p)C(d,!1);else{let A=y;o.forEach((M,D)=>{D===d?M.setAttribute("tabindex","0"):D!==A&&M.setAttribute("tabindex","-1")})}}function I(f){return()=>{C(f)}}function k(f){return T=>{let{key:x}=T,d=!1;if(l==="horizontal")switch(x){case"ArrowLeft":T.preventDefault(),S("prev"),d=!0;break;case"ArrowRight":T.preventDefault(),S("next"),d=!0;break}else switch(x){case"ArrowUp":T.preventDefault(),S("prev"),d=!0;break;case"ArrowDown":T.preventDefault(),S("next"),d=!0;break}if(!d)switch(x){case"Home":T.preventDefault(),S("first");break;case"End":T.preventDefault(),S("last");break;case" ":case"Enter":p||(T.preventDefault(),C(f));break;case"F10":if(T.shiftKey&&n?.onContextMenu){T.preventDefault();try{n.onContextMenu(f,o[f])}catch(A){console.error("[aria-ease] Error in tabs onContextMenu callback:",A)}}break}}}function r(f){return T=>{if(n?.onContextMenu){T.preventDefault();try{n.onContextMenu(f,o[f])}catch(x){console.error("[aria-ease] Error in tabs onContextMenu callback:",x)}}}}function m(){o.forEach((f,T)=>{let x=I(T),d=k(T),A=r(T);f.addEventListener("click",x),f.addEventListener("keydown",d),n?.onContextMenu&&(f.addEventListener("contextmenu",A),b.set(f,A)),s.set(f,d),u.set(f,x)})}function i(){o.forEach(f=>{let T=s.get(f),x=u.get(f),d=b.get(f);T&&(f.removeEventListener("keydown",T),s.delete(f)),x&&(f.removeEventListener("click",x),u.delete(f)),d&&(f.removeEventListener("contextmenu",d),b.delete(f))})}function E(){i(),o.forEach((f,T)=>{let x=c[T];f.removeAttribute("role"),f.removeAttribute("aria-selected"),f.removeAttribute("aria-controls"),f.removeAttribute("tabindex"),x.removeAttribute("role"),x.removeAttribute("aria-labelledby"),x.removeAttribute("tabindex"),x.hidden=!1}),a.removeAttribute("role"),a.removeAttribute("aria-orientation")}function H(){i();let f=Array.from(a.querySelectorAll(`.${t}`)),T=Array.from(document.querySelectorAll(`.${h}`));o.length=0,o.push(...f),c.length=0,c.push(...T),L(),m()}return L(),m(),{activateTab:C,cleanup:E,refresh:H}}function q(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 G={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:ce},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...le(),...j()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:fe},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ge},"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:me},"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={})=>ue(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:pe},"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={})=>de(e.relativeTarget)}};function ce(){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 le(){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 ue(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 pe(){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 de(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${q("option",e)} to have aria-selected='true'.`}]}function fe(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function ge(){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 me(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var X={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:he},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ve},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ye},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ke},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ae(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:Ee},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Te},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:xe},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Me},"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={})=>we(e.relativeTarget)}};function he(){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 ve(){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 ye(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function ke(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function Ae(e){return[{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function Ee(){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 Te(){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 xe(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function Me(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function we(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={})=>Ce(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Le(e.relativeTarget)}};function Le(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${q("tab",e)} to have focus.`}]}function He(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${q("tab",e)} to have tabindex='0'.`}]}function Ce(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${q("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${q("tab",e)} to be visible.`},He(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={})=>Se(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>$e(e.relativeTarget)}};function Se(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 $e(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={})=>De(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Ie(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>qe(e.relativeTarget)}};function De(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function Ie(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 ${q("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={})=>Re(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Pe(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>_e(e.relativeTarget)}};function Re(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function Pe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function _e(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${q("checkbox",e)} to have focus.`}]}var te={"toggle.pressed":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ve(e.relativeTarget)},"toggle.unpressed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Oe(e.relativeTarget)},"toggle.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Be(e.relativeTarget)}};function Ve(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"true",failureMessage:"Expected toggle to have aria-pressed='true' when pressed."}]}function Oe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"false",failureMessage:"Expected toggle to have aria-pressed='false' when unpressed."}]}function Be(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${q("toggle",e)} to have focus.`}]}function Ne(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(Ne(t,h.when))return h.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var Fe={combobox:G,menu:X,tabs:Q,accordion:Y,radio:Z,checkbox:ee,toggle:te},F=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},K=class{constructor(t){this.componentName=t;this.statePack=Fe[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,l={capabilities:["keyboard"]},p=(a,o=new Set)=>{if(o.has(a))return[];o.add(a);let c=h[a];if(!c)return[];let s=[];if(Array.isArray(c.requires))for(let u of c.requires)s=s.concat(p(u,o));return c.setup&&(s=s.concat(B(c.setup,l))),s};return t({ariaReference:(a,o,c)=>({requires:s=>{let u=p(s,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"required",setup:u}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"optional",setup:u}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"recommended",setup:u})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"recommended"})}),contains:(a,o)=>({requires:c=>{let s=p(c,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"recommended"})})}),this}static(t){return t({target:l=>{let p=o=>{let c=this.statePack,s={capabilities:["keyboard"]},u=(b,y=new Set)=>{if(y.has(b))return[];y.add(b);let L=c[b];if(!L)return[];let C=[];if(Array.isArray(L.requires))for(let S of L.requires)C=C.concat(u(S,y));return L.setup&&(C=C.concat(B(L.setup,s))),C};return u(o,new Set)},n=o=>o==="role"?"toHaveRole":"toHaveAttribute",a=(o,c,s)=>{let u=n(o);return{required:()=>this.staticAssertions.push({target:l,assertion:u,attribute:o,expectedValue:c,failureMessage:"",level:"required",setup:s}),optional:()=>this.staticAssertions.push({target:l,assertion:u,attribute:o,expectedValue:c,failureMessage:"",level:"optional",setup:s}),recommended:()=>this.staticAssertions.push({target:l,assertion:u,attribute:o,expectedValue:c,failureMessage:"",level:"recommended",setup:s})}};return{has:(o,c)=>({...a(o,c),requires:u=>{let b=p(u);return a(o,c,b)}})}}}),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,l){this.parent=t;this.statePack=h;this.event=l}_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(l=>typeof l=="string"?[l]:typeof l=="object"&&l!==null&&"type"in l&&"ref"in l?this._findStateKeyByTypeAndRef(l.type)?[{type:l.type,ref:l.ref}]:[]:[l])}_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 l={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},p=(s,u=new Set)=>{if(u.has(s))return[];u.add(s);let b=this.statePack[s];if(!b)return[];let y=[];if(Array.isArray(b.requires))for(let L of b.requires)y=y.concat(p(L,u));return b.setup&&(y=y.concat(B(b.setup,l))),y},n=[];for(let s of this._given)if(typeof s=="string")n.push(...p(s));else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let u=this._findStateKeyByTypeAndRef(s.type);if(u){let b=this.statePack[u];if(b&&b.setup)for(let y of b.setup)typeof y.steps=="function"?n.push(...y.steps({relativeTarget:s.ref})):Array.isArray(y.steps)&&n.push(...y.steps)}}let a=new Set;n=n.filter(s=>{let u=JSON.stringify(s);return a.has(u)?!1:(a.add(u),!0)});let o=[];for(let s of this._then)if(typeof s=="string"){let u=this.statePack[s];if(u&&u.assertion!==void 0){let b=u.assertion;if(typeof b=="function")try{b=b()}catch(y){throw new Error(`Error calling assertion function for state '${s}': ${y.message}`)}Array.isArray(b)?o.push(...b):o.push(b)}}else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let u=this._findStateKeyByTypeAndRef(s.type);if(u){let b=this.statePack[u];if(b&&b.assertion!==void 0){let y=b.assertion;if(typeof y=="function")try{y=y({relativeTarget:s.ref})}catch(L){throw new Error(`Error calling assertion function for state '${u}': ${L.message}`)}Array.isArray(y)?o.push(...y):o.push(y)}}}let c=[{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:c,assertions:o,...n.length?{setup:n}:{}})}};function St(e,t){let h=new K(e);return t(h),new F(h.build())}import Ke from"path";async function re(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 l={violations:[]};async function p(u){try{let b=await fetch(u,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(b.ok||b.status===304)return u}catch{return null}return null}let n=N(h.strictness),a={},o=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:u}=await import("./configLoader-ZEJVXLX7.js"),b=await u(process.cwd());if(a=b.config,b.configPath&&(o=Ke.dirname(b.configPath)),h.strictness===void 0){let y=a.test?.components?.find(L=>L?.name===e)?.strictness;n=N(y??a.test?.strictness)}}catch{h.strictness===void 0&&(n="balanced")}let c;try{if(t){let u=await p(t);if(u){console.log(`\u{1F3AD} Running Playwright tests on ${u}`);let{runContractTestsPlaywright:b}=await import("./contractTestRunnerPlaywright-OB2GWGOA.js");c=await b(e,u,n,a,o)}else throw new Error(`\u274C Dev server not running at ${t}
1
+ import{b as z,d as B}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";function Xe({accordionId:e,triggersClass:t,panelsClass:m,allowMultipleOpen:l=!1,callback:d}){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 a=Array.from(n.querySelectorAll(`.${t}`));if(a.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(m==="")return console.error("[aria-ease] 'panelsClass' should not be an empty string. Provide a class name that exists on the accordion panel elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let o=Array.from(n.querySelectorAll(`.${m}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${m}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(a.length!==o.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${a.length} triggers but ${o.length} panels.`),{cleanup:()=>{}};let c=new WeakMap,s=new WeakMap;function u(){a.forEach((i,T)=>{let C=o[T];i.id||(i.id=`${e}-trigger-${T}`),C.id||(C.id=`${e}-panel-${T}`),i.setAttribute("aria-controls",C.id),i.setAttribute("aria-expanded","false"),(!l||a.length<=6)&&C.setAttribute("role","region"),C.setAttribute("aria-labelledby",i.id),C.style.display="none"})}function v(i){if(i<0||i>=a.length){console.error(`[aria-ease] Invalid accordion index: ${i}`);return}let T=a[i],C=o[i];if(T.setAttribute("aria-expanded","true"),C.style.display="block",d?.onExpandedChange)try{d.onExpandedChange(i,!0)}catch(f){console.error("[aria-ease] Error in accordion onExpandedChange callback:",f)}}function y(i){if(i<0||i>=a.length){console.error(`[aria-ease] Invalid accordion index: ${i}`);return}let T=a[i],C=o[i];if(T.setAttribute("aria-expanded","false"),C.style.display="none",d?.onExpandedChange)try{d.onExpandedChange(i,!1)}catch(f){console.error("[aria-ease] Error in accordion onExpandedChange callback:",f)}}function E(i){a[i].getAttribute("aria-expanded")==="true"?y(i):(l||a.forEach((f,x)=>{x!==i&&y(x)}),v(i))}function S(i){return()=>{E(i)}}function H(i){return T=>{let{key:C}=T;switch(C){case"Enter":case" ":T.preventDefault(),E(i);break;case"ArrowDown":T.preventDefault();{let f=(i+1)%a.length;a[f].focus()}break;case"ArrowUp":T.preventDefault();{let f=(i-1+a.length)%a.length;a[f].focus()}break;case"Home":T.preventDefault(),a[0].focus();break;case"End":T.preventDefault(),a[a.length-1].focus();break}}}function q(){a.forEach((i,T)=>{let C=S(T),f=H(T);i.addEventListener("click",C),i.addEventListener("keydown",f),c.set(i,f),s.set(i,C)})}function k(){a.forEach(i=>{let T=c.get(i),C=s.get(i);T&&(i.removeEventListener("keydown",T),c.delete(i)),C&&(i.removeEventListener("click",C),s.delete(i))})}function r(){k(),a.forEach((i,T)=>{y(T)})}function b(){k();let i=Array.from(n.querySelectorAll(`.${t}`)),T=Array.from(n.querySelectorAll(`.${m}`));a.length=0,a.push(...i),o.length=0,o.push(...T),u(),q()}return u(),q(),{expandItem:v,collapseItem:y,toggleItem:E,cleanup:r,refresh:b}}function _(e){if(e.tagName!=="INPUT")return!1;let t=e.type;return["text","email","password","tel","number"].includes(t)}function V(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 O(e,t,m){let l=e.length,d=(t+m+l)%l;e.item(d).focus()}function se(e){return e.getAttribute("data-custom-click")!==null&&e.getAttribute("data-custom-click")!==void 0}function j(e,t,m){let l=t.item(m);switch(e.key){case"ArrowUp":case"ArrowLeft":{(!_(l)&&!V(l)||(_(l)||V(l))&&l.selectionStart===0)&&(e.preventDefault(),O(t,m,-1));break}case"ArrowDown":case"ArrowRight":{if(!_(l)&&!V(l))e.preventDefault(),O(t,m,1);else if(_(l)||V(l)){let d=l.value;l.selectionStart===d.length&&(e.preventDefault(),O(t,m,1))}break}case"Escape":{e.preventDefault();break}case"Enter":case" ":{(!W(l)&&!ie(l)&&se(l)||W(l))&&(e.preventDefault(),l.click());break}case"Tab":break;default:break}}function et({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 m=document.querySelector(`#${e}`);if(!m)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 l=null;function d(){return l||(l=m.querySelectorAll(`.${t}`)),l}let n=d();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 a=new Map;n.forEach(s=>{if(!a.has(s)){let u=v=>{let y=m.querySelectorAll(`.${t}`),E=Array.prototype.indexOf.call(y,s);j(v,y,E)};s.addEventListener("keydown",u),a.set(s,u)}});function o(){n.forEach(s=>{let u=a.get(s);u&&(s.removeEventListener("keydown",u),a.delete(s))})}function c(){l=null}return{cleanup:o,refresh:c}}function rt({checkboxGroupId:e,checkboxesClass:t,callback:m}){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 l=document.querySelector(`#${e}`);if(!l)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 d=Array.from(l.querySelectorAll(`.${t}`));if(d.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,a=new WeakMap;function o(){l.getAttribute("role")||l.setAttribute("role","group"),d.forEach(r=>{r.setAttribute("role","checkbox");let b=r.checked;r.setAttribute("aria-checked",b?"true":"false"),r.hasAttribute("tabindex")||r.setAttribute("tabindex","0")})}function c(r,b){if(m?.onCheckedChange)try{m.onCheckedChange(r,b)}catch(i){console.error("[aria-ease] Error in checkbox onCheckedChange callback:",i)}}function s(r){if(r<0||r>=d.length){console.error(`[aria-ease] Invalid checkbox index: ${r}`);return}let b=d[r],i=!b.checked;b.checked=i,b.setAttribute("aria-checked",i?"true":"false"),c(r,i)}function u(r,b){if(r<0||r>=d.length){console.error(`[aria-ease] Invalid checkbox index: ${r}`);return}let i=d[r];i.checked=b,i.setAttribute("aria-checked",b?"true":"false"),c(r,b)}function v(r){return()=>{let b=d[r];if("checked"in b&&typeof b.checked=="boolean")setTimeout(()=>{let i=b.checked;b.setAttribute("aria-checked",i?"true":"false"),c(r,i)},0);else{let i=b.getAttribute("aria-checked")==="true";b.setAttribute("aria-checked",i?"false":"true"),c(r,!i)}}}function y(r){return b=>{let{key:i}=b;switch(i){case" ":case"Spacebar":b.preventDefault(),s(r);break}}}function E(){d.forEach((r,b)=>{let i=v(b),T=y(b);r.addEventListener("click",i),r.addEventListener("keydown",T),n.set(r,T),a.set(r,i)})}function S(){d.forEach(r=>{let b=n.get(r),i=a.get(r);b&&(r.removeEventListener("keydown",b),n.delete(r)),i&&(r.removeEventListener("click",i),a.delete(r))})}function H(){S()}function q(){return d.map(r=>r.getAttribute("aria-checked")==="true")}function k(){return d.map((r,b)=>r.getAttribute("aria-checked")==="true"?b:-1).filter(r=>r!==-1)}return o(),E(),{toggleCheckbox:s,setCheckboxState:u,getCheckedStates:q,getCheckedIndices:k,cleanup:H}}function oe({menuId:e,menuItemsClass:t,triggerId:m,callback:l}){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 d=document.querySelector(`#${e}`);if(!d)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(m==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let n=document.querySelector(`#${m}`);if(!n)return console.error(`[aria-ease] Element with id="${m}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(t==="")return console.error("[aria-ease] 'menuItemsClass' should not be an empty string. Provide a class name to at least a menu item that exists before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(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"),d.setAttribute("role","menu"),d.setAttribute("aria-labelledby",m);let a=new WeakMap,o=new Map,c=null,s=null;function u(){return c||(c=d.querySelectorAll(`.${t}`)),c}function v(){if(!s){let g=u();s=[];for(let h=0;h<g.length;h++){let L=g.item(h),$=b(L),R=L.getAttribute("aria-disabled")==="true";$||(L.hasAttribute("tabindex")||L.setAttribute("tabindex","-1"),R||s.push(L))}}return s}function y(g){return{length:g.length,item:L=>g[L],forEach:L=>{g.forEach(L)},[Symbol.iterator]:function*(){for(let L of g)yield L}}}function E(){u().forEach(h=>{h.setAttribute("role","menuitem");let L=h.getAttribute("data-submenu-id")??h.getAttribute("aria-controls"),$=h.hasAttribute("aria-haspopup")&&L;L&&(h.hasAttribute("data-submenu-id")||$)&&(h.setAttribute("aria-haspopup","menu"),h.setAttribute("aria-controls",L),h.hasAttribute("aria-expanded")||h.setAttribute("aria-expanded","false"))})}function S(g,h,L){let $=g.length,R=(h+L+$)%$;g.item(R).focus()}function H(g,h){g.length!==0&&g[h]?.focus()}function q(g){return g.hasAttribute("aria-controls")&&g.hasAttribute("aria-haspopup")&&g.getAttribute("role")==="menuitem"}function k(g){let h=g;for(;h&&h.getAttribute("role")==="menuitem";){let L=h.closest('[role="menu"]');if(!L)break;L.style.display="none",h.setAttribute("aria-expanded","false");let $=L.getAttribute("aria-labelledby");if(!$)break;let R=document.getElementById($);if(!R)break;h=R}}E();function r(g,h,L){switch(g.key){case"ArrowLeft":{if(g.key==="ArrowLeft"&&n.getAttribute("role")==="menuitem"){g.preventDefault(),p();return}break}case"ArrowUp":{g.preventDefault(),S(y(v()),L,-1);break}case"ArrowRight":{if(g.key==="ArrowRight"&&q(h)){g.preventDefault();let $=h.getAttribute("aria-controls");if($){T($);return}}break}case"ArrowDown":{g.preventDefault(),S(y(v()),L,1);break}case"Home":{g.preventDefault(),H(v(),0);break}case"End":{g.preventDefault();let $=v();H($,$.length-1);break}case"Escape":{g.preventDefault(),p(),n.focus(),C&&C(!1);break}case"Enter":case" ":{if(g.preventDefault(),q(h)){let $=h.getAttribute("aria-controls");if($){T($);return}}h.click(),p(),C&&C(!1);break}case"Tab":{p(),k(n),C&&C(!1);break}default:break}}function b(g){let h=g.parentElement;for(;h&&h!==d;){if(h.getAttribute("role")==="menu"||h.id&&d.querySelector(`[aria-controls="${h.id}"]`))return!0;h=h.parentElement}return!1}function i(g){n.setAttribute("aria-expanded",g?"true":"false")}function T(g){let h=o.get(g);if(!h){let L=d.querySelector(`[aria-controls="${g}"]`);if(!L){console.error(`[aria-ease] Submenu trigger with aria-controls="${g}" not found in menu "${e}".`);return}if(!L.id){let R=`trigger-${g}`;L.id=R,console.warn(`[aria-ease] Submenu trigger for "${g}" had no ID. Auto-generated ID: "${R}".`)}if(!document.querySelector(`#${g}`)){console.error(`[aria-ease] Submenu element with id="${g}" not found. Cannot create submenu instance.`);return}h=oe({menuId:g,menuItemsClass:t,triggerId:L.id,callback:l}),o.set(g,h)}h.openMenu()}function C(g){if(l?.onExpandedChange)try{l.onExpandedChange(g)}catch(h){console.error("[aria-ease] Error in menu onExpandedChange callback:",h)}}function f(){v().forEach((h,L)=>{if(!a.has(h)){let $=R=>r(R,h,L);h.addEventListener("keydown",$),a.set(h,$)}})}function x(){v().forEach(h=>{let L=a.get(h);L&&(h.removeEventListener("keydown",L),a.delete(h))})}function w(){i(!0),d.style.display="block";let g=v();if(f(),g&&g.length>0&&g[0].focus(),l?.onExpandedChange)try{l.onExpandedChange(!0)}catch(h){console.error("[aria-ease] Error in menu onExpandedChange callback:",h)}}function p(){if(o.forEach(g=>g.closeMenu()),i(!1),d.style.display="none",x(),n.focus(),l?.onExpandedChange)try{l.onExpandedChange(!1)}catch(g){console.error("[aria-ease] Error in menu onExpandedChange callback:",g)}}function A(){n.getAttribute("aria-expanded")==="true"?p():w()}function M(g){if(!(n.getAttribute("aria-expanded")==="true"))return;let L=n.contains(g.target),$=d.contains(g.target);!L&&!$&&p()}n.addEventListener("click",A),document.addEventListener("click",M);function I(){x(),n.removeEventListener("click",A),document.removeEventListener("click",M),d.style.display="none",i(!1),o.forEach(g=>g.cleanup()),o.clear()}function P(){c=null,s=null}return{openMenu:w,closeMenu:p,cleanup:I,refresh:P}}function it({radioGroupId:e,radiosClass:t,defaultSelectedIndex:m,callback:l}){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 d=document.querySelector(`#${e}`);if(!d)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(d.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 a=new WeakMap,o=new WeakMap,c;m&&(c=m);function s(){d.getAttribute("role")||d.setAttribute("role","radiogroup"),n.forEach((k,r)=>{k.setAttribute("role","radio"),k.setAttribute("tabindex","0");let b=r===c;k.setAttribute("aria-checked",b?"true":"false"),k.checked!==void 0&&(k.checked=b)})}function u(k){if(k<0||k>=n.length){console.error(`[aria-ease] Invalid radio index: ${k}`);return}if(c>=0&&c<n.length&&(n[c].setAttribute("aria-checked","false"),n[c].checked!==void 0&&(n[c].checked=!1)),n[k].setAttribute("aria-checked","true"),n[k].checked!==void 0&&(n[k].checked=!0),n[k].focus(),l?.onValueChange)try{l.onValueChange(k,n[k].getAttribute("value"))}catch(r){console.error("[aria-ease] Error in radio onValueChange callback:",r)}c=k}function v(k){return()=>{let r=n[k];"checked"in r&&typeof r.checked=="boolean"?setTimeout(()=>{u(k)},0):u(k)}}function y(k){return r=>{let{key:b}=r,i=k;switch(b){case"ArrowDown":case"ArrowRight":r.preventDefault(),i=(k+1)%n.length,u(i);break;case"ArrowUp":case"ArrowLeft":r.preventDefault(),i=(k-1+n.length)%n.length,u(i);break;case" ":case"Enter":r.preventDefault(),u(k);break}}}function E(){n.forEach((k,r)=>{let b=v(r),i=y(r);k.addEventListener("click",b),k.addEventListener("keydown",i),a.set(k,i),o.set(k,b)})}function S(){n.forEach(k=>{let r=a.get(k),b=o.get(k);r&&(k.removeEventListener("keydown",r),a.delete(k)),b&&(k.removeEventListener("click",b),o.delete(k))})}function H(){S()}function q(){return c}return s(),E(),{selectRadio:u,getSelectedIndex:q,cleanup:H}}function ot({toggleId:e,togglesClass:t,isSingleToggle:m=!0,callback:l}){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 d=document.querySelector(`#${e}`);if(!d)return console.error(`[aria-ease] Element with id="${e}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let n;if(m)n=[d];else{if(!t)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(n=Array.from(d.querySelectorAll(`.${t}`)),n.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let a=new WeakMap,o=new WeakMap;function c(){n.forEach(r=>{r.tagName.toLowerCase()!=="button"&&!r.getAttribute("role")&&r.setAttribute("role","button"),r.hasAttribute("aria-pressed")||r.setAttribute("aria-pressed","false"),r.hasAttribute("tabindex")||r.setAttribute("tabindex","0")})}function s(r){if(r<0||r>=n.length){console.error(`[aria-ease] Invalid toggle index: ${r}`);return}let i=n[r].getAttribute("aria-pressed")==="true";u(r,!i)}function u(r,b){if(r<0||r>=n.length){console.error(`[aria-ease] Invalid toggle index: ${r}`);return}if(n[r].setAttribute("aria-pressed",b?"true":"false"),l?.onPressedChange)try{l.onPressedChange(r,b)}catch(i){console.error("[aria-ease] Error in checkbox onPressedChange callback:",i)}}function v(r){return()=>{s(r)}}function y(r){return b=>{let{key:i}=b;switch(i){case"Enter":case" ":b.preventDefault(),s(r);break}}}function E(){n.forEach((r,b)=>{let i=v(b),T=y(b);r.addEventListener("click",i),r.addEventListener("keydown",T),a.set(r,T),o.set(r,i)})}function S(){n.forEach(r=>{let b=a.get(r),i=o.get(r);b&&(r.removeEventListener("keydown",b),a.delete(r)),i&&(r.removeEventListener("click",i),o.delete(r))})}function H(){S()}function q(){return n.map(r=>r.getAttribute("aria-pressed")==="true")}function k(){return n.map((r,b)=>r.getAttribute("aria-pressed")==="true"?b:-1).filter(r=>r!==-1)}return c(),E(),{toggleButton:s,setPressed:u,getPressedStates:q,getPressedIndices:k,cleanup:H}}function lt({comboboxInputId:e,comboboxButtonId:t,listBoxId:m,listBoxItemsClass:l,callback:d}){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(m==="")return console.error("[aria-ease] 'listBoxId' should not be an empty string. Provide an id to the combobox listbox element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let a=document.getElementById(`${m}`);if(!a)return console.error(`[aria-ease] Element with id="${m}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(l==="")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(l))return console.error(`[aria-ease] Listbox option(s) with class="${l}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let c=t?document.getElementById(`${t}`):null,s=-1;n.setAttribute("role","combobox"),n.setAttribute("aria-autocomplete","list"),n.setAttribute("aria-controls",m),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-haspopup","listbox"),a.setAttribute("role","listbox");let u=null;function v(){return u||(u=a.querySelectorAll(`.${l}`)),Array.from(u).filter(p=>!p.hidden&&p.style.display!=="none")}function y(){return n.getAttribute("aria-expanded")==="true"}function E(p){let A=v();if(p>=0&&p<A.length){let M=A[p],I=M.id||`${m}-option-${p}`;if(M.id||(M.id=I),n.setAttribute("aria-activedescendant",I),typeof M.scrollIntoView=="function"&&M.scrollIntoView({block:"nearest",behavior:"smooth"}),d?.onActiveDescendantChange)try{d.onActiveDescendantChange(I,M)}catch(P){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",P)}}else n.setAttribute("aria-activedescendant","");s=p}function S(){if(n.setAttribute("aria-expanded","true"),a.style.display="block",d?.onExpandedChange)try{d.onExpandedChange(!0)}catch(p){console.error("[aria-ease] Error in combobox onExpandedChange callback:",p)}}function H(){if(n.setAttribute("aria-expanded","false"),n.setAttribute("aria-activedescendant",""),a.style.display="none",s=-1,d?.onExpandedChange)try{d.onExpandedChange(!1)}catch(p){console.error("[aria-ease] Error in combobox onExpandedChange callback:",p)}}function q(p){let A=p.textContent?.trim()||"";if(n.value=A,p.setAttribute("aria-selected","true"),H(),d?.onSelect)try{d.onSelect(p)}catch(M){console.error("[aria-ease] Error in combobox onSelect callback:",M)}}function k(p){let A=v(),M=y();switch(p.key){case"ArrowDown":if(p.preventDefault(),!M){S();return}if(A.length===0)return;{let I=s>=A.length-1?0:s+1;E(I)}break;case"ArrowUp":if(p.preventDefault(),!M)return;if(A.length>0){let I=s<=0?A.length-1:s-1;E(I)}break;case"Enter":M&&s>=0&&s<A.length&&(p.preventDefault(),q(A[s]));break;case"Escape":if(M)p.preventDefault(),H();else if(n.value&&(p.preventDefault(),n.value="",n.setAttribute("aria-activedescendant",""),v().forEach(P=>{P.getAttribute("aria-selected")==="true"&&P.setAttribute("aria-selected","false")}),d?.onClear))try{d.onClear()}catch(P){console.error("[aria-ease] Error in combobox onClear callback:",P)}break;case"Home":M&&A.length>0&&(p.preventDefault(),E(0));break;case"End":M&&A.length>0&&(p.preventDefault(),E(A.length-1));break;case"Tab":M&&s>=0&&s<A.length&&q(A[s]),M&&H();break}}function r(p){let A=p.target;if(A.classList.contains(l)){let I=v().indexOf(A);I>=0&&E(I)}}function b(p){let A=p.target;A.classList.contains(l)&&(p.preventDefault(),q(A))}function i(p){let A=p.target;!n.contains(A)&&!a.contains(A)&&(!c||!c.contains(A))&&H()}function T(){y()?H():(S(),n.focus())}function C(p){(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),T())}n.addEventListener("keydown",k),a.addEventListener("mousemove",r),a.addEventListener("mousedown",b),document.addEventListener("mousedown",i),c&&(c.setAttribute("tabindex","-1"),c.setAttribute("aria-label","Toggle options"),c.addEventListener("click",T),c.addEventListener("keydown",C));function f(){let p=a.querySelectorAll(`.${l}`);if(p.length===0)return;let A=null;for(let M of p)if(M.getAttribute("aria-selected")==="true"){A=M.textContent?.trim()||null;break}!A&&n.value&&(A=n.value.trim()),p.forEach((M,I)=>{M.setAttribute("role","option");let P=M.textContent?.trim()||"";A&&P===A?M.setAttribute("aria-selected","true"):M.setAttribute("aria-selected","false");let g=M.getAttribute("id");if(!g||g===""){let h=`${m}-option-${I}`;M.id=h,M.setAttribute("id",h)}})}f();function x(){n.removeEventListener("keydown",k),a.removeEventListener("mousemove",r),a.removeEventListener("mousedown",b),document.removeEventListener("mousedown",i),c&&(c.removeEventListener("click",T),c.removeEventListener("keydown",C))}function w(){u=null,f(),s=-1,E(-1)}return{cleanup:x,refresh:w,openListbox:S,closeListbox:H}}function dt({tabListId:e,tabsClass:t,tabPanelsClass:m,orientation:l="horizontal",activateOnFocus:d=!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 a=document.querySelector(`#${e}`);if(!a)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 o=Array.from(a.querySelectorAll(`.${t}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(m==="")return console.error("[aria-ease] 'tabPanelsClass' should not be an empty string. Provide a class name that exists on the tab panel elements before calling makeTabsAccessible."),{cleanup:()=>{}};let c=Array.from(document.querySelectorAll(`.${m}`));if(c.length===0)return console.error(`[aria-ease] No elements with class="${m}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(o.length!==c.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${o.length} tabs but ${c.length} panels.`),{cleanup:()=>{}};let s=new WeakMap,u=new WeakMap,v=new WeakMap,y=0;function E(){a.setAttribute("role","tablist"),a.setAttribute("aria-orientation",l),o.forEach((f,x)=>{let w=c[x];f.id||(f.id=`${e}-tab-${x}`),w.id||(w.id=`${e}-panel-${x}`),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")}),S(0,!1)}function S(f,x=!0){if(f<0||f>=o.length){console.error(`[aria-ease] Invalid tab index: ${f}`);return}o.forEach((A,M)=>{let I=c[M];A.setAttribute("aria-selected","false"),A.setAttribute("tabindex","-1"),I.hidden=!0});let w=o[f],p=c[f];if(w.setAttribute("aria-selected","true"),w.setAttribute("tabindex","0"),p.hidden=!1,x&&w.focus(),y=f,n?.onSelectedChange)try{n.onSelectedChange(f,!0)}catch(A){console.error("[aria-ease] Error in tabs onSelectedChange callback:",A)}}function H(f){let x=o.findIndex(A=>A===document.activeElement),w=x!==-1?x:y,p=w;switch(f){case"first":p=0;break;case"last":p=o.length-1;break;case"next":p=(w+1)%o.length;break;case"prev":p=(w-1+o.length)%o.length;break}if(o[p].focus(),o[p].setAttribute("tabindex","0"),o[y].setAttribute("tabindex","-1"),d)S(p,!1);else{let A=y;o.forEach((M,I)=>{I===p?M.setAttribute("tabindex","0"):I!==A&&M.setAttribute("tabindex","-1")})}}function q(f){return()=>{S(f)}}function k(f){return x=>{let{key:w}=x,p=!1;if(l==="horizontal")switch(w){case"ArrowLeft":x.preventDefault(),H("prev"),p=!0;break;case"ArrowRight":x.preventDefault(),H("next"),p=!0;break}else switch(w){case"ArrowUp":x.preventDefault(),H("prev"),p=!0;break;case"ArrowDown":x.preventDefault(),H("next"),p=!0;break}if(!p)switch(w){case"Home":x.preventDefault(),H("first");break;case"End":x.preventDefault(),H("last");break;case" ":case"Enter":d||(x.preventDefault(),S(f));break;case"F10":if(x.shiftKey&&n?.onContextMenu){x.preventDefault();try{n.onContextMenu(f,o[f])}catch(A){console.error("[aria-ease] Error in tabs onContextMenu callback:",A)}}break}}}function r(f){return x=>{if(n?.onContextMenu){x.preventDefault();try{n.onContextMenu(f,o[f])}catch(w){console.error("[aria-ease] Error in tabs onContextMenu callback:",w)}}}}function b(){o.forEach((f,x)=>{let w=q(x),p=k(x),A=r(x);f.addEventListener("click",w),f.addEventListener("keydown",p),n?.onContextMenu&&(f.addEventListener("contextmenu",A),v.set(f,A)),s.set(f,p),u.set(f,w)})}function i(){o.forEach(f=>{let x=s.get(f),w=u.get(f),p=v.get(f);x&&(f.removeEventListener("keydown",x),s.delete(f)),w&&(f.removeEventListener("click",w),u.delete(f)),p&&(f.removeEventListener("contextmenu",p),v.delete(f))})}function T(){i(),o.forEach((f,x)=>{let w=c[x];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}),a.removeAttribute("role"),a.removeAttribute("aria-orientation")}function C(){i();let f=Array.from(a.querySelectorAll(`.${t}`)),x=Array.from(document.querySelectorAll(`.${m}`));o.length=0,o.push(...f),c.length=0,c.push(...x),E(),b()}return E(),b(),{activateTab:S,cleanup:T,refresh:C}}function D(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 G={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:ce},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...le(),...J()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:fe},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ge},"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:me},"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={})=>ue(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:de},"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 ce(){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 le(){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 ue(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 de(){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 ${D("option",e)} to have aria-selected='true'.`}]}function fe(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function ge(){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 me(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var X={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:he},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ve},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ye},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:ke},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ae(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:Ee},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:Te},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:xe},"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={})=>Me(e.relativeTarget)}};function he(){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 ve(){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 ye(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function ke(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function Ae(e){return[{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function Ee(){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 Te(){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 xe(){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 Me(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={})=>Se(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Le(e.relativeTarget)},"tab.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>He(e.relativeTarget)}};function Le(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("tab",e)} to have focus.`}]}function He(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("tab",e)} not to have focus.`}]}function Ce(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${D("tab",e)} to have tabindex='0'.`}]}function Se(e){return[{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${D("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${D("tab",e)} to be visible.`},Ce(e)]}var Y={"panel.expanded":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>$e(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>De(e.relativeTarget)},"trigger.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ie(e.relativeTarget)},"trigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>qe(e.relativeTarget)}};function $e(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 De(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 Ie(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("trigger",e)} to have focus.`}]}function qe(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("trigger",e)} not to have focus.`}]}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={})=>Re(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Pe(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>_e(e.relativeTarget)},"radio.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Ve(e.relativeTarget)}};function Re(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function Pe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function _e(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("radio",e)} to have focus.`}]}function Ve(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("radio",e)} not 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={})=>Oe(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Be(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Fe(e.relativeTarget)},"checkbox.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Ne(e.relativeTarget)}};function Oe(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function Be(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function Fe(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("checkbox",e)} to have focus.`}]}function Ne(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("checkbox",e)} not to have focus.`}]}var te={"toggle.pressed":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Ke(e.relativeTarget)},"toggle.unpressed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Ue(e.relativeTarget)},"toggle.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ze(e.relativeTarget)},"toggle.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>We(e.relativeTarget)}};function Ke(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"true",failureMessage:"Expected toggle to have aria-pressed='true' when pressed."}]}function Ue(e){return[{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"false",failureMessage:"Expected toggle to have aria-pressed='false' when unpressed."}]}function ze(e){return[{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("toggle",e)} to have focus.`}]}function We(e){return[{target:"relative",assertion:"notToHaveFocus",relativeTarget:e,failureMessage:`Expected ${D("toggle",e)} not to have focus.`}]}function je(e,t){return t.some(m=>e.capabilities.includes(m))}function F(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let m of e)if(je(t,m.when))return m.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var Je={combobox:G,menu:X,tabs:Q,accordion:Y,radio:Z,checkbox:ee,toggle:te},N=class{constructor(t){this.jsonContract=t}toJSON(){return this.jsonContract}},K=class{constructor(t){this.componentName=t;this.statePack=Je[t]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let m=this.statePack,l={capabilities:["keyboard"]},d=(a,o=new Set)=>{if(o.has(a))return[];o.add(a);let c=m[a];if(!c)return[];let s=[];if(Array.isArray(c.requires))for(let u of c.requires)s=s.concat(d(u,o));return c.setup&&(s=s.concat(F(c.setup,l))),s};return t({ariaReference:(a,o,c)=>({requires:s=>{let u=d(s,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"required",setup:u}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"optional",setup:u}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"recommended",setup:u})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:a,attribute:o,to:c,level:"recommended"})}),contains:(a,o)=>({requires:c=>{let s=d(c,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"required",setup:s}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"optional",setup:s}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"recommended",setup:s})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:a,child:o,level:"recommended"})})}),this}static(t){return t({target:l=>{let d=o=>{let c=this.statePack,s={capabilities:["keyboard"]},u=(v,y=new Set)=>{if(y.has(v))return[];y.add(v);let E=c[v];if(!E)return[];let S=[];if(Array.isArray(E.requires))for(let H of E.requires)S=S.concat(u(H,y));return E.setup&&(S=S.concat(F(E.setup,s))),S};return u(o,new Set)},n=o=>o==="role"?"toHaveRole":"toHaveAttribute",a=(o,c,s)=>{let u=n(o);return{required:()=>this.staticAssertions.push({target:l,assertion:u,attribute:o,expectedValue:c,failureMessage:"",level:"required",setup:s}),optional:()=>this.staticAssertions.push({target:l,assertion:u,attribute:o,expectedValue:c,failureMessage:"",level:"optional",setup:s}),recommended:()=>this.staticAssertions.push({target:l,assertion:u,attribute:o,expectedValue:c,failureMessage:"",level:"recommended",setup:s})}};return{has:(o,c)=>({...a(o,c),requires:u=>{let v=d(u);return a(o,c,v)}})}}}),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,m,l){this.parent=t;this.statePack=m;this.event=l}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,m){return this._onTarget=t,this._onRelativeTarget=m,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(l=>typeof l=="string"?[l]:typeof l=="object"&&l!==null&&"type"in l&&"ref"in l?this._findStateKeyByTypeAndRef(l.type)?[{type:l.type,ref:l.ref}]:[]:[l])}_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 l={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},d=(s,u=new Set,v)=>{if(u.has(s))return[];u.add(s);let y=this.statePack[s];if(!y)return[];let E=[];if(Array.isArray(y.requires))for(let S of y.requires)E=E.concat(d(S,u,v));if(y.setup){let S=y.setup.filter(H=>H.when.some(q=>l.capabilities.includes(q)));for(let H of S)typeof H.steps=="function"?E=E.concat(H.steps({relativeTarget:v})):E=E.concat(H.steps)}return E},n=[];for(let s of this._given)typeof s=="string"?n=n.concat(d(s,new Set)):typeof s=="object"&&s.type&&(n=n.concat(d(s.type,new Set,s.ref)));let a=new Set;n=n.filter(s=>{let u=[s.type,s.target,s.relativeTarget].join(":");return a.has(u)?!1:(a.add(u),!0)});let o=[];for(let s of this._then)if(typeof s=="string"){let u=this.statePack[s];if(u&&u.assertion!==void 0){let v=u.assertion;if(typeof v=="function")try{v=v()}catch(y){throw new Error(`Error calling assertion function for state '${s}': ${y.message}`)}Array.isArray(v)?o.push(...v):o.push(v)}}else if(typeof s=="object"&&s!==null&&"type"in s&&"ref"in s){let u=this._findStateKeyByTypeAndRef(s.type);if(u){let v=this.statePack[u];if(v&&v.assertion!==void 0){let y=v.assertion;if(typeof y=="function")try{y=y({relativeTarget:s.ref})}catch(E){throw new Error(`Error calling assertion function for state '${u}': ${E.message}`)}Array.isArray(y)?o.push(...y):o.push(y)}}}let c=[{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:c,assertions:o,...n.length?{setup:n}:{}})}};function _t(e,t){let m=new K(e);return t(m),new N(m.build())}import Ge from"path";async function re(e,t,m={}){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 l={violations:[]};async function d(u){try{let v=await fetch(u,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(v.ok||v.status===304)return u}catch{return null}return null}let n=B(m.strictness),a={},o=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:u}=await import("./configLoader-ZEJVXLX7.js"),v=await u(process.cwd());if(a=v.config,v.configPath&&(o=Ge.dirname(v.configPath)),m.strictness===void 0){let y=a.test?.components?.find(E=>E?.name===e)?.strictness;n=B(y??a.test?.strictness)}}catch{m.strictness===void 0&&(n="balanced")}let c;try{if(t){let u=await d(t);if(u){console.log(`\u{1F3AD} Running Playwright tests on ${u}`);let{runContractTestsPlaywright:v}=await import("./contractTestRunnerPlaywright-CHCVW7VO.js");c=await v(e,u,n,a,o)}else throw new Error(`\u274C Dev server not running at ${t}
2
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(u){throw u instanceof Error?u:new Error(`\u274C Contract test execution failed: ${String(u)}`)}let s={violations:l.violations,raw:l,contract:c};if(c.failures.length>0&&t==="Playwright")throw new Error(`
3
3
  \u274C ${c.failures.length} accessibility contract test${c.failures.length>1?"s":""} failed (Playwright mode)
4
4
  \u2705 ${c.passes.length} test${c.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(l.violations.length>0){let u=l.violations.length,b=l.violations.map(y=>`
7
+ \u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(l.violations.length>0){let u=l.violations.length,v=l.violations.map(y=>`
8
8
  - ${y.id}: ${y.description}
9
9
  Impact: ${y.impact}
10
10
  Affected elements: ${y.nodes.length}
11
11
  Help: ${y.helpUrl}`).join(`
12
12
  `);throw new Error(`
13
13
  \u274C ${u} axe accessibility violation${u>1?"s":""} detected
14
- ${b}
14
+ ${v}
15
15
 
16
16
  \u{1F4CB} Full details available in result.violations`)}return s}var ne=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(ne=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,l)=>{e("npx vitest --run --reporter verbose",async(p,n,a)=>{if(console.log(n),a&&console.error(a),!p||p.code===0){try{let{displayBadgeInfo:c,promptAddBadge:s}=await import("./badgeHelper-IB5RTMAG.js");c("component"),await s("component",process.cwd()),console.log(t.dim(`
17
+ `);let{exec:e}=await import("child_process"),t=(await import("chalk")).default;return new Promise((m,l)=>{e("npx vitest --run --reporter verbose",async(d,n,a)=>{if(console.log(n),a&&console.error(a),!d||d.code===0){try{let{displayBadgeInfo:c,promptAddBadge:s}=await import("./badgeHelper-IB5RTMAG.js");c("component"),await s("component",process.cwd()),console.log(t.dim(`
18
18
  `+"\u2500".repeat(60))),console.log(t.cyan("\u{1F499} Found aria-ease helpful?")),console.log(t.white(" \u2022 Star us on GitHub: ")+t.blue.underline("https://github.com/aria-ease/aria-ease")),console.log(t.white(" \u2022 Share feedback: ")+t.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log(t.dim("\u2500".repeat(60)+`
19
- `))}catch(c){console.error("Warning: Could not display badge prompt:",c)}h({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let c=p?.code||1;l(new Error(`Tests failed with code ${c}`)),process.exit(c)}})})});async function ae(){await z()}export{ae as cleanupTests,St as createContract,Ue as makeAccordionAccessible,je as makeBlockAccessible,Xe as makeCheckboxAccessible,nt as makeComboboxAccessible,oe as makeMenuAccessible,Ze as makeRadioAccessible,it as makeTabsAccessible,tt as makeToggleAccessible,re as testUiComponent};
19
+ `))}catch(c){console.error("Warning: Could not display badge prompt:",c)}m({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let c=d?.code||1;l(new Error(`Tests failed with code ${c}`)),process.exit(c)}})})});async function ae(){await z()}export{ae as cleanupTests,_t as createContract,Xe as makeAccordionAccessible,et as makeBlockAccessible,rt as makeCheckboxAccessible,lt as makeComboboxAccessible,oe as makeMenuAccessible,it as makeRadioAccessible,dt as makeTabsAccessible,ot as makeToggleAccessible,re as testUiComponent};
@@ -0,0 +1,46 @@
1
+ import {a as a$1}from'./chunk-WIWSYIGK.js';import {d,a,c,e}from'./chunk-APUMBDOT.js';import {readFileSync}from'fs';import ge from'path';import {pathToFileURL}from'url';import {expect}from'@playwright/test';var ie=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies();}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>import('./MenuComponentStrategy-QHVBLUBR.js').then(t=>t.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>import('./AccordionComponentStrategy-S35ZYITU.js').then(t=>t.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>import('./ComboboxComponentStrategy-5AWO63DA.js').then(t=>t.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>import('./TabsComponentStrategy-DTQQUCK2.js').then(t=>t.TabsComponentStrategy)),this.builtInStrategies.set("radio",()=>import('./RadioComponentStrategy-TWMIMSYX.js').then(t=>t.RadioComponentStrategy)),this.builtInStrategies.set("checkbox",()=>import('./CheckboxComponentStrategy-ST2DWNYT.js').then(t=>t.CheckboxComponentStrategy)),this.builtInStrategies.set("toggle",()=>import('./ToggleComponentStrategy-UOGYK2U4.js').then(t=>t.ToggleComponentStrategy));}async loadStrategy(t,s,r){try{if(s)try{let n=ge.isAbsolute(s)?s:ge.resolve(r||process.cwd(),s),l=await import(pathToFileURL(n).href),i=l.default||l;if(!i)throw new Error(`No default export found in ${s}`);return i}catch(n){throw new Error(`Failed to load custom strategy from ${s}: ${n instanceof Error?n.message:String(n)}`)}let o=this.builtInStrategies.get(t);return o?o():null}catch(o){throw new Error(`Strategy loading failed for ${t}: ${o instanceof Error?o.message:String(o)}`)}}has(t,s){return !!s||this.builtInStrategies.has(t)}};var ne=class{static strategyRegistry=new ie;static isComponentConfig(t){return typeof t=="object"&&t!==null}static async detect(t,s,r=400,o=400,n){let l=this.isComponentConfig(s)?s:void 0,i=l?.contractPath;if(!i)throw new Error(`Contract path not found for component: ${t}`);let C=(()=>{if(ge.isAbsolute(i))return i;if(n){let se=ge.resolve(n,i);try{return readFileSync(se,"utf-8"),se}catch{}}let Q=ge.resolve(process.cwd(),i);try{return readFileSync(Q,"utf-8"),Q}catch{return new URL(i,import.meta.url).pathname}})(),k=readFileSync(C,"utf-8"),ee=JSON.parse(k).selectors,K=await this.strategyRegistry.loadStrategy(t,l?.strategyPath,n);if(!K)return null;let z=ee.main;return t==="tabs"?new K(z,ee):new K(z,ee,r,o)}};var oe=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=false;isCustomContract=false;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=false;hasPrintedDynamicSection=false;constructor(t=false,s=false){this.isPlaywright=t,this.isCustomContract=s;}log(t){process.stderr.write(t+`
2
+ `);}start(t,s,r){this.startTime=Date.now(),this.componentName=t,this.totalTests=s,this.hasPrintedStaticSection=false,this.hasPrintedDynamicSection=false,r&&(this.apgUrl=r);let o="Playwright (Real Browser)";this.log(`
3
+ ${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${t.charAt(0).toUpperCase()+t.slice(1)} Component - ${o}`),this.log(`${"\u2550".repeat(60)}
4
+ `);}reportStatic(t,s,r=0){this.staticPasses=t,this.staticFailures=s,this.staticWarnings=r;}reportStaticTest(t,s,r,o){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=true);let n=s==="pass"?"\u2713":s==="warn"?"\u26A0":s==="skip"?"\u25CB":"\u2717";this.log(` ${n} ${t}`),o&&this.log(` \u21B3 level=${o}`),(s==="fail"||s==="warn"||s==="skip")&&r&&this.log(` \u21B3 ${r}`);}reportTest(t,s,r){this.hasPrintedDynamicSection||(this.log(""),this.log(`${"\u2500".repeat(60)}`),this.log("\u2328\uFE0F Dynamic Interaction Tests"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedDynamicSection=true);let o={description:t.description,status:s,failureMessage:r,level:t.level};s==="skip"&&(o.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(o);let n={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},l=t.level?`[${t.level.toUpperCase()}] `:"";this.log(` ${n[s]} ${l}${t.description}`),s==="skip"&&!this.isPlaywright&&this.log(" \u21B3 Skipped (runs only in Playwright)"),s==="fail"&&r&&this.log(` \u21B3 ${r}`),s==="warn"&&r&&this.log(` \u21B3 ${r}`),s==="skip"&&r&&this.log(` \u21B3 ${r}`);}reportFailures(t){t.length!==0&&(this.log(`
5
+ ${"\u2500".repeat(60)}`),this.log(`\u274C Failures (${t.length}):
6
+ `),t.forEach((s,r)=>{this.log(`${r+1}. ${s}`),s.includes("aria-")?this.log(" \u{1F4A1} Add the missing ARIA attribute to improve screen reader support"):s.includes("focus")?this.log(" \u{1F4A1} Check keyboard event handlers and focus management"):s.includes("visible")&&this.log(" \u{1F4A1} Verify display/visibility styles and state management"),this.log("");}));}reportWarnings(){let t=this.dynamicResults.filter(s=>s.status==="warn");t.length===0&&this.staticWarnings===0||(this.log(`
7
+ ${"\u2500".repeat(60)}`),this.log(`\u26A0\uFE0F Warnings (${this.staticWarnings+t.length}):
8
+ `),this.log(`These checks are failing but treated as warnings under the active strictness mode.
9
+ `),t.forEach((s,r)=>{this.log(`${r+1}. ${s.description}`),s.failureMessage&&this.log(` \u21B3 ${s.failureMessage}`),s.level&&this.log(` \u21B3 level=${s.level}`);}),this.apgUrl&&this.log(`
10
+ Reference: ${this.apgUrl}
11
+ `));}reportSkipped(){if(this.skipped===0||this.isPlaywright)return;let t=this.dynamicResults.filter(s=>s.status==="skip");this.log(`
12
+ ${"\u2500".repeat(60)}`),this.log(`\u2139\uFE0F Skipped Tests (${this.skipped}):
13
+ `),this.log("These tests use native keyboard events via addEventListener,"),this.log(`which only run in Playwright (real browser).
14
+ `),t.forEach((s,r)=>{this.log(`${r+1}. ${s.description}`);}),this.log(`
15
+ \u{1F4A1} Run with Playwright for full validation:`),this.log(` testUiComponent('${this.componentName}', null, 'http://localhost:5173/test-harness?component=component_name')
16
+ `);}summary(t){let s=Date.now()-this.startTime,r=this.dynamicResults.filter(A=>A.status==="pass").length,o=this.dynamicResults.filter(A=>A.status==="fail").length,n=this.dynamicResults.filter(A=>A.status==="warn").length;this.skipped=this.dynamicResults.filter(A=>A.status==="skip").length,this.warnings=this.staticWarnings+n;let l=this.staticPasses+r,i=this.staticFailures+o,C=l+i+this.warnings,k=()=>{let A=`${this.componentName.charAt(0).toUpperCase()}${this.componentName.slice(1)}`;return this.isCustomContract?`${A} component validates against your custom accessibility policy \u2713`:`${A} component meets Aria-Ease baseline WAI-ARIA expectations \u2713`};return t.length>0&&this.reportFailures(t),this.reportWarnings(),this.reportSkipped(),this.log(`
17
+ ${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
18
+ `),i===0&&this.skipped===0&&this.warnings===0?(this.log(`\u2705 All ${C} tests passed!`),this.log(` ${k()}`)):i===0?(this.log(`\u2705 ${l}/${C} tests passed`),this.skipped>0&&this.log(`\u25CB ${this.skipped} tests skipped`),this.warnings>0&&this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings>1?"s":""}`),this.log(` ${k()}`)):(this.log(`\u274C ${i} test${i>1?"s":""} failed`),this.log(`\u2705 ${l} test${l>1?"s":""} passed`),this.warnings>0&&this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings>1?"s":""}`),this.skipped>0&&this.log(`\u25CB ${this.skipped} test${this.skipped>1?"s":""} skipped`)),this.log(`\u23F1\uFE0F Duration: ${s}ms`),this.log(`${"\u2550".repeat(60)}
19
+ `),i>0?(this.log("\u{1F527} Next Steps:"),this.log(" 1. Review the failures above"),this.log(" 2. Fix ARIA attributes and keyboard handlers"),this.log(` 3. Re-run tests to verify fixes
20
+ `)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
21
+ `),{passes:l,failures:i,skipped:this.skipped,duration:s}}error(t,s){this.log(`
22
+ \u274C Error: ${t}`),s&&this.log(` Context: ${s}`),this.log("");}};var N=class{constructor(t,s,r=400){this.page=t;this.selectors=s;this.timeoutMs=r;}isBrowserClosedError(t){return t instanceof Error&&t.message.includes("Target page, context or browser has been closed")}async focus(t,s,r){try{if(t==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let l=this.page.locator(n).first();return await l.count()?(await l.evaluate((C,k)=>{C.setAttribute("aria-activedescendant",k);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(t==="relative"&&s){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let l=await a$1.resolve(this.page,n,s);return l?(await l.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for focus.`}}let o=this.selectors[t];return o?(await this.page.locator(o).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${t} not found.`}}catch(o){return this.isBrowserClosedError(o)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${t}: ${o instanceof Error?o.message:String(o)}`}}}async type(t,s){try{let r=this.selectors[t];return r?(await this.page.locator(r).first().fill(s,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${t}: ${r instanceof Error?r.message:String(r)}`}}}async click(t,s){try{if(t==="document")return await this.page.mouse.click(10,10),{success:!0};if(t==="relative"&&s){let o=this.selectors.relative;if(!o)return {success:!1,error:"Relative selector not defined for click action."};let n=await a$1.resolve(this.page,o,s);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for click.`}}let r=this.selectors[t];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${t}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(t,s,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[s]||s;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),t==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let k=this.selectors.relative;if(!k)return {success:!1,error:"Relative selector not defined for keypress action."};let A=await a$1.resolve(this.page,k,r);return A?(await A.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let l=this.selectors[t];if(!l)return {success:!1,error:`Selector for keypress target ${t} not found.`};let i=this.page.locator(l).first();return await i.count()===0?{success:!1,error:`${t} element not found.`,shouldBreak:!0}:(await i.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(o){return this.isBrowserClosedError(o)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${s} on ${t}: ${o instanceof Error?o.message:String(o)}`}}}async hover(t,s){try{if(t==="relative"&&s){let o=this.selectors.relative;if(!o)return {success:!1,error:"Relative selector not defined for hover action."};let n=await a$1.resolve(this.page,o,s);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${s} for hover.`}}let r=this.selectors[t];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${t} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${t}: ${r instanceof Error?r.message:String(r)}`}}}};var te=class{constructor(t,s,r=400){this.page=t;this.selectors=s;this.timeoutMs=r;}async resolveTarget(t,s,r){try{if(t==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!s)return {target:null,error:"Relative target or expected value is not defined."};let l=await a$1.resolve(this.page,n,s);return l?{target:l}:{target:null,error:`Target ${t} not found.`}}let o=this.selectors[t];return o?{target:this.page.locator(o).first()}:{target:null,error:`Selector for assertion target ${t} not found.`}}catch(o){return {target:null,error:`Failed to resolve target ${t}: ${o instanceof Error?o.message:String(o)}`}}}async validateVisibility(t,s,r,o,n){try{return r?(await expect(t).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} is visible as expected. Test: "${n}".`}):(await expect(t).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} is not visible as expected. Test: "${n}".`})}catch{let l=this.selectors[s]||"",i=await this.page.evaluate(C=>{let k=C?document.querySelector(C):null;if(!k)return "element not found";let A=window.getComputedStyle(k);return `display:${A.display}, visibility:${A.visibility}, opacity:${A.opacity}`},l);return r?{success:false,failMessage:`${o} (actual: ${i})`}:{success:false,failMessage:`${o} ${s} is still visible (actual: ${i}).`}}}async validateAttribute(t,s,r,o,n,l){if(o==="!empty"){let k=await t.getAttribute(r);return k&&k.trim()!==""?{success:true,passMessage:`${s} has non-empty "${r}". Test: "${l}".`}:{success:false,failMessage:`${n} ${s} "${r}" should not be empty, found "${k}".`}}if(typeof o!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",o),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(o)}`);let i=o.split(" | ").map(k=>k.trim()),C=await t.getAttribute(r);return C!==null&&i.includes(C)?{success:true,passMessage:`${s} has expected "${r}". Test: "${l}".`}:{success:false,failMessage:`${n} ${s} "${r}" should be "${o}", found "${C}".`}}async validateValue(t,s,r,o,n){let l=await t.inputValue().catch(()=>"");return r==="!empty"?l&&l.trim()!==""?{success:true,passMessage:`${s} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should not be empty, found "${l}".`}:r===""?l===""?{success:true,passMessage:`${s} has empty value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should be empty, found "${l}".`}:l===r?{success:true,passMessage:`${s} has expected value. Test: "${n}".`}:{success:false,failMessage:`${o} ${s} value should be "${r}", found "${l}".`}}async validateFocus(t,s,r,o,n){try{return r?(await expect(t).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} has focus as expected. Test: "${n}".`}):(await expect(t).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${s} does not have focus as expected. Test: "${n}".`})}catch{let l=await this.page.evaluate(()=>{let i=document.activeElement;return i?`${i.tagName}#${i.id||"no-id"}.${i.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${o} (actual focus: ${l})`}}}async validateRole(t,s,r,o,n){let l=await t.getAttribute("role");return l===r?{success:true,passMessage:`${s} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${o} Expected role "${r}", found "${l}".`}}async validate(t,s){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,o;if(t.controlledBy){let n=t.controlledBy,l=this.selectors[n.target];if(!l)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let i=null;if(n.relativeTarget?i=await a$1.resolve(this.page,l,n.relativeTarget):i=this.page.locator(l).first(),!i)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let C=n.attribute||"aria-controls",k=await i.getAttribute(C);if(!k)return {success:false,failMessage:`Controlling element does not have attribute '${C}'.`,target:null};if(r=this.page.locator(`#${k}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${k}' not found.`,target:null}}else {let n=await this.resolveTarget(t.target,t.relativeTarget||t.expectedValue,t.selectorKey);if(r=n.target,o=n.error,o||!r)return {success:false,failMessage:o||`Target ${t.target} not found.`,target:null}}if(t.target==="input"&&t.attribute==="aria-activedescendant"&&t.expectedValue==="!empty"&&t.relativeTarget&&t.selectorKey){let n=await a$1.resolve(this.page,this.selectors[t.selectorKey],t.relativeTarget),l=n?await n.getAttribute("id"):null,i=await r.getAttribute("aria-activedescendant");return l&&i===l?{success:true,passMessage:`input[aria-activedescendant] matches id of ${t.relativeTarget}(${t.selectorKey}). Test: "${s}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${t.relativeTarget}(${t.selectorKey}), found "${i}".`}}switch(t.assertion){case "toBeVisible":return this.validateVisibility(r,t.target,true,t.failureMessage||"",s);case "notToBeVisible":return this.validateVisibility(r,t.target,false,t.failureMessage||"",s);case "toHaveAttribute":return t.attribute&&t.expectedValue!==void 0?this.validateAttribute(r,t.target,t.attribute,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return t.expectedValue!==void 0?this.validateValue(r,t.target,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,t.target,true,t.failureMessage||"",s);case "notToHaveFocus":return this.validateFocus(r,t.target,false,t.failureMessage||"",s);case "toHaveRole":return t.expectedValue!==void 0?this.validateRole(r,t.target,t.expectedValue,t.failureMessage||"",s):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${t.assertion}`}}}};async function nt(M,t,s,r,o){let n=r?.test?.components?.find(g=>g.name===M),l=!!n?.contractPath,i=new oe(true,l),C={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},k=r?.test?.disableTimeouts===true,ee=n?.disableTimeouts===true||k,K=(g,W,O)=>{if(ee)return 0;let L=g??W;return typeof L!="number"||!Number.isFinite(L)||L<0?O:L},z=K(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,C.actionTimeoutMs),Q=K(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,C.assertionTimeoutMs),se=K(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,C.navigationTimeoutMs),ce=K(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,C.componentReadyTimeoutMs),me=d(s),X=n?.contractPath;if(!X)throw new Error(`Contract path not found for component: ${M}`);let Ae=(()=>{if(ge.isAbsolute(X))return X;if(o){let W=ge.resolve(o,X);try{return readFileSync(W,"utf-8"),W}catch{}}let g=ge.resolve(process.cwd(),X);try{return readFileSync(g,"utf-8"),g}catch{return new URL(X,import.meta.url).pathname}})(),Me=readFileSync(Ae,"utf-8"),b=JSON.parse(Me),Ee=(b.relationships?.length||0)+(b.static.length||0)+b.dynamic.length,xe=b.meta?.source?.apg,V=[],q=[],J=[],E=[],v=null,x=(g,W)=>{let O=c(W),L=e(O,me);if(L==="error")return V.push(g),{status:"fail",level:O,detail:g};if(L==="warning")return q.push(g),{status:"warn",level:O,detail:g};let H=`${g} (ignored by strictness=${me}, level=${O})`;return E.push(H),{status:"skip",level:O,detail:H}},Pe=g=>g&&typeof g=="object"&&g.success===true;try{if(v=await a(),t){try{await v.goto(t,{waitUntil:"domcontentloaded",timeout:se});}catch(e){throw new Error(`Failed to navigate to ${t}. Ensure dev server is running and accessible. Original error: ${e instanceof Error?e.message:String(e)}`)}await v.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let g=await ne.detect(M,n,z,Q,o);if(!g)throw new Error(`Unsupported component: ${M}`);let W=g.getMainSelector();if(!W)throw new Error(`CRITICAL: No selector found in contract for ${M}`);try{await v.locator(W).first().waitFor({state:"attached",timeout:ce});}catch(e){throw new Error(`
23
+ \u274C CRITICAL: Component not found on page!
24
+ This usually means:
25
+ - The component didn't render
26
+ - The URL is incorrect
27
+ - The component selector '${W}' in the contract is wrong
28
+ - Original error: ${e}`)}i.start(M,Ee,xe),M==="menu"&&b.selectors.main&&await v.locator(b.selectors.main).first().waitFor({state:"visible",timeout:ce}).catch(()=>{});let O=M==="menu"&&b.selectors.submenuTrigger?await v.locator(b.selectors.submenuTrigger).count()>0:!1,L=e=>e.type==="aria-reference"&&[e.from,e.to].some(u=>["submenu","submenuTrigger","submenuItems"].includes(u||""))||e.type==="contains"&&[e.parent,e.child].some(u=>["submenu","submenuTrigger","submenuItems"].includes(u||"")),H=0,P=0,I=0;for(let e of b.relationships||[]){if(g&&typeof g.resetState=="function")try{await g.resetState(v);}catch(d){q.push(`Warning: resetState failed before relationship test: ${d instanceof Error?d.message:String(d)}`);}let u=c(e.level);if(Array.isArray(e.setup)&&e.setup.length>0){let w=function(c){return h.includes(c)};var ye=w;let d=new N(v,b.selectors,z),T=e.type==="aria-reference"?`${e.from}.${e.attribute} references ${e.to}`:`${e.parent} contains ${e.child}`,h=["focus","type","click","keypress","hover"],m=c=>({...c,type:w(c.type)?c.type:"click"}),$=e.setup.map(m),S=await le($,d,g,v,T,["submenu","submenuTrigger","submenuItems"]);if(S.skip){E.push(S.message||"Setup action skipped"),i.reportStaticTest(T,"skip",S.message,u);continue}if(!S.success){let c=`Relationship setup failed: ${S.error}`,a=x(c,e.level);a.status==="fail"&&(P+=1),a.status==="warn"&&(I+=1),i.reportStaticTest(T,a.status,a.detail,a.level);continue}}if(M==="menu"&&!O&&L(e)){let T=e.type==="aria-reference"?`${e.from}.${e.attribute} references ${e.to}`:`${e.parent} contains ${e.child}`,h="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";E.push(h),i.reportStaticTest(T,"skip",h,u);continue}if(e.type==="aria-reference"){let d=`${e.from}.${e.attribute} references ${e.to}`,T=b.selectors[e.from],h=b.selectors[e.to];if(!T||!h){let f=x(`Relationship selector missing: from="${e.from}" or to="${e.to}" not found in selectors.`,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(d,f.status,f.detail,f.level);continue}let w=v.locator(T).first(),m=v.locator(h).first(),$=await w.count()>0,S=await m.count()>0;if(!$||!S){if(M==="menu"&&L(e)){let B="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";E.push(B),i.reportStaticTest(d,"skip",B,u);continue}let f=x(`Relationship target not found: ${$?e.to:e.from}.`,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(d,f.status,f.detail,f.level);continue}let c=await w.getAttribute(e.attribute),a=await m.getAttribute("id");if(!a){let f=x(`Relationship target "${e.to}" must have an id for ${e.attribute} validation.`,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(d,f.status,f.detail,f.level);continue}if(!(c||"").split(/\s+/).filter(Boolean).includes(a)){let f=x(`Expected ${e.from} ${e.attribute} to reference id "${a}", found "${c||""}".`,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(d,f.status,f.detail,f.level);continue}J.push(`Relationship valid: ${e.from}.${e.attribute} -> ${e.to} (id=${a}).`),H+=1,i.reportStaticTest(d,"pass",void 0,u);continue}if(e.type==="contains"){let d=`${e.parent} contains ${e.child}`,T=b.selectors[e.parent],h=b.selectors[e.child];if(!T||!h){let c=x(`Relationship selector missing: parent="${e.parent}" or child="${e.child}" not found in selectors.`,e.level);c.status==="fail"&&(P+=1),c.status==="warn"&&(I+=1),i.reportStaticTest(d,c.status,c.detail,c.level);continue}let w=v.locator(T).first();if(!(await w.count()>0)){if(M==="menu"&&L(e)){let a="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";E.push(a),i.reportStaticTest(d,"skip",a,u);continue}let c=x(`Relationship parent target not found: ${e.parent}.`,e.level);c.status==="fail"&&(P+=1),c.status==="warn"&&(I+=1),i.reportStaticTest(d,c.status,c.detail,c.level);continue}if(await w.locator(h).count()<1){if(M==="menu"&&L(e)){let a="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";E.push(a),i.reportStaticTest(d,"skip",a,u);continue}let c=x(`Expected ${e.parent} to contain descendant matching selector for ${e.child}.`,e.level);c.status==="fail"&&(P+=1),c.status==="warn"&&(I+=1),i.reportStaticTest(d,c.status,c.detail,c.level);continue}J.push(`Relationship valid: ${e.parent} contains ${e.child}.`),H+=1,i.reportStaticTest(d,"pass",void 0,u);}}async function ve(e,u,d,T={}){if(!e||typeof e!="object"||!("ref"in e))return e;let h;if(e.ref==="relative"){if(!e.relativeTarget||!T.relativeBaseSelector)return;let w=d.locator(T.relativeBaseSelector),m=await w.count(),$=0;if(e.relativeTarget==="first"?$=0:e.relativeTarget==="second"?$=1:e.relativeTarget==="last"?$=m-1:isNaN(Number(e.relativeTarget))?$=0:$=Number(e.relativeTarget),$<0||$>=m)return;let S=w.nth($);return await we(S,e.property||e.attribute)}else {if(h=u[e.ref],!h)throw new Error(`Selector for ref '${e.ref}' not found in contract selectors.`);let w=d.locator(h).first();return await we(w,e.property||e.attribute)}}async function we(e,u){if(e)return !u||u==="id"?await e.getAttribute("id")??void 0:u==="class"?await e.getAttribute("class")??void 0:u==="textContent"?await e.evaluate(d=>d.textContent??void 0):u.startsWith("aria-")?await e.getAttribute(u)??void 0:u.endsWith("*")?await e.evaluate(T=>{let h=[];for(let w of Array.from(T.attributes))w.name.startsWith("aria-")&&h.push(`${w.name}=${w.value}`);return h.join(";")}):await e.getAttribute(u)??void 0}let Ie=new te(v,b.selectors,Q);async function le(e,u,d,T,h,w=[]){if(!Array.isArray(e)||e.length===0)return {success:!0};d&&typeof d.resetState=="function"&&await d.resetState(T);for(let m of e){let $={success:!0};try{if(m.type==="focus")m.target==="relative"&&m.relativeTarget?$=await u.focus("relative",m.relativeTarget):$=await u.focus(m.target);else if(m.type==="type"&&m.value)$=await u.type(m.target,m.value);else if(m.type==="click")$=await u.click(m.target,m.relativeTarget);else if(m.type==="keypress"&&m.key)$=await u.keypress(m.target,m.key,m.relativeTarget);else if(m.type==="hover")$=await u.hover(m.target,m.relativeTarget);else continue}catch(S){$={success:!1,error:S instanceof Error?S.message:String(S)};}if(!$.success){let S=$.error||"Setup action failed";return w.some(a=>h.includes(a)||S.includes(a))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${S}`}:{success:!1,error:S}}}return {success:!0}}for(let e of b.static||[]){if(g&&typeof g.resetState=="function")try{await g.resetState(v);}catch(c){q.push(`Warning: resetState failed before static test: ${c instanceof Error?c.message:String(c)}`);}if(e.target==="relative")continue;let u=`${e.target}${e.attribute?` (${e.attribute})`:""}`,d=c(e.level);if(M==="menu"&&e.target==="submenuTrigger"&&!O){let c=`Skipping submenu static assertion for ${e.target}: no submenu capability detected in rendered component.`;E.push(c),i.reportStaticTest(u,"skip",c,d);continue}let T=[];if(e.target||T.push("target"),e.attribute||T.push("attribute"),typeof e.expectedValue>"u"&&T.push("expectedValue"),T.length>0){let c=`${e.target||""}${e.attribute?` (${e.attribute})`:""}`,a=`Static assertion missing required field(s): ${T.join(", ")}`,y=x(a,e.level);y.status==="fail"&&(P+=1),y.status==="warn"&&(I+=1),i.reportStaticTest(c,y.status,y.detail,y.level);continue}if(Array.isArray(e.setup)&&e.setup.length>0){let y=function(D){return a.includes(D)};var ye=y;let c=new N(v,b.selectors,z),a=["focus","type","click","keypress","hover"],F=D=>({...D,type:y(D.type)?D.type:"click"}),f=e.setup.map(F),B=await le(f,c,g,v,u,["submenu","submenuTrigger","submenuItems"]);if(B.skip){E.push(B.message||"Setup action skipped"),i.reportStaticTest(u,"skip",B.message,d);continue}if(!B.success){let D=`Static setup failed: ${B.error}`,G=x(D,e.level);G.status==="fail"&&(P+=1),G.status==="warn"&&(I+=1),i.reportStaticTest(u,G.status,G.detail,G.level);continue}}let h=b.selectors[e.target];if(!h){let c=`Selector for target ${e.target} not found.`,a=x(c,e.level);a.status==="fail"&&(P+=1),a.status==="warn"&&(I+=1),i.reportStaticTest(u,a.status,a.detail,a.level);continue}let w=v.locator(h).first();if(!(await w.count()>0)){let c=`Target ${e.target} not found.`,a=x(c,e.level);a.status==="fail"&&(P+=1),a.status==="warn"&&(I+=1),i.reportStaticTest(u,a.status,a.detail,a.level);continue}let $=(c,a,y)=>{let F=new RegExp(`\\[${a}(?:=["']?([^\\]"']+)["']?)?\\]`),f=c.match(F);if(!f)return !1;if(!y)return !0;let B=f[1];return B?y.split(" | ").includes(B):!1},S=e.expectedValue;if(e.expectedValue&&typeof e.expectedValue=="object"&&"ref"in e.expectedValue){let c={},a=e.relativeTarget;if(e.expectedValue.ref==="relative"&&e.target==="relative"&&a){let y=b.selectors[a];if(!y)throw new Error(`Selector for relativeTarget '${a}' not found in contract selectors.`);c.relativeBaseSelector=y;}else if(e.expectedValue.ref==="relative"&&a){let y=b.selectors[a];if(!y)throw new Error(`Selector for relativeTarget '${a}' not found in contract selectors.`);c.relativeBaseSelector=y;}S=await ve(e.expectedValue,b.selectors,v,c);}if(e.expectedValue)if($(h,e.attribute,typeof S=="string"?S:void 0))J.push(`${e.attribute}="${S}" on ${e.target} verified by selector (already present in: ${h}).`),H+=1,i.reportStaticTest(u,"pass",void 0,d);else {let c=S??"",a=await Ie.validateAttribute(w,e.target,e.attribute,c,e.failureMessage,"Static ARIA Test");if(a.success&&a.passMessage)J.push(a.passMessage),H+=1,i.reportStaticTest(u,"pass",void 0,d);else if(!a.success&&a.failMessage){let y=x(a.failMessage,e.level);y.status==="fail"&&(P+=1),y.status==="warn"&&(I+=1),i.reportStaticTest(u,y.status,y.detail,y.level);}}else {let c=e.attribute.split(" | "),a=!1,y=!0;for(let F of c){let f=F.trim();if($(h,f)){J.push(`${f} on ${e.target} verified by selector (already present in: ${h}).`),a=!0;continue}if(y=!1,await w.getAttribute(f)!==null){a=!0;break}}if(!a&&!y){let F=e.failureMessage+` None of the attributes "${e.attribute}" are present.`,f=x(F,e.level);f.status==="fail"&&(P+=1),f.status==="warn"&&(I+=1),i.reportStaticTest(u,f.status,f.detail,f.level);}else !y&&a?(J.push(`At least one of the attributes "${e.attribute}" exists on the element.`),H+=1,i.reportStaticTest(u,"pass",void 0,d)):(H+=1,i.reportStaticTest(u,"pass",void 0,d));}}for(let e of b.dynamic||[]){if(!e.assertions||e.assertions.length===0){let p="Skipping test - no assertions found for this dynamic test.";E.push(p),i.reportTest({description:e.description,level:c(e.level)},"skip",p);continue}if(!v||v.isClosed()){console.warn(`
29
+ \u26A0\uFE0F Browser closed - skipping remaining ${b.dynamic.length-b.dynamic.indexOf(e)} tests
30
+ `),V.push(`CRITICAL: Browser/page closed before completing all tests. ${b.dynamic.length-b.dynamic.indexOf(e)} tests skipped.`);break}try{await g.resetState(v);}catch(p){let R=p instanceof Error?p.message:String(p);throw i.error(R),p}let{setup:u=[],action:d,assertions:T}=e,h=c(e.level),w=new N(v,b.selectors,z);if(Array.isArray(u)&&u.length>0){let R=function(U){return p.includes(U)};var ye=R;let p=["focus","type","click","keypress","hover"],Y=U=>({...U,type:R(U.type)?U.type:"click"}),ue=u.map(Y),j=await le(ue,w,g,v,e.description,["submenu","submenuTrigger","submenuItems"]);if(j.skip){E.push(j.message||"Setup action skipped"),i.reportTest({description:e.description,level:h},"skip",j.message);continue}if(!j.success){let U=x(`Setup failed: ${j.error}`,e.level);i.reportTest({description:e.description,level:h},U.status,U.detail);continue}}let m=V.length,$=q.length,S=E.length;if(await g.shouldSkipTest(e,v)){let p="Skipping test - component-specific conditions not met";E.push(p),i.reportTest({description:e.description,level:h},"skip",p);continue}let a=new te(v,b.selectors,Q),y=!1,F=null;for(let p of d){if(!v||v.isClosed()){V.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),y=!0;break}let R;if(p.type==="focus")p.target==="relative"&&p.relativeTarget?R=await w.focus("relative",p.relativeTarget):R=await w.focus(p.target);else if(p.type==="type"&&p.value)R=await w.type(p.target,p.value);else if(p.type==="click")R=await w.click(p.target,p.relativeTarget);else if(p.type==="keypress"&&p.key)R=await w.keypress(p.target,p.key,p.relativeTarget);else if(p.type==="hover")R=await w.hover(p.target,p.relativeTarget);else continue;if(!R.success){if(R.error){let Y=x(R.error,e.level);F={status:Y.status,detail:Y.detail};}y=!0;break}}if(y){i.reportTest({description:e.description,level:h},F?.status||"fail",F?.detail||V[V.length-1]);continue}let f=!1,B="";for(let p of T){let R;if(p.expectedValue&&typeof p.expectedValue=="object"&&"ref"in p.expectedValue)if(p.expectedValue.ref==="relative"){let{RelativeTargetResolver:Be}=await import('./RelativeTargetResolver-5SIQLWPN.js'),U=b.selectors.relative;if(!U)throw new Error("Relative selector not defined in contract selectors.");let $e=p.relativeTarget||"first",pe=await Be.resolve(v,U,$e);if(!pe)throw new Error(`Could not resolve relative target '${$e}' for expectedValue.`);let Te=p.expectedValue.property||p.expectedValue.attribute||"id";if(Te==="textContent")R=await pe.evaluate(re=>re.textContent??void 0);else {let re=await pe.getAttribute(Te);R=re===null?void 0:re;}}else R=await ve(p.expectedValue,b.selectors,v,{});else typeof p.expectedValue=="string"||typeof p.expectedValue>"u"?R=p.expectedValue:R="";let Y={...p,expectedValue:R},ue=R??"",j=await a.validate({...Y,expectedValue:ue},e.description);Pe(j)?J.push(j.passMessage):(f=!0,B=j.failMessage||"Assertion failed.");}if(f){i.reportTest({description:e.description,level:h},"fail",B);continue}let be=V.length,D=q.length,G=E.length;be>m?i.reportTest({description:e.description,level:h},"fail",V[V.length-1]):D>$?i.reportTest({description:e.description,level:h},"warn",q[q.length-1]):G>S?i.reportTest({description:e.description,level:h},"skip",E[E.length-1]):i.reportTest({description:e.description,level:h},"pass");}i.reportStatic(H,P,I),i.summary(V);}catch(g){if(g instanceof Error)throw g.message.includes("Executable doesn't exist")||g.message.includes("browserType.launch")?new Error(`
31
+ \u274C CRITICAL: Playwright browsers not found!
32
+ \u{1F4E6} Run: npx playwright install chromium`):g.message.includes("net::ERR_CONNECTION_REFUSED")||g.message.includes("NS_ERROR_CONNECTION_REFUSED")?new Error(`
33
+ \u274C CRITICAL: Cannot connect to dev server!
34
+ Make sure your dev server is running at ${t}`):g.message.includes("Timeout")&&g.message.includes("waitFor")?new Error(`
35
+ \u274C CRITICAL: Component not found on page!
36
+ The component selector could not be found within ${ce}ms.
37
+ This usually means:
38
+ - The component didn't render
39
+ - The URL is incorrect
40
+ - The component selector was not provided to the component utility, or a wrong selector was used
41
+ `):g.message.includes("Target page, context or browser has been closed")?new Error(`
42
+ \u274C CRITICAL: Browser/page was closed unexpectedly!
43
+ This usually means:
44
+ - The test timeout was too short
45
+ - The browser crashed
46
+ - An external process killed the browser`):g}finally{v&&await v.close();}return {passes:J,failures:V,skipped:E,warnings:q}}export{nt as runContractTestsPlaywright};
@@ -1 +1 @@
1
- 'use strict';function l(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 k={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:C},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...D(),...T()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:q},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:I},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:B},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:F},"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={})=>H(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:V},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:T},"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={})=>R(e.relativeTarget)}};function C(){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 D(){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 H(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 V(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function T(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function R(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${l("option",e)} to have aria-selected='true'.`}]}function q(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function I(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function B(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function F(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var x={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:P},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:$},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:O},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:z},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>L(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:K},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:U},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:j},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:J},"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={})=>G(e.relativeTarget)}};function P(){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 $(){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 O(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function z(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function L(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function K(){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 U(){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 j(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function J(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function G(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var A={"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={})=>W(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>X(e.relativeTarget)}};function X(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have focus.`}]}function N(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have tabindex='0'.`}]}function W(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${l("tab",e)} to be visible.`},N(e)]}var w={"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={})=>Q(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Y(e.relativeTarget)}};function Q(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 Y(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 S={"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={})=>Z(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ee(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>te(e.relativeTarget)}};function Z(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function ee(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function te(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("radio",e)} to have focus.`}]}var E={"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={})=>re(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ie(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ae(e.relativeTarget)}};function re(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function ie(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function ae(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("checkbox",e)} to have focus.`}]}var M={"toggle.pressed":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>se(e.relativeTarget)},"toggle.unpressed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ne(e.relativeTarget)},"toggle.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>oe(e.relativeTarget)}};function se(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"true",failureMessage:"Expected toggle to have aria-pressed='true' when pressed."}]}function ne(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"false",failureMessage:"Expected toggle to have aria-pressed='false' when unpressed."}]}function oe(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("toggle",e)} to have focus.`}]}function ue(e,t){return t.some(c=>e.capabilities.includes(c))}function m(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(ue(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var pe={combobox:k,menu:x,tabs:A,accordion:w,radio:S,checkbox:E,toggle:M},y=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},f=class{constructor(t){this.componentName=t;this.statePack=pe[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},d=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let n=c[o];if(!n)return [];let r=[];if(Array.isArray(n.requires))for(let a of n.requires)r=r.concat(d(a,i));return n.setup&&(r=r.concat(m(n.setup,p))),r};return t({ariaReference:(o,i,n)=>({requires:r=>{let a=d(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required",setup:a}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional",setup:a}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended",setup:a})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended"})}),contains:(o,i)=>({requires:n=>{let r=d(n,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let d=i=>{let n=this.statePack,r={capabilities:["keyboard"]},a=(s,u=new Set)=>{if(u.has(s))return [];u.add(s);let v=n[s];if(!v)return [];let b=[];if(Array.isArray(v.requires))for(let _ of v.requires)b=b.concat(a(_,u));return v.setup&&(b=b.concat(m(v.setup,r))),b};return a(i,new Set)},g=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,n,r)=>{let a=g(i);return {required:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,n)=>({...o(i,n),requires:a=>{let s=d(a);return o(i,n,s)}})}}}),this}when(t){return new h(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}}},h=class{constructor(t,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,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(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_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 p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},d=(r,a=new Set)=>{if(a.has(r))return [];a.add(r);let s=this.statePack[r];if(!s)return [];let u=[];if(Array.isArray(s.requires))for(let v of s.requires)u=u.concat(d(v,a));return s.setup&&(u=u.concat(m(s.setup,p))),u},g=[];for(let r of this._given)if(typeof r=="string")g.push(...d(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.setup)for(let u of s.setup)typeof u.steps=="function"?g.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&g.push(...u.steps);}}let o=new Set;g=g.filter(r=>{let a=JSON.stringify(r);return o.has(a)?false:(o.add(a),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let a=this.statePack[r];if(a&&a.assertion!==void 0){let s=a.assertion;if(typeof s=="function")try{s=s();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(s)?i.push(...s):i.push(s);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.assertion!==void 0){let u=s.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(v){throw new Error(`Error calling assertion function for state '${a}': ${v.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let n=[{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:n,assertions:i,...g.length?{setup:g}:{}});}};function Re(e,t){let c=new f(e);return t(c),new y(c.build())}exports.createContract=Re;
1
+ 'use strict';function o(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:C},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...D(),...k()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:B},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:I},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:F},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:$},"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={})=>R(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:V},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:k},"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={})=>q(e.relativeTarget)}};function C(){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 D(){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 R(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 V(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function k(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function q(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${o("option",e)} to have aria-selected='true'.`}]}function B(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function I(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function F(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function $(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var A={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:P},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:O},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:z},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:L},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>j(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:U},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:K},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:J},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:G},"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={})=>X(e.relativeTarget)}};function P(){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 O(){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 z(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function L(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function j(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function U(){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 K(){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 J(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function G(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function X(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var w={"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={})=>Y(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>N(e.relativeTarget)},"tab.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>W(e.relativeTarget)}};function N(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("tab",e)} to have focus.`}]}function W(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("tab",e)} not to have focus.`}]}function Q(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${o("tab",e)} to have tabindex='0'.`}]}function Y(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${o("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${o("tab",e)} to be visible.`},Q(e)]}var S={"panel.expanded":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Z(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ee(e.relativeTarget)},"trigger.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>te(e.relativeTarget)},"trigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>re(e.relativeTarget)}};function Z(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 ee(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 te(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("trigger",e)} to have focus.`}]}function re(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("trigger",e)} not to have focus.`}]}var E={"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={})=>ie(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ae(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>se(e.relativeTarget)},"radio.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ne(e.relativeTarget)}};function ie(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function ae(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function se(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("radio",e)} to have focus.`}]}function ne(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("radio",e)} not to have focus.`}]}var M={"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={})=>oe(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ue(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>pe(e.relativeTarget)},"checkbox.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ce(e.relativeTarget)}};function oe(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function ue(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 ${o("checkbox",e)} to have focus.`}]}function ce(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("checkbox",e)} not to have focus.`}]}var H={"toggle.pressed":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>le(e.relativeTarget)},"toggle.unpressed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ge(e.relativeTarget)},"toggle.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>de(e.relativeTarget)},"toggle.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ve(e.relativeTarget)}};function le(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"true",failureMessage:"Expected toggle to have aria-pressed='true' when pressed."}]}function ge(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"false",failureMessage:"Expected toggle to have aria-pressed='false' when unpressed."}]}function de(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("toggle",e)} to have focus.`}]}function ve(e){return [{target:"relative",assertion:"notToHaveFocus",relativeTarget:e,failureMessage:`Expected ${o("toggle",e)} not to have focus.`}]}function be(e,t){return t.some(l=>e.capabilities.includes(l))}function f(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let l of e)if(be(t,l.when))return l.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var me={combobox:x,menu:A,tabs:w,accordion:S,radio:E,checkbox:M,toggle:H},h=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},y=class{constructor(t){this.componentName=t;this.statePack=me[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let l=this.statePack,u={capabilities:["keyboard"]},v=(n,i=new Set)=>{if(i.has(n))return [];i.add(n);let s=l[n];if(!s)return [];let r=[];if(Array.isArray(s.requires))for(let a of s.requires)r=r.concat(v(a,i));return s.setup&&(r=r.concat(f(s.setup,u))),r};return t({ariaReference:(n,i,s)=>({requires:r=>{let a=v(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:i,to:s,level:"required",setup:a}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:i,to:s,level:"optional",setup:a}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:i,to:s,level:"recommended",setup:a})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:i,to:s,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:i,to:s,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:i,to:s,level:"recommended"})}),contains:(n,i)=>({requires:s=>{let r=v(s,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:i,level:"recommended"})})}),this}static(t){return t({target:u=>{let v=i=>{let s=this.statePack,r={capabilities:["keyboard"]},a=(p,c=new Set)=>{if(c.has(p))return [];c.add(p);let g=s[p];if(!g)return [];let b=[];if(Array.isArray(g.requires))for(let m of g.requires)b=b.concat(a(m,c));return g.setup&&(b=b.concat(f(g.setup,r))),b};return a(i,new Set)},d=i=>i==="role"?"toHaveRole":"toHaveAttribute",n=(i,s,r)=>{let a=d(i);return {required:()=>this.staticAssertions.push({target:u,assertion:a,attribute:i,expectedValue:s,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:u,assertion:a,attribute:i,expectedValue:s,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:u,assertion:a,attribute:i,expectedValue:s,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,s)=>({...n(i,s),requires:a=>{let p=v(a);return n(i,s,p)}})}}}),this}when(t){return new T(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}}},T=class{constructor(t,l,u){this.parent=t;this.statePack=l;this.event=u;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,l){return this._onTarget=t,this._onRelativeTarget=l,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(u=>typeof u=="string"?[u]:typeof u=="object"&&u!==null&&"type"in u&&"ref"in u?this._findStateKeyByTypeAndRef(u.type)?[{type:u.type,ref:u.ref}]:[]:[u])}_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 u={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},v=(r,a=new Set,p)=>{if(a.has(r))return [];a.add(r);let c=this.statePack[r];if(!c)return [];let g=[];if(Array.isArray(c.requires))for(let b of c.requires)g=g.concat(v(b,a,p));if(c.setup){let b=c.setup.filter(m=>m.when.some(_=>u.capabilities.includes(_)));for(let m of b)typeof m.steps=="function"?g=g.concat(m.steps({relativeTarget:p})):g=g.concat(m.steps);}return g},d=[];for(let r of this._given)typeof r=="string"?d=d.concat(v(r,new Set)):typeof r=="object"&&r.type&&(d=d.concat(v(r.type,new Set,r.ref)));let n=new Set;d=d.filter(r=>{let a=[r.type,r.target,r.relativeTarget].join(":");return n.has(a)?false:(n.add(a),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let a=this.statePack[r];if(a&&a.assertion!==void 0){let p=a.assertion;if(typeof p=="function")try{p=p();}catch(c){throw new Error(`Error calling assertion function for state '${r}': ${c.message}`)}Array.isArray(p)?i.push(...p):i.push(p);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let p=this.statePack[a];if(p&&p.assertion!==void 0){let c=p.assertion;if(typeof c=="function")try{c=c({relativeTarget:r.ref});}catch(g){throw new Error(`Error calling assertion function for state '${a}': ${g.message}`)}Array.isArray(c)?i.push(...c):i.push(c);}}}let s=[{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:s,assertions:i,...d.length?{setup:d}:{}});}};function ze(e,t){let l=new y(e);return t(l),new h(l.build())}exports.createContract=ze;