https://www.comptoirdesjardins.fr/modules/sendinblue/views/js/build/front/checkout/checkout.js?5.1.0
1class d{baseUrl;constructor(){this.baseUrl=window.prestashop?.modules?.sendinblue?.redeem_ajax_url||""}async createVoucher(e){const t={action:"createVoucher",reward_id:e};return this.makeRequest(t)}async createVoucherAndRedeem(e){const t={action:"createVoucherAndRedeem",reward_id:e};return this.makeRequest(t)}async redeemVoucher(e,t,i=900){const s={action:"redeemVoucher",reward_id:e,code:t,ttl:i};return this.makeRequest(s)}async makeRequest(e){if(!this.baseUrl)return{success:!1,error:"Sendinblue redeem AJAX URL is not configured"};try{const t={...e,ajax:1},i=new FormData;Object.keys(t).forEach(o=>{i.append(o,String(t[o]))});const s=await fetch(this.baseUrl,{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest"},body:i,credentials:"same-origin"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}catch(t){return console.error("API request failed:",t),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}}}const h=new d;class l{items;duration;showText;hideText;constructor(e,t={}){this.items=Array.from(e.querySelectorAll(".sib-accordion-item")),this.duration=t.duration??350,this.showText=t.showText??"See",this.hideText=t.hideText??"Hide",this.items.forEach(i=>{const s=i.querySelector(".sib-accordion-button"),r=i.querySelector(".sib-accordion-collapse");!s||!r||(r.style.transition=`height ${this.duration}ms ease`,s.addEventListener("click",()=>{if(r.classList.contains("is-open")){this.close(r,s);const a=s.querySelector("[data-btn]");a&&(a.textContent=this.showText)}else{this.open(r,s);const a=s.querySelector("[data-btn]");a&&(a.textContent=this.hideText)}}))})}open(e,t){this.items.forEach(s=>{const r=s.querySelector(".sib-accordion-collapse"),o=s.querySelector(".sib-accordion-button");if(r&&o&&r!==e){this.close(r,o);const a=o.querySelector("[data-btn]");a&&(a.textContent=this.showText)}});const i=e.scrollHeight;e.style.height=`${i}px`,e.classList.add("is-open"),t.setAttribute("aria-expanded","true")}close(e,t){e.style.height=`${e.scrollHeight}px`,e.offsetHeight,e.style.height="0px",e.classList.remove("is-open"),t.setAttribute("aria-expanded","false")}}class u{container=null;duration;position;closable;constructor(e={}){this.duration=e.duration??5e3,this.position=e.position??"top-right",this.closable=e.closable??!0,this.createContainer()}createContainer(){this.container=document.querySelector(".sib-toast-container"),this.container||(this.container=document.createElement("div"),this.container.className=`sib-toast-container sib-toast-${this.position}`,this.container.setAttribute("aria-live","polite"),this.container.setAttribute("aria-atomic","true"),document.body.appendChild(this.container))}show(e,t,i){if(!this.container)return;const s=i??this.duration,r=this.createToastElement(e,t);this.container.appendChild(r),requestAnimationFrame(()=>{r.classList.add("sib-toast-show")}),s>0&&setTimeout(()=>{this.hide(r)},s)}createToastElement(e,t){const i=document.createElement("div");i.className=`sib-toast sib-toast-${e}`,i.setAttribute("role","alert"),i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true");const s=document.createElement("div");s.className="sib-toast-content";const r=document.createElement("div");if(r.className="sib-toast-message",r.textContent=t,s.appendChild(r),this.closable){const o=document.createElement("button");o.type="button",o.className="sib-toast-close",o.setAttribute("aria-label","Close");const a=document.createElement("span");a.setAttribute("aria-hidden","true"),a.className="material-icons",a.textContent="close",o.appendChild(a),o.addEventListener("click",()=>this.hide(i)),s.appendChild(o)}return i.appendChild(s),i}hide(e){e.classList.remove("sib-toast-show"),e.classList.add("sib-toast-hide"),setTimeout(()=>{e.remove()},300)}}class m{toast;constructor(){this.toast=new u,this.init()}init(){this.attachEventListeners(),this.initializeAccordion()}attachEventListeners(){document.addEventListener("click",e=>{const t=e.target;if(!t)return;const i=t instanceof Element?t:t.parentElement;if(!i)return;const s=i.closest("[data-reward-btn]");s&&this.handleRedeemClick(e,s)}),typeof window.prestashop<"u"&&window.prestashop.on&&window.prestashop.on("updatedCart",()=>{this.initializeAccordion()})}htmlDecode(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}async handleRedeemClick(e,t){e.preventDefault();const i=t.getAttribute("data-reward-id");if(!i){this.showError("Invalid reward ID");return}if(t.hasAttribute("disabled"))return;t.setAttribute("disabled","true");const s=t.innerHTML||"";t.innerHTML+='<span class="sib-spinner-grow" role="status"><span class="sib-visually-hidden">Loading...</span></span>';
1try{const r=await h.createVoucherAndRedeem(i);if(!r.success||!r.data)throw new Error(r.error||"Failed to create voucher");const{code:o}=r.data;if(!o)throw new Error("Voucher code not received");const a=window.prestashop.modules.sendinblue.translations.voucher_created,c=typeof a=="string"?this.htmlDecode(a).replace("%code%",o):`Voucher created and applied successfully! Code: "${o}"`;this.showSuccess(c),this.refreshCartSummary(r.cart)}catch(r){const o=r instanceof Error?r.message:"An unexpected error occurred";this.showError(o)}finally{t.removeAttribute("disabled"),t.innerHTML=s}}showSuccess(e){this.toast.show("success",e)}showError(e){this.toast.show("error",e)}refreshCartSummary(e){typeof window.prestashop<"u"&&window.prestashop.emit&&window.prestashop.emit("updateCart",{resp:{cart:e}})}initializeAccordion(){document.querySelectorAll(".sib-accordion").forEach(e=>{new l(e,{duration:350,showText:window.prestashop.modules.sendinblue.translations.show||"Show",hideText:window.prestashop.modules.sendinblue.translations.hide||"Hide"})})}}document.addEventListener("DOMContentLoaded",()=>{new m});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.