function scrollToQueryId(queryId){
const targetElement=document.getElementById(`uagb-block-queryid-${queryId}`);
if(targetElement){
const rect=targetElement.getBoundingClientRect();
const adminBar=document.querySelector('#wpadminbar');
const adminBarOffSetHeight=adminBar?.offsetHeight||0;
const scrollTop=window?.pageYOffset||document?.documentElement?.scrollTop;
const targetOffset=(rect?.top + scrollTop) - adminBarOffSetHeight;
window.scrollTo({
top: targetOffset,
behavior: 'smooth'
});
}}
function findAncestorWithClass(element, className){
while(element&&! element.classList.contains(className) ){
element=element.parentNode;
}
return element;
}
document.addEventListener('DOMContentLoaded', function (){
function debounce(func, wait){
let timeout;
return function executedFunction(...args){
const context=this;
const later=()=> {
timeout=null;
func.apply(context, args);
};
clearTimeout(timeout);
timeout=setTimeout(later, wait);
};};
async function updateContent(event, paged=null, buttonFilter=null, current=null, loopParentContainer){
try{
const loopBuilder=loopParentContainer;
const search=loopBuilder?.querySelector('.uagb-loop-search' )?.value;
const sorting=loopBuilder?.querySelector('.uagb-loop-sort' )?.value;
const category=current?.value;
const categoryButtonFilterContainer=loopBuilder?.querySelector('.uagb-loop-category-inner');
const formData=new FormData();
if(search){
formData.append('search', search);
}
if(sorting){
formData.append('sorting', sorting);
}
if(category){
formData.append('category', category);
}
const checkBoxValues=loopParentContainer?.querySelectorAll('.uagb-cat-checkbox');
const checkedValues=[];
checkBoxValues?.forEach(checkBoxVal=> {
const isChecked=checkBoxVal.checked;
if(isChecked&&checkBoxVal.getAttribute('data-uagb-block-query-id')===event.target.dataset.uagbBlockQueryId){
checkedValues.push(checkBoxVal.value);
}});
if(checkedValues){
formData.append('checkbox', checkedValues);
}
if(paged){
formData.append('paged', paged);
}
if(buttonFilter){
formData.append('buttonFilter', JSON.stringify(buttonFilter.type) );
}
const queryId=event.target?.dataset?.uagbBlockQueryId||event.target?.parentElement?.dataset?.uagbBlockQueryId||categoryButtonFilterContainer?.dataset?.uagbBlockQueryId||event?.dataset?.uagbBlockQueryId||event.target.closest('a' )?.getAttribute('data-uagb-block-query-id');
scrollToQueryId(queryId);
formData.append('queryId', queryId);
formData.append('block_id', loopBuilder?.getAttribute('data-block_id') );
const output=await getUpdatedLoopWrapperContent(formData);
const loopElement=loopBuilder?.querySelector('#uagb-block-queryid-' + queryId);
if(loopElement&&output?.content?.wrapper){
loopElement.innerHTML=output.content.wrapper;
}
const loopPaginationContainers=loopBuilder?.querySelectorAll('#uagb-block-pagination-queryid-'+queryId);
if(loopPaginationContainers&&output?.content?.pagination){
loopPaginationContainers.innerHTML=output?.content?.pagination;
}
loopPaginationContainers?.forEach(loopPaginationContainer=> {
loopPaginationContainer.innerHTML=output.content.pagination;
});
} catch(error){
throw error;
}}
function handleInput(event){
const loopParentContainer=this.closest('.wp-block-uagb-loop-builder');
const searchInputs=loopParentContainer.querySelectorAll('.uagb-loop-search');
searchInputs.forEach(searchInput=> {
if(searchInput.getAttribute('data-uagb-block-query-id')===event.target.dataset.uagbBlockQueryId){
searchInput.value=event.target.value;
}});
updateContent(event, null, null, null, loopParentContainer);
}
function handleCheckBoxVal(event){
const loopParentContainer=this.closest('.wp-block-uagb-loop-builder');
const checkBoxValues=loopParentContainer.querySelectorAll('.uagb-cat-checkbox');
const checkedValues=[];
checkBoxValues.forEach(checkBoxVal=> {
const isChecked=checkBoxVal.checked;
if(isChecked&&checkBoxVal.getAttribute('data-uagb-block-query-id')===event.target.dataset.uagbBlockQueryId){
checkedValues.push(checkBoxVal.value);
}});
updateContent(event, null, null, null, loopParentContainer);
}
function handleSelect(event){
const loopParentContainer=this.closest('.wp-block-uagb-loop-builder');
const sortSelects=loopParentContainer.querySelectorAll('.uagb-loop-sort');
sortSelects.forEach(sortSelect=> {
if(sortSelect.getAttribute('data-uagb-block-query-id')===event.target.dataset.uagbBlockQueryId){
sortSelect.value=event.target.value;
}});
updateContent(event, null, null, null, loopParentContainer);
}
function handleCatSelect(event){
const loopParentContainer=this.closest('.wp-block-uagb-loop-builder');
const categorySelects=loopParentContainer.querySelectorAll('.uagb-loop-category');
categorySelects.forEach(categorySelect=> {
if(categorySelect.getAttribute('data-uagb-block-query-id')===event.target.dataset.uagbBlockQueryId){
categorySelect.value=event.target.value;
}});
updateContent(event, null, null, this, loopParentContainer);
}
function resetValues(container, selector, queryId, resetCallback){
const elements=container.querySelectorAll(selector);
elements.forEach(element=> {
const elementQueryId=element.dataset.uagbBlockQueryId;
if(elementQueryId===queryId){
resetCallback(element);
}});
}
function handleReset(event){
const loopParentContainer=this.closest('.wp-block-uagb-loop-builder');
let queryId=event.target.parentElement.dataset.uagbBlockQueryId;
if(event.target.tagName.toLowerCase()==='a'){
queryId=event.target.dataset.uagbBlockQueryId;
}else if(event.target.tagName.toLowerCase()==='svg'||event.target.tagName.toLowerCase()==='path'){
queryId=event.target.closest('a' )?.getAttribute('data-uagb-block-query-id');
}
const loopBuilder=findAncestorWithClass(event.target.parentNode, 'wp-block-uagb-loop-builder');
resetValues(loopBuilder, '.uagb-loop-search', queryId, element=> {
element.value='';
});
resetValues(loopBuilder, '.uagb-loop-sort', queryId, element=> {
element.value='';
});
resetValues(loopBuilder, '.uagb-loop-category', queryId, element=> {
element.value='';
});
resetValues(loopBuilder, '.uagb-cat-checkbox', queryId, element=> {
element.checked=false;
});
updateContent(event, null, null, null, loopParentContainer);
}
const resetButtons=document.querySelectorAll('.uagb-loop-reset');
const searchInputs=document.querySelectorAll('.uagb-loop-search');
searchInputs.forEach(searchInput=> {
const debouncedHandleInput=debounce(handleInput, 250);
searchInput.addEventListener('input', debouncedHandleInput);
});
const sortSelects=document.querySelectorAll('.uagb-loop-sort');
sortSelects.forEach(sortSelect=> {
const debouncedHandleInput=debounce(handleSelect, 250);
sortSelect.addEventListener('change', debouncedHandleInput);
});
const categorySelects=document.querySelectorAll('.uagb-loop-category');
categorySelects.forEach(categorySelect=> {
const debouncedHandleInput=debounce(handleCatSelect, 250);
categorySelect.addEventListener('change', debouncedHandleInput);
});
const checkBoxValues=document.querySelectorAll('.uagb-cat-checkbox');
checkBoxValues.forEach(checkBoxVal=> {
const debouncedHandleInput=debounce(handleCheckBoxVal, 250);
checkBoxVal.addEventListener('click', debouncedHandleInput);
});
resetButtons.forEach(resetButton=> {
const debouncedHandleReset=debounce(handleReset, 250);
resetButton.addEventListener('click', debouncedHandleReset);
});
const oldPaginations=document.querySelectorAll('.wp-block-uagb-loop-builder > :not(.uagb-loop-pagination).wp-block-uagb-buttons');
oldPaginations?.forEach(function(container){
const parentContainer=document.createElement('div');
parentContainer.classList.add('uagb-loop-pagination');
const queryIdPAginationLink=container.querySelector('a').getAttribute('data-uagb-block-query-id');
parentContainer.id='uagb-block-pagination-queryid-'+queryIdPAginationLink;
parentContainer.innerHTML=container.outerHTML;
container.parentNode.insertBefore(parentContainer, container.nextSibling);
container.parentNode.removeChild(container);
});
const paginationContainer=document.querySelectorAll('.uagb-loop-pagination');
paginationContainer.forEach(pagination=> {
pagination.addEventListener('click', function(event){
event.preventDefault();
const loopParentContainer=this.closest('.wp-block-uagb-loop-builder');
if(event.target.tagName.toLowerCase()==='a'){
updateContent(event, event.target.dataset.uagbBlockQueryPaged, null, null, loopParentContainer);
}
if(( event.target.tagName.toLowerCase()==='div'&&event.target.parentElement.tagName.toLowerCase()==='a') ){
updateContent(event, event.target.parentElement.dataset.uagbBlockQueryPaged, null, null, loopParentContainer);
}
if(event.target.tagName.toLowerCase()==='svg'&&event.target.tagName.toLowerCase()==='path'){
updateContent(event.target.parentElement.parentElement, event?.target?.closest('a' )?.getAttribute('data-uagb-block-query-paged'), null, null, loopParentContainer);
}});
});
const categoryButtonFilterContainer=document.querySelectorAll('.uagb-loop-category-inner ');
categoryButtonFilterContainer.forEach(buttons=> {
buttons.addEventListener('click', function(event){
event.preventDefault();
const loopParentContainer=this.closest('.wp-block-uagb-loop-builder');
if(event.target.tagName.toLowerCase()==='a'){
updateContent(event, null, event.target.children[0].dataset, null, loopParentContainer);
}
if(( event.target.tagName.toLowerCase()==='div'&&event.target.parentElement.tagName.toLowerCase()==='a') ){
updateContent(event, null, event.target.dataset, null, loopParentContainer);
}});
});
});
function getUpdatedLoopWrapperContent(data){
data.append('action', 'uagb_update_loop_builder_content');
data.append('postId', uagb_loop_builder?.post_id);
data.append('postType', uagb_loop_builder?.what_post_type);
data.append('security', uagb_loop_builder?.nonce)
return fetch(uagb_loop_builder?.ajax_url, {
method: 'POST',
credentials: 'same-origin',
body: data,
})
.then(response=> {
if(! response.ok){
throw new Error('Network response was not ok');
}
return response.json();
})
.then(output=> {
if(output.success){
return output.data;
}
throw new Error(output.data.message);
})
.catch(error=> {
throw error;
});
};
const UAGBBlockPositioning={init(t,e){const s=document.querySelector(e);s?.classList.contains("uagb-position__sticky")&&UAGBBlockPositioning.handleSticky(s,t)},handleSticky(t,e){var s=()=>{return document.querySelector("#wpadminbar")?.offsetHeight||0},p=()=>{"undefined"!=typeof AOS&&e?.UAGAnimationType&&(t.dataset.aos=e?.UAGAnimationType,t.dataset.aosDuration=e?.UAGAnimationTime,t.dataset.aosDelay=e?.UAGAnimationDelay,t.dataset.aosEasing=e?.UAGAnimationEasing,t.dataset.aosOnce=!0,setTimeout(()=>{AOS.refreshHard()},100))};const o=t.getBoundingClientRect(),y=e?.isBlockRootParent?null:t.parentElement,i=((t,e,s)=>{const o=document.createElement("div"),i=(o.style.height=e.height+"px",o.style.boxSizing="border-box",window.getComputedStyle(t));return s?(o.style.width="100%",o.style.maxWidth=i.getPropertyValue("max-width")||e.width+"px",o.style.padding=i.getPropertyValue("padding")||0,o.style.margin=i.getPropertyValue("margin")||0,o.style.border=i.getPropertyValue("border")||0,o.style.borderColor="transparent"):(o.style.width=e.width+"px",o.style.margin=i.getPropertyValue("margin")||0),o})(t,o,y);let n,a,l,r;const c={top:0,bottom:0},d={top:0,right:0,bottom:0,left:0};if(e?.UAGStickyRestricted){r=y.getBoundingClientRect();const g=window.getComputedStyle(y);d.top=parseInt(g.getPropertyValue("padding-top")||0,10),d.bottom=parseInt(g.getPropertyValue("padding-bottom")||0,10),c.top=r.top+(window.pageYOffset||0)+d.top,c.bottom=r.bottom+(window.pageYOffset||0)-d.bottom-o.height-s()-(e?.UAGStickyOffset||0)}"bottom"===e?.UAGStickyLocation?(n=o.top+(window.pageYOffset||0)-window.innerHeight+o.height+(e?.UAGStickyOffset||0),a=`${e?.UAGStickyOffset||0}px`,(l=void 0!==window.pageYOffset?window.pageYOffset:document.body.scrollTop)<=n&&!t.classList.contains("uagb-position__sticky--stuck")&&(t.parentNode.insertBefore(i,t),t.classList.add("uagb-position__sticky--stuck"),t.style.bottom=`calc(${a} - ${window.innerHeight}px)`,t.style.left=o.left+"px",t.style.width=o.width+"px",t.style.zIndex="999",setTimeout(()=>{t.style.bottom=a},50)),p(),window.addEventListener("scroll",()=>{(l=void 0!==window.pageYOffset?window.pageYOffset:document.body.scrollTop)<=n?t.classList.contains("uagb-position__sticky--stuck")||(t.parentNode.insertBefore(i,t),t.classList.add("uagb-position__sticky--stuck"),t.style.bottom=a,t.style.left=o.left+"px",t.style.width=o.width+"px",t.style.zIndex="999"):l>n&&t.classList.contains("uagb-position__sticky--stuck")&&(t.parentNode.removeChild(i),t.classList.remove("uagb-position__sticky--stuck"),t.style.bottom="",t.style.left="",t.style.width="",t.style.zIndex="")})):(n=o.top+(window.pageYOffset||0)-s()-(e?.UAGStickyOffset||0),a=s()+(e?.UAGStickyOffset||0)+"px",(l=void 0!==window.pageYOffset?window.pageYOffset:document.body.scrollTop)>=n&&!t.classList.contains("uagb-position__sticky--stuck")&&(t.parentNode.insertBefore(i,t),t.classList.add("uagb-position__sticky--stuck"),e?.UAGStickyRestricted&&l>=c.bottom?(t.classList.remove("uagb-position__sticky--stuck"),t.classList.add("uagb-position__sticky--restricted"),t.style.top="",t.style.bottom=d.bottom+"px",t.style.left=`${i?.offsetLeft||0}px`):(t.style.top=`calc(${a} - ${window.innerHeight}px)`,t.style.left=o.left+"px",t.style.top=a),t.style.width=o.width+"px",t.style.zIndex="999"),p(),window.addEventListener("scroll",()=>{(l=void 0!==window.pageYOffset?window.pageYOffset:document.body.scrollTop)>=n?t.classList.contains("uagb-position__sticky--stuck")||t.classList.contains("uagb-position__sticky--restricted")?e?.UAGStickyRestricted&&!t.classList.contains("uagb-position__sticky--restricted")&&l>=c.bottom?(t.classList.remove("uagb-position__sticky--stuck"),t.classList.add("uagb-position__sticky--restricted"),t.style.top="",t.style.bottom=d.bottom+"px",t.style.left=`${i?.offsetLeft||0}px`):t.classList.contains("uagb-position__sticky--restricted")&&l<c.bottom&&(t.classList.remove("uagb-position__sticky--restricted"),t.classList.add("uagb-position__sticky--stuck"),t.style.top=a,t.style.bottom="",t.style.left=o.left+"px",t.style.width=o.width+"px",t.style.zIndex="999"):(t.parentNode.insertBefore(i,t),t.classList.add("uagb-position__sticky--stuck"),t.style.top=a,t.style.left=o.left+"px",t.style.width=o.width+"px",t.style.zIndex="999"):l<n&&t.classList.contains("uagb-position__sticky--stuck")&&(t.parentNode.removeChild(i),t.classList.remove("uagb-position__sticky--stuck"),t.style.top="",t.style.left="",t.style.width="",t.style.zIndex="")}))}};
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AOS=t():e.AOS=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="dist/",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=n(1),a=(o(r),n(6)),u=o(a),c=n(7),f=o(c),s=n(8),d=o(s),l=n(9),p=o(l),m=n(10),b=o(m),v=n(11),y=o(v),g=n(14),h=o(g),w=[],k=!1,x={offset:120,delay:0,easing:"ease",duration:400,disable:!1,once:!1,startEvent:"DOMContentLoaded",throttleDelay:99,debounceDelay:50,disableMutationObserver:!1},j=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(e&&(k=!0),k)return w=(0,y.default)(w,x),(0,b.default)(w,x.once),w},O=function(){w=(0,h.default)(),j()},_=function(){w.forEach(function(e,t){e.node.removeAttribute("data-aos"),e.node.removeAttribute("data-aos-easing"),e.node.removeAttribute("data-aos-duration"),e.node.removeAttribute("data-aos-delay")})},S=function(e){return e===!0||"mobile"===e&&p.default.mobile()||"phone"===e&&p.default.phone()||"tablet"===e&&p.default.tablet()||"function"==typeof e&&e()===!0},z=function(e){x=i(x,e),w=(0,h.default)();var t=document.all&&!window.atob;return S(x.disable)||t?_():(document.querySelector("body").setAttribute("data-aos-easing",x.easing),document.querySelector("body").setAttribute("data-aos-duration",x.duration),document.querySelector("body").setAttribute("data-aos-delay",x.delay),"DOMContentLoaded"===x.startEvent&&["complete","interactive"].indexOf(document.readyState)>-1?j(!0):"load"===x.startEvent?window.addEventListener(x.startEvent,function(){j(!0)}):document.addEventListener(x.startEvent,function(){j(!0)}),window.addEventListener("resize",(0,f.default)(j,x.debounceDelay,!0)),window.addEventListener("orientationchange",(0,f.default)(j,x.debounceDelay,!0)),window.addEventListener("scroll",(0,u.default)(function(){(0,b.default)(w,x.once)},x.throttleDelay)),x.disableMutationObserver||(0,d.default)("[data-aos]",O),w)};e.exports={init:z,refresh:j,refreshHard:O}},function(e,t){},,,,,function(e,t){(function(t){"use strict";function n(e,t,n){function o(t){var n=b,o=v;return b=v=void 0,k=t,g=e.apply(o,n)}function r(e){return k=e,h=setTimeout(s,t),_?o(e):g}function a(e){var n=e-w,o=e-k,i=t-n;return S?j(i,y-o):i}function c(e){var n=e-w,o=e-k;return void 0===w||n>=t||n<0||S&&o>=y}function s(){var e=O();return c(e)?d(e):void(h=setTimeout(s,a(e)))}function d(e){return h=void 0,z&&b?o(e):(b=v=void 0,g)}function l(){void 0!==h&&clearTimeout(h),k=0,b=w=v=h=void 0}function p(){return void 0===h?g:d(O())}function m(){var e=O(),n=c(e);if(b=arguments,v=this,w=e,n){if(void 0===h)return r(w);if(S)return h=setTimeout(s,t),o(w)}return void 0===h&&(h=setTimeout(s,t)),g}var b,v,y,g,h,w,k=0,_=!1,S=!1,z=!0;if("function"!=typeof e)throw new TypeError(f);return t=u(t)||0,i(n)&&(_=!!n.leading,S="maxWait"in n,y=S?x(u(n.maxWait)||0,t):y,z="trailing"in n?!!n.trailing:z),m.cancel=l,m.flush=p,m}function o(e,t,o){var r=!0,a=!0;if("function"!=typeof e)throw new TypeError(f);return i(o)&&(r="leading"in o?!!o.leading:r,a="trailing"in o?!!o.trailing:a),n(e,t,{leading:r,maxWait:t,trailing:a})}function i(e){var t="undefined"==typeof e?"undefined":c(e);return!!e&&("object"==t||"function"==t)}function r(e){return!!e&&"object"==("undefined"==typeof e?"undefined":c(e))}function a(e){return"symbol"==("undefined"==typeof e?"undefined":c(e))||r(e)&&k.call(e)==d}function u(e){if("number"==typeof e)return e;if(a(e))return s;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(l,"");var n=m.test(e);return n||b.test(e)?v(e.slice(2),n?2:8):p.test(e)?s:+e}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f="Expected a function",s=NaN,d="[object Symbol]",l=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,m=/^0b[01]+$/i,b=/^0o[0-7]+$/i,v=parseInt,y="object"==("undefined"==typeof t?"undefined":c(t))&&t&&t.Object===Object&&t,g="object"==("undefined"==typeof self?"undefined":c(self))&&self&&self.Object===Object&&self,h=y||g||Function("return this")(),w=Object.prototype,k=w.toString,x=Math.max,j=Math.min,O=function(){return h.Date.now()};e.exports=o}).call(t,function(){return this}())},function(e,t){(function(t){"use strict";function n(e,t,n){function i(t){var n=b,o=v;return b=v=void 0,O=t,g=e.apply(o,n)}function r(e){return O=e,h=setTimeout(s,t),_?i(e):g}function u(e){var n=e-w,o=e-O,i=t-n;return S?x(i,y-o):i}function f(e){var n=e-w,o=e-O;return void 0===w||n>=t||n<0||S&&o>=y}function s(){var e=j();return f(e)?d(e):void(h=setTimeout(s,u(e)))}function d(e){return h=void 0,z&&b?i(e):(b=v=void 0,g)}function l(){void 0!==h&&clearTimeout(h),O=0,b=w=v=h=void 0}function p(){return void 0===h?g:d(j())}function m(){var e=j(),n=f(e);if(b=arguments,v=this,w=e,n){if(void 0===h)return r(w);if(S)return h=setTimeout(s,t),i(w)}return void 0===h&&(h=setTimeout(s,t)),g}var b,v,y,g,h,w,O=0,_=!1,S=!1,z=!0;if("function"!=typeof e)throw new TypeError(c);return t=a(t)||0,o(n)&&(_=!!n.leading,S="maxWait"in n,y=S?k(a(n.maxWait)||0,t):y,z="trailing"in n?!!n.trailing:z),m.cancel=l,m.flush=p,m}function o(e){var t="undefined"==typeof e?"undefined":u(e);return!!e&&("object"==t||"function"==t)}function i(e){return!!e&&"object"==("undefined"==typeof e?"undefined":u(e))}function r(e){return"symbol"==("undefined"==typeof e?"undefined":u(e))||i(e)&&w.call(e)==s}function a(e){if("number"==typeof e)return e;if(r(e))return f;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(d,"");var n=p.test(e);return n||m.test(e)?b(e.slice(2),n?2:8):l.test(e)?f:+e}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c="Expected a function",f=NaN,s="[object Symbol]",d=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,p=/^0b[01]+$/i,m=/^0o[0-7]+$/i,b=parseInt,v="object"==("undefined"==typeof t?"undefined":u(t))&&t&&t.Object===Object&&t,y="object"==("undefined"==typeof self?"undefined":u(self))&&self&&self.Object===Object&&self,g=v||y||Function("return this")(),h=Object.prototype,w=h.toString,k=Math.max,x=Math.min,j=function(){return g.Date.now()};e.exports=n}).call(t,function(){return this}())},function(e,t){"use strict";function n(e,t){var n=window.document,r=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,a=new r(o);i=t,a.observe(n.documentElement,{childList:!0,subtree:!0,removedNodes:!0})}function o(e){e&&e.forEach(function(e){var t=Array.prototype.slice.call(e.addedNodes),n=Array.prototype.slice.call(e.removedNodes),o=t.concat(n).filter(function(e){return e.hasAttribute&&e.hasAttribute("data-aos")}).length;o&&i()})}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){};t.default=n},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return navigator.userAgent||navigator.vendor||window.opera||""}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i,a=/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s)|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(|\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(|\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg(g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v)|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v)|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|)|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i,u=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i,c=/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s)|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(|\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(|\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg(g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v)|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v)|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|)|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i,f=function(){function e(){n(this,e)}return i(e,[{key:"phone",value:function(){var e=o();return!(!r.test(e)&&!a.test(e.substr(0,4)))}},{key:"mobile",value:function(){var e=o();return!(!u.test(e)&&!c.test(e.substr(0,4)))}},{key:"tablet",value:function(){return this.mobile()&&!this.phone()}}]),e}();t.default=new f},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t,n){var o=e.node.getAttribute("data-aos-once");t>e.position?e.node.classList.add("aos-animate"):"undefined"!=typeof o&&("false"===o||!n&&"true"!==o)&&e.node.classList.remove("aos-animate")},o=function(e,t){var o=window.pageYOffset,i=window.innerHeight;e.forEach(function(e,r){n(e,i+o,t)})};t.default=o},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(12),r=o(i),a=function(e,t){return e.forEach(function(e,n){e.node.classList.add("aos-init"),e.position=(0,r.default)(e.node,t.offset)}),e};t.default=a},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(13),r=o(i),a=function(e,t){var n=0,o=0,i=window.innerHeight,a={offset:e.getAttribute("data-aos-offset"),anchor:e.getAttribute("data-aos-anchor"),anchorPlacement:e.getAttribute("data-aos-anchor-placement")};switch(a.offset&&!isNaN(a.offset)&&(o=parseInt(a.offset)),a.anchor&&document.querySelectorAll(a.anchor)&&(e=document.querySelectorAll(a.anchor)[0]),n=(0,r.default)(e).top,a.anchorPlacement){case"top-bottom":break;case"center-bottom":n+=e.offsetHeight/2;break;case"bottom-bottom":n+=e.offsetHeight;break;case"top-center":n+=i/2;break;case"bottom-center":n+=i/2+e.offsetHeight;break;case"center-center":n+=i/2+e.offsetHeight/2;break;case"top-top":n+=i;break;case"bottom-top":n+=e.offsetHeight+i;break;case"center-top":n+=e.offsetHeight/2+i}return a.anchorPlacement||a.offset||isNaN(t)||(o=t),n+o};t.default=a},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){for(var t=0,n=0;e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop);)t+=e.offsetLeft-("BODY"!=e.tagName?e.scrollLeft:0),n+=e.offsetTop-("BODY"!=e.tagName?e.scrollTop:0),e=e.offsetParent;return{top:n,left:t}};t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return e=e||document.querySelectorAll("[data-aos]"),Array.prototype.map.call(e,function(e){return{node:e}})};t.default=n}])});
window.addEventListener('load', function(){
setTimeout(function(){
AOS.init();
}, 0);
});
let scrollData=true;
let scrollOffset=30;
let scrolltoTop=false;
let scrollElement=null;
let uagbTOCCollapseListener=true;
UAGBTableOfContents={
_getDocumentElement(){
let document_element=document;
const getEditorIframe=document.querySelectorAll('iframe[name="editor-canvas"]');
if(getEditorIframe?.length){
const iframeDocument=getEditorIframe?.[0]?.contentWindow?.document||getEditorIframe?.[0]?.contentDocument;
if(iframeDocument){
document_element=iframeDocument;
}}
return document_element;
},
_setCollapseIconMargin(id, attr){
const document_collapsable=UAGBTableOfContents._getDocumentElement();
const block_element=document_collapsable.querySelector(id);
const uagbLoader=block_element.querySelector('.uagb-toc__loader');
const firstListItem=block_element.querySelector('li.uagb-toc__list:not(.uagb-toc__list--expandable)');
if(firstListItem){
const listFontSize=window.getComputedStyle(firstListItem).fontSize;
const listWrap=block_element.querySelector('.uagb-toc__list-wrap');
const widthValue=`calc(${listFontSize} / 3)`;
const escapedId=id?.replace(/\./g, '');
const existingStyleSheet=document_collapsable.querySelector(`#${escapedId}-toc-style`);
if(existingStyleSheet){
existingStyleSheet.remove();
}
const styleSheet=document_collapsable.createElement('style');
styleSheet.id=`${escapedId}-toc-style`;
const userAgent=navigator.userAgent.toLowerCase();
const isSafari=/^((?!chrome|android|crios|fxios).)*safari/i.test(userAgent)&&!userAgent.includes('edge');
const isFirefox=userAgent.includes('firefox');
const isFirefoxOrSafari=isSafari||isFirefox;
const calculateMarginRightDisc=(fontSize)=> {
const baseFontSize=8;
const baseMargin=5;
const increment=5;
const fontSizeNumeric=parseFloat(fontSize);
const increments=(( fontSizeNumeric - baseFontSize) / 8);
const marginRight=baseMargin +(increments * increment);
return `${marginRight}px`;
};
const calculateMarginRightDecimal=(ListFontSize)=> {
const fontSize=parseFloat(ListFontSize);
const baseMargin=(1 / 4) * fontSize;
const additionalMargin=Math.max(0,(fontSize - 16) / 8) * 2;
return(baseMargin + additionalMargin);
};
let marginRight;
let marginLeft='-0.5px';
if('disc'===attr?.markerView){
if(isFirefoxOrSafari){
marginRight=calculateMarginRightDisc(listFontSize);
marginLeft=isFirefox ? '1px':'-0.5px';
}else{
marginRight=listFontSize;
}}
if('decimal'===attr?.markerView){
const marginRightDeducting=calculateMarginRightDecimal(listFontSize)
marginRight=`${parseFloat(listFontSize) - marginRightDeducting}px`;
marginLeft='1px'
}
styleSheet.innerHTML +=`
${ id } .list-open::before,
${ id } .list-collapsed::before {
width: ${ widthValue };}
${ id } .list-open,
${ id } .list-collapsed {
margin-right: ${ marginRight };
margin-left: ${ marginLeft };}
[dir="rtl"] ${ id } .list-open,
[dir="rtl"] ${ id } .list-collapsed {
margin-right: ${ marginLeft };
margin-left: ${ marginRight };}
`;
document_collapsable.head.appendChild(styleSheet);
setTimeout(()=> {
block_element.style.opacity='';
uagbLoader?.remove();
listWrap?.classList.remove('uagb-toc__list-hidden');
}, 300);
}},
_initCollapsableList(id, attr){
const document_collapsable=UAGBTableOfContents._getDocumentElement();
const block_element=document_collapsable.querySelector(id);
if(attr?.isFrontend&&attr?.enableCollapsableList&&! block_element.classList.contains('init-collapsed-script') ){
block_element.classList.add('init-collapsed-script');
const ulElements=block_element.querySelectorAll('ul.uagb-toc__list');
if('function'===typeof UAGBTableOfContents._setCollapseIconMargin){
UAGBTableOfContents._setCollapseIconMargin(id, attr);
}
ulElements.forEach(( ul)=> {
const spanElement=ul.parentElement.querySelector('.list-open');
ul.classList.add('transition');
ul.dataset.originalMaxHeight=ul.scrollHeight + 'px';
if(spanElement){
const isExpanded=spanElement.getAttribute('aria-expanded')==='true';
ul.style.maxHeight=isExpanded ? ul.dataset.originalMaxHeight:'0px';
ul.style.overflow=isExpanded ? 'visible':'hidden';
ul.addEventListener('transitionend', ()=> {
if(ul.style.maxHeight!=='0px'){
ul.style.overflow='visible';
}});
}else{
ul.style.maxHeight=ul.dataset.originalMaxHeight;
ul.style.overflow='visible';
}});
const spanList=Array.from(block_element.getElementsByClassName('list-open') );
spanList.forEach(( ele)=> {
const handleToggle=()=> {
const ulElement=ele.parentElement.querySelector('ul');
if(! ulElement){
return;
}
const isExpanded=ele.getAttribute('aria-expanded')==='true';
ele.setAttribute('aria-expanded', ! isExpanded);
if(! isExpanded){
ulElement.classList.remove('uagb-toc__list--hidden-child');
}
setTimeout(()=> {
if(isExpanded){
ulElement.style.maxHeight='0px';
ulElement.style.overflow='hidden';
}else{
ulElement.style.maxHeight=ulElement.dataset.originalMaxHeight;
}
ele.classList.toggle('list-open', ! isExpanded);
ele.classList.toggle('list-collapsed', isExpanded);
ulElement.classList.toggle('uagb-toc__list--child-of-closed-list');
}, 0);
if(isExpanded){
setTimeout(()=> {
ulElement.classList.add('uagb-toc__list--hidden-child');
}, 300);
}};
ele.addEventListener('click', handleToggle);
ele.addEventListener('keydown',(event)=> {
if(event.key==='Enter'||event.key===' '){
event.preventDefault();
handleToggle(event);
}});
ele.setAttribute('aria-expanded', ele.classList.contains('list-open') );
});
if(attr?.initiallyCollapseList){
ulElements.forEach(( ul)=> {
const hasSiblingSpan=ul.parentElement.querySelector('span');
if(hasSiblingSpan){
ul.style.maxHeight='0px';
ul.style.overflow='hidden';
ul.classList.add('uagb-toc__list--child-of-closed-list');
setTimeout(()=> {
ul.classList.add('uagb-toc__list--hidden-child');
}, 300);
const spanElement=ul.parentElement.querySelector('.list-open');
if(spanElement){
spanElement.setAttribute('aria-expanded', 'false');
spanElement.classList.remove('list-open');
spanElement.classList.add('list-collapsed');
}}
});
}}
},
init(id, attr){
if(( attr?.makeCollapsible&&! attr?.initialCollapse)||! attr?.makeCollapsible){
UAGBTableOfContents._initCollapsableList(id, attr);
}
const document_element=UAGBTableOfContents._getDocumentElement();
if(document.querySelector('.uagb-toc__list')!==null){
document.querySelector('.uagb-toc__list').addEventListener('click',
UAGBTableOfContents._scroll
);
}
if(document.querySelector('.uagb-toc__scroll-top')!==null){
document.querySelector('.uagb-toc__scroll-top').addEventListener('click',
UAGBTableOfContents._scrollTop
);
}
if(attr?.makeCollapsible){
const elementToOpen=document_element.querySelector(id);
if(uagbTOCCollapseListener){
document_element.addEventListener('click', collapseListener);
uagbTOCCollapseListener=false;
}
function collapseListener(event){
const element=event.target;
const condition1=element?.tagName==='path'||element?.tagName==='svg'||element?.tagName==='DIV';
const condition2=element?.className==='uagb-toc__title'||element?.parentNode?.className==='uagb-toc__title'||element?.parentNode?.tagName==='svg';
if(condition1&&condition2){
const $root=element?.closest(`.wp-block-uagb-table-of-contents${id}`);
const tocListWrapEl=elementToOpen?.querySelector('.wp-block-uagb-table-of-contents .uagb-toc__list-wrap');
if(! tocListWrapEl){
return;
}
if($root?.classList?.contains('uagb-toc__collapse') ){
$root?.classList?.remove('uagb-toc__collapse');
UAGBTableOfContents._slideDown(tocListWrapEl,
500,
id,
attr
);
}else{
$root?.classList?.add('uagb-toc__collapse');
UAGBTableOfContents._slideUp(tocListWrapEl,
500
);
}}
}}
document.addEventListener('scroll',
UAGBTableOfContents._showHideScroll
);
},
_slideUp(target, duration){
target.style.transitionProperty='height, margin, padding';
target.style.transitionDuration=duration + 'ms';
target.style.boxSizing='border-box';
target.style.height=target.offsetHeight + 'px';
target.offsetHeight;
target.style.overflow='hidden';
target.style.height=0;
target.style.paddingTop=0;
target.style.paddingBottom=0;
target.style.marginTop=0;
target.style.marginBottom=0;
window.setTimeout(()=> {
target.style.display='none';
target.style.removeProperty('height');
target.style.removeProperty('padding-top');
target.style.removeProperty('padding-bottom');
target.style.removeProperty('margin-top');
target.style.removeProperty('margin-bottom');
target.style.removeProperty('overflow');
target.style.removeProperty('transition-duration');
target.style.removeProperty('transition-property');
}, duration);
},
_slideDown(target, duration, id, attr){
target.style?.removeProperty('display');
let display=window?.getComputedStyle(target).display;
if(display==='none') display='block';
target.style.display=display;
const height=target.offsetHeight;
target.style.overflow='hidden';
target.style.height=0;
target.style.paddingTop=0;
target.style.paddingBottom=0;
target.style.marginTop=0;
target.style.marginBottom=0;
target.offsetHeight;
target.style.boxSizing='border-box';
target.style.transitionProperty='height, margin, padding';
target.style.transitionDuration=duration + 'ms';
target.style.height=height + 'px';
target.style.removeProperty('padding-top');
target.style.removeProperty('padding-bottom');
target.style.removeProperty('margin-top');
target.style.removeProperty('margin-bottom');
window.setTimeout(()=> {
target.style.removeProperty('height');
target.style.removeProperty('overflow');
target.style.removeProperty('transition-duration');
target.style.removeProperty('transition-property');
UAGBTableOfContents._initCollapsableList(id, attr);
}, duration);
},
hyperLinks(){
const hash=window.location.hash.substring(0);
if(''===hash||/[^a-z0-9_-]$/.test(hash) ){
return;
}
function escapeSelector(selector){
return selector.replace(/([.#$+\^*[\](){}|\\])/g, '\\$1');
}
let hashId=encodeURI(hash.substring(0) );
hashId=escapeSelector(hash);
const selectedAnchor=document?.querySelector(hashId);
if(null===selectedAnchor){
return;
}
const node=document.querySelector('.wp-block-uagb-table-of-contents');
scrollOffset=node.getAttribute('data-offset');
const offset=document.querySelector(hash).offsetTop;
if(null!==offset){
scroll( {
top: offset - scrollOffset,
behavior: 'smooth',
});
}},
_showHideScroll(){
scrollElement=document.querySelector('.uagb-toc__scroll-top');
if(null!==scrollElement){
if(window.scrollY > 300){
if(scrolltoTop){
scrollElement.classList.add('uagb-toc__show-scroll');
}else{
scrollElement.classList.remove('uagb-toc__show-scroll');
}}else{
scrollElement.classList.remove('uagb-toc__show-scroll');
}}
},
_scrollTop(){
window.scrollTo({
top: 0,
behavior: 'smooth',
});
},
_scroll(e){
e.preventDefault();
let hash=e.target.getAttribute('href');
if(! hash&&e.target.tagName&&e.target.tagName!=='A'){
const getHash=e.target.closest('a');
if(getHash){
hash=getHash.getAttribute('href');
}}
if(hash){
const node=document.querySelector('.wp-block-uagb-table-of-contents');
scrollData=node.getAttribute('data-scroll');
scrollOffset=node.getAttribute('data-offset');
let offset=null;
hash=hash.substring(1);
if(document?.querySelector("[id='" + hash + "']") ){
offset=document.querySelector("[id='" + hash + "']" )?.getBoundingClientRect().top + window.scrollY;
}
if(scrollData){
if(null!==offset){
scroll( {
top: offset - scrollOffset,
behavior: 'smooth',
});
}}else{
scroll( {
top: offset,
behavior: 'auto',
});
}}
},
selectDomElement(id){
const thisScope=document.querySelector(`${ id }:not(.script-init)`);
if(! thisScope){
return null;
}
thisScope.classList.add('script-init');
return thisScope;
},
parseTocSlug(slug){
if(! slug){
return slug;
}
const parsedSlug=slug
.toString()
.toLowerCase()
.replace(/\…+/g, '')
.replace(/\u2013|\u2014/g, '')
.replace(/&(amp;)/g, '')
.replace(/[&]nbsp[;]/gi, '-')
.replace(/[^a-zA-Z0-9\u00C0-\u017F _-]/g, '')
.replace(/&(mdash;)/g, '')
.replace(/\s+/g, '-')
.replace(/[&\/\\#,^!+()$~%.\[\]'":*?;-_<>{}@‘’”“|]/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '');
return decodeURI(encodeURIComponent(parsedSlug) );
},
mapTocAnchorsForHref(anchors){
for(const anchor of anchors){
const href=anchor.textContent;
const parsedHref=UAGBTableOfContents.parseTocSlug(href);
anchor.setAttribute('href', `#${parsedHref}`);
}},
_run(attr, id){
setTimeout(function (){
UAGBTableOfContents._runWithTimeOut(attr, id);
}, 500);
},
_runWithTimeOut(attr, id){
const $thisScope=UAGBTableOfContents.selectDomElement(id);
if(! $thisScope){
return;
}
if($thisScope.querySelector('.uag-toc__collapsible-wrap')!==null){
if($thisScope.querySelector('.uag-toc__collapsible-wrap').length > 0){
$thisScope.querySelector('.uagb-toc__title-wrap').classList.add('uagb-toc__is-collapsible');
}}
const allowedHTags=[];
let allowedHTagStr;
if(undefined!==attr.mappingHeaders){
attr.mappingHeaders.forEach(function(h_tag, index){
h_tag===true ? allowedHTags.push('h' +(index + 1) ):null;
});
allowedHTagStr=null!==allowedHTags ? allowedHTags.join(','):'';
}
const allHeader =
undefined!==allowedHTagStr&&''!==allowedHTagStr
? document.body.querySelectorAll(allowedHTagStr)
: document.body.querySelectorAll('h1, h2, h3, h4, h5, h6');
if(0!==allHeader.length){
const tocListWrap=$thisScope.querySelector('.uagb-toc__list-wrap');
if(! tocListWrap){
return;
}
const divsArr=Array.from(allHeader);
const aTags=tocListWrap.getElementsByTagName('a');
UAGBTableOfContents.mapTocAnchorsForHref(aTags);
const ArrayOfDuplicateElements=function(headingArray=[]){
const arrayWithDuplicateEntries=[];
headingArray.reduce(( temporaryArray, currentVal)=> {
if(! temporaryArray.some(( item)=> item.innerText===currentVal.innerText) ){
temporaryArray.push(currentVal);
}else{
arrayWithDuplicateEntries.push(currentVal);
}
return temporaryArray;
}, []);
return arrayWithDuplicateEntries;
};
const duplicateHeadings=ArrayOfDuplicateElements(divsArr);
for(let i=0; i < divsArr.length; i++){
let headerText=UAGBTableOfContents.parseTocSlug(divsArr[ i ].innerText);
if(''!==divsArr[ i ].innerText){
if(headerText.length < 1){
const searchText=divsArr[ i ].innerText;
for(let j=0; j < aTags.length; j++){
if(aTags[ j ].textContent===searchText){
const randomID='#toc_' + Math.random();
aTags[ j ].setAttribute('href', randomID);
headerText=randomID.substring(1);
}}
}}
const span=document.createElement('span');
span.id=headerText;
span.className='uag-toc__heading-anchor';
divsArr[ i ].prepend(span);
for(let k=0; k < duplicateHeadings.length; k++){
const randomID='#toc_' + Math.random();
duplicateHeadings[ k ]
?.querySelector('.uag-toc__heading-anchor')
?.setAttribute('id', randomID.substring(1) );
const anchorElements=Array.from(tocListWrap.getElementsByTagName('a') );
const duplicateHeadingsInTOC=ArrayOfDuplicateElements(anchorElements);
for(let l=0; l < duplicateHeadingsInTOC.length; l++){
duplicateHeadingsInTOC[ k ]?.setAttribute('href', randomID);
}}
}}
scrolltoTop=attr.scrollToTop;
const scrollToTopSvg =
'<svg xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" width="26px" height="16.043px" viewBox="57 35.171 26 16.043" enable-background="new 57 35.171 26 16.043" xml:space="preserve"><path d="M57.5,38.193l12.5,12.5l12.5-12.5l-2.5-2.5l-10,10l-10-10L57.5,38.193z"/></svg>';
scrollElement=document.querySelector('.uagb-toc__scroll-top');
if(scrollElement===null){
const scrollToTopDiv=document.createElement('div');
scrollToTopDiv.classList.add('uagb-toc__scroll-top');
scrollToTopDiv.innerHTML=scrollToTopSvg;
document.body.appendChild(scrollToTopDiv);
}
if(scrollElement!==null){
scrollElement.classList.add('uagb-toc__show-scroll');
}
UAGBTableOfContents._showHideScroll();
UAGBTableOfContents.hyperLinks();
UAGBTableOfContents.init(id, attr);
},
};
document.addEventListener("DOMContentLoaded", function(){ window.addEventListener('load', function(){
UAGBTableOfContents._run({"mappingHeaders":[false,true,false,false,false,false],"scrollToTop":false,"makeCollapsible":false,"enableCollapsableList":false,"initialCollapse":false,"markerView":"disc","isFrontend":true,"initiallyCollapseList":false}, '.uagb-block-5ea66dbd');
});
});