1class DeliveryEstimation extends HTMLElement{constructor(){super(),this.minDateElement=null,this.maxDateElement=null,this.config={locale:"fr",minDays:3,maxDays:5,noSaturday:!1,noSunday:!1,dateFormat:"in_letters",showWeekday:!0,cutoffHour:null}}connectedCallback(){this.minDateElement=this.querySelector('[data-ref="min-date"]'),this.maxDateElement=this.querySelector('[data-ref="max-date"]'),this.#loadConfiguration(),this.#calculateAndDisplayDates()}#loadConfiguration(){this.config.locale=this.dataset.locale||"fr",this.config.minDays=parseInt(this.dataset.minDays)||3,this.config.maxDays=parseInt(this.dataset.maxDays)||5,this.config.noSaturday=this.dataset.noSaturday==="true",this.config.noSunday=this.dataset.noSunday==="true",this.config.dateFormat=this.dataset.dateFormat||"in_letters",this.config.showWeekday=this.dataset.showWeekday==="true";const cutoffHour=this.dataset.cutoffHour;cutoffHour&&cutoffHour!==""&&(this.config.cutoffHour=parseInt(cutoffHour))}#calculateAndDisplayDates(){const minDate=this.#calculateDeliveryDate(this.config.minDays),maxDate=this.#calculateDeliveryDate(this.config.maxDays);this.minDateElement&&(this.minDateElement.textContent=this.#formatDate(minDate)),this.maxDateElement&&(this.maxDateElement.textContent=this.#formatDate(maxDate))}#calculateDeliveryDate(daysToAdd){const now=new Date;let startDate=new Date;this.config.cutoffHour!==null&&now.getHours()>=this.config.cutoffHour&&startDate.setDate(startDate.getDate()+1);let businessDaysAdded=0,currentDate=new Date(startDate);for(;businessDaysAdded<daysToAdd;){currentDate.setDate(currentDate.getDate()+1);const dayOfWeek=currentDate.getDay(),isSaturday=dayOfWeek===6,isSunday=dayOfWeek===0;!(isSaturday&&this.config.noSaturday||isSunday&&this.config.noSunday)&&businessDaysAdded++}for(;this.#isNonDeliveryDay(currentDate);)currentDate.setDate(currentDate.getDate()+1);return currentDate}#isNonDeliveryDay(date){const dayOfWeek=date.getDay(),isSaturday=dayOfWeek===6,isSunday=dayOfWeek===0;return isSaturday&&this.config.noSaturday||isSunday&&this.config.noSunday}#formatDate(date){const options={};this.config.dateFormat==="numbers"?(options.day="numeric",options.month="numeric"):(options.day="numeric",options.month="long"),this.config.showWeekday&&(options.weekday="long");let formattedDate=new Intl.DateTimeFormat(this.config.locale,options).format(date);return formattedDate=this.#capitalizeFirstLetter(formattedDate),formattedDate}#capitalizeFirstLetter(str){return str&&str.charAt(0).toUpperCase()+str.slice(1)}}customElements.get("delivery-estimation")||customElements.define("delivery-estimation",DeliveryEstimation); 2//# sourceMappingURL=/cdn/shop/t/18/assets/delivery-estimation.js.map?v=474244501600467341781090903
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.