(()=>{"use strict";var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wp.domReady;var i=t.n(e);const s=window.jQuery;var r=t.n(s);i()((()=>{const t=r()(document),{ruleData:e,userRoles:i}=tec.ticketsPlus.commerce.purchaseRules.singlePost.data,s=()=>i,n=e=>{const i=t.find(`.tec-tickets-plus-purchase-rules-messages__message--restriction[data-rule-id="${e}"]`);i.length&&i.show(),tribe.tickets.utils.disable(t.find("#tribe-tickets__tickets-submit"),!0)},c=()=>parseInt(t.find(".tribe-tickets__tickets-footer .tribe-tickets__tickets-footer-quantity-number").text()),o=()=>{const e=t.find("#tribe-tickets__tickets-form .tribe-tickets__tickets-item"),i=[];for(const t of e){const e=parseInt(r()(t).data("ticket-id"));e&&!isNaN(e)&&i.push({id:e,price:parseFloat(r()(t).data("ticket-price")),name:r()(t).find(".tribe-tickets__tickets-item-content-title").text().trim().toLowerCase(),quantity:parseInt(r()(t).find(`#tribe-tickets__tickets-item-quantity-number--${e}`).val())})}return i},a=t=>{for(const e in t){const{ticketLimit:i}=t[e];c()>i&&n(e)}},u=t=>{for(const e in t){const{ticketLimit:i,limitedTicket:s}=t[e];for(const t of o())if((t.name.includes(s.toLowerCase())||t.id===parseInt(s))&&!(t.quantity<=i)){n(e);break}}},k=e=>{for(const i in e){const{ticketMinimum:s,requirement:r}=e[i];"quantity"===r&&c()<s&&n(i),"total"===r&&parseFloat(t.find(".tribe-tickets__tickets-footer-total .tribe-amount").text())<s&&n(i)}},l=t=>{for(const e in t){const{ticketMinimum:i,limitedTicket:s}=t[e];for(const t of o())if((t.name.includes(s.toLowerCase())||t.id===parseInt(s))&&t.quantity&&!(t.quantity>=i)){n(e);break}}},d=t=>{for(const e in t){const{userRoles:i}=t[e],r=s();i.includes("not-guest")&&r.length>0||r.some((t=>i.includes(t)))||n(e)}},f=t=>{for(const e in t){const{requiredTickets:i,restrictedTicket:s}=t[e];if(!s)continue;const r=[];for(const t of o())if((t.name.includes(s.toLowerCase())||t.id===parseInt(s))&&!(0>=t.quantity)){r.push(t);break}if(r.length)for(const t of i){let i=!1;for(const s of o())if(s.name.includes(t.toLowerCase())||s.id===parseInt(t)){if(s.quantity<1){n(e);break}i=!0;break}i||n(e);break}}};t.on("afterTicketsAddRemove.tribeTicketsBlock",(()=>{t.find(".tec-tickets-plus-purchase-rules-messages__message--restriction").hide();for(const t in e)switch(t){case"event-purchase-limit":a(e[t]);break;case"ticket-purchase-limit":u(e[t]);break;case"event-purchase-min":k(e[t]);break;case"ticket-purchase-min":l(e[t]);break;case"user-role-restriction":d(e[t]);break;case"combined-purchase":f(e[t]);break;default:throw new Error(`Invalid rule type: ${t}`)}}))})),window.ticketsPlus=window.ticketsPlus||{},window.ticketsPlus.purchaseRules=window.ticketsPlus.purchaseRules||{},window.ticketsPlus.purchaseRules.singlePost={}})();