//prettier-ignore (()=>{"use strict";const t="undefined"!=typeof window&&"undefined"!=typeof document,e={cartGroups:["ex-cart"],gridTiles:["*"],alternatives:["*"]},s=t=>"*"===t||Boolean(document.body?.classList.contains(t)),a=t&&["ex-a-2127645"].some(s),i=t=>a&&e[t].some(s),n=i("cartGroups"),r=i("gridTiles"),o=i("alternatives")||r;if(t&&(!n&&!r&&!o||window.__cswLoaded))return;t&&document.body.classList.add("csw-on");const c=(...t)=>console.warn("[csw]",...t),l=t=>String(t??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[t])),d=t=>new Promise(e=>setTimeout(e,t)),u={1:"Next Day Delivery",2:"1-2 Day Delivery",3:"3-5 Day Delivery",4:"4 Day Delivery",5:"5-8 Day Delivery",6:"6-8 Day Delivery",7:"7-10 Day Delivery",8:"8-10 Day Delivery",10:"10-14 Day Delivery",14:"14-18 Day Delivery",15:"15-20 Day Delivery",21:"21-28 Day Delivery",28:"28-36 Day Delivery",49:"42-49 Day Delivery",63:"63 Day Delivery",99:"Made to Order",901:"Next Day Delivery",902:"1-2 Day Delivery",904:"4-6 Day Delivery",905:"5-7 Working Days Delivery",907:"7-10 Working Days Delivery",915:"15-20 Working Days Delivery"},p=t=>99===t?1/0:t>900?t-900:t,h=t=>t<=2?"fast":t<=10?"medium":"slow",m=t=>h(p(t)),w=t=>u[t]?.replace(/ Delivery$/,"").replace(/(\d) Day$/,"$1 Days");function f(t){const e=Number(t.quantity)||0,s=String(t.location_name||"").replace(/\s*Stock$/i,"");return`${l(s)} ${e}`}function y(t){const e=(t||[]).filter(t=>/local|group/i.test(String(t.location_name||"")));return e.length>0&&e.every(t=>(Number(t.quantity)||0)<=0)}const g=t=>t.map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e??"")).join("&");async function v(t,e,s){const a=await fetch(t,{method:"POST",signal:s?AbortSignal.timeout(s):void 0,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest","X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]')?.content||""},body:g(e)});if(!a.ok)throw Object.assign(new Error(`${t}: HTTP ${a.status}`),{status:a.status});return{data:await a.json().catch(()=>{}),redirected:a.redirected}}const b=new Map;function k(t){if(t=String(t),!b.has(t)){const e=v(`/api/products/${t}`,[["compare","1"]],15e3).then(({data:e})=>{if(!e?.product)throw Object.assign(new Error(`/api/products/${t}: status ${e?.status}`),{final:!0});return{product:e.product,available:"success"===e.status}},t=>{throw t.status>=400&&t.status<500&&408!==t.status&&429!==t.status&&(t.final=!0),t});e.catch(()=>b.delete(t)),b.set(t,e)}return b.get(t)}async function _(t){const e=t.map(t=>["products[]",t.sku]);t.forEach((t,s)=>e.push([`productData[${s}][item_id]`,t.itemId],[`productData[${s}][sku]`,t.sku],[`productData[${s}][uom]`,t.uom],[`productData[${s}][template_item]`,t.template??""],[`productData[${s}][inventory_v2]`,t.inventoryV2??""]));const{data:s}=await v(`/ajax/live-inventory?_=${Date.now()}`,e,15e3);if("success"!==s?.status||!Array.isArray(s.data))throw new Error(`live-inventory: status ${s?.status}`);return s.data}async function S(t,e=15e3){const s=`table.items-list tr.item_${t}`,a=document.querySelector(`${s} .delete-btn`);if(!a)return!document.querySelector(s);a.click();const i=Date.now();for(;document.querySelector(s);){if(Date.now()-i>e)return!1;await d(100)}return!0}async function $(t,e,s){const{data:a,redirected:i}=await v("/cart/addcart",[["product",JSON.stringify(t)],["qty",e]]);if(i||!a||"object"!=typeof a)throw new Error("addcart: not added (redirected or not JSON)");if("status"in a&&!/^(200|success|ok|true)$/i.test(String(a.status)))throw new Error("addcart: "+(a.message||a.status));let n=!1;if("function"==typeof window.updateminicart)try{window.updateminicart(a,!1,"add-item")}catch(t){c("updateminicart",t)}const r=document.querySelector(".shopping-cart")?.__vue__;if(r&&Array.isArray(a.minicart_items))try{const t=new Set((r.items||[]).map(t=>t.session_cart_id));r.updateItemsInTheCart({...a,minicart_items:a.minicart_items.map(({item_obj:e,created_at:s,updated_at:a,...i})=>t.has(i.session_cart_id)?i:r.transformCartItems([{...i,created_at:s,quote_id:i.session_id,item_shipping_type:i.item_shipping_type??3,product_labels:i.product_labels??""}])[0])}),a.minicart_totals&&(r.totals={...r.totals,...a.minicart_totals}),await new Promise(t=>r.$nextTick(t))}catch(t){c("cart table update",t),n="cart"===s}else n="cart"===s;return document.dispatchEvent(new CustomEvent("cart-total-update")),{data:a,reload:n}}const M=Object.assign({api:"https://api.heymojo.dev/alternatives/v1/eu/stores/1655/products/",track:!0,searchTimeoutMs:3e4,searchConcurrency:3,pollDelaysMs:[5e3,1e4,15e3],runCapMs:6e4,removeTimeoutMs:15e3,maxCandidates:40,showMax:4,showAllMax:20,closeMaxRatio:3,packRatioLimit:20},t&&window.cswAlternativesConfig||{}),q={title:"Alternatives for",inStock:"in stock",queued:"Waiting for the previous search to finish",step1:"Preparing your search",step2:"Searching the store",step3:"Checking suitability",checking:"Still checking… more may appear",empty:"No in-stock alternatives right now.",stillChecking:"Still checking alternatives for this item. Try again in a minute.",added:"Added",add:"Add to basket",addAlso:"Add {sku} to basket as well",swap:"Swap",swapping:"Swapping…",swapTitle:"Replace {orig} in your basket with this",swapPartial:"Added. We couldn't remove {orig} — please remove it from your basket.",adding:"Adding…",failed:"Try again",cannotAdd:"Not available to add",showAll:"Show all {n}",showFewer:"Show fewer",showMore:"Show more",loadingMore:"Searching…",srSearching:"Searching the store",srResults:"alternatives in stock",browse:"Or browse similar products in",browseMore:"Not quite right? Browse",browseCta:"Browse {name}"},A=t=>Number(String(t??"").replace(/[^\d.]/g,"")),x=t=>{const e=String(t??"").trim();return/^[1-9]\d{0,11}$/.test(e)?e:""},T=t=>[t.productId,t.catalogId,t.supplierId,t.price].every(t=>Number.isFinite(t)&&t>0)&&t.sku&&t.title?t:null;function E(t){try{return(JSON.parse(document.getElementById("cartdata")?.value||"{}").store_cart||[]).find(e=>Number(e.item_id)===t)||null}catch{return null}}function L(t){const e=t?.href||t?.url,s=String(t?.textContent||t?.title||t?.name||"").trim();if(!e||!s||!/^(https?:\/\/|\/)/.test(e))return null;try{const t=new URL(e,"https://www.heatons.co.uk");return t.searchParams.set("in_stock_only","true"),{name:s,url:/^\//.test(e)?t.pathname+t.search+t.hash:t.href}}catch{return{name:s,url:e}}}async function C(t,e){const s=await fetch(M.api+t,{signal:AbortSignal.timeout(e)});if(200!==s.status)throw Object.assign(new Error("HTTP "+s.status),{status:s.status});return s.json()}function N(t,e){let s=0,a="",i=!1;for(let n=e;nt&&"object"==typeof t&&t.sku)}function I(t,e){const s=t[e];let a,i;if('"'===s||"'"===s){let n=e+1;for(;n[...t.matchAll(e)].map(t=>t.index),a=[...t.matchAll(/\$t_item\.item_sku\s*=\s*"([^"]+)"\s*;/g)],i=[...s(/\$t_item\s*=\s*\{/g),...a.map(t=>t.index)],n=[...i,...s(//gi)];for(const s of a){if(e.has(s[1]))continue;const a=Math.max(0,...n.filter(t=>tt>s.index)),o=t.slice(a,i),c={},l=/\$t_item\.([A-Za-z_]\w*)\s*=\s*/g;let d;for(;d=l.exec(o);){const[t,e]=I(o,l.lastIndex);void 0!==t&&(c[d[1]]=t),l.lastIndex=Math.max(l.lastIndex,e)}e.set(s[1],c)}return e}const j=t=>t.replace(/&(quot|amp|lt|gt|#39);/g,(t,e)=>({quot:'"',amp:"&",lt:"<",gt:">","#39":"'"}[e]));function O(t){const e=new Map,s=[...t.matchAll(/]*\bdata-sku="([^"]+)"[^>]*>/g)];return s.forEach((a,i)=>{if(e.has(a[1]))return;const n=t.slice(a.index,s[i+1]?.index??t.length),r=n.match(/]*class="[^"]*product-tile-image[^"]*"[^>]*\bhref="([^"]+)"/)||n.match(/class="product-name">\s*j(a[0].match(new RegExp(`\\b${t}="([^"]*)"`))?.[1]??"");e.set(a[1],{url:r?j(r[1]):"",vendorCode:o("data-seller-vendor-code"),inventoryV2:o("data-inventory-v2"),leadTime:o("data-leadtime")})}),e}function H(t){const e=D(t);if(!e.length)return[];const s=P(t),a=O(t);return e.map(t=>{const e=String(t.sku).trim(),i=s.get(e)||null,n=a.get(e)||{};return{item:Number(t.item),sku:e,name:String(t.name??"").trim(),price:A(t.price),image:t.image?String(t.image):"",url:n.url||"",vendorCode:n.vendorCode||"",inventoryV2:n.inventoryV2||"",leadTime:Number(n.leadTime)||null,catalogId:x(i?.item_catalog_id),supplierId:x(i?.item_supplier_id)||x(t.supplier),cart:i}}).filter(t=>x(t.item))}async function R(t,e,s){const a="/search?query="+encodeURIComponent(t)+(e?"&in_stock_only=true":""),i=await fetch(a,{signal:AbortSignal.any?AbortSignal.any([s,AbortSignal.timeout(M.searchTimeoutMs)]):s});return i.ok?H(await i.text()):[]}function B(t,e){const s=new Map,a=[],i=Math.max(0,...t.map(t=>t.products.length));for(let n=0;n=M.maxCandidates)continue;const o={...t,inStock:i.inStock};s.set(t.item,o),a.push(o)}return a}function F(t){const e=String(t??"").match(/\b(?:pack|box|tub|case) of (\d+)\b|\b(\d+)\s*(?:pack|pk)\b/i),s=e&&Number(e[1]??e[2]);return s>0?s:null}function J(t,e){const s=F(e.title),a=F(t.name);return s&&a&&Math.max(s,a)/Math.min(s,a)1&&/^\d{5,}$/.test(e[e.length-1])&&e.pop(),new Set(e)}function W(t,e){const[s,a]=[z(t),z(e)],[i,n]=s.size<=a.size?[s,a]:[a,s];return[...i].every(t=>n.has(t))&&n.size-i.size<=1}function U(t,e,s,a){const i=new Map(e.map(t=>[t.item,t])),n=t=>Math.max(s.price*(3===t?M.closeMaxRatio:2),s.price+5),r=[];for(const e of t){const t=i.get(e);if(!t||!t.inStock||!Number.isFinite(t.price))continue;const o=a?.get(e)??2,c=J(t,s);c>=s.price/2&&c<=n(o)&&r.push({...t,compare:c,level:o})}r.sort((t,e)=>e.level-t.level||Math.abs(t.compare-s.price)-Math.abs(e.compare-s.price));const o=[];for(const t of r)o.some(e=>W(e.name,t.name))||o.push(t);return o}const V=(t,e)=>t.slice(0,e?M.showAllMax:M.showMax),G=t=>t.length>=M.showMax&&t.every(t=>3===t.level),X=t=>t.length<=2?[t]:[t.slice(0,2),t.slice(2)];function Y(t,e){const s=!(e&&e.local<=0&&e.group<=0)&&w(t.leadTime),a=(t,e)=>`${t} ${e}`;return`
${s||"Contact Us for Availability"}
`+(s&&e?`
${a("Local",e.local)}${a("Group",e.group)}
`:"")+"
"}const K={item_is_multiple:0,item_minimum_order:1,item_maximum_order:0,item_multiple_qty:0,item_is_contract:0,pack_uom:"1",item_pack:"1",item_cost_center_id:0,item_department_id:0,item_images:[],item_price_type:0,item_price_unit:1,modifiers:null,og_sku:"",swap_type:"",line_ref:"",additional_data:"{}"};function Q(t){const e=Object.assign({},K,t.cart||{},{item_id:t.item,item_sku:t.sku,item_catalog_id:Number(t.catalogId)||0,item_supplier_id:Number(t.supplierId)||0,item_name:t.cart?.item_name||t.name});return t.vendorCode&&(e.additional_data=JSON.stringify({vendor_code:t.vendorCode})),delete e.item_vendor_code,e}if(t){window.__cswLoaded=!0;for(const[t,e]of[[n,function(){const t=[],e=new Map;Object.keys(u).map(Number).sort((t,e)=>p(t)-p(e)||t-e).forEach(s=>{const a=u[s];let i=t.find(t=>t.label===a);i||(i={id:`lt-${s}`,label:a,tier:h(p(s))},t.push(i)),e.set(s,i)});const s={id:"contact-us",label:"Contact Us for Availability",tier:"unknown"},a={id:"loading",label:"Checking Availability…",tier:"loading"},i=[...t,a,s],n=new Map(i.map((t,e)=>[t.id,e])),r=148061607,o="COMPLETEDEL",m={item_id:r,item_sku:o,item_catalog_id:1e3,item_catalog_item_id:167157880,item_supplier_id:1e3,item_is_multiple:0,item_minimum_order:1,item_maximum_order:0,item_multiple_qty:0,item_is_contract:0,item_name:"Complete Order Delivery",item_image_thumbnail_path:"",item_image_thumbnail:"",item_cost_center_id:0,item_department_id:0,pack_uom:"EA",item_pack:"1",item_price_type:0,item_price_unit:1,item_shipping_type:3,modifiers:null,line_ref:"",additional_data:'{"vendor_code":"2614"}'},w={},g=new Set,v={},b={},M={};let q=[],A=!0,x="partial",T=!1;const E=t=>`${t} ${1===t?"item":"items"}`;function L(){const t=document.getElementById("cartdata");if(!t||!t.value.trim())return[];try{return JSON.parse(t.value).store_cart||[]}catch(t){return console.error("cartdata: invalid JSON",t),[]}}const C=t=>t&&null!=t.item_id&&t.item_sku,N=()=>!!document.querySelector("table.items-list tr.item_148061607"),D=(t,e)=>t.querySelectorAll(`tr.item_${e}`);function I(t){const i=t.item_catalog_item_id;if(null==i)return s;if(!Object.prototype.hasOwnProperty.call(v,i))return a;if(g.has(t.item_sku)&&!w[t.item_sku])return a;if(y(w[t.item_sku]))return s;const n=v[i];return null==n?s:e.get(n)||s}function P(){document.querySelectorAll(".csw-delivery-options .csw-delivery-radio").forEach(t=>{const e=t.getAttribute("data-value")===x;t.classList.toggle("csw-checked",e),t.setAttribute("aria-checked",e?"true":"false")}),document.querySelectorAll('.csw-delivery-options input[name="csw_delivery_method"]').forEach(t=>{t.value=x})}function j(t,e=!1){if(T||t===x)return;x=t,P();const s=e?"Updating delivery options…":"together"===t?"Arranging a single delivery…":"Switching to separate deliveries…",a=("together"===t?async function(){const{reload:t}=await $(m,1,"cart");t&&window.location.reload()}():J()).catch(t=>console.error("Delivery choice update failed:",t));F(!0,s),Promise.race([a,d(15e3)]).then(()=>{F(!1),Q()})}function O(t,e,s){if(!t)return;let a=Array.from(t.children).find(t=>t.classList.contains("csw-delivery-options"));s?(a||(a=function(){const t=document.createElement("div");return t.className="csw-delivery-options",t.innerHTML=`
Delivery options
one delivery, one tree

Your items have different lead times.
If you choose to receive everything together, we will plant a tree on your behalf.

`,t.querySelectorAll(".csw-delivery-radio").forEach(t=>{const e=e=>{e.preventDefault(),e.stopPropagation(),j(t.getAttribute("data-value"))};t.addEventListener("click",e),t.addEventListener("keydown",t=>{" "!==t.key&&"Enter"!==t.key||e(t)})}),t.classList.toggle("csw-is-busy",T),t}(),t.insertBefore(a,e||null)),function(t,e){const s=t=>t.map(t=>`${l(t)}`).join("");t.querySelector('[data-csw-lines="together"]').innerHTML=s(e.together),t.querySelector('[data-csw-lines="partial"]').innerHTML=s(e.partial);const a=t.querySelector(".csw-dopt-footer");a.textContent=e.footer,a.hidden=!e.footer}(a,s)):a&&a.remove()}function H(t){document.querySelectorAll("a.btn.to-checkout").forEach(e=>{t?(e.hasAttribute("data-csw-href")||e.setAttribute("data-csw-href",e.getAttribute("href")||""),e.removeAttribute("href"),e.setAttribute("aria-disabled","true"),e.classList.add("csw-checkout-disabled")):e.hasAttribute("data-csw-href")&&(e.setAttribute("href",e.getAttribute("data-csw-href")),e.removeAttribute("data-csw-href"),e.removeAttribute("aria-disabled"),e.classList.remove("csw-checkout-disabled"))})}let R=null;function B(){const t=document.querySelector(".shopping-cart");if(!R||!t)return;const e=t.getBoundingClientRect();R.style.top=`${e.top+window.scrollY}px`,R.style.left=`${e.left+window.scrollX}px`,R.style.width=`${e.width}px`,R.style.height=`${e.height}px`}function F(t,e="Updating your basket…"){T=t,t?function(t){R||(R=document.createElement("div"),R.className="csw-busy-overlay",R.innerHTML='
Please wait while we update your basket.
',document.body.appendChild(R)),R.querySelector(".csw-busy-title").textContent=t,R.hidden=!1,B(),window.addEventListener("resize",B)}(e):(R&&(R.hidden=!0),window.removeEventListener("resize",B)),document.querySelectorAll(".shopping-cart").forEach(e=>{e.inert=t,e.toggleAttribute("data-csw-busy",t),e.setAttribute("aria-busy",String(t))}),document.querySelectorAll(".csw-delivery-options").forEach(e=>e.classList.toggle("csw-is-busy",t)),H(t)}const J=()=>S(r,15e3);function z(t){const e=t.querySelector("td.name");if(!e)return null;let s=e.querySelector(":scope > .csw-delivery");return s||(s=document.createElement("div"),s.className="csw-delivery",s.innerHTML='
',e.insertBefore(s,e.firstChild)),s}const W=new WeakSet,U="undefined"!=typeof ResizeObserver?new ResizeObserver(t=>{t.forEach(t=>{const e=t.contentRect.width;0!==e&&t.target.toggleAttribute("data-csw-compact",e<920)})}):null;function V(e,i){const r=function(t){const e=t.querySelector("thead tr");return e&&e.children.length||6}(e);!function(t,e){t.dataset.cswGrid||(t.dataset.cswGrid="1",(t=>!!t.closest(".mobile"))(t)||(6===e?(t.dataset.cswTuned="1",function(t){if(W.has(t))return;W.add(t);const e=t.clientWidth;e>0&&t.toggleAttribute("data-csw-compact",e<920),U&&U.observe(t)}(t)):t.style.gridTemplateColumns=`repeat(${e}, minmax(0, max-content))`))}(e,r);const o=e.querySelector("tbody");if(!o)return;o.querySelectorAll("tr.csw-band").forEach(t=>t.remove());const c=new Map;i.forEach((t,i)=>{D(e,i.item_id).forEach(e=>{e.style.order=n.get(t.id),function(t,e,i){const n=z(t);n&&n.dataset.cswBucket!==e.id&&(n.dataset.cswBucket=e.id,n.dataset.cswTier=e.tier,n.querySelector(".csw-dl-status").innerHTML=function(t,e){if(t.id===a.id)return'Checking availability…';const i=`${l(t.label)}`;return t.id!==s.id?i:i+`Search alternatives`}(e,i))}(e,t,i),function(t,e){const s=z(t)?.querySelector(".csw-stock-list"),a=e?e.map(t=>`${t.location_name}:${t.quantity}`).join("|"):"";s&&s.dataset.key!==a&&(s.dataset.key=a,s.innerHTML=e?e.map(f).join(""):"",s.hidden=!e?.length)}(e,w[i.item_sku])}),c.set(t,(c.get(t)||0)+1)});const d=document.createDocumentFragment();[...c].sort(([t],[e])=>n.get(t.id)-n.get(e.id)).forEach(([t,e])=>d.appendChild(function(t,e,s){const a=document.createElement("tr");return a.className="csw-band",a.setAttribute("data-csw-bucket",t.id),a.setAttribute("data-csw-tier",t.tier),a.style.order=n.get(t.id),a.innerHTML=`
${l(t.label)}${E(e)}
`,a}(t,e,r))),o.insertBefore(d,o.firstChild),function(e,s){const a=[...e.querySelectorAll("tbody > tr")];a.forEach(t=>t.removeAttribute("data-csw-consol"));const i=e.querySelector("tbody > tr.item_148061607"),n=[...e.querySelectorAll("tbody > tr.csw-band")].filter(e=>t.some(t=>t.id===e.dataset.cswBucket));s.forEach((t,s)=>{G.has(t)&&n.push(...D(e,s.item_id))});const r=Boolean(i&&n.length);if(e.toggleAttribute("data-csw-consol-on",r),!r)return;const o=new Map(a.map((t,e)=>[t,e])),c=n.reduce((t,e)=>{return s=e,a=t,((Number(s.style.order)||0)-(Number(a.style.order)||0)||o.get(s)-o.get(a))>0?e:t;var s,a});i.setAttribute("data-csw-consol","first"),n.forEach(t=>t.setAttribute("data-csw-consol",t===c?"last":"mid"))}(e,i)}const G=new Set(t);function X(){const t=new Map(q.map(t=>[t,I(t)]));Array.from(document.querySelectorAll("table.items-list")).forEach(e=>V(e,t)),function(t){const e=t.every(t=>t.id!==a.id),i=e&&new Set(t.map(t=>t.id)).size>1,r=i?function(t){const e=new Map;let a=0;t.forEach(t=>{t.id!==s.id?(e.has(t.id)||e.set(t.id,{bucket:t,count:0}),e.get(t.id).count+=1):a+=1});const i=Array.from(e.values()).sort((t,e)=>n.get(t.bucket.id)-n.get(e.bucket.id)),r=i.reduce((t,e)=>t+e.count,0),o=i[i.length-1];return{together:[...o?[`${E(r)} – ${o.bucket.label}`]:[],"One delivery, one tree"],partial:i.map(t=>`${E(t.count)} – ${t.bucket.label}`),footer:a?`${E(a)} ${1===a?"has":"have"} no date yet and will follow separately.`:""}}(t):null;H(T||!e),document.querySelectorAll(".desktop .carttotals_container").forEach(t=>{const e=t.querySelector(".cart-resume");O(t,e&&e.parentNode===t?e:t.firstChild,r)}),document.querySelectorAll(".mobile .cart-header-actions").forEach(t=>{O(t.parentNode,t,r)}),i&&P(),e&&!i&&!T&&N()&&j("partial",!0)}([...t.values()])}let Y;function K(){clearTimeout(Y),Y=setTimeout(Q,300)}function Q(){if(T)return;const t=function(){const t=A?L():function(){const t=window.$mini_cart;if(t){if(Array.isArray(t))return t;if(Array.isArray(t.store_cart))return t.store_cart}return L()}();return function(t){t.forEach(t=>{null!=t.item_id&&null!=t.item_catalog_item_id&&(M[t.item_id]=t.item_catalog_item_id)})}(t),t.forEach(t=>{null==t.item_catalog_item_id&&null!=M[t.item_id]&&(t.item_catalog_item_id=M[t.item_id])}),t}().filter(C);A=!1,x=N()?"together":"partial",q=t.filter(t=>!(t=>Number(t.item_id)===r||t.item_sku===o)(t)),q.length?(X(),function(){const t=[...new Map(q.filter(t=>!w[t.item_sku]&&!g.has(t.item_sku)).map(t=>[t.item_sku,t])).values()];t.length&&(t.forEach(t=>g.add(t.item_sku)),_(t.map(t=>({sku:t.item_sku,itemId:t.item_id,uom:t.item_pack_uom||t.pack_uom||"EA",template:t.item_og_sku||"",inventoryV2:t.inventory_v2?JSON.stringify(t.inventory_v2):""}))).then(t=>t.forEach(t=>{t.sku&&Array.isArray(t.shipping?.warehouses)&&(w[t.sku]=t.shipping.warehouses)})).catch(t=>console.error("Stock fetch error:",t)).finally(()=>{t.forEach(t=>g.delete(t.item_sku)),X()}))}(),function(){const t=[...new Set(q.map(t=>t.item_catalog_item_id))].filter(t=>null!=t&&!Object.prototype.hasOwnProperty.call(v,t)&&!b[t]);t.length&&(t.forEach(t=>{b[t]=async function(t){for(let e=1;;e+=1)try{const{product:e,available:s}=await k(t);if(!s)throw Object.assign(new Error(`/api/products/${t}: not available`),{final:!0});const a=parseInt(e.item_lead_time,10);return void(v[t]=Number.isNaN(a)?null:a)}catch(s){if(s.final||e>=2)return(s.final?c:console.error)("Lead time unavailable, showing Contact Us:",s.message),void(v[t]=null);await d(1500)}}(t).finally(()=>{delete b[t]})}),Promise.allSettled(t.map(t=>b[t])).then(X))}()):N()&&j("partial",!0)}!function(){const t=document.querySelector("h1"),e=t&&getComputedStyle(t).fontFamily;e&&document.documentElement.style.setProperty("--csw-font-brand",e)}(),Q(),document.addEventListener("live-pricing-done",K),document.addEventListener("cart-total-update",()=>setTimeout(K,0))}],[r,function(){function t(t){const e=t.querySelector(".buttons.group");if(!e)return;t.classList.contains("csw-tile")||t.classList.add("csw-tile");const a="1"===t.dataset.configurablemaster||"true"===t.dataset.configurableproduct||Boolean(e.querySelector(":scope > .is-master")),i=Boolean(e.querySelector(":scope > :is(.qty-list, .inputquantity)")&&e.querySelector(".live-inventory-v2-add-to-cart-wrapper .btn-add-to-cart"))?"buy":a?"configure":"other";t.dataset.cswMode!==i&&(t.dataset.cswMode=i);const n=Number(t.dataset.leadtime),r=w(n);let o=e.querySelector(":scope > .csw-delivery");const c=!(a&&!r);t.dataset.cswCard!==(c?"1":"0")&&(t.dataset.cswCard=c?"1":"0"),c||(o?.remove(),o=null),c&&!o&&(o=document.createElement("div"),o.className="csw-delivery",e.prepend(o));const d=function(t){try{const e=JSON.parse(t.querySelector("[data-locations]")?.dataset.locations||"null");if(Array.isArray(e)&&e.length)return e}catch{}const e=[...t.querySelectorAll(".product-stock-wrap .stock-entry")].map(t=>({location_name:t.querySelector(".stock-warehouse")?.textContent.trim(),quantity:Number(t.querySelector(".stock-quanitity")?.textContent.replace(/[^\d-]/g,""))}));return e.length?e:null}(t),u=!a&&!r,p='
'+(u?`Contact usSearch alternatives`:`${l(r)}`)+"
"+(!u&&d?`
${d.map(f).join("")}
`:"");o&&o.dataset.key!==p&&(o.dataset.key=p,o.dataset.cswTier=u?"unknown":m(n),o.innerHTML=p);const h=!u&&!a&&y(d);let g=e.querySelector(":scope > .csw-alt-link--below");h&&!g?e.insertAdjacentHTML("beforeend",`Search alternatives`):!h&&g&&g.remove();const v=!o||!u&&!o.querySelector(".csw-stock-list");o?.classList.toggle("csw-delivery--strip",v),t.dataset.cswSlim!==(v?"1":"0")&&(t.dataset.cswSlim=v?"1":"0"),"buy"!==i?e.querySelectorAll(":scope > .csw-tile-step").forEach(t=>t.remove()):e.querySelector(".csw-tile-step")||e.insertAdjacentHTML("beforeend",''),s(e.querySelector(".btn-add-to-cart"));const b=t.querySelector(".footer-wrapper-price");b&&!b.querySelector(".csw-tile-code")&&b.insertAdjacentHTML("beforeend",`${l(t.dataset.sku||"")}`)}const e=t=>String(t||"").replace(/["']/g,'"').replace(/\s+/g," ").trim();function s(t){const s=t?.closest(".live-inventory-v2-add-to-cart-wrapper");if(!s)return;const a=e(t.innerHTML),i=Boolean(t.querySelector("i"))||[t.dataset.loadingText,t.dataset.completeText].some(t=>t&&e(t)===a),n=!i&&(t.disabled||t.classList.contains("disabled"));s.hasAttribute("data-csw-state")!==i&&s.toggleAttribute("data-csw-state",i),s.hasAttribute("data-csw-wait")!==n&&s.toggleAttribute("data-csw-wait",n)}const a=()=>document.querySelectorAll(".product[data-item-id]").forEach(t);document.addEventListener("click",t=>{const e=t.target.closest(".csw-tile .csw-tile-step");if(!e)return;const s=e.closest(".buttons.group")?.querySelector(".qty-list, .inputquantity");s&&(s.value=Math.max(1,(parseInt(s.value,10)||1)+Number(e.dataset.step)),s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("change",{bubbles:!0})))}),a();let i=0;new MutationObserver(t=>{let e=!1;for(const a of t){const t=(1===a.target.nodeType?a.target:a.target.parentElement)?.closest?.(".csw-tile .btn-add-to-cart");t?s(t):"childList"!==a.type&&"data-locations"!==a.attributeName&&"data-leadtime"!==a.attributeName||(e=!0)}e&&!i&&(i=setTimeout(()=>{i=0,a()},100))}).observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-locations","data-leadtime","disabled","class"]})}],[o,function(){const t=new Map;let e=Promise.resolve();class s{constructor(t){this.product=t,this.state={phase:"phrases",queued:!0,searched:0,searchTotal:0,pending:[],ranked:[],shown:[],expanded:!1,stoppedEarly:!1,searching:!1,loadingMore:!1,stock:{},category:null,finished:!1,stillPending:!1},this.listener=null,this.candidates=[],this.controller=new AbortController,this.seed=!1,this.sets=[],this.skipped=[],this.lastRes=null,this.capped=!1,this.polls=0,this.pollTimer=null,this.capTimer=null,this.nextPollAt=0,this.active=!1,this.busy=!1,this.livePrices=new Map,this.stockRequested=new Set}set(t){Object.assign(this.state,t),this.listener?.(this.state)}clearTimers(){clearTimeout(this.capTimer),clearTimeout(this.pollTimer),this.capTimer=this.pollTimer=null}armCap(){clearTimeout(this.capTimer),this.capTimer=setTimeout(()=>this.expire(),M.runCapMs)}schedulePoll(t){clearTimeout(this.pollTimer),this.pollTimer=setTimeout(()=>this.poll(),t)}resume(){this.active=!0,this.state.finished||("checking"===this.state.phase&&(this.capped=!1),this.armCap(),"checking"!==this.state.phase||!this.state.pending.length||this.pollTimer||this.busy||this.state.loadingMore||this.schedulePoll(Math.max(0,this.nextPollAt-Date.now())))}pause(){this.active=!1,this.clearTimers()}async loadCategory(){if(!this.categoryAsked)if(this.categoryAsked=!0,this.product.category)this.set({category:this.product.category});else if(this.product.catalogItemId)try{const{product:t}=await k(this.product.catalogItemId),e=L({url:t.public_category_url,name:t.item_category_name});e&&this.set({category:e})}catch{}}expire(){this.state.finished||(this.capped=!0,"searching"===this.state.phase||this.state.loadingMore?this.controller.abort():"checking"===this.state.phase&&this.pollTimer&&this.finish({stillPending:this.state.pending.length>0}))}finish(t={}){this.clearTimers(),this.set({...t,pending:[],searching:!1,loadingMore:!1,finished:!0}),this.state.shown.length||this.state.stillPending||n(this.product.productId,"none")}fail(e,s){c(e,s),this.finish(),t.delete(this.product.productId)}retryChecks(){this.polls=0,this.capped=!1,this.set({finished:!1,phase:"checking",stillPending:!1}),this.armCap(),this.poll()}async start(){if(this.state.finished)return;let t;this.set({queued:!1}),this.armCap();try{t=await async function(t){const e=await C(`${t.productId}/phrases?catalogId=${t.catalogId}&supplierId=${t.supplierId}`,2e4),s=Array.isArray(e?.queries)?e.queries.filter(t=>"string"==typeof t&&t.trim()).slice(0,6):[];if(!s.length)throw new Error("phrases: empty answer");return{queries:s,seed:!0===e.seed}}(this.product)}catch(t){return void(404===t.status||503===t.status?this.finish():this.fail("phrases",t))}this.seed=t.seed;const e=this.seed?[t.queries]:X(t.queries);this.set({phase:"searching",searching:!0,searchTotal:t.queries.length*(this.seed?2:1)});for(let t=0;t[{inStock:!0,phrase:t,products:[]},...e?[{inStock:!1,phrase:t,products:[]}]:[]]);let a=0;return await Promise.all(Array.from({length:M.searchConcurrency},async()=>{for(;a`${t.item}:${t.catalogId}:${t.supplierId}`).join(","),i=await C(`${t.productId}/picks?catalogId=${t.catalogId}&supplierId=${t.supplierId}&c=${a}${s?"&seed=1":""}`,15e3),n=t=>Array.isArray(t)?t.map(Number).filter(Number.isFinite):null,r=n(i?.approved),o=n(i?.pending);if(!r||!o)throw new Error("picks: malformed answer");const c=new Map;for(const[t,e]of Object.entries(i.match||{}))[1,2,3].includes(e)&&c.set(Number(t),e);return{approved:r,pending:o,match:c}}(this.product,this.candidates,this.seed);if(this.state.finished)return null;const e=new Map(this.candidates.map(t=>[t.item,t]));if(await this.priceCandidates(t.approved.map(t=>e.get(t)).filter(t=>t?.inStock)),this.state.finished)return null;const s=this.candidates.map(t=>this.livePrices.has(t.sku)?{...t,price:this.livePrices.get(t.sku)}:t),a=U(t.approved,s,this.product,t.match),i=V(a,this.state.expanded);return this.lastRes=t,this.set({pending:t.pending,ranked:a,shown:i}),this.loadStock(i),t}catch(t){return 404===t.status?this.finish():"TimeoutError"===t.name?this.finish({stillPending:!0}):this.fail("picks",t),null}finally{this.busy=!1}}afterJudge(t){if(!t.pending.length||this.polls>=M.pollDelaysMs.length||this.capped)return void this.finish({stillPending:t.pending.length>0});const e=M.pollDelaysMs[this.polls];this.nextPollAt=Date.now()+e,this.active&&this.schedulePoll(e)}async poll(){if(this.state.finished)return;this.pollTimer=null;const t=await this.judge();t&&!this.state.finished&&(this.polls++,this.afterJudge(t))}toggleExpanded(){if(this.state.stoppedEarly)return void this.showMore();const t=!this.state.expanded;this.set({expanded:t,shown:V(this.state.ranked,t)}),this.loadStock(this.state.shown)}async showMore(){if(this.state.loadingMore||!this.skipped.length)return;this.clearTimers(),this.capped=!1,this.controller.signal.aborted&&(this.controller=new AbortController),this.set({loadingMore:!0,finished:!1,phase:"checking",stoppedEarly:!1}),this.armCap();const t=this.skipped;if(this.skipped=[],this.sets.push(...await this.runSearches(t,!1)),this.state.finished)return;this.candidates=B(this.sets,this.product);const e=await this.judge();e&&!this.state.finished&&(this.set({loadingMore:!1,expanded:!0,shown:V(this.state.ranked,!0)}),this.loadStock(this.state.shown),e.pending.length?(this.polls=0,this.afterJudge(e)):this.finish())}async priceCandidates(t){const e=t.filter(t=>!this.livePrices.has(t.sku));if(e.length)try{const t=await async function(t){const e=[];t.forEach((t,s)=>{e.push([`products[${s}][pack_uom]`,t.cart?.pack_uom??"1"],[`products[${s}][sku]`,t.sku],[`products[${s}][pack]`,t.cart?.item_pack??"1"],[`products[${s}][qty]`,1],[`products[${s}][template_item]`,t.cart?.template_item??""]),t.vendorCode&&e.push([`products[${s}][vendor_code]`,t.vendorCode]),e.push([`products[${s}][item_id]`,t.item])});const{data:s}=await v("/ajax/live-pricing",e,15e3),a={};for(const t of s?.data||[])Number.isFinite(Number(t.price))&&(a[t.sku]=Number(t.price));return a}(e);for(const s of e)Number.isFinite(t[s.sku])&&this.livePrices.set(s.sku,t[s.sku])}catch(t){c("live pricing (comparing on search-page prices)",t)}}async loadStock(t){const e=t.filter(t=>!this.stockRequested.has(t.sku));if(!e.length)return;e.forEach(t=>this.stockRequested.add(t.sku));const s=await async function(t){const e=await _(t.map(t=>({sku:t.sku,itemId:t.item,uom:t.cart?.pack_uom??"1",template:t.cart?.template_item??"",inventoryV2:t.inventoryV2}))),s={};for(const t of e){let e=0,a=0;for(const s of t.shipping?.warehouses||[])/^local/i.test(String(s.warehouse||s.location_name))?e+=Number(s.quantity)||0:a+=Number(s.quantity)||0;s[t.sku]={local:e,group:a,count:Number(t.shipping?.count)||0,hideAdd:1===Number(t.shipping?.hide_addtocart)}}return s}(e).catch(()=>({}));Object.values(s).some(t=>t.count>0||t.local+t.group>0)&&this.set({stock:{...this.state.stock,...s}})}}function a(t,e,s){if(M.track)try{const a=M.api+t+"/events/"+e+(s?"?"+new URLSearchParams(s):"");if(navigator.sendBeacon?.(a))return;fetch(a,{method:"POST",keepalive:!0}).catch(()=>{})}catch(t){c("track",t)}}const i=new Set;function n(t,e){i.has(e+":"+t)||(i.add(e+":"+t),a(t,e))}const r='',o='',d='',u='',p=()=>window.innerWidth<768,h=(t,e)=>`${t}${l(e)}`;let m=null,w=null;const f=()=>Boolean(m?.matches(":popover-open"));function y(){f()&&m.hidePopover()}let g=0;function b(){w&&f()&&!g&&(g=requestAnimationFrame(()=>{g=0,w&&f()&&x()}))}function x(){if(!document.contains(w.link)){const t=[...document.querySelectorAll(".csw-alt-link")].find(t=>t.dataset.cswSku===w.link.dataset.cswSku&&t.getClientRects().length);t&&(w.link=t)}if(m.classList.toggle("is-sheet",p()),p())return void(m.style.cssText="");const t=w.link.getBoundingClientRect(),e=Math.min(window.innerWidth>=1024?720:560,window.innerWidth-16);m.style.width=e+"px";const s=m.offsetHeight;let a=t.bottom+8;a+s>window.innerHeight-8&&(a=Math.max(8,t.top-s-8)),m.style.left=Math.min(Math.max(8,t.left+t.width/2-e/2),window.innerWidth-e-8)+"px",m.style.top=a+"px"}const N=(t,e)=>`
  • ${o}${l(e)}${1===t?'':""}
  • `,D=(t,e)=>`${t}${l(e)}`;function I(t){if(!w)return;const e=t=>m.querySelector(t),s=t.shown.length>0,a=["phrases","searching","checking"].indexOf(t.phase),i=e(".csw-alt-steps");i.hidden=s||t.finished,i.querySelectorAll(".csw-alt-step").forEach((e,s)=>{if(e.classList.toggle("is-done",!i.hidden&&s[t.dataset.sku,t]));t.shown.forEach((t,e)=>{let s=o.get(t.sku);if(s)o.delete(t.sku);else{const e=document.createElement("template");e.innerHTML=function(t,e){const s="cart"===e?.context,a=s?e.qty:1,i=s?``:``,n=t.url?`${l(t.name)}`:`${l(t.name)}`;return`
    \n
    \n
    ${t.image?``:""}
    \n
    ${n}${l(t.sku)}
    \n ${o=t.price,"£"+(Number.isFinite(o)?o.toFixed(2):"—")}\n
    \n
    \n
    ${i}
    \n
    \n
    `;var o}(t,w.product),s=e.content.firstElementChild}n.children[e]!==s&&n.insertBefore(s,n.children[e]||null)}),o.forEach(t=>t.remove()),n.querySelectorAll(".csw-alt-row").forEach(e=>{const s=Y(t.shown.find(t=>t.sku===e.dataset.sku),t.stock[e.dataset.sku]),a=e.querySelector(".csw-alt-card");a.innerHTML!==s&&(a.innerHTML=s);const i=Boolean(t.stock[e.dataset.sku]?.hideAdd);e.querySelectorAll(".csw-alt-add, .csw-alt-swap").forEach(t=>{t.disabled=i||Boolean(w.swapping),i?(t.dataset.title??=t.title,t.title=q.cannotAdd):t.title===q.cannotAdd&&(t.title=t.dataset.title||"")})});const c=e(".csw-alt-more");let y="";t.stoppedEarly||t.loadingMore?y=s?t.loadingMore?q.loadingMore:q.showMore:"":t.ranked.length>M.showMax&&(y=t.expanded?q.showFewer:q.showAll.replace("{n}",Math.min(t.ranked.length,M.showAllMax))),c.hidden=!y,c.disabled=t.loadingMore,c.innerHTML=(t.loadingMore?u:"")+l(y),c.setAttribute("aria-expanded",String(t.expanded)),e(".csw-alt-count").textContent=s?` · ${t.shown.length} ${q.inStock}`:"",e(".csw-alt-foot").hidden=!(s&&(t.pending.length||t.searching||t.loadingMore));const g=e(".csw-alt-empty");g.hidden=!(t.finished&&!s),g.textContent=t.stillPending?q.stillChecking:q.empty;const v=e(".csw-alt-cat"),b=t.category?s?"more":t.finished&&!t.stillPending?"cta":"line":"";if(v.hidden=!b,b&&v.dataset.key!==b+t.category.url){const{url:e,name:s}=t.category;v.dataset.key=b+e,v.classList.toggle("is-cta","cta"===b),v.innerHTML="cta"===b?`${l(q.browseCta.replace("{name}",s))}`:`${l("more"===b?q.browseMore:q.browse)} ${l(s)}`}const k=s?`${t.shown.length} ${q.srResults}`:t.finished?g.textContent:q.srSearching;k!==w.srText&&(w.srText=k,e(".csw-alt-sr").textContent=k),!p()&&f()&&x()}function j(t){const e=t.closest(".csw-alt-row"),s=w?.run.state.shown.find(t=>t.sku===e.dataset.sku);return s&&{row:e,c:s,qty:Math.max(1,parseInt(e.querySelector("input").value,10)||1)}}async function O(t){if(t.target.closest(".csw-alt-x"))return void y();if(t.target.closest(".csw-alt-cat a"))return void(w&&n(w.product.productId,"category"));if(t.target.closest(".csw-alt-more"))return void w?.run.toggleExpanded();const e=t.target.closest("[data-qty]");if(e){const t=e.parentElement.querySelector("input");return void(t.value=Math.max(1,(parseInt(t.value,10)||1)+Number(e.dataset.qty)))}const s=t.target.closest(".csw-alt-swap");if(s)return void async function(t){if(!w||t.disabled||w.swapping)return;const e=j(t);if(!e)return;const{row:s,c:i,qty:n}=e,{productId:r,sku:p,lineRef:h}=w.product;w.swapping=!0,I(w.run.state),t.classList.add("is-busy"),t.innerHTML=D(u,q.swapping);const m=()=>{w&&(w.swapping=!1,I(w.run.state))};try{const{reload:e}=await $({...Q(i),line_ref:h||""},n,"cart");a(r,"added",{alternative:i.item,qty:Math.min(n,9999),swap:1});const c=await S(r,M.removeTimeoutMs);if(e)return void setTimeout(()=>window.location.reload(),700);if(c)return m(),void y();t.classList.replace("is-busy","is-done"),t.innerHTML=D(o,q.added),s.insertAdjacentHTML("beforeend",`

    ${l(q.swapPartial.replace("{orig}",p))}

    `)}catch(e){c("swap",e),t.classList.replace("is-busy","is-error"),t.innerHTML=D(d,q.failed),setTimeout(()=>{t.classList.remove("is-error"),t.innerHTML=D(d,q.swap)},2e3)}m()}(s);const i=t.target.closest(".csw-alt-add");if(!i||i.classList.contains("is-busy")||i.classList.contains("is-done"))return;const p=j(i);if(!p)return;const{c:m,qty:f}=p,{context:g,productId:v}=w.product;i.classList.add("is-busy"),i.innerHTML=h(u,q.adding);try{const{reload:t}=await $(Q(m),f,g);if(a(v,"added",{alternative:m.item,qty:Math.min(f,9999)}),i.classList.replace("is-busy","is-done"),i.innerHTML=h(o,q.added),i.title=q.added,t)return void setTimeout(()=>window.location.reload(),700)}catch(t){c("add to basket",t),i.classList.replace("is-busy","is-error"),i.innerHTML=h(r,q.failed),i.title=q.failed}setTimeout(()=>{i.classList.remove("is-done","is-error"),i.innerHTML=h(r,q.add),i.title=""},2e3)}function H(a,i){m||(m=document.createElement("div"),m.className="csw-alt-pop",m.setAttribute("role","dialog"),m.setAttribute("aria-label","Alternatives"),m.setAttribute("popover","auto"),m.addEventListener("toggle",t=>{"closed"===t.newState&&function(){if(!w||f())return;const{run:t,link:e}=w;t.pause(),t.listener=null,w=null,document.contains(e)&&e.focus({preventScroll:!0})}()}),m.addEventListener("click",O),m.addEventListener("auxclick",t=>{1===t.button&&t.target.closest(".csw-alt-cat a")&&w&&n(w.product.productId,"category")}),document.body.appendChild(m),window.addEventListener("scroll",b,{passive:!0}),window.addEventListener("resize",b));const r=function(a){let i=t.get(a.productId);return i||(i=new s(a),t.set(a.productId,i),e=e.then(()=>i.start()).catch(t=>i.fail("run",t))),i}(i);if(r.loadCategory(),w?.run===r&&f())return w.link=a,void x();w&&(w.run.pause(),w.run.listener=null,w=null,y()),w={run:r,link:a,product:i,srText:""},m.innerHTML=function(t){const e=`csw-alt-list-${l(t.productId)}`;return`
    ${l(q.title)} ${l(t.sku)}
    \n
    \n
      ${N(0,q.step1)}${N(1,q.step2)}${N(2,q.step3)}
    \n
    \n \n \n \n \n

    \n
    `}(i),r.listener=I,x(),m.showPopover(),I(r.state),r.state.finished&&r.state.stillPending&&r.retryChecks(),r.resume(),m.querySelector(".csw-alt-x").focus({preventScroll:!0})}document.addEventListener("click",t=>{const e=t.target.closest(".csw-alt-link");if(!e||!e.closest(".cartproductlines_container")&&!e.closest(".product[data-item-id]"))return;t.preventDefault();const s=function(t){if(t.closest(".cartproductlines_container")){const e=t.closest("tr.item"),s=[...e?.classList??[]].find(t=>/^item_\d+$/.test(t)),a=Number(s?.slice(5)),i=(Array.isArray(window.$mini_cart)?window.$mini_cart:[]).find(t=>Number(t.item_id)===a);return T({productId:a,catalogId:Number(i?.item_catalog_id),supplierId:Number(i?.item_supplier_id),price:A(i?.item_price||e?.querySelector(".item_line_price")?.textContent),title:String(i?.item_name??e?.querySelector("td.name a.bolder")?.textContent??"").trim(),sku:String(t.dataset.cswSku??"").trim(),qty:Math.max(1,parseInt(e?.querySelector("input.quantity")?.value||i?.qty,10)||1),lineRef:String(e?.querySelector("input.ref")?.value||i?.line_ref||"").trim(),catalogItemId:Number(i?.item_catalog_item_id||E(a)?.item_catalog_item_id)||null,context:"cart"})}const e=t.closest(".product[data-item-id]");if(!e)return null;const s=String(t.dataset.cswSku||e.dataset.sku||"").trim(),a=P(e.innerHTML).get(s);return T({productId:Number(e.dataset.itemId),catalogId:Number(a?.item_catalog_id),supplierId:Number(e.dataset.supplierId||a?.item_supplier_id),price:A(e.querySelector(".price-label[data-value]")?.dataset.value||e.dataset.nativePrice),title:String(e.dataset.itemName||a?.item_name||"").trim(),sku:s,category:L(e.querySelector(".product-category a")),context:"grid"})}(e);s&&(n(s.productId,"opened"),H(e,s))})}]])if(t)try{e()}catch(t){console.error("[csw]",e.name,t)}}else"object"==typeof module&&module.exports&&(module.exports={deliveryHTML:Y,parseProductsList:D,parseCards:P,parseTiles:O,parseSearchPage:H,buildCandidates:B,packCount:F,comparablePrice:J,sameProduct:W,rankAlternatives:U,chooseToShow:V,fullOfCloseMatches:G,stagesOf:X,cartProductFor:Q,CONFIG:M})})();