(()=>{"use strict";const e="update",t="remove";class n{constructor(e,t){this.dom=e,this.data=t}run(){throw new Error(`Action type '${this.data.type}' - not implemented`)}getElementByXPath(e){return this.dom.evaluate(e,this.dom,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}createElement(e,t=[],n=""){const i=document.createElement(e);return t.forEach(e=>{i.setAttribute(e.name,e.value)}),n&&(i.textContent=n),i}}class i extends n{run(){const{xpath:n,action:i,attribute_name:r,attribute_value:a}=this.data,s=n.replace("svg","*[name()='svg']"),o=this.getElementByXPath(s);if(!o)return!1;switch(i){case"add":case e:o.setAttribute(r,a);const n={alt:["role","title"],role:["alt","title"]};n[r]&&n[r].forEach(e=>o.removeAttribute(e));break;case t:o.removeAttribute(r);break;case"clear":o.setAttribute(r,"")}return!0}}class r extends n{run(){const{xpath:n,action:i,content:r,child:a}=this.data,s=this.getElementByXPath(n);if(!s)return!1;let o=null;if(a)try{o=this.createElement(a.tag,a.attributes||[],a.content||"")}catch(e){return}switch(i){case e:s.nodeValue=r;break;case t:s.remove();break;case"add_child":o&&s.appendChild(o);break;case"remove_child":o&&s.removeChild(o);break;case"add_before":o&&s.parentNode&&s.parentNode.insertBefore(o,s);break;case"add_after":o&&s.parentNode&&s.parentNode.insertBefore(o,s.nextSibling)}return!0}}class a extends n{run(){const{xpath:e,find:t,replace:n}=this.data,i=this.getElementByXPath(e);if(!i)return!1;const r=i.outerHTML;if("string"!=typeof t||"string"!=typeof n)return!1;if(!r.includes(t))return!1;const a=r.replace(t,n);if(a===r)return!1;const s=document.createElement("div");s.innerHTML=a;const o=s.firstElementChild;return o&&i.parentNode&&i.parentNode.replaceChild(o,i),!0}}class s{constructor(e){this.remediations=e,this.classMap={attribute:i,element:r,replace:a},this.checkTimeout=null,this.runAll()}runAll(){this.remediations=this.remediations.filter(e=>!this.runRemediation(e))}runRemediation(e){const t=(e.type||"").toLowerCase(),n=this.classMap[t];if(n)try{return new n(document,e).run()}catch(t){window.AllyRemediations?.debug&&window.AllyRemediations.debug&&console.error("Remediation failed",t,e)}return!1}checkRemediations(){this.isComplete()||this.runAll()}isComplete(){return 0===this.remediations.length}}if(window?.AllyRemediations&&Array.isArray(window.AllyRemediations?.remediations)){let o=null,l=null,d=!1;function c(){d?o.runAll():(d=!0,o=new s(window.AllyRemediations.remediations),window.MutationObserver&&o.remediations.length>0&&(l=new MutationObserver(e=>{let t=!1;for(const n of e)if("childList"===n.type&&n.addedNodes.length>0){t=!0;break}t&&(clearTimeout(o.checkTimeout),o.checkTimeout=setTimeout(()=>{o.checkRemediations(),o.isComplete()&&l&&(l.disconnect(),l=null)},100))}),l.observe(document.body,{childList:!0,subtree:!0})))}window.addEventListener("DOMContentLoaded",function(){setTimeout(()=>{c()},400)}),"loading"!==document.readyState&&setTimeout(()=>{c()},400)}})();