$(document).ready(function(){RichTextEditor.Init();document.addEventListener("SmoothStateLoaded",function(){RichTextEditor.Init()})});var RichTextEditor=function(){return{Init:function(){this.Iframes.init();this.Buttons.init();this.Tables.init();this.GlossaryTerms.init();this.Footnotes.init()},Iframes:{init:function(){var n=$(".editable-text iframe");n.each(function(){var n=$(this),t=n.attr("width"),i=n.attr("height"),r=56.25;isNaN(t)||isNaN(i)||(r=i/t*100);n.attr("data-wrap")!=="false"&&n.wrap('<div class="e-responsive-iframe" style="padding-bottom:'+r+'%"><\/div>')})}},Buttons:{init:function(){$('.editable-text a[href="#send-feedback"]').attr("role","button").attr("data-js-open-modal","#feedback-form-modal").attr("href","#")}},Tables:{dec2hex:function(n){return n.toString(16).padStart(2,"0")},generateId:function(n){var t=new Uint8Array((n||40)/2);return window.crypto.getRandomValues(t),Array.from(t,this.dec2hex).join("")},init:function(){document.querySelectorAll(".editable-text table").forEach(n=>{const i=this.generateId(6),r=[],t=[];for(let u=0;u<n.rows.length;u++){const f=n.rows[u];if(u>0){const f=Array.from(n.rows[u-1].cells).reduce(function(n,t,r){return t.tagName==="TH"&&t.scope==="col"&&t.id===""&&(t.id=`t${i}-r${u-1}-c${r}`),n.concat(Array(t.colSpan)).fill(t.tagName==="TH"&&t.scope==="col"?t:null,-t.colSpan)},[]);for(const n of t)n.rowIndex!==u-1&&f.splice(n.virtualIndex,0,...Array(n.element.colSpan).fill(n.element.tagName==="TH"?n.element:null,0));f.some(n=>n!==null)&&r.push(f)}for(const n of t)n.endIndex<=u&&t.splice(t.indexOf(n));const e=[];for(let n=0;n<f.cells.length;n++){const o=f.cells[n],s=t.reduce((n,t)=>t.virtualIndex<=n&&(n+=t.element.colSpan),n,e.reduce((n,t)=>n+t.colSpan,0)),h=Array.from(f.cells).filter(t=>t.tagName==="TH"&&t.cellIndex<n&&t.scope==="row");h.push(...t.filter(n=>n.element.tagName==="TH"&&n.element.scope==="row"&&n.virtualIndex<s).map(n=>n.element));h.push(...r.flatMap(n=>n.slice(s,s+o.colSpan)).filter(n=>n!==null));o.tagName==="TH"&&o.id===""&&(o.id=`t${i}-c${o.cellIndex}-r${u}`);o.rowSpan>1?t.push({rowIndex:u,endIndex:u+o.rowSpan,element:o,inlineIndex:o.cellIndex,virtualIndex:s}):e.push(o);o.headers=h.filter((n,t)=>h.indexOf(n)===t).map(n=>n.id).join(" ")}}})}},GlossaryTerms:{dictionary:new Map,init:function(){this.loadData().then(n=>{n&&this.setTooltips()});document.addEventListener("SmoothStateLoaded",()=>{this.init()})},setTooltips:function(){document.querySelectorAll(".editable-text [data-glossary-term]").forEach(n=>{const t=this.dictionary.get(n.getAttribute("data-glossary-term"));if(window.Popper){let i=n.querySelector("[data-glossary-tooltip]");i||(i=document.createElement("span"),i.className="glossary-tooltip",i.textContent=t,i.insertAdjacentHTML("beforeend",'<span class="glossary-tooltip-arrow" data-popper-arrow><\/span>'),n.appendChild(i));let r=Popper.createPopper(n,i,{placement:"top",modifiers:[{name:"offset",options:{offset:[0,12]}}]});n.addEventListener("mouseenter",()=>{i.classList.add("is-expanded"),r.update()});n.addEventListener("mouseleave",()=>{i.classList.remove("is-expanded")})}else n.setAttribute("title",t)})},loadData:function(){var i=document.querySelectorAll(".editable-text [data-glossary-term]"),n,t;return i.length?(n=[...new Set(Array.from(i).map(n=>n.getAttribute("data-glossary-term")))].filter(n=>!this.dictionary.has(n)),!n.length)?Promise.resolve(!0):(t=new URL("/AIHWWebServices/GlossaryService.asmx/GetDefinitions",window.location.origin),t.searchParams.append("idPaths",JSON.stringify(n)),fetch(t,{method:"GET",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"}}).then(n=>n.json()).then(n=>{for(let t=0;t<n.d.length;t++){const i=n.d[t];this.dictionary.set(i.path,i.definition)}return!0})):Promise.resolve(!1)}},Footnotes:{containers:[],init:function(){(this.containers=Array.from(document.querySelectorAll('[id^="footnotes"]')).map(n=>({id:n.id,element:n,lastClicked:null,backToContent:null})),this.containers.length)&&(document.querySelectorAll('a[href^="#footnotes"]').forEach(n=>{n.addEventListener("click",()=>{const t=this.containers.find(t=>t.id===new URL(n.href).hash.substring(1));t&&(t.lastClicked=n,this.updateBackToContent())})}),this.updateBackToContent())},updateBackToContent:function(){for(const n of this.containers){const i=document.querySelectorAll(`a[href$="#${n.id}"]`).length;if(i<1){n.backToContent&&(n.backToContent.remove(),n.backToContent=null);continue}const t=i>1;n.backToContent||(n.backToContent=document.createElement("a"),n.backToContent.classList.add("e-footnotes-back"),n.backToContent.href="#",n.backToContent.textContent="Back to content",n.backToContent.addEventListener("click",i=>{i.preventDefault();history.replaceState("","",location.pathname+location.search);let r;if(t?n.lastClicked&&(r=n.lastClicked):r=document.querySelector(`a[href$="#${n.id}"]`),r){const n=r.getBoundingClientRect().top+window.scrollY-window.innerHeight/2;"scrollBehavior"in document.documentElement.style?window.scrollTo({top:n,behavior:"smooth"}):window.scrollTo(0,n);r.focus({preventScroll:!0})}}),n.element.appendChild(document.createTextNode(" ")),n.element.appendChild(n.backToContent));n.backToContent.style.display=!t||n.lastClicked?"":"none";n.backToContent.classList.toggle("is-multi-mode",t)}}}}}()