PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | assets/js/dist/admin/addons.min.js +1 -1 4.4.5 → 4.4.9 View file →
@@ -1 +1 @@
1 -(()=>{"use strict";const e={};let t;"undefined"!=typeof lpDataAdmin&&(t=lpDataAdmin.lp_rest_url,e.admin={apiAdminNotice:t+"lp/v1/admin/tools/admin-notices",apiAddons:t+"lp/v1/addon/all",apiAddonAction:t+"lp/v1/addon/action-n",apiAddonsPurchase:t+"lp/v1/addon/info-addons-purchase",apiSearchCourses:t+"lp/v1/admin/tools/search-course",apiSearchUsers:t+"lp/v1/admin/tools/search-user",apiAssignUserCourse:t+"lp/v1/admin/tools/assign-user-course",apiUnAssignUserCourse:t+"lp/v1/admin/tools/unassign-user-course"}),"undefined"!=typeof lpData&&(t=lpData.lp_rest_url,e.frontend={apiWidgets:t+"lp/v1/widgets/api",apiCourses:t+"lp/v1/courses/archive-course",apiAJAX:t+"lp/v1/load_content_via_ajax/",apiProfileCoverImage:t+"lp/v1/profile/cover-image"}),t&&(e.apiCourses=t+"lp/v1/courses/",e.apiEditCoursesArchiveBlock=t+"lp/v1/courses/edit-archive-block",e.apiCoursesSuggest=t+"lp/v1/courses/courses-suggest");const s=e;let a,n,o,c;const l=window.location.search,i=new URLSearchParams(l),r=i.get("tab");let d;const u=[],p=(e,t)=>{const s=d.querySelector(".lp-notify-action").cloneNode(!0);s.classList.remove("clone"),d.insertBefore(s,d[0]);const a=s.querySelector(`.${s.classList.value}__success`),n=s.querySelector(`.${s.classList.value}__error`);"success"===e?(a.classList.add("show"),a.querySelector(".message").innerHTML=t):(n.classList.add("show"),n.querySelector(".message").innerHTML=t),d.classList.add("show"),setTimeout(()=>{s.remove(),1===d.querySelectorAll(".lp-notify-action").length&&d.classList.remove("show")},"success"===e?3e3:4e3)};((e="")=>{const t=r?`?tab=${r}`:`?${e}`;fetch(s.admin.apiAddons+t,{method:"GET",headers:{"X-WP-Nonce":lpDataAdmin.nonce}}).then(e=>e.json()).then(e=>{const{status:t,message:s,data:a}=e;"success"===t?(n=a.html,o=a.addons):n=s}).catch(e=>{console.log(e)})})();const v=e=>{e<4?c.classList.add("max-3-items"):c.classList.remove("max-3-items")},h=setInterval(()=>{if(a&&d){if(n&&a&&d){a.innerHTML=n,c=a.querySelector("#lp-addons");const e=document.querySelector(".lp-nav-tab-wrapper");if(!e)return void clearInterval(h);const t=e.cloneNode(!0);a.insertBefore(t,a.children[0]),t.style.display="flex",e.remove();const s=t.querySelector(".nav-tab.nav-tab-active span");v(parseInt(s.textContent)),clearInterval(h)}}else a=document.querySelector(".lp-addons-page"),d=document.querySelector(".lp-notify-action-wrapper")},1);document.addEventListener("DOMContentLoaded",e=>{}),document.addEventListener("click",e=>{let t=e.target;if("span"===t.tagName.toLowerCase()){e.preventDefault();const s=t.closest(".btn-addon-action");s&&s.click()}if(t.closest(".btn-addon-action")){t=t.closest(".btn-addon-action"),e.preventDefault(),t.classList.add("handling");let a="";const n=t.closest(".lp-addon-item"),c=o[n.dataset.slug],l=t.dataset.action,i=n.querySelector(".lp-addon-item__purchase");if("purchase"===l)return i.style.display="block",void(i.querySelector(".purchase-install").style.display="flex");if("update-purchase-code"===l)return i.querySelector(".purchase-update").style.display="flex",void(i.style.display="block");if("buy"===l){const e=t.dataset.link;return void window.open(e,"_blank")}if("cancel"===l)return void(i.style.display="none");if("install"===l&&t.dataset.link){t.classList.remove("handling");const e=t.dataset.link;return void window.open(e,"_blank")}i&&(a=i.querySelector("input[name=purchase-code]").value),((e,t)=>{const a=e.addon.slug;-1===u.indexOf(a)&&(u.push(a),fetch(s.admin.apiAddonAction,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":lpDataAdmin.nonce},body:JSON.stringify({...e})}).then(e=>e.json()).then(e=>{const s=u.indexOf(a);-1!==s&&u.splice(s,1);const{status:n,message:o,data:c}=e;t&&t(n),p(n,o)}).catch(e=>{p("error",`error js: ${e}`),console.log(e)}))})({purchase_code:a,action:l,addon:c},function(e,s,o){if("success"===e)if("install"===l){n.classList.add("installed","activated"),n.classList.remove("not_installed"),i.style.display="none";const e=document.querySelector(".nav-tab[data-tab=installed] span");e.textContent=parseInt(e.textContent)+1;const t=document.querySelector(".nav-tab[data-tab=not_installed] span");t.textContent=parseInt(t.textContent)-1,i.querySelector(".purchase-install").style.display="none",i.querySelector(".purchase-update").querySelector(".enter-purchase-code").value=a}else"update"===l?(n.querySelector(".addon-version-current").innerHTML=c.version,n.classList.remove("update")):"activate"===l?n.classList.add("activated"):"deactivate"===l?n.classList.remove("activated"):"update-purchase"===l&&(i.style.display="none");t.classList.remove("handling")})}if(t.classList.contains("nav-tab")){e.preventDefault(),document.querySelectorAll(".nav-tab").forEach(function(e){e.classList.remove("nav-tab-active")}),t.classList.add("nav-tab-active");const s=t.dataset.tab,n=a.querySelectorAll(".lp-addon-item");a.querySelector("#lp-search-addons__input").value="",i.set("tab",s),window.history.pushState({},"",`${window.location.pathname}?${i.toString()}`);let o=0;n.forEach(e=>{e.classList.remove("search-not-found"),"all"===s||e.classList.contains(s)?(e.classList.remove("hide"),o++):e.classList.add("hide")}),v(o)}}),document.addEventListener("input",e=>{const t=e.target;if("lp-search-addons__input"===t.id&&(e=>{const t=a.querySelectorAll(".lp-addon-item");let s=0;t.forEach(t=>{const a=t.querySelector("a").textContent;t.classList.contains("hide")||(a.toLowerCase().includes(e.toLowerCase())?(t.classList.remove("search-not-found"),s++):t.classList.add("search-not-found"))}),v(s)})(t.value),t.classList.contains("enter-purchase-code")){e.preventDefault();const s=t.value,a=t.closest(".lp-addon-item__purchase");a&&(a.querySelector("input[name=purchase-code]").value=s)}})})();
1 +(()=>{var t={9455(t,e,o){"use strict";o.d(e,{A:()=>r});var s=o(1601),n=o.n(s),a=o(6314),i=o.n(a)()(n());i.push([t.id,"/*!\n * Toastify js 1.12.0\n * https://github.com/apvarun/toastify-js\n * @license MIT licensed\n *\n * Copyright (C) 2018 Varun A P\n */\n\n.toastify {\n padding: 12px 20px;\n color: #ffffff;\n display: inline-block;\n box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n background: linear-gradient(135deg, #73a5ff, #5477f5);\n position: fixed;\n opacity: 0;\n transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n border-radius: 2px;\n cursor: pointer;\n text-decoration: none;\n max-width: calc(50% - 20px);\n z-index: 2147483647;\n}\n\n.toastify.on {\n opacity: 1;\n}\n\n.toast-close {\n background: transparent;\n border: 0;\n color: white;\n cursor: pointer;\n font-family: inherit;\n font-size: 1em;\n opacity: 0.4;\n padding: 0 5px;\n}\n\n.toastify-right {\n right: 15px;\n}\n\n.toastify-left {\n left: 15px;\n}\n\n.toastify-top {\n top: -150px;\n}\n\n.toastify-bottom {\n bottom: -150px;\n}\n\n.toastify-rounded {\n border-radius: 25px;\n}\n\n.toastify-avatar {\n width: 1.5em;\n height: 1.5em;\n margin: -7px 5px;\n border-radius: 2px;\n}\n\n.toastify-center {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n max-width: -moz-fit-content;\n}\n\n@media only screen and (max-width: 360px) {\n .toastify-right, .toastify-left {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n }\n}\n",""]);const r=i},6314(t){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var o="",s=void 0!==e[5];return e[4]&&(o+="@supports (".concat(e[4],") {")),e[2]&&(o+="@media ".concat(e[2]," {")),s&&(o+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),o+=t(e),s&&(o+="}"),e[2]&&(o+="}"),e[4]&&(o+="}"),o}).join("")},e.i=function(t,o,s,n,a){"string"==typeof t&&(t=[[null,t,void 0]]);var i={};if(s)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(i[l]=!0)}for(var c=0;c<t.length;c++){var d=[].concat(t[c]);s&&i[d[0]]||(void 0!==a&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=a),o&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=o):d[2]=o),n&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=n):d[4]="".concat(n)),e.push(d))}},e}},1601(t){"use strict";t.exports=function(t){return t[1]}},5072(t){"use strict";var e=[];function o(t){for(var o=-1,s=0;s<e.length;s++)if(e[s].identifier===t){o=s;break}return o}function s(t,s){for(var a={},i=[],r=0;r<t.length;r++){var l=t[r],c=s.base?l[0]+s.base:l[0],d=a[c]||0,u="".concat(c," ").concat(d);a[c]=d+1;var p=o(u),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var f=n(h,s);s.byIndex=r,e.splice(r,0,{identifier:u,updater:f,references:1})}i.push(u)}return i}function n(t,e){var o=e.domAPI(e);return o.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;o.update(t=e)}else o.remove()}}t.exports=function(t,n){var a=s(t=t||[],n=n||{});return function(t){t=t||[];for(var i=0;i<a.length;i++){var r=o(a[i]);e[r].references--}for(var l=s(t,n),c=0;c<a.length;c++){var d=o(a[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}a=l}}},7659(t){"use strict";var e={};t.exports=function(t,o){var s=function(t){if(void 0===e[t]){var o=document.querySelector(t);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(t){o=null}e[t]=o}return e[t]}(t);if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(o)}},540(t){"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056(t,e,o){"use strict";t.exports=function(t){var e=o.nc;e&&t.setAttribute("nonce",e)}},7825(t){"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(o){!function(t,e,o){var s="";o.supports&&(s+="@supports (".concat(o.supports,") {")),o.media&&(s+="@media ".concat(o.media," {"));var n=void 0!==o.layer;n&&(s+="@layer".concat(o.layer.length>0?" ".concat(o.layer):""," {")),s+=o.css,n&&(s+="}"),o.media&&(s+="}"),o.supports&&(s+="}");var a=o.sourceMap;a&&"undefined"!=typeof btoa&&(s+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleTagTransform(s,t,e.options)}(e,t,o)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113(t){"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7736(t){var e;e=function(t){var e=function(t){return new e.lib.init(t)};function o(t,e){return e.offset[t]?isNaN(e.offset[t])?e.offset[t]:e.offset[t]+"px":"0px"}function s(t,e){return!(!t||"string"!=typeof e||!(t.className&&t.className.trim().split(/\s+/gi).indexOf(e)>-1))}return e.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,ariaLive:"polite",style:{background:""}},e.lib=e.prototype={toastify:"1.12.0",constructor:e,init:function(t){return t||(t={}),this.options={},this.toastElement=null,this.options.text=t.text||e.defaults.text,this.options.node=t.node||e.defaults.node,this.options.duration=0===t.duration?0:t.duration||e.defaults.duration,this.options.selector=t.selector||e.defaults.selector,this.options.callback=t.callback||e.defaults.callback,this.options.destination=t.destination||e.defaults.destination,this.options.newWindow=t.newWindow||e.defaults.newWindow,this.options.close=t.close||e.defaults.close,this.options.gravity="bottom"===t.gravity?"toastify-bottom":e.defaults.gravity,this.options.positionLeft=t.positionLeft||e.defaults.positionLeft,this.options.position=t.position||e.defaults.position,this.options.backgroundColor=t.backgroundColor||e.defaults.backgroundColor,this.options.avatar=t.avatar||e.defaults.avatar,this.options.className=t.className||e.defaults.className,this.options.stopOnFocus=void 0===t.stopOnFocus?e.defaults.stopOnFocus:t.stopOnFocus,this.options.onClick=t.onClick||e.defaults.onClick,this.options.offset=t.offset||e.defaults.offset,this.options.escapeMarkup=void 0!==t.escapeMarkup?t.escapeMarkup:e.defaults.escapeMarkup,this.options.ariaLive=t.ariaLive||e.defaults.ariaLive,this.options.style=t.style||e.defaults.style,t.backgroundColor&&(this.options.style.background=t.backgroundColor),this},buildToast:function(){if(!this.options)throw"Toastify is not initialized";var t=document.createElement("div");for(var e in t.className="toastify on "+this.options.className,this.options.position?t.className+=" toastify-"+this.options.position:!0===this.options.positionLeft?(t.className+=" toastify-left",console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.")):t.className+=" toastify-right",t.className+=" "+this.options.gravity,this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.'),this.options.style)t.style[e]=this.options.style[e];if(this.options.ariaLive&&t.setAttribute("aria-live",this.options.ariaLive),this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)t.appendChild(this.options.node);else if(this.options.escapeMarkup?t.innerText=this.options.text:t.innerHTML=this.options.text,""!==this.options.avatar){var s=document.createElement("img");s.src=this.options.avatar,s.className="toastify-avatar","left"==this.options.position||!0===this.options.positionLeft?t.appendChild(s):t.insertAdjacentElement("afterbegin",s)}if(!0===this.options.close){var n=document.createElement("button");n.type="button",n.setAttribute("aria-label","Close"),n.className="toast-close",n.innerHTML="&#10006;",n.addEventListener("click",function(t){t.stopPropagation(),this.removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}.bind(this));var a=window.innerWidth>0?window.innerWidth:screen.width;("left"==this.options.position||!0===this.options.positionLeft)&&a>360?t.insertAdjacentElement("afterbegin",n):t.appendChild(n)}if(this.options.stopOnFocus&&this.options.duration>0){var i=this;t.addEventListener("mouseover",function(e){window.clearTimeout(t.timeOutValue)}),t.addEventListener("mouseleave",function(){t.timeOutValue=window.setTimeout(function(){i.removeElement(t)},i.options.duration)})}if(void 0!==this.options.destination&&t.addEventListener("click",function(t){t.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination}.bind(this)),"function"==typeof this.options.onClick&&void 0===this.options.destination&&t.addEventListener("click",function(t){t.stopPropagation(),this.options.onClick()}.bind(this)),"object"==typeof this.options.offset){var r=o("x",this.options),l=o("y",this.options),c="left"==this.options.position?r:"-"+r,d="toastify-top"==this.options.gravity?l:"-"+l;t.style.transform="translate("+c+","+d+")"}return t},showToast:function(){var t;if(this.toastElement=this.buildToast(),!(t="string"==typeof this.options.selector?document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||"undefined"!=typeof ShadowRoot&&this.options.selector instanceof ShadowRoot?this.options.selector:document.body))throw"Root element is not defined";var o=e.defaults.oldestFirst?t.firstChild:t.lastChild;return t.insertBefore(this.toastElement,o),e.reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout(function(){this.removeElement(this.toastElement)}.bind(this),this.options.duration)),this},hideToast:function(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this.removeElement(this.toastElement)},removeElement:function(t){t.className=t.className.replace(" on",""),window.setTimeout(function(){this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),t.parentNode&&t.parentNode.removeChild(t),this.options.callback.call(t),e.reposition()}.bind(this),400)}},e.reposition=function(){for(var t,e={top:15,bottom:15},o={top:15,bottom:15},n={top:15,bottom:15},a=document.getElementsByClassName("toastify"),i=0;i<a.length;i++){t=!0===s(a[i],"toastify-top")?"toastify-top":"toastify-bottom";var r=a[i].offsetHeight;t=t.substr(9,t.length-1),(window.innerWidth>0?window.innerWidth:screen.width)<=360?(a[i].style[t]=n[t]+"px",n[t]+=r+15):!0===s(a[i],"toastify-left")?(a[i].style[t]=e[t]+"px",e[t]+=r+15):(a[i].style[t]=o[t]+"px",o[t]+=r+15)}return this},e.lib.init.prototype=e.lib,e},t.exports?t.exports=e():this.Toastify=e()}},e={};function o(s){var n=e[s];if(void 0!==n)return n.exports;var a=e[s]={id:s,exports:{}};return t[s].call(a.exports,a,a.exports,o),a.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var s in e)o.o(e,s)&&!o.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.nc=void 0,(()=>{"use strict";var t=o(7736),e=o.n(t),s=o(5072),n=o.n(s),a=o(7825),i=o.n(a),r=o(7659),l=o.n(r),c=o(5056),d=o.n(c),u=o(540),p=o.n(u),h=o(1113),f=o.n(h),m=o(9455),v={};v.styleTagTransform=f(),v.setAttributes=d(),v.insert=l().bind(null,"head"),v.domAPI=i(),v.insertStyleElement=p(),n()(m.A,v),m.A&&m.A.locals&&m.A.locals;const y={text:"",gravity:lpData.toast.gravity,position:lpData.toast.position,className:`${lpData.toast.classPrefix}`,close:1==lpData.toast.close,stopOnFocus:1==lpData.toast.stopOnFocus,duration:lpData.toast.duration},g=(t,o="success",s)=>{let n=y;s&&(n={...n,...s}),new(e())({...n,text:t,className:`${lpData.toast.classPrefix} ${o}`}).showToast()},b="loading",w=(t,e)=>{t&&(e?t.classList.add(b):t.classList.remove(b))},A=(t,e)=>{document.addEventListener(t,o=>{const s=o.target;let n={e:o,target:s};e.forEach(e=>{n={...n,...e},e.conditionBeforeCallBack&&!0!==e.conditionBeforeCallBack(n)||"keydown"===t&&e.checkIsEventEnter&&"Enter"!==o.key||s.closest(e.selector)&&(e.class?e.class[e.callBack](n):e.callBack(n))})})};window.lpToggleEnableInit=0,window.lpFullScreenViewInit=0;class C{constructor(){this.elAddonsPage=null,this.urlParams=new URLSearchParams(window.location.search)}static selectors={elAddonsPage:".lp-addons-page",elLPAddons:"#lp-addons",elAddonItem:".lp-addon-item",elBtnAction:".btn-addon-action",elNavTab:".nav-tab",elNavTabActive:".nav-tab.nav-tab-active",elCategory:".lp-addons-category",elCategoryActive:".lp-addons-category.active",elSearchInput:"#lp-search-addons__input",elItemPurchase:".lp-addon-item__purchase",elPurchaseInstall:".purchase-install",elPurchaseCode:".enter-purchase-code",elLicense:".lp-addon-license"};init(){((t,e)=>{const o=document.querySelector(t);o?e():new MutationObserver((o,s)=>{const n=document.querySelector(t);n&&(s.disconnect(),e())}).observe(document.documentElement,{childList:!0,subtree:!0})})(C.selectors.elLPAddons,()=>{this.elAddonsPage=document.querySelector(C.selectors.elAddonsPage),this.elAddonsPage&&(this.filterAddons(),this.events())})}events(){A("click",[{selector:C.selectors.elBtnAction,class:this,callBack:this.handleBtnAction.name},{selector:C.selectors.elNavTab,class:this,callBack:this.handleTabClick.name},{selector:C.selectors.elCategory,class:this,callBack:this.handleCategoryClick.name},{selector:C.selectors.elPurchaseCode,class:this,callBack:this.handlePurchaseCodeClick.name}]),A("input",[{selector:C.selectors.elSearchInput,class:this,callBack:this.handleSearchInput.name},{selector:C.selectors.elPurchaseCode,class:this,callBack:this.handlePurchaseCodeInput.name}])}getAddonData(t){try{return JSON.parse(t.dataset.addon)}catch(t){return null}}addonsAction(t){const{action:e,addon:o,el:s,elAddonItem:n}=t,a=C.selectors,i={action:"addon_action",action_type:e,addon:o,purchase_code:t.purchase_code||"",id_url:"addon-action"};window.lpAJAXG.fetchAJAX(i,{success:t=>{const{status:o,message:i,data:r}=t;if(g(i,o),"success"===o&&r?.html)n.outerHTML=r.html;else if("install"===e||"update-purchase"===e){const t=s.closest(a.elPurchaseInstall),e=t?t.querySelector(a.elPurchaseCode):null;e&&(e.classList.add("is-error"),e.setAttribute("aria-invalid","true"))}w(s,0)},error:t=>{w(s,0),g(`error js: ${t}`,"error")}})}filterAddons(){const t=C.selectors,e=this.elAddonsPage.querySelectorAll(t.elAddonItem);this.updateTabCounts(e);const o=this.elAddonsPage.querySelector(t.elNavTabActive),s=this.elAddonsPage.querySelector(t.elCategoryActive),n=this.elAddonsPage.querySelector(t.elSearchInput),a=o?o.dataset.tab:"all",i=s?s.dataset.category:"all",r=(n?n.value.trim().toLowerCase():"").split(/\s+/).filter(Boolean);this.updateCategoryCounts(e,a),e.forEach(t=>{const e=JSON.parse(t.dataset.addon),o=t.querySelector("a").textContent.toLowerCase()+e.description,s=(t.dataset.category||"").split(/\s+/).filter(Boolean),n="all"===a||t.classList.contains(a),l="all"===i||s.includes(i),c=r.every(t=>o.includes(t)),d=n&&l&&c;t.classList.toggle("hide",!n),t.classList.toggle("search-not-found",!d)})}updateCategoryCounts(t,e){const o={all:0};t.forEach(t=>{("all"===e||t.classList.contains(e))&&(o.all++,(t.dataset.category||"").split(/\s+/).filter(Boolean).forEach(t=>{o[t]=(o[t]||0)+1}))}),this.elAddonsPage.querySelectorAll(C.selectors.elCategory).forEach(t=>{const e=o[t.dataset.category]||0,s=t.querySelector(".lp-addons-category__count");s&&(s.textContent=`(${e})`),t.hidden="all"!==t.dataset.category&&0===e})}updateTabCounts(t){this.elAddonsPage.querySelectorAll(C.selectors.elNavTab).forEach(e=>{const o=e.dataset.tab,s=Array.from(t).filter(t=>"all"===o||t.classList.contains(o)).length,n=e.querySelector("span");n&&(n.textContent=s)})}handlePurchaseCodeClick(t){const{target:e}=t;if(!e.value.startsWith("***"))return;e.value="";const o=e.closest(C.selectors.elItemPurchase);o&&(o.querySelector("input[name=purchase-code]").value="")}handleBtnAction(t){const{e,target:o}=t,s=C.selectors,n=o.closest(s.elBtnAction);if("A"===n.tagName)return;e.preventDefault(),w(n,1);let a="";const i=n.closest(s.elAddonItem),r=this.getAddonData(i),l=n.dataset.action,c=i.querySelector(s.elItemPurchase);if(r){if("purchase"===l||"update-purchase-code"===l){const t=c.querySelector(s.elPurchaseInstall),e=t.querySelector(s.elPurchaseCode),o=t.querySelector(".lp-addon-purchase__submit");if("update-purchase-code"===l){const t=i.querySelector(s.elLicense);e.value=t&&t.dataset.purchaseCodeMasked||"",o.dataset.action="update-purchase"}else e.value="",o.dataset.action="install";return e.classList.remove("is-error"),e.removeAttribute("aria-invalid"),c.querySelector("input[name=purchase-code]").value="",t.style.display="flex",c.style.display="block",e.focus(),void w(n,0)}if("cancel"===l)return c.style.display="none",c.querySelector(s.elPurchaseInstall).style.display="none",void w(n,0);c&&(a=c.querySelector("input[name=purchase-code]").value),this.addonsAction({purchase_code:a,action:l,addon:r,el:n,elAddonItem:i})}else w(n,0)}handleTabClick(t){const{e,target:o}=t,s=C.selectors,n=o.closest(s.elNavTab);e.preventDefault(),this.elAddonsPage.querySelectorAll(s.elNavTab).forEach(t=>{t.classList.remove("nav-tab-active"),t.setAttribute("aria-pressed","false")}),n.classList.add("nav-tab-active"),n.setAttribute("aria-pressed","true");const a=n.dataset.tab;this.elAddonsPage.querySelector(s.elSearchInput).value="",this.elAddonsPage.querySelectorAll(s.elCategory).forEach(t=>{const e="all"===t.dataset.category;t.classList.toggle("active",e),t.setAttribute("aria-pressed",e?"true":"false")}),this.urlParams.set("tab",a),window.history.pushState({},"",`${window.location.pathname}?${this.urlParams.toString()}`),this.filterAddons()}handleCategoryClick(t){const{e,target:o}=t,s=o.closest(C.selectors.elCategory);e.preventDefault(),this.elAddonsPage.querySelectorAll(C.selectors.elCategory).forEach(t=>{const e=t===s;t.classList.toggle("active",e),t.setAttribute("aria-pressed",e?"true":"false")}),this.filterAddons()}handleSearchInput(){this.filterAddons()}handlePurchaseCodeInput(t){const{e,target:o}=t;e.preventDefault(),o.classList.remove("is-error"),o.removeAttribute("aria-invalid");const s=o.value,n=o.closest(C.selectors.elItemPurchase);n&&(n.querySelector("input[name=purchase-code]").value=s)}}(new C).init()})()})();