//prettier-ignore
(()=>{"use strict";if(window.HeyMojoWarehouseStock)return;const e={warehouses:[{match:["IE"],label:"Warehouse Ireland"},{match:["UK"],label:"Warehouse UK"}],showUnlisted:!0,text:{heading:"Stock availability",available:"Available",unavailable:"Unavailable",inStock:e=>`${e} in stock`,due:e=>`Due ${e}`,checking:"Checking stockā¦"},endpoint:"/ajax/live-inventory",refreshFromApi:!0,batchSize:50,loggedIn:null},t=".product[data-sku]",n=".live-inventory-v2-wrapper",a="hm-wh-native-hidden",o=new Map,r=new Set,i=new Set,s=new WeakMap,h=e=>String(e??"").trim().toLowerCase(),l=e=>Number(e).toLocaleString("en-IE"),d=e=>String(e??"").replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),c=e=>{if(!e)return null;try{const t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t)return Object.values(t)}catch(e){}return null},u=t=>`
${d(e.text.heading)}${d(t)}
`,p=(e,t)=>{e.querySelectorAll(n).forEach(e=>{e.closest(".hm-wh")||e.classList.toggle(a,t)})},m=(t,n,a)=>{const r=o.get(t.key)||t.domData;let s;if(r?s=((t,n,a)=>{const o=(t=>{const n=new Set,a=e.warehouses.map(e=>{const a=e.match.map(h),o=t.findIndex((e,t)=>!n.has(t)&&(a.includes(h(e.location_name))||a.includes(h(e.warehouse))));return o<0?{label:e.label,qty:0,due:""}:(n.add(o),{label:e.label,qty:Number(t[o].quantity)||0,due:t[o].due_date})});return e.showUnlisted&&t.forEach((e,t)=>{n.has(t)||a.push({label:e.location_name||e.warehouse||"Warehouse",qty:Number(e.quantity)||0,due:e.due_date})}),a})(t),r=o.reduce((e,t)=>e+Math.max(t.qty,0),0),i=r>0?a?e.text.inStock(l(r)):e.text.available:e.text.unavailable,s=o.map(t=>{const n=t.qty>0,o=n?a?e.text.inStock(l(t.qty)):e.text.available:e.text.unavailable,r=n?"":(e=>{const t=String(e??"").trim();let n,a,o,r=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(t);if(r)[,n,a,o]=r.map(Number);else{if(!(r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t)))return"";[,o,a,n]=r.map(Number)}if(!o||!a||!n)return"";const i=new Date(o,a-1,n),s=new Date;return s.setHours(0,0,0,0),Number.isNaN(i.getTime())||i${d(t.label)}`+(r?`${d(e.text.due(r))}`:"")+""+`${n?'':''}${d(o)}`}).join("");return(n?u(i):"")+``})(r,t.large,a):i.has(t.key)||(s=(t=>{const n='';return(t?u(e.text.checking):`${d(e.text.checking)}`)+``})(t.large)),!s)return n.hidden=!0,void p(t.root,!1);n.hidden=!1,n._hmHtml!==s&&(n._hmHtml=s,n.innerHTML=s),n.setAttribute("aria-busy",r?"false":"true"),p(t.root,!0)},w=t=>{const n=new URLSearchParams;return t.forEach((e,t)=>{n.append("products[]",e.sku),n.append(`productData[${t}][item_id]`,e.itemId),n.append(`productData[${t}][sku]`,e.sku),n.append(`productData[${t}][uom]`,e.uom||"EA"),n.append(`productData[${t}][template_item]`,""),n.append(`productData[${t}][inventory_v2]`,e.inventoryV2)}),fetch(`${e.endpoint}?_=${Date.now()}`,{method:"POST",credentials:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest","X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]')?.getAttribute("content")||"","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:n}).then(e=>{if(!e.ok)throw new Error(`live-inventory ${e.status}`);return e.json()}).then(e=>{if("success"!==e?.status)throw new Error("live-inventory returned no data");(e.data||[]).forEach(e=>{e?.sku&&o.set(String(e.sku).toUpperCase(),e.shipping?.warehouses||[])}),t.forEach(e=>{o.has(e.key)||i.add(e.key)})}).catch(e=>{console.warn("[HeyMojo] Warehouse stock request failed:",e),t.forEach(e=>i.add(e.key))}).finally(y)},g=new WeakSet,f="MutationObserver"in window?new MutationObserver(e=>{e.some(e=>!e.target.closest?.(".hm-wh")&&![...e.addedNodes,...e.removedNodes].every(e=>1===e.nodeType&&e.classList.contains("hm-wh")))&&y()}):null,_=()=>{f&&["productCompareModal","quickviewproduct"].forEach(e=>{const t=document.getElementById(e);t&&!g.has(t)&&(g.add(t),f.observe(t,{childList:!0,subtree:!0}))});const a="boolean"==typeof e.loggedIn?e.loggedIn:!!document.querySelector(".btn-add-to-cart, .addItemToCart, .has-price"),o=(()=>{const e=[];return document.querySelectorAll(t).forEach(n=>{if(n.parentElement?.closest(t))return;if(n.closest(".hm-wh"))return;const a=n.getAttribute("data-sku");if(!a)return;const o=n.matches(".product-shopping-actions");e.push({root:n,sku:a,key:a.toUpperCase(),large:o,kind:o?"pdp":"tile",itemId:n.getAttribute("data-item-id")||"",uom:n.getAttribute("data-pack-uom")||"",inventoryV2:n.getAttribute("data-inventory-v2")||"",domData:c(n.querySelector(".live-inventory-v2-shipping[data-locations]")?.getAttribute("data-locations"))})}),document.querySelectorAll("#quickviewproduct .catalog-single, #productquickview .catalog-single").forEach(t=>{const n=t.querySelector("[data-sku]")?.getAttribute("data-sku"),a=/:\s*(\S+)\s*$/.exec(t.querySelector(".prod-sku")?.textContent||"")?.[1],o=[...t.classList].find(e=>e.startsWith("sku-"))?.slice(4).toUpperCase(),r=n||a||o;if(!r)return;const i=([...t.classList].find(e=>/^item_\d+$/.test(e))||"").slice(5);e.push({root:t,sku:r,key:r.toUpperCase(),large:!0,kind:"quickview",itemId:i,uom:t.querySelector("[data-pack-uom]")?.getAttribute("data-pack-uom")||"",inventoryV2:"",domData:c(t.querySelector(".live-inventory-v2-shipping[data-locations]")?.getAttribute("data-locations"))})}),e})();o.forEach(t=>{let o=s.get(t.root);if(!o||!o.isConnected){if(o=(t=>{const{root:a,kind:o}=t,r=(t=>{const n=document.createElement("section");return n.className="hm-wh hm-wh--"+(t?"large":"compact"),n.setAttribute("aria-label",e.text.heading),n})(t.large);if("pdp"===o){const e=[...a.children].find(e=>e.matches(".product-compare-action"));return e?e.before(r):a.appendChild(r),r}if("quickview"===o){const e=a.querySelector(".product-shopping-actions");if(!e)return null;const t=e.querySelector(".product-shopping-actions-addtocart");return t?t.after(r):e.appendChild(r),r}const i=a.querySelector(n);if(!i)return null;const s=i.closest(".live-inventory-v2-add-to-cart-wrapper")||i,h=s.closest(".buttons.group");return(h&&a.contains(h)?h:s).after(r),h&&a.contains(h)&&h.classList.add("hm-wh-host"),r})(t),!o)return;s.set(t.root,o)}m(t,o,a)}),(t=>{const n=[];t.forEach(t=>{r.has(t.key)||!e.refreshFromApi&&t.domData||(r.add(t.key),n.push(t))});for(let t=0;t{b=!1;try{_()}catch(e){console.error("[HeyMojo] Warehouse stock failed:",e)}}))}const x=`\n.hm-wh{display:block;width:100%;box-sizing:border-box;margin:10px 0 0;border:1px solid #e2e2e2;border-radius:10px;background:#fff;overflow:hidden;text-align:left;font-weight:400;line-height:1.3;color:#313231}\n.hm-wh *{box-sizing:border-box}\n.hm-wh[hidden]{display:none!important}\n.hm-wh__list{list-style:none;margin:0;padding:0}\n.hm-wh__row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:0;padding:8px 10px;list-style:none;background:#fff}\n.hm-wh__row::before,.hm-wh__row::after{content:none!important}\n.hm-wh__row+.hm-wh__row{border-top:1px solid #ececec}\n.hm-wh__name{display:flex;flex-direction:column;gap:2px;min-width:0;font-size:12.5px;font-weight:600;color:#313231}\n.hm-wh__due{font-size:11px;font-weight:400;color:#5f6264}\n.hm-wh__status{display:inline-flex;align-items:center;gap:5px;flex-shrink:0;white-space:nowrap;font-size:11.5px;font-weight:600;line-height:1.3;border-radius:999px;padding:3px 8px}\n.hm-wh__status--in{background:#e7f4eb;color:#146c2e}\n.hm-wh__status--out{background:#fbeaea;color:#a51d1d}\n.hm-wh__icon{width:12px;height:12px;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}\n.hm-wh--large{margin:14px 0;border-radius:14px}\n.hm-wh__head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:12px 14px 10px;background:#fafafa;border-bottom:1px solid #ececec}\n.hm-wh__title{font-size:14px;font-weight:600;color:#313231}\n.hm-wh__total{font-size:13px;font-weight:500;color:#5f6264}\n.hm-wh--large .hm-wh__row{padding:11px 14px}\n.hm-wh--large .hm-wh__name{font-size:14px}\n.hm-wh--large .hm-wh__due{font-size:12px}\n.hm-wh--large .hm-wh__status{font-size:13px;padding:4px 10px}\n.hm-wh--large .hm-wh__icon{width:14px;height:14px}\n.hm-wh__skel{display:block;width:104px;height:10px;border-radius:5px;background:#ebebeb;animation:hm-wh-pulse 1.2s ease-in-out infinite}\n.hm-wh__skel--pill{width:76px;height:20px;border-radius:10px;background:#f0f0f0}\n@keyframes hm-wh-pulse{50%{opacity:.5}}\n@media (prefers-reduced-motion:reduce){.hm-wh__skel{animation:none}}\n.hm-wh__sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.${a}{display:none!important}\n.hm-wh-host{height:auto!important}\n`;(()=>{if(document.getElementById("hm-wh-styles"))return;const e=document.createElement("style");e.id="hm-wh-styles",e.textContent=x,document.head.appendChild(e)})(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",y):y(),["live-inventory-done","live-pricing-done"].forEach(e=>document.addEventListener(e,y)),window.jQuery&&window.jQuery(document).on("shown.bs.modal",y),window.HeyMojoWarehouseStock={refresh:y,config:e}})();