(()=>{let e=!1,i="https://api.lerentools.com/",o=LS.store.id+"/rules/get_business_rules",c=LS.store.id+"/products/hidden_installment",p=null,u=null,m={customer_tn_id:LS.customer,cart:{cart_tn_id:LS.cart.id,total:{currency:"ARS",value:null},items:LS.cart.items&&0({product_tn_id:t.id,variant_tn_id:t.variant_id,quantity:t.quantity})):[]}},g=null,h=null,_=null,f=null,v=null,y=null,b=!1,j=!1,x=!1;const S="lerentoolsBusinessRules_"+LS.store.id,L="tnCurrentData"+LS.store.id,I="lerentoolsProductsHiddenInstallments"+LS.store.id,q="lerentoolsLastRequestTimestamp_"+LS.store.id;function C(t,e,s,n){var r=t.find(".js-price-display"),n=function(t,e){let s=t.replace("$","");return s="MXN"==e?s.replace(",",""):s.replace(".","").replace(",","."),t=parseFloat(s),Number.isInteger(t)?parseInt(t):t}(r.text(),n),a=t.find(".js-installment-amount.product-installment-amount"),t=t.find(".js-installment-price.product-installment-value");let l;e=(l="fixed"==e?n-s:n*((100-s)/100))/a.text(),r.hasClass("lerentools-price-discount")||(r.addClass("lerentools-price-discount"),r.text(LS.formatToCurrency(l<0?0:l)),t.text(LS.formatToCurrency(e<0?0:e)))}const N=t=>{t=localStorage.getItem(t);return t?JSON.parse(t):null},Q=(t,e)=>{localStorage.setItem(t,JSON.stringify(e))},T=()=>{var e=N(L);if(e){if(m.customer_tn_id!==e.customer_tn_id)return!1;if(m.cart.cart_tn_id!==e.cart.cart_tn_id)return!1;if(m.cart.total.value!==e.cart.total.value)return!1;if(m.cart.items.length!==e.cart.items.length)return!1;for(let t=0;t{const t=N(I);var e=N(q);const s=Math.floor(Date.now()/1e3);const n=t=>{g=t,Q(S,t),Q(L,m),Q(q,s),j=!1},r=()=>{j||(j=!0,d.post(i+o,m).done(n).fail(t=>{console.log("Error obteniendo business rules",t),j=!1}))},a=()=>{let t=d(".js-cart-total-container .js-cart-total");0<(t=0{var t,e,s;g&&g.status&&g.rules?.payment_providers_message&&"product"===LS.template&&(t=g.rules.payment_providers_message,s=d("div#installments-modal"),e=d(".lerentools-custom-payments-message"),0"+t+""),e.prepend(s))},500),v=v||setInterval(()=>{var t,e,s;g&&g.status&&g.rules?.shipping_carriers_message&&(t=g.rules.shipping_carriers_message,e=d("div.js-shipping-calculator-response"),s=d(".lerentools-custom-shipping-message"),0"+t+""),e.prepend(s))},500),y=y||setInterval(()=>{var t,e,s,n,r,a;g&&g.status&&g.rules?.disable_cart_installments&&(t=g.rules?.disable_cart_installments,e=g.rules?.disable_cart_installments_text,n=(s=d("div.js-cart-total-container")).find("div.js-installments-cart-total"),r=d(".js-payment-discount-price-cart-container"),a=d(".lerentools-custom-installments-message"),0"+e+""),s.append(a)),0{var t,e;a(),T()||r(),e=d('[name*="go_to_checkout"]'),g&&g.status&&g.rules&&g.rules.disable_cart?(e.css("pointer-events","none"),e.parent().css("cursor","not-allowed"),g.rules.disable_cart_text&&(0==(t=d("#lerentools-business-rules-message")).length?e.before('

'+g.rules.disable_cart_text+"

"):t.text(g.rules.disable_cart_text))):(e.css("pointer-events","initial"),e.parent().css("cursor","initial"),d("#lerentools-business-rules-message").remove())},500),_=_||setInterval(()=>{if(g&&g.status&&g.rules.promotions&&g.rules.promotions.length){var t=g.rules.promotions[0].specs?.hide_promotion,e=g.rules.promotions[0].specs?.tier,s=g.rules.promotions[0].specs?.type,n=g.rules.promotions[0].specs?.amount_raw,r=g.rules.promotions[0].specs?.currency;if(!t&&("line_items"===e||"percentage"===s)){"product"===LS.template&&C(d("div#single-product"),s,n,r);for(const a of d("[data-product-id]"))C(d(a),s,n,r)}}},500),LS.registerOnChangeVariant(function(t){jQueryNuvem(".lerentools-price-discount").removeClass("lerentools-price-discount")}),t=>{if(x=!1,(p=t).status&&p.products&&p.products.length){if("product"===LS.template){t=p.products.find(t=>t.tn_id===LS.product.id);if(t&&t.tn_id){var e=d("div#single-product"),s=(d(".js-max-installments").hide(),d(".js-product-discount-container").hide(),e.find(".js-product-payments-container")),n=s.find("div.js-max-installments-container"),r=e.find("div.js-payment-discount-price-product-container");if((0'+t.installments_text+"

");else{const c=e.find(".price-container");(0'+t.installments_text+"

")}}}for(const u of p.products){var a=d("div[data-product-id='"+u.tn_id+"']"),l=a.find(".item-price-container"),i=a.find("div.js-max-installments-container"),o=a.find("div.js-payment-discount-price-product-container");0'+u.installments_text+"

")}}});t&&e&&s-e<600?u=u||setInterval(()=>{l(t)},1e3):x||(x=!0,d.get(i+c).done(t=>{Q(I,t),l(t)}).fail(t=>{console.log("Error obteniendo productos sin cuotas",t),x=!1}))},r=500,a=!0;const s=function(){var t=this,e=arguments,s=a&&!l;clearTimeout(l),l=setTimeout(function(){l=null,a||n.apply(t,e)},r),s&&n.apply(t,e)};const d=new MutationObserver(()=>{e?s(e):jQuery&&s(jQuery)}),w={attributes:!0,attributeFilter:["value"],childList:!0,subtree:!0,characterData:!0};var t=[3,5,0],E="undefined"==typeof jQuery?[0,0,0]:$?.fn?.jquery?.split(".").map(t=>parseInt(t));if(E[0]{(e=jQuery.noConflict(!0))&&(d.observe(document.body,w),s(e))};let t=document.createElement("script");t.type="text/javascript",t.readyState?t.onreadystatechange=()=>{"loaded"!=t.readyState&&"complete"!=t.readyState||(t.onreadystatechange=null,O())}:t.onload=()=>{O()},t.src=E,document.getElementsByTagName("head")[0].appendChild(t)}else d.observe(document.body,w),s(jQuery)})();