tribe.helpPage=tribe.helpPage||{},function(e,t){"use strict";t.selectors={copyButton:".system-info-copy-btn",optInMsg:".tribe-sysinfo-optin-msg",autoInfoOptIn:"#tribe_auto_sysinfo_opt_in",accordion:".tec-ui-accordion",openSupportChat:"[data-open-support-chat]",helpHubIframe:"#tec-settings__support-hub-iframe",iframeLoader:"#tec-settings__support-hub-iframe-loader",modalButtonSpan:"#tec-settings-nav-modal-open span",navLinkText:".tec-nav__link"},t.setup=()=>{t.setupSystemInfo(),t.setupCopyButton(),t.setupTabs(),t.IframeZendeskClickHandler(),t.IframeRender()},t.IframeRender=()=>{const e=document.querySelector(t.selectors.helpHubIframe),n=document.querySelector(t.selectors.iframeLoader);e&&e.addEventListener("load",(()=>{e.classList.remove("hidden"),n&&n.classList.add("hidden")}))},t.sendMessageToIframe=e=>{document.querySelector(t.selectors.helpHubIframe).contentWindow&&document.querySelector(t.selectors.helpHubIframe).contentWindow.postMessage(e,window.origin)},t.openZendeskInIframe=e=>{e.preventDefault(),t.sendMessageToIframe({action:"runScript",data:"openZendesk"})},t.IframeZendeskClickHandler=()=>{const e=document.querySelector(t.selectors.openSupportChat);e&&e.addEventListener("click",(e=>t.openZendeskInIframe(e)))},t.setupAccordionsFor=n=>{e.fn.accordion?e(n).find(t.selectors.accordion).accordion({active:!0,collapsible:!0,heightStyle:"content",icons:{header:"ui-icon-plus",activeHeader:"ui-icon-minus"}}):console.error("jQuery UI Accordion library is missing.")},t.setupCopyButton=()=>{if("undefined"==typeof tribe_system_info)return;const n=new ClipboardJS(t.selectors.copyButton),o='<span class="dashicons dashicons-clipboard license-btn"></span>',s=tribe_system_info.clipboard_btn_text;e(".system-info-copy-btn").on("click",(e=>{e.preventDefault()})),n.on("success",(e=>{e.clearSelection(),e.trigger.innerHTML=o+'<span class="optin-success">'+tribe_system_info.clipboard_copied_text+"<span>",window.setTimeout((function(){e.trigger.innerHTML=o+s}),5e3)})),n.on("error",(e=>{e.trigger.innerHTML=o+'<span class="optin-fail">'+tribe_system_info.clipboard_fail_text+"<span>",window.setTimeout((()=>{e.trigger.innerHTML=o+s}),5e3)}))},t.setupSystemInfo=()=>{"undefined"!=typeof tribe_system_info&&(t.$system_info_opt_in=e(t.selectors.autoInfoOptIn),t.$system_info_opt_in_msg=e(t.selectors.optInMsg),t.$system_info_opt_in.on("change",(()=>{this.checked?t.doAjaxRequest("generate"):t.doAjaxRequest("remove")})))},t.doAjaxRequest=n=>{const o={action:"tribe_toggle_sysinfo_optin",confirm:tribe_system_info.sysinfo_optin_nonce,generate_key:n};e.post(ajaxurl,o,(n=>{if(n.success)t.$system_info_opt_in_msg.html("<p class='optin-success'>"+n.data+"</p>");else{let o="<p class='optin-fail'>"+tribe_system_info.sysinfo_error_message_text+"</p>";n.data&&(n.data.message?o+="<p>"+n.data.message+"</p>":n.message&&(o+="<p>"+n.message+"</p>"),n.data.code&&(o+="<p>"+tribe_system_info.sysinfo_error_code_text+" "+n.data.code+"</p>"),n.data.status&&(o+="<p>"+tribe_system_info.sysinfo_error_status_text+n.data.status+"</p>")),t.$system_info_opt_in_msg.html(o),e(t.selectors.autoInfoOptIn).prop("checked",!1)}}))},t.setupTabs=()=>{const e=document.querySelectorAll("[data-tab-target]");document.querySelectorAll(".tec-tab-container").forEach((e=>{e.classList.add("hidden")}));const n=document.querySelector(".tec-nav__tab.tec-nav__tab--active"),o=n?document.getElementById(n.getAttribute("data-tab-target")):null;if(n){const e=n.querySelector(t.selectors.navLinkText).textContent.trim(),o=document.querySelector(t.selectors.modalButtonSpan);o&&(o.textContent=e)}o&&o.classList.remove("hidden"),t.setupTabEventListeners(e,o)},t.setupTabEventListeners=(e,n)=>{t.activeTabContainer=n,document.addEventListener("click",(n=>{const o=n.target.closest("[data-tab-target]");if(!o)return;const s=o.getAttribute("data-tab-target");t.updateActiveTab(e,s),t.updateActiveContent(o,s)}))},t.updateActiveTab=(e,t)=>{e.forEach((e=>e.classList.remove("tec-nav__tab--active"))),document.querySelectorAll(`[data-tab-target="${t}"]`).forEach((e=>{e.classList.add("tec-nav__tab--active")}))},t.updateActiveContent=(e,n)=>{t.activeTabContainer&&t.activeTabContainer.classList.add("hidden");const o=document.getElementById(n);if(o){o.classList.remove("hidden"),t.activeTabContainer=o;const e=o.getAttribute("data-link-title"),n=document.querySelector(t.selectors.modalButtonSpan);n&&e&&(n.textContent=e),t.setupAccordionsFor(t.activeTabContainer)}},e(t.setup)}(jQuery,tribe.helpPage),window.tec=window.tec||{},window.tec.common=window.tec.common||{},window.tec.common.admin=window.tec.common.admin||{},window.tec.common.admin.helpPage={};