/*!
 * 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
 */
$(function(){window.SimplyIn={ajax:"",phones:!1,email_field:!1,email_login_field:!1,customer_email:null,is_login:!1,last_code:!1,is_login_page:!1,on_close_refresh_page:!1,redirect_to_checkout_on_close:!1,counting_interval:!1,counting_message_interval:!1,push_notification_interval:!1,autocomplete_interval:!1,validate_code_timeout:!1,validate_code_sended:!1,last_popup:"",delivery_popup:"",delivery_popup_scroll:0,popup:null,counting_value:0,counting_value_message:0,select_customer_privacy:!1,select_psgdpr:!1,submit_guest_form:!1,login_request_send:!1,active_popup_is_login:!1,last_email:"",send_sms_code_run:!1,send_email_code_run:!1,hideIconCheckout:!1,showIconCheckout:!1,new_account_listeners_inited:!1,force_login:!1,submit_email_in_progress:!1,widgetDisabled:!1,one_click_retired:!1,one_click_busy:!1,one_click_stood_down:!1,one_click_timer:null,init:async function(e={}){this.ajax=simplyin.controllers.ajax,this.is_login=""!=simplyin.customer_email,this.select_customer_privacy=simplyin.select_customer_privacy,this.select_psgdpr=simplyin.select_psgdpr,this.submit_guest_form=simplyin.submit_guest_form,simplyin.display&&!1===simplyin.display.bar_color&&$("body").addClass("simplyin-bar-mono"),simplyin.display&&!1===simplyin.display.badge_color&&$("body").addClass("simplyin-badge-mono"),simplyin.display&&simplyin.display.accent_color&&document.documentElement.style.setProperty("--simplyin-accent-color",simplyin.display.accent_color),simplyin.display&&simplyin.display.font_color&&document.documentElement.style.setProperty("--simplyin-font-color",simplyin.display.font_color),simplyin.order_sended||(void 0!==simplyin.order?this.placeOrder():await this.preloadImages().then(()=>{this.initCheckout(),this.initEventListeners(),this.initEventListenersPin(),this.initEventListenersDelivery(),this.initEventListenersEditAddress(),this.initEventListenersAddParcelLocker(),this.initEventListenersNewAccount(),this.initDhlAssistantDisplay(),this.dpdshippingmodule(),this.furgonetkamodule(),this.authController(),this.initAddressForm(),this.initOneClickOffer()}),this.customer_email=simplyin.customer_email)},initCheckout:function(){this.initOpcStandard(),simplyin.customer.need_login&&"order"==simplyin.controller&&$("#checkout-personal-information-step.-current").length>0&&(simplyin.customer.need_login=!1,this.force_login=!0,this.submitEmail(!1))},preloadImages(){const e=simplyin.files_url+"/views/img/";return Promise.all(["logo_smalln.svg","logo_medium.svg","edit_icon.svg","trash_icon.svg","close_icon.svg","point.svg","expand_icon.svg","dots_icon.svg","add_icon.svg"].map(i=>new Promise(n=>{const t=new Image;t.onload=n,t.onerror=n,t.src=e+i})))},initAddressForm:function(){const e=this;simplyin.customer.logged&&1==simplyin.customer.logged&&0==simplyin.customer.has_selected_address&&simplyin.customer.has_token&&-1==window.location.search.indexOf("action")&&e.showPopupByType("delivery",{email:simplyin.customer_email}),"dpd"==simplyin.customer.point.label&&e.waitForElement(".dpdshipping-pudo-new-point",function(){dpdshippingSavePudoCode(simplyin.customer.point.locker_id,{modal:function(e){}});let e=$("span.dpdshipping-selected-point");dpdshippingGetPudoAddress(simplyin.customer.point.locker_id,e)},2e4)},waitForElement:function(e,i,n){if($(e).length)i();else{var t=new MutationObserver(function(){$(e).length&&(t.disconnect(),i())});t.observe(document.body,{childList:!0,subtree:!0}),n&&setTimeout(function(){t.disconnect()},n)}},barEnabled:function(){return!simplyin.display||!!simplyin.display.bar},badgeEnabled:function(){return!0},barHtml:function(){return`\n                <div class="simplyin-logo-container">\n                  <div class="simplyin-logo-inner">\n                    <div class="simplyin-logo-svg-wrap">\n                      <span class="simplyin-logo-line"></span>\n                      <span class="simplyin-logo-caption">${simplyin.labels.bar_caption}</span>\n                      <img class="simplyin-logo-brand" src="${simplyin.files_url}/views/img/logo_medium.svg" alt="simply.in"/>\n                      <span class="simplyin-logo-line"></span>\n                    </div>\n                  </div>\n                </div>\n            `},fieldBadgeHtml:function(){return`\n                <div class="simplyin-field-badge">\n                  <img class="simplyin-field-badge-logo" src="${simplyin.files_url}/views/img/logo_medium.svg" alt="simply.in"/>\n                </div>\n            `},injectFieldBadge:function(e){var i=$(e);i.length&&!i.siblings(".simplyin-field-badge").length&&(i.parent().hasClass("simplyin-field-wrap")||i.wrap('<div class="simplyin-field-wrap"></div>'),i.after(this.fieldBadgeHtml()),$(".simplyin-show-popup").is(":visible")&&$(".simplyin-field-badge").hide())},initOpcStandard:function(){if(this.email_field='#customer-form input[name="email"]',$(this.email_field).length){var e=$(this.email_field),i=e.closest(".form-group"),n=$("#customer-form");i.length&&n.length&&(n.prepend(i),this.customer_email=simplyin.customer_email,""!=simplyin.customer_email?(e.parent().append(`\n                            <div class="simplyin-show-popup">\n                                <div class="simplyin-show-popup-icon">\n                                    <img width="30" height="30" src="${simplyin.files_url}/views/img/logo_smalln.svg"/>\n                                    <svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n                                      <rect y="0.5" width="12" height="12" rx="6" fill="#33CC40"></rect>\n                                      <path d="M3.23096 6.54276L5.07711 8.38892L8.76942 4.38892" stroke="white" stroke-width="1.23077" stroke-linecap="round" stroke-linejoin="round"></path>\n                                    </svg>\n                                </div>\n                                <div class="simplyin-show-popup-edit">\n                                    <span>${simplyin.labels.data_completed}</span>\n                                    <div class="simplyin-show-popup-edit-bottom">\n                                      <span>${simplyin.labels.change}</span>\n                                      <svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">\n                                        <path d="M8.41604 2.74719L8.97217 2.19107C9.89359 1.26964 11.3875 1.26964 12.3089 2.19107C13.2304 3.11249 13.2304 4.60641 12.3089 5.52783L11.7528 6.08396M8.41604 2.74719C8.41604 2.74719 8.48556 3.92897 9.5283 4.97171C10.571 6.01445 11.7528 6.08396 11.7528 6.08396M8.41604 2.74719L3.30329 7.85994C2.957 8.20624 2.78385 8.37939 2.63494 8.5703C2.45928 8.79551 2.30868 9.03919 2.18581 9.29701C2.08164 9.51558 2.00421 9.74789 1.84934 10.2125L1.3535 11.7M11.7528 6.08396L6.64006 11.1967C6.29376 11.543 6.12061 11.7162 5.9297 11.8651C5.70449 12.0407 5.46082 12.1913 5.20299 12.3142C4.98442 12.4184 4.75211 12.4958 4.28751 12.6507L2.8 13.1465M2.8 13.1465L1.8375 13.4673C1.60887 13.5435 1.35679 13.484 1.18638 13.3136C1.01596 13.1432 0.956457 12.8911 1.03267 12.6625L1.3535 11.7M2.8 13.1465L1.3535 11.7" stroke="#2D40F6" stroke-width="1.6"></path>\n                                      </svg>\n                                    </div>\n                                </div>\n                            </div>\n                        `),$(e).val(simplyin.customer_email),simplyin.customer.has_token||this.hideIcon()):(e.parent().append(` <br/>\n                            <div class="simplyin-show-popup" style="margin-left: 0">\n                                <div class="simplyin-show-popup-icon">\n                                    <img width="30" height="30" src="${simplyin.files_url}/views/img/logo_smalln.svg"/>\n                                    <svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n                                      <rect y="0.5" width="12" height="12" rx="6" fill="#33CC40"></rect>\n                                      <path d="M3.23096 6.54276L5.07711 8.38892L8.76942 4.38892" stroke="white" stroke-width="1.23077" stroke-linecap="round" stroke-linejoin="round"></path>\n                                    </svg>\n                                </div>\n                                <div class="simplyin-show-popup-edit">\n                                    <span>${simplyin.labels.data_completed}</span>\n                                    <div class="simplyin-show-popup-edit-bottom">\n                                      <span>${simplyin.labels.change}</span>\n                                      <svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">\n                                        <path d="M8.41604 2.74719L8.97217 2.19107C9.89359 1.26964 11.3875 1.26964 12.3089 2.19107C13.2304 3.11249 13.2304 4.60641 12.3089 5.52783L11.7528 6.08396M8.41604 2.74719C8.41604 2.74719 8.48556 3.92897 9.5283 4.97171C10.571 6.01445 11.7528 6.08396 11.7528 6.08396M8.41604 2.74719L3.30329 7.85994C2.957 8.20624 2.78385 8.37939 2.63494 8.5703C2.45928 8.79551 2.30868 9.03919 2.18581 9.29701C2.08164 9.51558 2.00421 9.74789 1.84934 10.2125L1.3535 11.7M11.7528 6.08396L6.64006 11.1967C6.29376 11.543 6.12061 11.7162 5.9297 11.8651C5.70449 12.0407 5.46082 12.1913 5.20299 12.3142C4.98442 12.4184 4.75211 12.4958 4.28751 12.6507L2.8 13.1465M2.8 13.1465L1.8375 13.4673C1.60887 13.5435 1.35679 13.484 1.18638 13.3136C1.01596 13.1432 0.956457 12.8911 1.03267 12.6625L1.3535 11.7M2.8 13.1465L1.3535 11.7" stroke="#2D40F6" stroke-width="1.6"></path>\n                                      </svg>\n                                    </div>\n                                </div>\n                            </div>\n                        `),this.hideIcon()))}else{$(".identity").parent().prepend(`\n                    <div class="simplyin-identity-right">\n                        <div class="simplyin-show-popup">\n                            <div class="simplyin-show-popup-icon">\n                                <img width="30" height="30" src="${simplyin.files_url}/views/img/logo_smalln.svg"/>\n                                <svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n                                  <rect y="0.5" width="12" height="12" rx="6" fill="#33CC40"></rect>\n                                  <path d="M3.23096 6.54276L5.07711 8.38892L8.76942 4.38892" stroke="white" stroke-width="1.23077" stroke-linecap="round" stroke-linejoin="round"></path>\n                                </svg>\n                            </div>\n                            <div class="simplyin-show-popup-edit">\n                                <span>${simplyin.labels.data_completed}</span>\n                                <div class="simplyin-show-popup-edit-bottom">\n                                  <span>${simplyin.labels.change}</span>\n                                  <svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">\n                                    <path d="M8.41604 2.74719L8.97217 2.19107C9.89359 1.26964 11.3875 1.26964 12.3089 2.19107C13.2304 3.11249 13.2304 4.60641 12.3089 5.52783L11.7528 6.08396M8.41604 2.74719C8.41604 2.74719 8.48556 3.92897 9.5283 4.97171C10.571 6.01445 11.7528 6.08396 11.7528 6.08396M8.41604 2.74719L3.30329 7.85994C2.957 8.20624 2.78385 8.37939 2.63494 8.5703C2.45928 8.79551 2.30868 9.03919 2.18581 9.29701C2.08164 9.51558 2.00421 9.74789 1.84934 10.2125L1.3535 11.7M11.7528 6.08396L6.64006 11.1967C6.29376 11.543 6.12061 11.7162 5.9297 11.8651C5.70449 12.0407 5.46082 12.1913 5.20299 12.3142C4.98442 12.4184 4.75211 12.4958 4.28751 12.6507L2.8 13.1465M2.8 13.1465L1.8375 13.4673C1.60887 13.5435 1.35679 13.484 1.18638 13.3136C1.01596 13.1432 0.956457 12.8911 1.03267 12.6625L1.3535 11.7M2.8 13.1465L1.3535 11.7" stroke="#2D40F6" stroke-width="1.6"></path>\n                                  </svg>\n                                </div>\n                            </div>\n                        </div>\n                    </div>\n                `)}this.barEnabled()&&$("#checkout-personal-information-step").prepend(this.barHtml()),this.badgeEnabled()&&this.injectFieldBadge(this.email_field),this.dockBadge()},initOneClickOffer:function(){this.one_click_stood_down=this.force_login,"undefined"!=typeof prestashop&&"function"==typeof prestashop.on&&prestashop.on("updatedCart",()=>{this.syncOneClickOfferState()}),this.syncOneClickOfferState()},syncOneClickOfferState:function(){$(".simplyin-one-click").length&&(this.one_click_stood_down||this.one_click_retired?this.retireOneClickOffer():$(".simplyin-one-click-button").prop("disabled",this.one_click_busy))},startOneClickAuthorization:function(){if(!this.one_click_busy&&!this.one_click_retired){this.setOneClickBusy(!0),this.force_login=!0,this.customer_email=simplyin.customer.email,this.one_click_timer=setTimeout(()=>{this.setOneClickBusy(!1)},15e3);var e=this.submitEmail(!1);e&&"function"==typeof e.always&&(e.always(()=>{clearTimeout(this.one_click_timer)}),e.fail(()=>{this.setOneClickBusy(!1)}))}},setOneClickBusy:function(e){clearTimeout(this.one_click_timer),this.one_click_busy=e,$(".simplyin-one-click-button").prop("disabled",e)},retireOneClickOffer:function(){this.one_click_retired=!0,this.setOneClickBusy(!1),$(".simplyin-one-click").remove()},initEventListeners:function(){const e=this;$(document).on("click",".simplyin-popup-close-button, .simplyin-popup-overlay",function(){$(this).hasClass("simplyin-popup-overlay")&&"1"===$("#simplyin-input-code").attr("data-shop-login-challenge")||e.hidePopup()}),$(document).on("click",".simplyin-show-popup",function(){e.showLastPopup()}),$(document).on("input",this.email_field,function(){e.force_login=!1;let i=!1;e.is_login&&e.customer_email!=$(this).val()&&(i=!0),e.customer_email!=$.trim($(this).val())&&(e.login_request_send=!1,e.isValidEmailAddress(e.customer_email)||e.hideIcon(),e.customer_email=$.trim($(this).val()),e.stopPushNotifications(),e.submitEmail(i))}),$(document).on("click","#simplyin-button-send-sms",function(){e.sendSmsCode(),e.stopPushNotifications()}),$(document).on("click","#simplyin-button-send-email",function(){e.sendEmailCode(),e.stopPushNotifications()}),$(document).on("click","#simplyin-button-resend-shop-login",function(){e.startShopLoginEmailChallenge(!0)}),$(document).on("click",".simplyin-one-click-button",function(i){i.preventDefault(),e.startOneClickAuthorization()})},toggleElement:function(e,i,n){let t=$("#"+i+" "+e);n?$(t).slideDown({duration:150}):$(t).slideUp({duration:150})},positionMenu:function(e,i){let n=e.offset(),t=e.outerHeight(),s=e.outerWidth();window.innerWidth<685?i.css({top:n.top+t+"px",right:s+"px",zIndex:20000001}):i.css({top:n.top+t+"px",left:n.left+"px",zIndex:20000001})},toggleDeliveryAddress:function(e){let i=$(e).data("target"),n=$(e).is(".expanded");$('.popup-address-select-label-group input[type="checkbox"]').is(":checked");this.toggleElement(".popup-address-select-group",i,n)},initEventListenersPin:function(){const e=this;var i='#simplyin-input-code input[type="text"]';$(document).on("keypress",i,function(e){/[0-9]/.test(e.key)||e.preventDefault()}),$(document).on("input",i,function(){var n=$(i),t=n.index(this),s=this.value;if((s=s.replace(/\D/g,"")).length>1){for(let e=0;e<s.length&&t+e<n.length;e++)n.eq(t+e).val(s[e]);let e=t+s.length<n.length?t+s.length:n.length-1;n.eq(e).focus().select()}else this.value=s,1===s.length&&t<n.length-1&&n.eq(t+1).focus().select();e.validatePinCode()}),$(document).on("keydown",i,function(e){var n=$(i),t=n.index(this);switch(e.key){case"Backspace":if(e.preventDefault(),this.value="",t>0)n.eq(t-1).focus().select();break;case"ArrowLeft":if(t>0)e.preventDefault(),n.eq(t-1).focus().select();break;case"ArrowRight":if(t<n.length-1)e.preventDefault(),n.eq(t+1).focus().select()}}),$(document).on("paste",i,function(n){n.preventDefault();const t=(n.originalEvent||n).clipboardData||window.clipboardData;if(!t)return;const s=(t.getData("text")||"").replace(/\D/g,"");if(!s)return;const o=$(i);let a=o.index(this);for(let e=0;e<s.length&&a<o.length;e++,a++)o.eq(a).val(s[e]);o.filter((e,i)=>""===i.value);e.validatePinCode()}),$(document).on("keyup",i,e.validatePinCode)},removeContextMenu:function(){$(".dropdown-actions-menu").remove(),$(".simplyin-popup-overlay-context").remove()},deleteAddress:function(e,i){const n=this;n.removeContextMenu();n.confirmationPopup(simplyin.labels.delete_header,simplyin.labels.confirm_delete,function(){let t={action:"deleteAddress",ajax:1,ajax_token:simplyin.ajax_token,id:e,address_type:i};$.ajax({url:n.ajax,method:"POST",data:t,dataType:"json"}).done(t=>{t.success&&("billingAddresses"==i?$(`.popup-address-select[data-id="${e}"]`).parent().remove():$(`.popup-address-select[data-id="${e}"]`).remove(),n.removeContextMenu(),n.checkSelectedAddress(),n.last_popup="")})})},initEventListenersDelivery:function(){const e=this;$(document).on("change",'#simplyin-parcel-lockers input[name="simplyin-parcel-locker-selected"],#simplyin-delivery-points input[name="simplyin-delivery-point-selected"]',function(){$("#popup-delivery-parcel-locker-address .popup-selected-address .popup-address-label-line-1").html($(this).data("address-1")),"simplyin-delivery-point-selected"==$(this).attr("name")?$('input[name="simplyin-parcel-locker-selected"]').prop("checked",!1):$('input[name="simplyin-delivery-point-selected"]').prop("checked",!1)}),$(document).on("change",'input[name="simplyin-invoice-address"]',function(){$("#popup-invoice-address .popup-selected-address .popup-selected-address-line-1").html($(this).data("address-1")),$("#popup-invoice-address .popup-selected-address .popup-selected-address-line-2").html($(this).data("address-2"))}),$(document).on("change",'input[name="simplyin-delivery-address"]',function(){$("#popup-delivery-address .popup-selected-address .popup-selected-address-line-1").html($(this).data("address-1")),$("#popup-delivery-address .popup-selected-address .popup-selected-address-line-2").html($(this).data("address-2"))}),$(document).on("click",function(){e.removeContextMenu()}),$(document).on("click",".simplyin-button-edit",function(i){i.stopPropagation(),e.removeContextMenu(),e.editAddress($(this).data("id"),$(this).data("address-type"))}),$(document).on("click",".simplyin-button-delete",function(i){i.stopPropagation();let n=$(this).data("id"),t=$(this).data("address-type");e.deleteAddress(n,t)}),$(document).on("click",".popup-address-actions",function(i){i.stopPropagation(),e.removeContextMenu();let n=$(this).parents(".popup-address-selector").find(".popup-address-select").length,t=parseInt($(this).parents(".popup-address-selector").data("edit")),s=parseInt($(this).parents(".popup-address-selector").data("delete")),o=parseInt($(this).parents(".popup-address-selector").data("force-delete")),a=simplyin.labels.edit,l=(simplyin.labels.delete,$('<div class="dropdown-actions-menu"><ul></ul></div>')),p=$(this).parents(".popup-address-select").data("id");if(!t&&!s)return;let r="";r=$(this).parents("#popup-invoice-address").length?"billingAddresses":$(this).parents("#popup-delivery-address").length?"shippingAddresses":"parcelLockers",t&&$(l).find("ul").append(`\n                        <li class="simplyin-button-edit edit-action" data-id="${p}" data-address-type="${r}">\n                            <svg class="simplyin-action-icon" width="23" height="24" viewBox="0 0 23 24" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="${a}">\n                              <path d="M20.3103 7.2539L16.1216 3.06422C15.9823 2.92489 15.8169 2.81437 15.6349 2.73897C15.4529 2.66357 15.2578 2.62476 15.0608 2.62476C14.8638 2.62476 14.6687 2.66357 14.4867 2.73897C14.3047 2.81437 14.1393 2.92489 14 3.06422L2.43969 14.6255C2.2998 14.7642 2.18889 14.9295 2.11341 15.1115C2.03792 15.2935 1.99938 15.4887 2.00001 15.6858V19.8755C2.00001 20.2733 2.15804 20.6548 2.43935 20.9361C2.72065 21.2174 3.10218 21.3755 3.50001 21.3755H7.6897C7.88675 21.3761 8.08197 21.3375 8.26399 21.2621C8.44602 21.1866 8.61122 21.0757 8.75001 20.9358L20.3103 9.37547C20.4496 9.23617 20.5602 9.0708 20.6356 8.88879C20.711 8.70678 20.7498 8.5117 20.7498 8.31468C20.7498 8.11767 20.711 7.92259 20.6356 7.74058C20.5602 7.55857 20.4496 7.3932 20.3103 7.2539ZM7.6897 19.8755H3.50001V15.6858L11.75 7.43578L15.9397 11.6255L7.6897 19.8755ZM17 10.5642L12.8103 6.37547L15.0603 4.12547L19.25 8.31422L17 10.5642Z"/>\n                            </svg>\n                            ${a}\n                        </li>\n                    `),(n>1&&s||o)&&$(l).find("ul").append(`\n                        <li class="simplyin-button-delete delete-action" data-id="${p}" data-address-type="${r}">\n                            <svg class="simplyin-action-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Usuń">\n                              <path d="M20.25 5.25H16.5V4.5C16.5 3.90326 16.2629 3.33097 15.841 2.90901C15.419 2.48705 14.8467 2.25 14.25 2.25H9.75C9.15326 2.25 8.58097 2.48705 8.15901 2.90901C7.73705 3.33097 7.5 3.90326 7.5 4.5V5.25H3.75C3.55109 5.25 3.36032 5.32902 3.21967 5.46967C3.07902 5.61032 3 5.80109 3 6C3 6.19891 3.07902 6.38968 3.21967 6.53033C3.36032 6.67098 3.55109 6.75 3.75 6.75H4.5V20.25C4.5 20.6478 4.65804 21.0294 4.93934 21.3107C5.22064 21.592 5.60218 21.75 6 21.75H18C18.3978 21.75 18.7794 21.592 19.0607 21.3107C19.342 21.0294 19.5 20.6478 19.5 20.25V6.75H20.25C20.4489 6.75 20.6397 6.67098 20.7803 6.53033C20.921 6.38968 21 6.19891 21 6C21 5.80109 20.921 5.61032 20.7803 5.46967C20.6397 5.32902 20.4489 5.25 20.25 5.25ZM9 4.5C9 4.30109 9.07902 4.11032 9.21967 3.96967C9.36032 3.82902 9.55109 3.75 9.75 3.75H14.25C14.4489 3.75 14.6397 3.82902 14.7803 3.96967C14.921 4.11032 15 4.30109 15 4.5V5.25H9V4.5ZM18 20.25H6V6.75H18V20.25ZM10.5 10.5V16.5C10.5 16.6989 10.421 16.8897 10.2803 17.0303C10.1397 17.171 9.94891 17.25 9.75 17.25C9.55109 17.25 9.36032 17.171 9.21967 17.0303C9.07902 16.8897 9 16.6989 9 16.5V10.5C9 10.3011 9.07902 10.1103 9.21967 9.96967C9.36032 9.82902 9.55109 9.75 9.75 9.75C9.94891 9.75 10.1397 9.82902 10.2803 9.96967C10.421 10.1103 10.5 10.3011 10.5 10.5Z"/>\n                            </svg>\n                            Usuń\n                        </li>\n                    `),n>=1&&(t||s)&&$(l).find("li").length>0&&($(".simplyin-popup").parent().append(l),SimplyIn.positionMenu($(this),l))}),$(document).on("change",'.popup-address-select-label-group input[type="checkbox"]',function(i){i.preventDefault();const n=$('.popup-button-expand[data-target="popup-delivery-address"]')[0];let t=$(this).parents(".popup-address-select-label-group").find('input[type="checkbox"]').is(":checked"),s=$('.popup-button-expand[data-target="popup-delivery-address"]');return t||s.is(".expanded")?s.removeClass("expanded"):s.addClass("expanded"),t?$("#popup-delivery-address").find('input[type="radio"]').prop("checked",!1):$("#popup-delivery-address").find('input[type="radio"]:first').prop("checked",!0),e.toggleDeliveryAddress(n),!1}),$(window).on("resize",function(){e.removeContextMenu()}),$(document).on("change",".simplyin-delivery-type",function(e){e.preventDefault(),"address"==$(this).val()?($(".popup-delivery-address-box").show(),$(".popup-delivery-parcel-locker-box").hide()):($(".popup-delivery-parcel-locker-box .popup-button-expand").addClass("expanded"),$(".popup-delivery-address-box").hide(),$(".popup-delivery-parcel-locker-box").show())}),$(document).on("click",'.popup-button-expand[data-target="popup-invoice-address"]',function(i){i.preventDefault();let n=$(this).data("target"),t=$(this).is(".expanded");$(this).toggleClass("expanded"),e.toggleElement(".popup-address-select-group",n,!t)}),$(document).on("click",'.popup-button-expand[data-target="popup-delivery-parcel-locker-address"]',function(i){i.preventDefault();let n=$(this).data("target"),t=$(".popup-address-selector-header button.active").data("target"),s=$(".popup-address-selector-header button:not(.active)").data("target");$(this).toggleClass("expanded");let o=$(this).is(".expanded");e.toggleElement(".popup-address-select-group",n,o),$("#"+t).show(),$("#"+s).hide()}),$(document).on("click",'.popup-button-expand[data-target="popup-delivery-address"]',function(i){i.preventDefault(),$(this).toggleClass("expanded"),e.toggleDeliveryAddress(this)}),$(document).on("change",'#popup-delivery-address input[type="radio"]',function(e){e.preventDefault(),$('.popup-address-select-label-group input[type="checkbox"]').prop("checked",!1)}),$(document).on("click",".popup-address-selector-header button",function(e){e.preventDefault(),$(".popup-delivery-parcel-locker-box .popup-button-expand").addClass("expanded");let i=$(this).data("target");$(this).addClass("active").siblings().removeClass("active"),$("#"+i).show().siblings().hide()}),$(document).on("click",".popup-address-actions-add",function(i){i.preventDefault();let n=$(this).data("type");e.storeDeliveryPopup();var t={action:"addAddress",ajax:1,ajax_token:simplyin.ajax_token,address_type:n};$.ajax({url:e.ajax,method:"POST",data:t,dataType:"json"}).done(i=>{i.success&&(e.showPopupByContent(i.html),e.initAutocomplete(),$("#pickup-search").focus())})}),$(document).on("click",".popup-select-address",function(){e.selectAddress()})},initAutocomplete:function(){const e=this,i=document.querySelector(".simplyin-autocomplete #pickup-search");if(!i)return;const n=document.createElement("div");function t(){const e=i.getBoundingClientRect();n.style.width=e.width+"px",n.style.left=e.left+window.scrollX+"px",n.style.top=e.bottom+window.scrollY+"px"}n.className="autocomplete-dropdown",n.style.position="absolute",n.style.zIndex="999999999",n.style.display="none",n.style.backgroundColor="#fff",n.style.border="1px solid #ccc",n.style.maxHeight="200px",n.style.overflowY="auto",document.body.appendChild(n);let s=null,o=null;function a(){o&&(o.abort(),o=null)}i.addEventListener("input",function(l){s&&(clearTimeout(s),s=null),a();const p=i.value;p.length<3?n.style.display="none":s=setTimeout(function(){o=e.fetchAddressSuggestions({term:p},function(s){o=null,n.innerHTML="",s&&s.length?(s.forEach(t=>{const s=document.createElement("div");s.textContent=t.label||t.value||t,s.style.padding="5px 10px",s.style.cursor="pointer",s.addEventListener("mousedown",function(o){o.preventDefault(),i.value=s.textContent;const a={item:t};e.handleSelect(o,a),n.style.display="none"}),n.appendChild(s)}),t(),n.style.display="block"):n.style.display="none"})},300)}),document.addEventListener("click",function(e){i.contains(e.target)||n.contains(e.target)||(s&&(clearTimeout(s),s=null),a(),n.style.display="none")});let l=-1;i.addEventListener("keydown",function(e){const i=n.querySelectorAll("div");i.length&&("ArrowDown"===e.key?(e.preventDefault(),l=(l+1)%i.length,i.forEach((e,i)=>e.style.background=i===l?"#ddd":"")):"ArrowUp"===e.key?(e.preventDefault(),l=(l-1+i.length)%i.length,i.forEach((e,i)=>e.style.background=i===l?"#ddd":"")):"Enter"===e.key&&(e.preventDefault(),l>=0&&(i[l].dispatchEvent(new Event("mousedown")),l=-1)))}),window.addEventListener("resize",t),window.addEventListener("scroll",t)},fetchAddressSuggestions:function(e,i){const n=this;return $.ajax({url:n.ajax,method:"POST",data:{action:"searchAddress",ajax:1,ajax_token:simplyin.ajax_token,address:e.term},dataType:"json",success:function(e){if(e&&e.data){const t=n.mapAddressData(e.data);i(t)}}})},mapAddressData:function(e){return e.map(function(e){return{label:e.formatted_address,value:e.formatted_address,place_id:e.place_id,geometry:e.geometry}})},handleSelect:function(e,i){const n=this;$('.simplyin-pickup-list-item input[name="pickup-option"]').val(i.item.value);let t=i.item.geometry.location.lat,s=i.item.geometry.location.lng,o={action:"getClosestParcelLockers",ajax:1,ajax_token:simplyin.ajax_token,coordinates:{lat:t,lng:s}};$.ajax({url:SimplyIn.ajax,method:"POST",data:o,dataType:"json"}).done(e=>{e.success&&n.fillParcelsList(e)})},initEventListenersEditAddress:function(){const e=this;$(document).on("click",".simplyin-popup-addres-form button.simplyin-cancel",function(i){i.preventDefault(),e.retrieveDeliveryPopup()}),$(document).on("click",".simplyin-popup-addres-form button.simplyin-submit",function(i){i.preventDefault(),e.submitAddress()})},clearParcelsList:function(){$(".pickup-placeholder").show(),$(".pickup-list-container").empty().hide()},fillParcelsList:function(e){const i=this;if(e.data.count){let n="";$.each(e.data.data,function(e,i){let t=i.locker,s=i.info,o=t.address,a=Math.round(1e3*s.distance),l=s.provider,p=t.desc;n+=`\n                        <div class="simplyin-pickup-list-item">\n                            <label class="pickup-item">\n                                <input\n                                    type="radio"\n                                    name="pickup-option"\n                                    value="${t._id}"\n                                    data-id="${t.lockerId}"\n                                    data-address="${o}"\n                                    data-desc="${p}"\n                                    data-locker-id="${t.lockerId}"\n                                    data-logo-url="${l.logoUrl}"\n                                    data-label="${l.name}"\n                                    data-provider-id="${t.providerId}"\n                                    data-service-type="${t.service_type}"\n                                >\n                                <div class="pickup-info">\n                                    <img src="${l.logoUrl}" alt="${l.name}">\n                                    <div class="pickup-details">\n                                        <strong>${t.lockerId}</strong>\n                                        <span>${o}</span>\n                                        <span>${simplyin.labels.edit}: ${a} m</span>\n                                    </div>\n                                </div>\n                            </label>\n                        </div>\n                    `}),i.clearParcelsList(),$(".pickup-list-container").html(n),$(".pickup-placeholder").hide(),$(".pickup-list-container").show()}else i.clearParcelsList()},selectNewParcel:function(e){let i=$(e).data("id"),n=$(e).data("address"),t=$(e).data("desc");$("#simplyin-pickup-number").html(i),$("#simplyin-pickup-address").html(n),$("#simplyin-pickup-info").html(t)},initEventListenersAddParcelLocker:function(){const e=this;$(document).on("change",'.simplyin-pickup-list-item input[name="pickup-option"]',function(){e.selectNewParcel(this)}),$(document).on("click",".simplyin-autocomplete button.simplyin-cancel",function(i){i.preventDefault(),e.retrieveDeliveryPopup(),$('input[name="simplyin-delivery-type"][value="parcel_locker"]').prop("checked",!0)}),$(document).on("click",".simplyin-autocomplete button.simplyin-submit",function(i){i.preventDefault();const n=$('input[name="pickup-option"]:checked');n.length&&(e.addNewParcelLocker(n),$('input[name="simplyin-delivery-type"][value="parcel_locker"]').prop("checked",!0))}),$(document).on("enter",'.simplyin-popup input[name="pickup-name"]',function(i){const n=$('input[name="pickup-option"]:checked');n.length&&e.addNewParcelLocker(n)})},addNewParcelLocker:function(e){const i=this;let n={action:"submitAddress",ajax:1,ajax_token:simplyin.ajax_token,parcel:{address_type:"parcelLockers",_id:$(e).val(),logoUrl:$(e).data("logoUrl"),addressName:$.trim($("#pickup-name").val())?$.trim($("#pickup-name").val()):e.data("id"),lockerId:e.data("id"),address:e.data("address"),label:e.data("label"),providerId:e.data("providerId"),service_type:e.data("service-type")}};$.ajax({url:SimplyIn.ajax,method:"POST",data:n,dataType:"json"}).done(e=>{if(e.success&&void 0!==e.html){let n=$(e.html),t=n.find("#simplyin-delivery-points").html(),s=n.find("#simplyin-parcel-lockers").html();i.retrieveDeliveryPopup(),$("#simplyin-parcel-lockers").html(s),$("#simplyin-delivery-points").html(t)}})},submitAddress:function(e){const i=this;let n=$("form.simplyin-popup-addres-form"),t=n.find("input[required]"),s=!0;if($.each(t,function(e,i){""==$(i).val()?($(i).parents(".form-group").addClass("error"),s=!1):$(i).parents(".form-group").removeClass("error")}),!s)return!1;let o={action:"submitAddress",ajax:1,ajax_token:simplyin.ajax_token};var a=new FormData;$.each(o,function(e,i){a.append(e,i)}),$.each(n[0].elements,function(e,i){""!=i.name&&a.append("address["+i.name+"]",i.value)}),$.ajax({url:this.ajax,method:"POST",data:a,processData:!1,contentType:!1,dataType:"json"}).done(e=>{e.success&&(!0!==e.is_valid&&"object"==typeof e.is_valid?(n.find(".form-group").removeClass("error"),$.each(e.is_valid,function(i,t){n.find('input[name="'+i+'"]').parents(".form-group").addClass("error"),n.find('input[name="'+i+'"]').parents(".form-group").find(".error-message").html(e.is_valid[i])})):!0===e.is_valid&&void 0!==e.address?(i.retrieveDeliveryPopup(),i.upgradeAddress(e)):!0===e.is_valid&&void 0!==e.add_address&&(i.retrieveDeliveryPopup(),i.addAddress(e.address,e.address_type,e.html)),i.checkSelectedAddress())})},checkSelectedAddress:function(){0==$('input[name="simplyin-invoice-address"]:checked').length&&$('input[name="simplyin-invoice-address"]:first').prop("checked",!0),$(".popup-address-checkbox .checkbox:checked")&&0==$('input[name="simplyin-delivery-address"]:checked').length&&$('input[name="simplyin-delivery-address"]:first').prop("checked",!0)},upgradeAddress:function(e){let i=e.address,n=(e.address_type,"");n=$('div[data-id="'+i._id+'"]');let t=i.addressName,s=i.street;""!=i.appartmentNumber&&(s=i.street+"/"+i.appartmentNumber),s=s+", "+i.city,n.find(".popup-address-label-line-1").html(t),n.find(".popup-address-label-line-2").html(s),n.find(".icon").html(i.icon)},addAddress:function(e,i,n){let t="",s=$(n),o=!1,a="";"billingAddresses"==i?(o=s.find("#popup-invoice-address .popup-address-select-group:last"),t=$("#popup-invoice-address"),a='input[name="simplyin-invoice-address"]:last'):"shippingAddresses"==i?(o=s.find("#popup-delivery-address .popup-address-select:last"),t=$("#popup-delivery-address").find(".popup-address-select-group"),a='input[name="simplyin-delivery-address"]:last'):"parcelLockers"==i&&(o=!1),t.length&&!1!==o&&(t.append(o),$(a).prop("checked",!0),"shippingAddresses"==i&&($('#popup-delivery-address .popup-address-checkbox input[type="checkbox"]').prop("checked",!1),t.show(),$('.popup-button-expand[data-target="popup-delivery-address"]').addClass("expanded")))},selectDefaultAddress:function(){let e=$('input[name="simplyin-invoice-address"]:checked').data("id");if(!e)return;let i=e,n={action:"selectAddress",ajax:1,ajax_token:simplyin.ajax_token,invoice_address:e,service_type:"",delivery_address:i,selected_point:""};$.ajax({url:this.ajax,method:"POST",data:n,dataType:"json"})},selectAddress:function(){const e=this;let i=$('input[name="simplyin-invoice-address"]:checked').data("id"),n="",t="",s="";"address"==$('.simplyin-delivery-type[type="radio"]:checked').val()?n=$('.popup-address-checkbox input[type="checkbox"]').is(":checked")?$('input[name="simplyin-invoice-address"]:checked').data("id"):$('input[name="simplyin-delivery-address"]:checked').data("id"):$('input[name="simplyin-parcel-locker-selected"]:checked').length?(s="parcel",t=$('input[name="simplyin-parcel-locker-selected"]:checked').data("id")):$('input[name="simplyin-delivery-point-selected"]:checked').length&&(s="delivery",t=$('input[name="simplyin-delivery-point-selected"]:checked').data("id"));let o={action:"selectAddress",ajax:1,ajax_token:simplyin.ajax_token,invoice_address:i,service_type:s,delivery_address:n,selected_point:t};$.ajax({url:this.ajax,method:"POST",data:o,dataType:"json"}).done(i=>{i.redirect?(e.on_close_refresh_page=!0,e.hidePopup()):(e.hidePopup(),e.selectCheckbox())})},submitEmail:function(e){this.last_popup="";const i=this;if(0==this.is_login||e){this.is_login=!1;var n=this.customer_email;if(!this.isValidEmailAddress(n)&&!1===this.force_login)return;var t={action:"submitEmail",ajax:1,ajax_token:simplyin.ajax_token,email:n,logout:e,force_login:this.force_login?1:0};return $.ajax({url:i.ajax,method:"POST",data:t,dataType:"json"}).done(e=>{if(e&&e.success&&e.show_popup&&e.shop_login_challenge){if(n!==i.customer_email)return;return i.last_email=n,i.last_code=!1,i.validate_code_sended=!1,i.showPopupByContent(e.html),i.codeStartCounting(),void i.focusOnCode()}return e&&e.success&&e.show_popup?(i.userUsedPushNotifications=e.userUsedPushNotifications,i.last_popup=e.html,i.last_email=n,i.login_request_send=!0,i.showPopupByContent(e.html),i.focusOnCode(),i.showIcon(),i.active_popup_is_login=!1,$(".simplyin-show-popup").not(".simplyin-show-popup-login").addClass("simplyin-confirm-profile"),$(".simplyin-show-popup").not(".simplyin-show-popup-login").find(".simplyin-show-popup-edit > span").first().text(simplyin.labels.confirm_profile),i.is_login||simplyin.customer.has_token||i.dockConfirmProfile(),i.phoneCheckboxManager&&(i.phoneCheckboxManager.state.userExistsInSimplyIn=!0,i.phoneCheckboxManager.hideCheckbox()),void(e.userUsedPushNotifications?i.checkPushNotification():i.codeStartCounting())):e&&"NOT_FOUND"==e.error?(i.hideIcon(),i.retireOneClickOffer(),i.phoneCheckboxManager&&(i.phoneCheckboxManager.state.userExistsInSimplyIn=!1,$("#checkout-payment-step.-current").length&&!$("#simplyin-phone-checkbox").length&&i.phoneCheckboxManager.showCheckbox()),void(n===i.customer_email&&(simplyin.hide_phone_field=!1,i.initEventListenersNewAccount()))):(i.login_request_send=!1,void i.notifyServerError())}).fail(()=>{i.login_request_send=!1,i.notifyServerError()})}},showLastPopup:function(){const e=this;""==e.customer_email&&1==simplyin.customer.logged&&void 0!==simplyin.customer.email&&(e.customer_email=simplyin.customer.email,e.submitEmail(!1)),e.is_login&&(e.last_popup?e.showPopupByContent(e.last_popup):e.showPopupByType("delivery",{email:e.customer_email})),!e.is_login&&e.login_request_send&&""!=e.last_email&&""!=e.last_popup&&(e.customer_email=e.last_email,e.submitEmail(!1))},confirmedChip:function(){return this.active_popup_is_login?$(".simplyin-show-popup-login"):$(".simplyin-show-popup").not(".simplyin-show-popup-login")},showPopupByContent:function(e){this.last_popup=e,0===$(".simplyin-popup-box").length?this.popup=$("<div>").addClass("simplyin-popup-box").appendTo("body")[0]:this.popup=document.querySelector(".simplyin-popup-box"),$(".simplyin-popup-box").html(e),setTimeout(()=>{$(".simplyin-popup-box").addClass("visible")},100)},showPopupByType:function(e,i={}){const n=this;var t={action:"getForm",type:e,ajax:1,ajax_token:simplyin.ajax_token},s=new FormData;$.each(t,function(e,i){s.append(e,i)}),$.each(i,function(e,i){s.append(e,i)}),$.ajax({url:n.ajax,method:"POST",data:s,processData:!1,contentType:!1,dataType:"json"}).done(e=>{e.success?n.showPopupByContent(e.html):"Session expired"==e.error&&(n.is_login=!1,n.submitEmail(!1))})},isOnCheckoutController:function(){return"order"===simplyin.controller},hidePopup:function(){const e=this;this.one_click_busy&&this.setOneClickBusy(!1);var i=$(".simplyin-popup-box");i.length&&(i.removeClass("visible"),setTimeout(()=>{i.remove(),e.on_close_refresh_page&&(e.redirect_to_checkout_on_close&&simplyin.checkout_url?window.location.href=simplyin.checkout_url:window.location.reload())},300))},notifyServerError:function(e){var i=e||(simplyin.labels&&simplyin.labels.generic_error?simplyin.labels.generic_error:"Something went wrong. Please try again."),n=$(".simplyin-popup-content"),t=n.find(".code-error-message");!t.length&&e&&n.length&&(t=$('<div class="code-error-message"></div>').appendTo(n)),t.length?t.show().text(i):this.disableWidget()},disableWidget:function(){this.widgetDisabled||(this.widgetDisabled=!0,this.retireOneClickOffer(),$(".simplyin-popup-box").remove(),$(".simplyin-logo-container, .simplyin-field-badge, .simplyin-show-popup, .autocomplete-dropdown, .simplyin-confirmation-popup, .simplyin-popup-overlay-confirmation, #simplyin-phone-prerender").remove(),$(document).off("keydown.simplyinConfirm"))},sendSmsCode:function(){const e=this;if(!e.send_sms_code_run){var i={action:"sendSmsCode",ajax:1,ajax_token:simplyin.ajax_token,email:this.customer_email,force_login:this.force_login?1:0};e.send_sms_code_run=!0,setTimeout(function(){e.send_sms_code_run=!1},3e4),$.ajax({url:e.ajax,method:"POST",data:i,dataType:"json"}).done(i=>{if(i&&i.success)return e.showPopupByContent(i.html),e.codeStartCounting(),void e.focusOnCode();i&&"NOT_FOUND"===i.error?e.retireOneClickOffer():(e.send_sms_code_run=!1,e.notifyServerError())}).fail(()=>{e.send_sms_code_run=!1,e.notifyServerError()})}},sendEmailCode:function(){const e=this;if(!e.send_email_code_run){var i={action:"sendEmailCode",ajax:1,ajax_token:simplyin.ajax_token,email:this.customer_email,force_login:this.force_login?1:0};e.send_email_code_run=!0,setTimeout(function(){e.send_email_code_run=!1},3e4),$.ajax({url:e.ajax,method:"POST",data:i,dataType:"json"}).done(i=>{if(i&&i.success)return e.showPopupByContent(i.html),e.codeStartCounting(),void e.focusOnCode();i&&"NOT_FOUND"===i.error?e.retireOneClickOffer():(e.send_email_code_run=!1,e.notifyServerError(i&&i.message))}).fail(()=>{e.send_email_code_run=!1,e.notifyServerError()})}},startShopLoginEmailChallenge:function(e){const i=this;if(!i.shop_login_challenge_run){i.shop_login_challenge_run=!0,setTimeout(function(){i.shop_login_challenge_run=!1},3e4);var n={action:"sendShopLoginEmailOtp",ajax:1,ajax_token:simplyin.ajax_token,isResend:e?1:0};$.ajax({url:i.ajax,method:"POST",data:n,dataType:"json"}).done(e=>{if(e&&e.success)return i.last_code=!1,i.validate_code_sended=!1,i.showPopupByContent(e.html),i.codeStartCounting(),void i.focusOnCode();i.shop_login_challenge_run=!1,i.notifyServerError(e&&e.message)}).fail(()=>{i.shop_login_challenge_run=!1,i.notifyServerError()})}},validatePinCode:function(){const e=window.SimplyIn;e.validate_code_sended||(e.validate_code_timeout&&clearTimeout(e.validate_code_timeout),e.validate_code_timeout=setTimeout(()=>{var i='#simplyin-input-code input[type="text"]',n="";$(i).each(function(){n+=this.value});var t="1"===$("#simplyin-input-code").attr("data-shop-login-challenge"),s=$(i).length||4;if(n.length==s){e.validate_code_sended=!0;var o={action:t?"verifyShopLoginEmailOtp":"checkCode",ajax:1,ajax_token:simplyin.ajax_token,email:SimplyIn.customer_email,code:n,force_login:SimplyIn.force_login?1:0};if(n==e.last_code)return void(e.validate_code_sended=!1);$.ajax({url:e.ajax,method:"POST",data:o,dataType:"json"}).done(n=>{if(e.validate_code_sended=!1,n&&"TOO_MANY_REQUESTS"==n.code){$(".simplyin-popup-content .code-error-message").show();var t=n.message.split("\n");t.length>1?e.startCountingMessage(t):$(".simplyin-popup-content .code-error-message").html(t[0])}else if(n&&0==n.isCodeValid)$(".simplyin-popup-content .code-error-message").show(),$(".simplyin-popup-content .code-error-message").text(simplyin.labels.code_invalid),$(i).addClass("invalid").removeClass("valid");else if(n&&n.success){if(e.stopCounting(),"1"===$("#simplyin-input-code").attr("data-shop-login-challenge"))return void window.location.reload();if(n.login_result&&n.login_result.challenge_available)return void e.startShopLoginEmailChallenge();e.showIcon();var s=e.confirmedChip();s.removeClass("simplyin-confirm-profile"),s.find(".simplyin-show-popup-edit > span").first().text(simplyin.labels.data_completed),e.phoneCheckboxManager&&e.phoneCheckboxManager.hideCheckbox(!0),"function"==typeof e.showChangeDataButton&&e.showChangeDataButton(),e.is_login_page?window.location.reload():(e.showPopupByContent(n.html),e.selectDefaultAddress()),e.loginCustomer(e.customer_email),n.login_result.is_guest?($('#customer-form input[name="firstname"]').val(n.login_result.firstname).trigger("input").trigger("change"),$('#customer-form input[name="lastname"]').val(n.login_result.lastname).trigger("input").trigger("change"),e.selectCheckbox()):(e.on_close_refresh_page=!0,e.redirect_to_checkout_on_close=!e.isOnCheckoutController())}else n&&n.isCodeValid&&!n.success?(e.last_code=!1,$(".simplyin-popup-content .code-error-message").show(),$(".simplyin-popup-content .code-error-message").text(simplyin.labels.code_consumed),$(i).removeClass("valid")):(e.last_code=!1,$(".simplyin-popup-content .code-error-message").show(),$(".simplyin-popup-content .code-error-message").text(simplyin.labels.generic_error),$(i).removeClass("valid"))}).fail(()=>{e.validate_code_sended=!1,e.last_code=!1,$(".simplyin-popup-content .code-error-message").show(),$(".simplyin-popup-content .code-error-message").text(simplyin.labels.generic_error),$(i).removeClass("valid")})}else $(".simplyin-popup-content .code-error-message").hide(),$(i).addClass("valid").removeClass("invalid")},300))},isValidEmailAddress:function(e){return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/.test(e)},codeStartCounting:function(){const e=this;var i=".simplyin-popup-footer .buttons",n=".simplyin-popup-footer .sent-messages";this.counting_interval&&clearInterval(this.counting_interval),this.counting_value=30,$(i).hide(),$(n).show(),this.counting_interval=setInterval(()=>{this.counting_value--,this.counting_value<=0&&(clearInterval(this.counting_interval),this.counting_value=0,$(i).show(),$(n).hide()),$(".simplyin-popup-footer .time").text(e.formatTime(this.counting_value))},1e3)},stopPushNotifications:function(){this.push_notification_interval&&(clearInterval(this.push_notification_interval),this.push_notification_interval=!1)},stopCounting:function(){this.counting_interval&&(clearInterval(this.counting_interval),this.counting_interval=!1)},checkPushNotification:function(){const e=this;this.push_notification_interval&&clearInterval(this.push_notification_interval);let i=0;this.push_notification_interval=setInterval(()=>{if(i++>60)e.stopPushNotifications();else{var n={action:"checkPushNotification",ajax:1,ajax_token:simplyin.ajax_token,email:this.customer_email};$.ajax({url:e.ajax,method:"POST",data:n,dataType:"json"}).done(i=>{if(i&&i.success){e.stopPushNotifications(),e.showIcon();var n=e.confirmedChip();return n.removeClass("simplyin-confirm-profile"),n.find(".simplyin-show-popup-edit > span").first().text(simplyin.labels.data_completed),e.loginCustomer(e.customer_email),e.login_request_send=!1,e.phoneCheckboxManager&&e.phoneCheckboxManager.hideCheckbox(!0),"function"==typeof e.showChangeDataButton&&e.showChangeDataButton(),e.is_login_page?window.location.reload():(e.showPopupByContent(i.html),e.selectDefaultAddress()),void(i.login_result.is_guest?($('#customer-form input[name="firstname"]').val(i.login_result.firstname).trigger("input").trigger("change"),$('#customer-form input[name="lastname"]').val(i.login_result.lastname).trigger("input").trigger("change")):(e.on_close_refresh_page=!0,e.redirect_to_checkout_on_close=!e.isOnCheckoutController()))}i&&i.error&&(e.stopPushNotifications(),e.login_request_send=!1,e.notifyServerError(simplyin.labels.code_consumed))})}},1e3)},startCountingMessage:function(e){const i=this;this.counting_message_interval&&clearInterval(this.counting_message_interval),this.counting_value_message=parseInt(e[1]);var n=".simplyin-popup-content .code-error-message";$(n).html(e[0]+"<br />"+i.formatTime(this.counting_value_message)),this.counting_message_interval=setInterval(()=>{this.counting_value_message--,this.counting_value_message<=0&&(clearInterval(this.counting_message_interval),this.counting_value_message=0,$(n).html(""),$(n).hide()),$(n).html(e[0]+"<br />"+i.formatTime(this.counting_value_message))},1e3)},formatTime:function(e){return e<10?"00:0"+e.toString():"00:"+e.toString()},loginCustomer:function(e){this.customer_email=e,this.is_login=!0,this.retireOneClickOffer(),this.is_login_page},storeDeliveryPopup:function(){this.delivery_popup=$(".simplyin-popup-box").children().clone(!0,!0),this.delivery_popup_scroll=$(".simplyin-popup").scrollTop()},retrieveDeliveryPopup:function(){const e=this;e.delivery_popup&&(e.showPopupByContent(e.delivery_popup),$(".simplyin-popup").length&&e.delivery_popup_scroll&&$(".simplyin-popup").scrollTop(e.delivery_popup_scroll))},editAddress:function(e,i){const n=this;n.storeDeliveryPopup();var t={action:"editAddress",ajax:1,ajax_token:simplyin.ajax_token,id:e,address_type:i};$.ajax({url:n.ajax,method:"POST",data:t,dataType:"json"}).done(e=>{e.success&&n.showPopupByContent(e.html)})},confirmationPopup:function(e,i,n){const t=$('<div class="simplyin-popup-overlay-confirmation"><div>'),s=$(`\n                <div class="simplyin-confirmation-popup">\n                    <div class="simplyin-popup-header-confirmation">\n                        <span class="simplyin-title">\n                            ${e}\n                        </span>\n                        <div class="simplyin-popup-close-button-confirmation">\n                            <img width="20" height="21"\n                                 src="${simplyin.files_url}/views/img/close_icon.svg"\n                                 alt=""\n                                 class="simplyin-close">\n                        </div>\n                    </div>\n                    <div class="simplyin-message">\n                        ${i}\n                    </div>\n                    <div class="simplyin-actions">\n                        <button type="button"\n                                class="simplyin-btn simplyin-btn-secondary">\n                            ${simplyin.labels.cancel}\n                        </button>\n                        <button type="button"\n                                class="simplyin-btn simplyin-btn-danger">\n                            ${simplyin.labels.delete}\n                        </button>\n                    </div>\n                </div>\n            `);$("body").append(s),$("body").append(t);const o=()=>{s.remove(),t.remove(),$(document).off("keydown.simplyinConfirm")};t.on("click",function(){o()}),$(document).on("keydown.simplyinConfirm",function(e){"Escape"===e.key?o():"Enter"===e.key&&(o(),$.isFunction(n)&&n())}),s.on("click",".simplyin-popup-close-button-confirmation",o).on("click",".simplyin-btn-secondary",o).on("click",".simplyin-btn-danger",function(){o(),$.isFunction(n)&&n()})},logout:function(){e.is_login=!1;const e=this;var i={action:"logout",ajax:1,ajax_token:simplyin.ajax_token};$.ajax({url:e.ajax,method:"POST",data:i,dataType:"json"}).done(i=>{e.hidePopup()})},hideIcon:function(){"function"==typeof this.hideIconCheckout&&this.hideIconCheckout(),$(".simplyin-show-popup").hide(),$(".simplyin-field-badge").show()},showIcon:function(){"function"==typeof this.showIconCheckout&&this.showIconCheckout(),$(".simplyin-show-popup").show(),$(".simplyin-field-badge").hide()},dockConfirmProfile:function(){var e=$(".simplyin-show-popup").not(".simplyin-show-popup-login").filter(".simplyin-confirm-profile").first();if(e.length&&!e.parent().hasClass("simplyin-field-wrap")){var i=$(this.email_field).closest(".simplyin-field-wrap");if(i.length||(i=$(this.email_field).siblings(".simplyin-field-wrap").first()),i.length){var n=$('<span class="simplyin-show-popup-home" style="display:none"></span>');e.before(n),e.data("simplyinPopupHome",n),i.append(e)}}},undockConfirmProfile:function(){$(".simplyin-field-wrap > .simplyin-show-popup").not(".simplyin-show-popup-login").each(function(){var e=$(this).data("simplyinPopupHome");e&&e.length&&(e.replaceWith(this),$(this).removeData("simplyinPopupHome"))})},dockBadge:function(){var e=$(this.email_field);if(e.length){e.parent().hasClass("simplyin-field-wrap")||e.wrap('<div class="simplyin-field-wrap"></div>');var i=e.parent(),n=$(".simplyin-show-popup").not(".simplyin-show-popup-login").first();n.length&&!n.parent().hasClass("simplyin-field-wrap")&&i.append(n)}},focusOnCode:function(){$('#simplyin-input-code input[type="text"]:first').length&&$('#simplyin-input-code input[type="text"]:first').focus()},placeOrder:function(){$.ajax({url:SimplyIn.ajax,method:"POST",data:{action:"placeOrder",ajax:1,ajax_token:simplyin.ajax_token,order_token:simplyin.order.order_token,id_cart:simplyin.order.id_cart},dataType:"json"}).done(e=>{e.success})},loadPhoneCountries:function(){const e=this;$.getJSON(simplyin.files_url+"views/json/phones.json",function(i){e.phones=i})},validatePhoneNumber:function(e=!1){const i=this,n=$("#simplyin-phone-checkbox .phone-input input");if(0==n.length)return!0;const t=n.val().replace(/\D/g,""),s=$("#simplyin-phone-checkbox #simplyin-phone-country").find("option:selected").data("prefix"),o=i.phones.find(e=>e.country_code===s),a=o.phone_number_lengths.includes(t.length),l=o.mobile_begin_with.some(e=>t.startsWith(e));let p="";return p=l?t.replace(/(\d{3})(\d{3})(\d{3})/,"$1 $2 $3"):t.replace(/(\d{2})(\d{3})(\d{2})(\d{2})/,"$1 $2 $3 $4"),$(n).val(p),a&&o&&l?(i.hideValidateWarningMessage(),!0):(i.showValidateWarningMessage(e),!1)},showValidateWarningMessage:function(e=!1){e?$("#simplyin-phone-checkbox .phone-input-warning").hide().fadeIn():$("#simplyin-phone-checkbox .phone-input-warning").show()},hideValidateWarningMessage:function(){$("#simplyin-phone-checkbox .phone-input-warning").hide()},bindNewAccountEvent:function(){const e=this,i=document.querySelector("#payment-confirmation button");if(!i)return;const n=i=>{if(!e.validatePhoneNumber(!0))return i.preventDefault(),i.stopPropagation(),i.stopImmediatePropagation(),!1};i._simplyinNewAccountHandler&&i.removeEventListener("click",i._simplyinNewAccountHandler,{capture:!0}),i.addEventListener("click",n,{capture:!0}),i._simplyinNewAccountHandler=n},unbindNewAccountEvent:function(){const e=document.querySelector("#payment-confirmation button");e&&e._simplyinNewAccountHandler&&(e.removeEventListener("click",e._simplyinNewAccountHandler,{capture:!0}),e._simplyinNewAccountHandler=null)},storeNewAccountDetails:function(e){const i=$("#simplyin-phone-checkbox .phone-input input").val(),n=$("#simplyin-phone-checkbox #simplyin-phone-country").find("option:selected").data("prefix")+" "+i.replace(/\D/g,""),t={action:"storeNewAccountDetails",ajax:1,ajax_token:simplyin.ajax_token,phone:e?n:0};$.ajax({url:SimplyIn.ajax,method:"POST",data:t,dataType:"json"}).done(e=>{})},initEventListenersNewAccount:function(){const e=this;e.initialized_new_account_events||"undefined"!=typeof SimplyInPhoneCheckboxManager&&(e.phoneCheckboxManager=new SimplyInPhoneCheckboxManager({checkoutType:"classic",emailFieldSelector:'#customer-form input[name="email"]',containerSelector:"#checkout-payment-step .payment-options",ajaxUrl:e.ajax,ajaxToken:simplyin.ajax_token,debug:!1}),e.initialized_new_account_events=!0,$(document).off("change.simplyin blur.simplyin",'input[name="phone"]'),$(document).on("change.simplyin blur.simplyin",'input[name="phone"]',function(){var i=$("#simplyin-phone-checkbox .phone-input input");if(!($(this).closest("#simplyin-phone-checkbox").length>0)&&i.length){let s=$(this).val();if(e.phoneCheckboxManager&&"function"==typeof e.phoneCheckboxManager.removeCountryPrefix){var n=e.phoneCheckboxManager.removeCountryPrefix(s).replace(/\D/g,""),t=e.phoneCheckboxManager.getMaxPhoneLengthForSelectedCountry();i.val(n.substring(0,t)),e.phoneCheckboxManager.validatePhoneNumber(),e.phoneCheckboxManager.storePhoneNumber()}else e.phoneCheckboxManager&&"function"==typeof e.phoneCheckboxManager.parseAndSetPhoneNumber?e.phoneCheckboxManager.parseAndSetPhoneNumber(s):0!==s.indexOf("+")&&i.val(s)}}))},initDhlAssistantDisplay:function(){if(simplyin.customer.point&&"dhl"===simplyin.customer.point.label){var e=simplyin.customer.point.locker_id;if(e&&""!==e.trim()){var i=simplyin.customer.point.address||"",n=(simplyin.customer.point.address_name||e)+(i?" "+i:"");this.waitForElement("#dhlassistant_messages .success.current-address",function(){$("#dhlassistant_messages .success.current-address").text(n).show(),$('button[name="confirmDeliveryOption"]').attr("disabled",!1)},2e4)}}},dpdshippingmodule:function(){if($(".dpdshipping-pudo-new-point").length&&"dpd"==simplyin.customer.point.label&&"undefined"!=typeof dpdshippingSavePudoCode&&"undefined"!=typeof dpdshipping_token&&"undefined"!=typeof dpdshipping_csrf&&"undefined"!=typeof dpdshipping_id_cart){let e={modal:function(e){}};dpdshippingSavePudoCode(simplyin.customer.point.locker_id,e);let i=$("span.dpdshipping-selected-point");dpdshippingGetPudoAddress(simplyin.customer.point.locker_id,i)}},furgonetkamodule:function(){if("function"!=typeof furgonetkaMapCallback)return;if(!(simplyin.customer.point&&simplyin.customer.point.locker_id&&""!==simplyin.customer.point.locker_id.trim()))return;const e=function(){if($(".furgonetka-set-point").length){let e=simplyin.customer.point.label;"inpost"===e&&(e="paczkomat");const i=simplyin.id_carrier,n=document.getElementById("furgonetka-machine-"+i);if(n){const e=new MutationObserver(function(t){""===n.textContent.trim()||n.classList.contains("furgonetka-hidden")||($('.shipping-radio input[type="radio"][value="'+i+',"]').trigger("click"),e.disconnect())});e.observe(n,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),setTimeout(function(){e.disconnect()},5e3)}furgonetkaMapCallback({code:simplyin.customer.point.locker_id,name:simplyin.customer.point.locker_id,type:e},i)}else requestAnimationFrame(e)};requestAnimationFrame(e)},authController:function(){const e=this;let i=['#login-form input[name="email"]','#checkout-login-form input[name="email"]'],n=i.find(e=>$(e).length)||i[0],t=n===i[1];if($(n).length){if(!t&&e.barEnabled()){let i=$("section.login-form");i.length||(i=$(n).closest("form")),i.prepend(e.barHtml()),i.children(".simplyin-logo-container").first().addClass("simplyin-logo-container--login")}e.badgeEnabled()&&e.injectFieldBadge(n),e.email_login_field=$(n),customer_email=simplyin.customer_email,e.email_login_field.parent().append(`\n                    <div class="simplyin-show-popup simplyin-show-popup-login">\n                        <div class="simplyin-show-popup-icon">\n                            <img width="30" height="30" src="${simplyin.files_url}/views/img/logo_smalln.svg"/>\n                            <svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n                              <rect y="0.5" width="12" height="12" rx="6" fill="#33CC40"></rect>\n                              <path d="M3.23096 6.54276L5.07711 8.38892L8.76942 4.38892" stroke="white" stroke-width="1.23077" stroke-linecap="round" stroke-linejoin="round"></path>\n                            </svg>\n                        </div>\n                        <div class="simplyin-show-popup-edit">\n                            <span>${simplyin.labels.data_completed}</span>\n                            <div class="simplyin-show-popup-edit-bottom">\n                              <span>${simplyin.labels.change}</span>\n                              <svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">\n                                <path d="M8.41604 2.74719L8.97217 2.19107C9.89359 1.26964 11.3875 1.26964 12.3089 2.19107C13.2304 3.11249 13.2304 4.60641 12.3089 5.52783L11.7528 6.08396M8.41604 2.74719C8.41604 2.74719 8.48556 3.92897 9.5283 4.97171C10.571 6.01445 11.7528 6.08396 11.7528 6.08396M8.41604 2.74719L3.30329 7.85994C2.957 8.20624 2.78385 8.37939 2.63494 8.5703C2.45928 8.79551 2.30868 9.03919 2.18581 9.29701C2.08164 9.51558 2.00421 9.74789 1.84934 10.2125L1.3535 11.7M11.7528 6.08396L6.64006 11.1967C6.29376 11.543 6.12061 11.7162 5.9297 11.8651C5.70449 12.0407 5.46082 12.1913 5.20299 12.3142C4.98442 12.4184 4.75211 12.4958 4.28751 12.6507L2.8 13.1465M2.8 13.1465L1.8375 13.4673C1.60887 13.5435 1.35679 13.484 1.18638 13.3136C1.01596 13.1432 0.956457 12.8911 1.03267 12.6625L1.3535 11.7M2.8 13.1465L1.3535 11.7" stroke="#2D40F6" stroke-width="1.6"></path>\n                              </svg>\n                            </div>\n                        </div>\n                    </div>\n                `),this.hideIconLogin(),e.email_login_field.parent().addClass("simplyin-display-flex"),$(document).on("input",n,function(){let i=!1;e.is_login&&e.customer_email!=$(this).val()&&(i=!0),e.customer_email=$.trim($(this).val()),e.submitEmailLogin(i)})}},submitEmailLogin:function(e){this.last_popup="";const i=this;if(0==this.is_login||e){this.is_login=!1;var n=this.customer_email;if(!this.isValidEmailAddress(n))return;if(i.login_request_send&&i.last_email==n)return;if(i.is_login_page=!0,!this.isValidEmailAddress(n))return;if(i.login_request_send&&i.last_email==n)return;var t={action:"submitEmail",login:1,ajax:1,ajax_token:simplyin.ajax_token,email:n,logout:e};i.login_request_send=!0,i.last_email=n,$.ajax({url:i.ajax,method:"POST",data:t,dataType:"json"}).done(e=>{if(e&&e.success&&e.show_popup&&e.shop_login_challenge){if(n!==i.last_email)return;return i.last_code=!1,i.validate_code_sended=!1,i.showPopupByContent(e.html),i.codeStartCounting(),void i.focusOnCode()}if(e&&e.success&&e.show_popup)return i.userUsedPushNotifications=e.userUsedPushNotifications,i.showPopupByContent(e.html),i.focusOnCode(),i.showIconLogin(),i.active_popup_is_login=!0,$(".simplyin-show-popup-login").addClass("simplyin-confirm-profile"),$(".simplyin-show-popup-login .simplyin-show-popup-edit > span").first().text(simplyin.labels.confirm_profile),simplyin.hide_phone_field=!0,void(e.userUsedPushNotifications?i.checkPushNotification():i.codeStartCounting());e&&"NOT_FOUND"==e.error?i.hideIconLogin():(i.login_request_send=!1,i.notifyServerError())}).fail(()=>{i.login_request_send=!1,i.notifyServerError()})}},hideIconLogin:function(){$(".simplyin-show-popup-login").hide()},showIconLogin:function(){$(".simplyin-show-popup-login").show()},selectCheckbox:function(){const e=this;if(e.select_customer_privacy&&$('input[name="customer_privacy"]').length&&$('input[name="customer_privacy"]').prop("checked",!0),e.select_psgdpr&&$('input[name="psgdpr"]').length&&$('input[name="psgdpr"]').prop("checked",!0),!e.submit_guest_form)return!1;$("#customer-form").find('button[type="submit"]').trigger("click")}},"classic"==simplyin.checkout&&SimplyIn.init()});