"undefined"==typeof moment&&alert("Moment error");const DeliveryOpts=["08915","08914","08913","08910","08270","10578","12754"];function Product(e){const t=this;t.name=ko.observable(e.name||e.ProductName||""),t.sku=e.sku,t.qty=ko.observable(e.qty?e.qty:""),t.productprice=e.ProductPrice,t.productdiscount=Math.max(e.ProductDiscount,e.voucherDiscount,e.warrantyDiscount||0),t.productpricediscounted=getFinalPrice(e.ProductPrice,t.productdiscount),t.productsub=e.ProductSub||"",t.productimage=e.ProdLargeImage||"",t.warrantyID=e.warrantyId||0,t.id=e.id,t.pkg=e.pkg,t.productimage.startsWith("/")||(t.productimage="/"+t.productimage),t.productship=e.ProductShip||"",t.ppcharge=e.PPCharge||0,t.printing="Yes"==e.Artwork,t.special="Yes"==e.Special,t.dyesub="Yes"==e.DyeSub}function BasketViewModel(){const e=this;function t(){var e=new Date,t=new Date;t.setHours(15,45,0,0);var o=t.getTime()-e.getTime();o<0&&(t.setDate(t.getDate()+1),o=t.getTime()-e.getTime());var n=Math.floor(o/36e5),r=Math.floor(o%36e5/6e4),a=Math.floor(o%6e4/1e3);return(n=(n<10?"0":"")+n)+":"+(r=(r<10?"0":"")+r)+":"+(a=(a<10?"0":"")+a)}function o(){var e=new Date,t=e.getDay(),o=e.getHours(),n=e.getMinutes();return t>=1&&t<=5&&14==o&&n>=45||15==o&&n<45}e.products=ko.observableArray([]),e.country=ko.observable(localStorage.getItem("country")),e.country.subscribe((function(t){localStorage.setItem("country",t),e.postcode(""),e.deliveryOption(void 0),document.querySelectorAll(".delivery-opt-cont").forEach((function(e){e.classList.remove("selected")})),document.querySelectorAll('input[name="delivery-opts"]').forEach((function(e){e.checked=!1}))})),e.postcode=ko.observable(localStorage.getItem("postcode")),e.postcode.subscribe((function(t){localStorage.setItem("postcode",t),e.saveOptions()})),e.deliveryOption=ko.observable(),e.deliveryTime=ko.observable(),e.postcodeVerify=ko.observable(!1),e.productFocused=ko.observable(),e.getPPCharge=ko.computed((function(){if(!e.postcodeVerify())return NaN;if(e.calcSubtotal()>=basketConfig.free_delivery)return 0;let t=e.products();return 0===t.length?null:Math.max.apply(Math,t.map((function(e){return e.ppcharge})))})),e.getShippingDays=ko.computed((function(){let t=e.products();if(0===t.length)return null;return e.hasPrinting()?null:Math.max.apply(Math,t.map((function(e){return e.productship})))})),e.timeLeftNextDay=ko.observable(t()),e.shouldDisplayCutoffCountdown=ko.observable(o()),setInterval((function(){e.timeLeftNextDay(t())}),1e3),function t(){e.shouldDisplayCutoffCountdown(o());var n,r=new Date,a=r.getDay(),i=r.getHours(),c=r.getMinutes();if(a>=1&&a<=5)if(i<14||14==i&&c<45){var s=new Date(r);s.setHours(14,45,0,0),n=s-r}else if(i>15||15==i&&c>=45){var u=r;u.setDate(r.getDate()+(a%5+1)),u.setHours(14,45,0,0),n=u-r}else{var d=new Date(r);d.setHours(15,45,0,0),n=d-r}else{var l=new Date(r);l.setDate(r.getDate()+(8-a)%7),l.setHours(14,45,0,0),n=l-r}setTimeout(t,n)}(),e.getShippingDate=ko.computed((function(){var t=e.getShippingDays();if(null==t)return"TBD";var o=moment(),n=(new Date).getHours(),r=(new Date).getMinutes();return(n>15||15===n&&r>=45)&&(o=o.businessAdd(1)),(o=o.businessAdd(t)).format("DD MMM")})),e.getEarliestShippingDate=function(){var t=e.getShippingDays();if(null==t)return null;var o=moment(),n=(new Date).getHours(),r=(new Date).getMinutes();return(n>15||15===n&&r>=45)&&(o=o.businessAdd(1)),o=o.businessAdd(t)},e.hasPrinting=function(){let t=e.products();for(let e=0;enew Product(e))))},e.calcSubtotal=function(){let t=0;const o=e.products();for(let e=0;e