(()=>{/*!
 * Copyright 2024-2025 Simply.IN Sp. z o.o.
 *
 * NOTICE OF LICENSE
 * Licensed under the EUPL-1.2 or later.
 * You may not use this work except in compliance with the Licence.
 * Copy of the Licence is available at: https://joinup.ec.europa.eu/software/page/eupl
 * It is bundled with this package in the file LICENSE.txt
 *
 * @author    Simply.IN Sp. z o.o.
 * @copyright 2024-2025 Simply.IN Sp. z o.o.
 * @license   https://joinup.ec.europa.eu/software/page/eupl
 */var e=window.jQuery,a=window.simplyin;e(function(){window.SimplyInPayment.bindOnChangeDeliveryOption=function(){let n=this,t=null,i=!1;e(document).ajaxComplete(function(o,d,r){let l=10;r.data&&typeof r.data=="string"&&r.data.includes("action=selectDeliveryOption")&&(t&&clearInterval(t),t=setInterval(function(){e("#card-number").find("div").length==0?(window.SimplyInPayment.setupCardForm(),clearInterval(t)):(l--,l<=0&&clearInterval(t))},150)),n.addIcon()})},window.SimplyInPayment.bindBlikConfirmationEvents=function(){let n=this;typeof tc_confirmOrderValidations<"u"&&(tc_confirmOrderValidations.simplyin_blik=function(){if(e(n.errorMsgBlik).hide(),e(n.successMsgBlik).hide(),n.checkBlikCode()){let t=n.getBlikCode(),i={action:"selectPaymentMethod",ajax:1,ajax_token:a.ajax_token,cart_token:a.cart_token,payment_id:e('input[name="simplyin-payment-option"]:checked').val(),payment_type:"blik",payment_provider:e('input[name="simplyin-payment-option"]:checked').data("payment-provider-name"),provider_image:e('input[name="simplyin-payment-option"]:checked').data("provider-image"),logo:e('input[name="simplyin-payment-option"]:checked').data("logo"),blik_code:t};return e.ajax({url:a.controllers.payment_ajax,method:"POST",data:i,dataType:"json"}),typeof checkAndHideGlobalError=="function"&&checkAndHideGlobalError(),!0}else return e(n.errorMsgBlik).text(n.l("Invalid BLIK code")).show(),typeof scrollToElement=="function"&&scrollToElement(e(n.errorMsgBlik)),!1})},window.SimplyInPayment.bindGeneralConfirmationEvent=function(){let n=this;typeof tc_confirmOrderValidations<"u"&&(tc_confirmOrderValidations.simplyin_general=function(){if(e('input[type="radio"][data-module-name^="simplyin"]:checked').length==0)return!0;let t=e(".simplyin-payment-option:checked"),i=e("#simplyin-payment-error");if(!t.length)return i&&(i.html(n.l("Please select a payment method")),i.fadeIn(),e(".simplyin-payment-option-item").addClass("select-method"),typeof scrollToElement=="function"&&scrollToElement(i)),!1;i&&i.fadeOut()})},window.SimplyInPayment.unbindGeneralConfirmationEvent=function(){typeof tc_confirmOrderValidations<"u"&&typeof tc_confirmOrderValidations.simplyin_general<"u"&&delete tc_confirmOrderValidations.simplyin_general},window.SimplyInPayment.unbindBlikConfirmationEvents=function(){typeof tc_confirmOrderValidations<"u"&&typeof tc_confirmOrderValidations.simplyin_blik<"u"&&delete tc_confirmOrderValidations.simplyin_blik},window.SimplyInPayment.bindCardConfirmationEvents=function(){let n=this,t=typeof showGlobalError=="function"?showGlobalError:null;typeof tc_confirmOrderValidations<"u"&&(tc_confirmOrderValidations.simplyin_card=function(){return n.ott_corect?!0:(e(n.errorMsg).hide(),e(n.successMsg).hide(),typeof showGlobalError=="function"&&(showGlobalError=function(){}),n.cc.createToken().then(i=>{if(i&&i.oneTimeToken){e(n.successMsg).show();let o={action:"selectPaymentMethod",ajax:1,ajax_token:a.ajax_token,cart_token:a.cart_token,payment_id:e('input[name="simplyin-payment-option"]:checked').val(),payment_type:"add-card",payment_provider:e('input[name="simplyin-payment-option"]:checked').data("payment-provider-name"),provider_image:e('input[name="simplyin-payment-option"]:checked').data("provider-image"),logo:e('input[name="simplyin-payment-option"]:checked').data("logo")};e("#simplyin-save-card").is(":checked")?(o.card_name=e("#card-name").val(),o.card_save="1"):(o.card_name="",o.card_save="0"),o.last_digits=i.last4digits,o.card_provider=i.organization,o.ott=i.oneTimeToken,e.ajax({url:a.controllers.payment_ajax,method:"POST",data:o,dataType:"json"}).done(()=>{n.ott_corect=!0,e("#confirm_order").click(),showGlobalError=t})}else typeof showGlobalError=="function"&&(showGlobalError=t,showGlobalError()),e(n.errorMsg).text(n.l("Invalid tokenization response")),e(n.errorMsg).show(),typeof scrollToElement=="function"&&scrollToElement(e(n.errorMsg))}).catch(i=>{e(n.errorMsg).text(n.l("Problem processing card")),e(n.errorMsg).show()}),!1)})},window.SimplyInPayment.unbindCardConfirmationEvents=function(){typeof tc_confirmOrderValidations<"u"&&typeof tc_confirmOrderValidations.simplyin_card<"u"&&delete tc_confirmOrderValidations.simplyin_card},window.SimplyInPayment.hideCardErrors=function(){let n=this;e(".ccIframe-component.has-focus").length&&(typeof checkAndHideGlobalError=="function"&&checkAndHideGlobalError(),e(n.errorMsg).hide())},window.SimplyInPayment.autoSelectPayment=function(){let n=this,t=0,i=setInterval(()=>{e('input[type="radio"][data-module-name^="simplyin"]').length&&(e('input[type="radio"][data-module-name^="simplyin"]').prop("checked",!0).trigger("change"),n.bindGeneralConfirmationEvent(),clearInterval(i)),t++,t>10&&clearInterval(i),n.cc===null&&(n.setupCardForm(),n.addIcon())},500)},window.SimplyInPayment.addIcon=function(){let n=this;if(e(".simplyin-logo-payment").length==0){var t=`${a.files_url}/views/img/logo_smalln.svg`,i=e('.payment-options div[data-payment-module="simplyin"] label').first();i.css({"margin-right":"5px",display:"flex","flex-wrap":"wrap",gap:"10px"}),n.newImg===!1&&(n.newImg=e("<img>",{class:"simplyin-logo-payment",src:t,alt:"Simply.IN",width:20,height:20})),i.find("img").css({height:"20px"}),i.find("img").before(n.newImg),i.find("img").first().after(" & ")}},a.checkout=="thecheckout"&&(window.SimplyInPayment.init(),window.SimplyInPayment.bindOnChangeDeliveryOption(),typeof doNotRefreshOnPaymentMethods<"u"&&doNotRefreshOnPaymentMethods.push("simplyin"))});})();
