https://www.raphandremy.com/cdn/shop/t/166/assets/website-custom.js?v=172454054816646150571788509372
1function galleryNav(dir){const thumbs=Array.from(document.querySelectorAll("#gallery-thumbs .g-thumb"));if(!thumbs.length)return;const cur=thumbs.findIndex(t=>t.classList.contains("active")),next=Math.max(0,Math.min(thumbs.length-1,(cur===-1?0:cur)+dir)),thumb=thumbs[next];if(!thumb)return;const url=thumb.querySelector("img")?.src.replace(/&width=\d+/,"&width=900").replace(/\?width=\d+/,"?width=900")||"";selThumb(thumb,url),thumb.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"}),document.getElementById("gallery-prev")?.classList.toggle("hidden",next===0),document.getElementById("gallery-next")?.classList.toggle("hidden",next===thumbs.length-1)}function initGalleryArrows(){document.querySelectorAll("#gallery-thumbs .g-thumb").length<=1?(document.getElementById("gallery-prev")?.classList.add("hidden"),document.getElementById("gallery-next")?.classList.add("hidden")):document.getElementById("gallery-prev")?.classList.add("hidden")}function updateRewardsPoints(){price=document.getElementById("product-price-current")?.dataset.price||0,console.log("Current price:",price);const el=document.getElementById("rewards-points");el&&(el.textContent=Math.round(price*2/100))}const COLOURS=[{name:"Grey",hex:"#A8A5A1",bg:"#EDECEB",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_Grey.jpg?v=1740128403"},{name:"White",hex:"#ECEAE5",bg:"#F5F4F2",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_White.jpg?v=1740128403"},{name:"Beige",hex:"#C8B8A0",bg:"#F2EDE5",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_Beige.jpg?v=1740128403"},{name:"Dusty Pink",hex:"#DCA8A8",bg:"#F7EEEE",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_Dusty_Pink.jpg?v=1740128403"},{name:"Mauve",hex:"#B8909C",bg:"#F0E8EC",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie.Mauve.jpg?v=1740128403"},{name:"Pistachio Green",hex:"#9CB894",bg:"#EDF3EB",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_Pistashio.jpg?v=1740128403"},{name:"Army Green",hex:"#6B7C5A",bg:"#E8EDE3",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_Army_Green.jpg?v=1740128403"},{name:"Sky Blue",hex:"#88B4D0",bg:"#E8F2F8",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_blue.jpg?v=1740128403"},{name:"Agean Teal",hex:"#4A8C9C",bg:"#E3F0F3",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_Agean_Teal.jpg?v=1740128403"},{name:"Navy Blue",hex:"#2C3E6B",bg:"#E3E8F0",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Premium_Bamboo_Onesie_Navy.jpg?v=1740127651"}],SIZES=["0\u20133M","3\u20136M","6\u201312M","12\u201318M","18\u201324M"],VARIANT_OOS={"0\u20133M":new Set(["Grey","Beige","Dusty Pink","Mauve","Pistachio Green","Army Green","Sky Blue","Agean Teal","Navy Blue"]),"3\u20136M":new Set(["Grey","White","Beige","Dusty Pink","Mauve","Pistachio Green","Army Green","Sky Blue","Agean Teal","Navy Blue"]),"6\u201312M":new Set(["Grey","White","Beige","Dusty Pink","Pistachio Green","Army Green","Sky Blue","Agean Teal","Navy Blue"]),"12\u201318M":new Set(["Grey","White","Beige","Pistachio Green","Army Green","Sky Blue","Agean Teal","Navy Blue"]),"18\u201324M":new Set(["Grey","Beige","Mauve","Pistachio Green","Navy Blue"])};
1function isVariantOOS(size,colourName){return VARIANT_OOS[size]?.has(colourName)??!1}function isSizeFullyOOS(size){return VARIANT_OOS[size]?.size===COLOURS.length}function isColourFullyOOS(colourName){return SIZES.every(size=>isVariantOOS(size,colourName))}function sizeInStockCount(size){return COLOURS.length-(VARIANT_OOS[size]?.size??0)}const LOW_STOCK=new Set([]);let activeColour=0,activeSize=null,activeOOS=!1,bundleOpen=!1,bundleQty=1;document.addEventListener("DOMContentLoaded",()=>{updateRewardsPoints(),buildThumbs(),initGalleryArrows(),buildRecommendations(),setPersonaliseCTALink()});function buildStars(rating){const container=document.getElementById("stars-display");if(!container)return;const full=Math.floor(rating),partial=rating-full,empty=5-full-(partial>0?1:0);let html="";const gold="#555",muted="#ccc";for(let i=0;i<full;i++)html+=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${gold}" xmlns="http://www.w3.org/2000/svg"> 2 <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/> 3 </svg>`;if(partial>0){const pct=Math.round(partial*100);html+=`<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 4 <defs><linearGradient id="pg"><stop offset="${pct}%" stop-color="${gold}"/><stop offset="${pct}%" stop-color="${muted}"/></linearGradient></defs> 5 <path fill="url(#pg)" d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/> 6 </svg>`}for(let i=0;i<empty;i++)html+=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${muted}" xmlns="http://www.w3.org/2000/svg"> 7 <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/> 8 </svg>`;container.innerHTML=html}function buildSwatches(){document.getElementById("swatches").innerHTML=COLOURS.map((c,i)=>{const fullyOOS=isColourFullyOOS(c.name);return`<div class="swatch ${i===0?"active":""} ${fullyOOS?"swatch--oos":""}" 9 style="background:${c.hex};" title="${c.name}${fullyOOS?" (Sold Out)":""}" 10 onclick="setColour(${i})"></div>`}).join("")}function setColour(i){activeColour=i,document.querySelectorAll("#swatches .swatch").forEach((el,j)=>el.classList.toggle("active",j===i)),applyColour(),activeSize&&updateVariantState(),bundleOpen&&bundleQty>1&&void 0,mcSetColour(i)}function renderBundleItems(){}function applyColour(){const c=COLOURS[activeColour];document.getElementById("colour-name").textContent=c.name,document.getElementById("s-colour").textContent=c.name;const mainImg=document.getElementById("gallery-main-img");mainImg&&(mainImg.src=c.img+"&width=900",mainImg.alt="Premium Bamboo Classic Baby Onesie in "+c.name);const ctImg=document.getElementById("colour-thumb-img");ctImg&&(ctImg.src=c.img+"&width=200"),document.getElementById("s-thumb").style.background=c.bg;const sti=document.getElementById("s-thumb-img");sti&&(sti.src=c.img+"&width=120"),syncCTSThumbs(),document.getElementById("size-btns").children.length&&updateSizeBadges(),document.getElementById("size-btns").children.length&&updateSizeBadges()}function buildSizes(){document.getElementById("size-btns").innerHTML=SIZES.map(s=>{const key=s.replace("\u2013","-");return`<div class="sz-wrap" id="sz-wrap-${key}"> 11 <span class="oos-badge" id="oos-badge-${key}" style="display:none;">OOS</span> 12 <button class="sz" id="sz-btn-${key}" onclick="setSize('${s}', this)">${s}</button> 13 </div>`}).join(""),updateSizeBadges()}function updateSizeBadges(){const colourName=COLOURS[activeColour].name;SIZES.forEach(s=>{const key=s.replace("\u2013","-"),badge=document.getElementById("oos-badge-"+key),btn=document.getElementById("sz-btn-"+key);if(!badge||!btn)return;const oos=isVariantOOS(s,colourName);badge.style.display=oos?"block":"none",btn.classList.toggle("oos",oos)})}function setSize(s,btn){activeSize=s,document.querySelectorAll("#size-btns .sz").forEach(el=>el.classList.remove("active")),btn.classList.add("active"),document.getElementById("size-name").textContent=s,document.getElementById("size-name").style.color="var(--ink)",document.getElementById("size-error").classList.remove("show"),document.getElementById("s-size").textContent=`Size: ${s}`,updateVariantState()}function updateVariantState(){if(!activeSize)return;const colourName=COLOURS[activeColour].name;activeOOS=isVariantOOS(activeSize,colourName);const atcBtn=document.getElementById("atc-btn"),stickyBtn=document.getElementById("sticky-atc-btn"),warning=document.getElementById("oos-warning");activeOOS?(atcBtn.textContent="Notify Me When Available",stickyBtn.textContent="Notify Me When Available",warning.classList.remove("show")):(atcBtn.textContent="Add to cart",stickyBtn.textContent="Add to cart",sizeInStockCount(activeSize)<=2?(document.getElementById("oos-warning-text").textContent="Only a few pieces remaining.",warning.classList.add("show")):warning.classList.remove("show"))}function buildThumbs(){const imageElements=document.querySelectorAll("#product-gallery-images-data .gallery-images-data"),THUMB_URLS=Array.from(imageElements).map(element=>element.dataset.image);document.getElementById("gallery-thumbs").innerHTML=THUMB_URLS.map((url,i)=>`<div class="g-thumb ${i===0?"active":""}" onclick="selThumb(this,'${url}')" style=""> 14 <img src="${url}" alt="Product detail" style="width:100%;height:100%;object-fit:cover;border-radius:var(--r);"> 15 </div>`).join("");const mainImg=document.getElementById("gallery-main-img"),firstThumb=document.querySelector(".gallery-thumbs .g-thumb");mainImg&&firstThumb&&(firstThumb.querySelector("img").src=mainImg.src+"&width=300")}function selThumb(el,imgUrl){if(document.querySelectorAll(".g-thumb").forEach(t=>t.classList.remove("active")),el.classList.add("active"),imgUrl){const mainImg=document.getElementById("gallery-main-img");mainImg.src=imgUrl}}
15function handleBundleATC(){const btn=document.getElementById("btn-bundle-atc"),qty=bundleQty,label=qty===1?"1 onesie":`${qty} onesies`;btn.textContent=`${label} added to cart`,btn.classList.add("added"),setTimeout(()=>{btn.textContent="Add Items to Cart",btn.classList.remove("added")},2400)}function handleCTSATC(){const btn=document.getElementById("btn-cts-atc"),mainColour=COLOURS[activeColour].name;addToCart("Classic Baby Onesie",mainColour,activeSize||"0\u20133M",34.9,(COLOURS.find(c=>c.name===mainColour)||{}).img);const CTS_NAMES={1:"Premium Bamboo Bandana Bib",2:"Baby Beanie",3:"Velcro Mittens",4:"Hooded Baby Towel",5:"Premium Bamboo Sleeping Bag",6:"Premium Bamboo Swaddle",7:"Premium Bamboo Baby Leggings"},CTS_PRICES_MAP={1:19.9,2:29.9,3:29.9,4:39.9,5:59.9,6:29.9,7:24.9},CTS_IMGS={1:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/230512326597_0070_01_RM_1600x1600_4ac1e3c6-23f4-45ca-b72d-759eb2915dee.jpg?v=1687776837&width=120",2:"https://cdn.shopify.com/s/files/1/0078/0940/0883/products/191125222110_0001_01_CA_2048x2048_74eb4949-09d5-4f09-ba01-589ea3fc42d6.jpg?v=1668360823&width=120",3:"https://cdn.shopify.com/s/files/1/0078/0940/0883/products/191125222110_0012_01_CA_2048x2048_83e1e7ae-beb8-45dc-ac39-cc4bab9272da.jpg?v=1709710292&width=120",4:"https://www.raphandremy.com/cdn/shop/products/Personalised_RAPH_REMY_Hooded_Baby_Towel_1.jpg?v=1679469936&width=120",5:"https://www.raphandremy.com/cdn/shop/files/Sleeping-Bag-Front_Army-Green.webp?v=1773202734&width=120",6:"https://www.raphandremy.com/cdn/shop/products/Personalised_swaddle.jpg?v=1674724522&width=120",7:"https://www.raphandremy.com/cdn/shop/files/RAPH_REMY_Premium_Bamboo_Baby_Leggings_Grey.jpg?v=1740128403&width=120"};Object.entries(ctsState).forEach(([k,checked])=>{if(!checked)return;const idx=parseInt(k),colour=COLOURS[ctsItemColours[idx]??activeColour].name,pickerEl=document.getElementById("cts-picker-"+idx),activeSzEl=pickerEl?pickerEl.querySelector(".cts-sz.active"):null,itemSize=activeSzEl?activeSzEl.textContent:"One Size";addToCart(CTS_NAMES[idx],colour,itemSize,CTS_PRICES_MAP[idx],CTS_IMGS[idx])});const count=Object.values(ctsState).filter(Boolean).length+1;btn.textContent=`${count} item${count>1?"s":""} added`,btn.classList.add("added"),setTimeout(()=>{btn.textContent="Add Items to Cart",btn.classList.remove("added")},2e3)}const CTS_PRICES={1:18.9,2:22.9,3:19.9};let ctsState={1:!1,2:!1,3:!1},ctsItemColours={1:0,2:0,3:0};function initCTS(){[1,2,3,4,5,6,7].forEach(idx=>{const el=document.getElementById(`cts-colours-${idx}`);el.innerHTML=COLOURS.map((c,i)=>`<div class="cts-swatch ${i===0?"active":""}" style="background:${c.hex};" title="${c.name}" 16 onclick="setCTSColour(${idx},${i},this)"></div>`).join("")}),syncCTSThumbs()}function syncCTSThumbs(){const img0=document.getElementById("cts-img-0");img0&&(img0.src=COLOURS[activeColour].img+"&width=120")}function toggleCTS(idx){ctsState[idx]=!ctsState[idx];const cb=document.getElementById(`cts-cb-${idx}`),pkl=document.getElementById(`cts-picker-${idx}`);cb.classList.toggle("checked",ctsState[idx]),pkl.classList.toggle("open",ctsState[idx]),ctsState[idx]&&(ctsItemColours[idx]=activeColour,document.querySelectorAll(`#cts-colours-${idx} .cts-swatch`).forEach((el,j)=>el.classList.toggle("active",j===activeColour))),updateCTSTotal()}function setCTSColour(idx,colIdx,el){ctsItemColours[idx]=colIdx,el.closest(".cts-colour-row").querySelectorAll(".cts-swatch").forEach((b,j)=>b.classList.toggle("active",j===colIdx))}function updateCTSTotal(){const addOnCount=Object.values(ctsState).filter(Boolean).length,totalCount=1+addOnCount,subtotal=34.9+Object.entries(ctsState).reduce((s,[k,v])=>s+(v&&{1:19.9,2:29.9,3:29.9,4:39.9,5:59.9,6:29.9,7:24.9}[+k]||0),0);let discPct=0;totalCount>=5?discPct=.2:totalCount>=3&&(discPct=.15);const discAmount=subtotal*discPct,total=subtotal-discAmount,saveEl=document.getElementById("cts-save-label"),saveBar=document.getElementById("cts-save-bar"),totalEl=document.getElementById("cts-total"),origEl=document.getElementById("cts-total-orig"),priceEl=document.getElementById("cts-total-price");if(totalEl.classList.toggle("show",addOnCount>0),discPct>0)origEl&&(origEl.textContent=`SGD $${subtotal.toFixed(2)}`,origEl.classList.add("show")),priceEl.textContent=`SGD $${total.toFixed(2)}`,saveEl.textContent=`You save SGD $${discAmount.toFixed(2)} (${Math.round(discPct*100)}% off)`,saveEl.classList.add("show"),saveBar.classList.add("show");else if(addOnCount>0){origEl&&(origEl.textContent="",origEl.classList.remove("show")),priceEl.textContent=`SGD $${subtotal.toFixed(2)}`;const piecesNeeded=totalCount<3?3-totalCount:5-totalCount,nextDisc=totalCount<3?"15%":"20%";saveEl.textContent=`Add ${piecesNeeded} more piece${piecesNeeded>1?"s":""} to unlock ${nextDisc} off`,saveEl.classList.add("show"),saveBar.classList.add("show")}else origEl&&(origEl.textContent="",origEl.classList.remove("show")),priceEl.textContent=`SGD $${subtotal.toFixed(2)}`,saveEl.classList.remove("show"),saveBar.classList.remove("show")}function switchTab(id,btn){document.querySelectorAll(".tab-btn").forEach(b=>b.classList.remove("active")),document.querySelectorAll(".tab-pane").forEach(p=>p.classList.remove("active")),btn.classList.add("active"),document.getElementById("tab-"+id).classList.add("active")}function toggleAcc(id){document.getElementById(id).classList.toggle("open")}const YMAL=[{name:"Premium Bamboo Long Sleeve Baby Onesie",price:39.9,badge:"Bestseller",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/230512326597_0053_01_RM_1600x1600_07432c31-7885-425c-afb8-c3fb89465441.jpg?v=1769761692",url:"https://www.raphandremy.com/products/premium-bamboo-long-sleeve-baby-onesie"},{name:"Premium Bamboo Baby Onesie Dress",price:39.9,badge:null,img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/230512326597_0001_01_RM_1600x1600_5261d6ad-4968-4641-adf3-d12fbe1b2399.jpg?v=1769761888",url:"https://www.raphandremy.com/products/premium-bamboo-baby-onesie-dress"},{name:"Premium Bamboo Sleeveless Baby Onesie",price:31.9,badge:"New Colours",img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/RAPH_REMY_Sleeveless_Onesie_Sky_Blue.jpg?v=1750063683",url:"https://www.raphandremy.com/products/premium-bamboo-sleeveless-baby-onesie"},{name:"Premium Bamboo Baby Leggings",price:34.9,badge:null,img:"https://cdn.shopify.com/s/files/1/0078/0940/0883/files/230512326597_0044_01_RM_1600x1600_8e2a402b-fb2d-4ae6-ad94-c9dae7e59a8b.jpg?v=1769761669",url:"https://www.raphandremy.com/products/premium-bamboo-baby-leggings"}];async function apiFetch(url,options={}){try{const defaultOptions={headers:{"Content-Type":"application/json",...options.headers},...options},response=await fetch(url,defaultOptions);if(!response.ok)throw new Error(`HTTP Error: ${response.status} - ${response.statusText}`);return await response.json()}catch(error){throw console.error(`[apiFetch Error] fetching ${url}:`,error.message),error}}function productCardItemColorPicker(productId,ci,el){el.closest(".ymal-card-swatches").querySelectorAll(".ymal-card-swatch").forEach((s,j)=>s.classList.toggle("active",j===ci));const cardImg=document.querySelector(`#product-card-item-${productId} .ymal-img img`);cardImg&&(cardImg.src=el?.getAttribute("data-image")+"&width=600");const swatchUrl=el.getAttribute("data-url");swatchUrl&&document.querySelectorAll(`#product-card-item-${productId} .ymal-card-link`).forEach(a=>a.href=swatchUrl);const variantSizes=JSON.parse(el.getAttribute("data-size")||"[]"),sizeSelect=document.getElementById(`ymal-size-${productId}`);sizeSelect&&(sizeSelect.innerHTML='<option value="" disabled selected>Select a size</option>'+variantSizes.map(vs=>`<option value="${vs.variantId}" ${vs.isAvailable?"":"disabled"}>${vs.size}</option>`).join(""));const atcBtn=document.getElementById(`ymal-add-${productId}`);atcBtn&&(atcBtn.disabled=!0,atcBtn.classList.remove("ready"))}function productCardItemSizePicker(productId,el){const atcBtn=document.getElementById(`ymal-add-${productId}`),productSelect=document.getElementById(`product-select-${productId}`);atcBtn&&productSelect&&(atcBtn.disabled=!1,atcBtn.classList.toggle("ready",!!el.value),productSelect.value=el.value)}async function buildRecommendations(){const grid=document.getElementById("ymal-grid");if(!grid)return;const url=grid.getAttribute("data-url");if(!url)return;const hide=()=>document.querySelectorAll(".product-details-section-recommendations").forEach(el=>el.style.display="none");let html;try{const res=await fetch(url);if(!res.ok){hide();return}html=await res.text()}catch{hide();return}const next=new DOMParser().parseFromString(html,"text/html").getElementById("ymal-grid");if(!next||!next.children.length){hide();return}grid.innerHTML=next.innerHTML}const ymalSel={};function ymalPickColour(pi,ci,el){el.closest(".ymal-card-swatches").querySelectorAll(".ymal-card-swatch").forEach((s,j)=>s.classList.toggle("active",j===ci)),ymalSel[pi]||(ymalSel[pi]={}),ymalSel[pi].colour=ci}function ymalPickSize(pi,sel){ymalSel[pi]||(ymalSel[pi]={}),ymalSel[pi].size=sel.value,document.getElementById(`ymal-add-${pi}`).classList.toggle("ready",!!sel.value)}function ymalConfirmAdd(pi){const btn=document.getElementById(`ymal-add-${pi}`),szSel=document.getElementById(`ymal-size-${pi}`);
16if(!szSel||!szSel.value){szSel.style.borderColor="var(--red)",szSel.style.boxShadow="0 0 0 2px rgba(232,64,64,.15)",szSel.focus(),setTimeout(()=>{szSel.style.borderColor="",szSel.style.boxShadow=""},1800);return}const p=YMAL[pi],size=szSel.value,colourIdx=ymalSel[pi]?.colour??0,colour=COLOURS[colourIdx].name;addToCart(p.name,colour,size,p.price,p.img),btn.textContent="Added to Cart",btn.classList.add("added"),setTimeout(()=>{szSel&&(szSel.value=""),btn.textContent="Add to Cart",btn.classList.remove("added","ready"),delete ymalSel[pi]},2e3)}function initSticky(){const hero=document.getElementById("product-top"),bar=document.getElementById("sticky-bar");if(window.matchMedia("(max-width: 768px)").matches||window.matchMedia("(hover: none)").matches){bar.classList.add("visible");return}new IntersectionObserver(([e])=>{bar.classList.toggle("visible",!e.isIntersecting)},{rootMargin:"-60px 0px 0px 0px",threshold:0}).observe(hero)}document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".rev-filter-btn").forEach(btn=>{btn.addEventListener("click",()=>{btn.closest(".rev-filters").querySelectorAll(".rev-filter-btn").forEach(b=>b.classList.remove("active")),btn.classList.add("active")})})});function rrScrollToId(id){const el=document.getElementById(id);if(!el)return;const top=el.getBoundingClientRect().top+window.pageYOffset-window.rrHeaderOffset();window.scrollTo({top,behavior:"smooth"})}function pairSelectSz(sel,cardId){const btn=document.getElementById(cardId+"-btn");sel.value?btn.classList.add("ready"):btn.classList.remove("ready")}function pairAdd(cardId){const btn=document.getElementById(cardId+"-btn");if(!btn.classList.contains("ready"))return;const sel=btn.closest(".pair-card").querySelector(".pair-size-select");btn.textContent="Added",btn.classList.add("added"),btn.classList.remove("ready"),setTimeout(()=>{btn.textContent="Add",btn.classList.remove("added"),sel.value=""},1800)}(function(){let touchStartX=0,touchStartY=0;function getGalleryUrls(){return Array.from(document.querySelectorAll("#gallery-thumbs .g-thumb")).map(t=>{const img=t.querySelector("img");return img?img.src.replace(/&width=\d+/,"&width=900"):null}).filter(Boolean)}function getActiveIndex(){return Array.from(document.querySelectorAll("#gallery-thumbs .g-thumb")).findIndex(t=>t.classList.contains("active"))}function goToIndex(idx){const thumbs=Array.from(document.querySelectorAll("#gallery-thumbs .g-thumb"));if(!thumbs.length)return;const clamped=Math.max(0,Math.min(idx,thumbs.length-1)),thumb=thumbs[clamped];if(thumb){const url=thumb.querySelector("img")?.src.replace(/&width=\d+/,"&width=900")||"";selThumb(thumb,url),thumb.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})}}document.addEventListener("DOMContentLoaded",()=>{const el=document.getElementById("gallery-main");el&&(el.addEventListener("touchstart",e=>{touchStartX=e.touches[0].clientX,touchStartY=e.touches[0].clientY},{passive:!0}),el.addEventListener("touchend",e=>{const dx=e.changedTouches[0].clientX-touchStartX,dy=e.changedTouches[0].clientY-touchStartY;if(Math.abs(dx)<30||Math.abs(dy)>Math.abs(dx)*.8)return;const cur=getActiveIndex();goToIndex(dx<0?cur+1:cur-1)},{passive:!0}))}),window.galleryGoTo=goToIndex})();const FREE_SHIP_THRESHOLD=99,CURRENCY="SGD $";let cartItems=[],cartUpsells=[{id:"u1",name:"Classic Onesie \xB7 Beige",colour:"Beige",colourHex:"#C8B8A0",price:34.9,label:""},{id:"u2",name:"Classic Onesie \xB7 Dusty Pink",colour:"Dusty Pink",colourHex:"#DCA8A8",price:34.9,label:""},{id:"u3",name:"Classic Onesie \xB7 Agean Teal",colour:"Agean Teal",colourHex:"#4A8C9C",price:34.9,label:""},{id:"u4",name:"Classic Onesie \xB7 Army Green",colour:"Army Green",colourHex:"#6B7C5A",price:34.9,label:""}],upsellAdded=new Set;const COLOUR_HEX=Object.fromEntries(COLOURS.map(c=>[c.name,c.hex]));function openCart(){document.getElementById("cart-drawer").classList.add("open"),document.getElementById("cart-overlay").classList.add("open"),document.body.style.overflow="hidden",renderCart()}function closeCart(){document.getElementById("cart-drawer").classList.remove("open"),document.getElementById("cart-overlay").classList.remove("open"),document.body.style.overflow=""}document.addEventListener("keydown",e=>{e.key==="Escape"&&closeCart()}),(function(){const drawer=document.getElementById("cart-drawer");if(!drawer)return;let startY=0,isDragging=!1;drawer.addEventListener("touchstart",e=>{const body=document.getElementById("cart-body");body&&body.scrollTop>0||(startY=e.touches[0].clientY,isDragging=!0,drawer.style.transition="none")},{passive:!0}),drawer.addEventListener("touchmove",e=>{if(!isDragging)return;const delta=e.touches[0].clientY-startY;delta>0&&(drawer.style.transform="translateY("+delta+"px)")},{passive:!0}),drawer.addEventListener("touchend",e=>{if(!isDragging)return;isDragging=!1,drawer.style.transition="",e.changedTouches[0].clientY-startY>80?closeCart():drawer.style.transform=""},{passive:!0})})();function addToCart(name,colour,size,price2,img){const hex=COLOUR_HEX[colour]||"#B0ACA8",existing=cartItems.find(i=>i.name===name&&i.colour===colour&&i.size===size);if(existing)existing.qty++;else{const colourImg=(COLOURS.find(c=>c.name===colour)||{}).img||null;cartItems.push({id:Date.now()+Math.random(),name,colour,colourHex:hex,size,price:price2,img:img||colourImg,qty:1})}updateBadge(),renderCart(),openCart()}function changeQty(id,delta){const item=cartItems.find(i=>i.id===id);item&&(item.qty+=delta,item.qty<=0&&(cartItems=cartItems.filter(i=>i.id!==id)),updateBadge(),renderCart())}function removeItem(id){cartItems=cartItems.filter(i=>i.id!==id),updateBadge(),renderCart()}function upsellAdd(uid,btnEl){if(upsellAdded.has(uid))return;upsellAdded.add(uid);
16const u=cartUpsells.find(x=>x.id===uid);u&&addToCart(u.name,u.colour,"3\u20136M",u.price),btnEl.textContent="Added",btnEl.classList.add("added")}function getSubtotal(){return cartItems.reduce((sum,i)=>sum+i.price*i.qty,0)}function getTotalQty(){return cartItems.reduce((sum,i)=>sum+i.qty,0)}function updateBadge(){const qty=getTotalQty(),badge=document.getElementById("cart-badge");badge&&(qty>0?(badge.textContent=qty>9?"9+":qty,badge.style.display="flex"):badge.style.display="none")}function renderShipBar(){const textEl=document.getElementById("cart-ship-text"),fillEl=document.getElementById("cart-ship-fill");if(!textEl||!fillEl)return;const qty=getTotalQty();if(qty===0){fillEl.style.width="0%",fillEl.style.background="",textEl.className="cart-ship-text",textEl.innerHTML="Add <strong>3 items</strong> to unlock 15% off";return}if(qty>=5)fillEl.style.width="100%",fillEl.style.background="var(--green)",textEl.className="cart-ship-text done",textEl.innerHTML="<strong>20% off</strong> applied \u2713";else if(qty>=3){const need=5-qty,pct=Math.round(qty/5*100);fillEl.style.width=pct+"%",fillEl.style.background="var(--green)",textEl.className="cart-ship-text done",textEl.innerHTML=`<strong>15% off applied</strong> \u2014 add ${need} more item${need===1?"":"s"} for 20%`}else{const need=3-qty,pct=Math.round(qty/3*100);fillEl.style.width=pct+"%",fillEl.style.background="",textEl.className="cart-ship-text",textEl.innerHTML=`Add <strong>${need} more item${need===1?"":"s"}</strong> to unlock 15% off`}}function renderItemHTML(item){const total=(item.price*item.qty).toFixed(2),bg=item.colourHex||"#ede9e3",thumbSrc=item.img?item.img.includes("?")?item.img+"&width=160":item.img+"?width=160":"";return` 17 <div class="cart-item" id="ci-${item.id}"> 18 <div class="cart-item-img" style="background:${bg}22;"> 19 ${thumbSrc?`<img src="${thumbSrc}" alt="${item.name}" style="width:100%;height:100%;object-fit:cover;display:block;">`:`<div style="width:22px;height:22px;border-radius:50%;background:${bg};opacity:.5;"></div>`} 20 </div> 21 <div class="cart-item-meta"> 22 <div class="cart-item-name">${item.name}</div> 23 <div class="cart-item-variant">${item.colour} \xB7 ${item.size}</div> 24 <div class="cart-item-actions"> 25 <div class="cart-qty"> 26 <button class="cart-qty-btn" onclick="changeQty(${item.id}, -1)" aria-label="Decrease quantity">\u2212</button> 27 <span class="cart-qty-num">${item.qty}</span> 28 <button class="cart-qty-btn" onclick="changeQty(${item.id}, 1)" aria-label="Increase quantity">+</button> 29 </div> 30 <button class="cart-item-remove" onclick="removeItem(${item.id})">Remove</button> 31 </div> 32 </div> 33 <div class="cart-item-price">${CURRENCY}${total}</div> 34 </div> 35 `}function renderUpsells(){const nudge=document.getElementById("cart-upsell");if(!nudge)return;const qty=getTotalQty(),titleEl=document.getElementById("cart-bundle-title"),subEl=document.getElementById("cart-bundle-sub");if(qty===0){nudge.classList.remove("show");return}if(nudge.style.display="flex",qty>=6)titleEl&&(titleEl.textContent="30% bundle discount applied"),subEl&&(subEl.textContent="Your 6+ item discount is active at checkout."),nudge.style.background="var(--green-light)",nudge.style.borderColor="#c8e6d2",titleEl&&(titleEl.style.color="var(--green)");else if(qty>=4)titleEl&&(titleEl.textContent="20% bundle discount applied"),subEl&&(subEl.textContent=`Add ${6-qty} more item${6-qty===1?"":"s"} to unlock 30% off.`),nudge.style.background="var(--green-light)",nudge.style.borderColor="#c8e6d2",titleEl&&(titleEl.style.color="var(--green)");else{const need=4-qty;titleEl&&(titleEl.textContent=`Add ${need} more item${need===1?"":"s"} to unlock 20% off`),subEl&&(subEl.textContent="4 items = 20% off \xB7 6+ items = 30% off"),nudge.style.background="var(--off-white)",nudge.style.borderColor="",titleEl&&(titleEl.style.color="var(--ink)")}}function renderCart(){const isEmpty=cartItems.length===0,emptyEl=document.getElementById("cart-empty"),itemsEl=document.getElementById("cart-items"),upsellEl=document.getElementById("cart-upsell"),footerEl=document.getElementById("cart-footer"),countEl=document.getElementById("cart-header-count"),subEl=document.getElementById("cart-subtotal-price"),qty=getTotalQty();if(countEl&&(countEl.textContent=qty>0?`My Bag (${qty})`:"My Bag"),isEmpty){emptyEl.style.display="flex",itemsEl.style.display="none",upsellEl&&(upsellEl.style.display="none"),footerEl.style.display="none";const pkgElEmpty=document.getElementById("cart-pkg-upsell");pkgElEmpty&&(pkgElEmpty.style.display="none")}else{emptyEl.style.display="none",itemsEl.style.display="block",footerEl.style.display="block";const pkgEl=document.getElementById("cart-pkg-upsell"),pkgAlreadyInCart=cartItems.some(i=>i.name==="DIY Gift Supplies");if(pkgEl&&(pkgEl.style.display=pkgAlreadyInCart?"none":"flex"),!pkgAlreadyInCart){const pkgBtn=document.getElementById("cart-pkg-btn");pkgBtn&&(pkgBtn.textContent="Add",pkgBtn.classList.remove("added")),packagingAdded=!1}itemsEl.innerHTML=cartItems.map(renderItemHTML).join(""),renderSubtotalWithDiscount(),renderUpsells()}renderShipBar()}let packagingAdded=!1;function addPackaging(btnEl){if(packagingAdded)return;packagingAdded=!0,addToCart("DIY Gift Supplies","N/A","One Size",9.9,"https://www.raphandremy.com/cdn/shop/files/RAPH_REMY_DIY_Gift_Supplies_5a95e0c6-2cd9-4001-9d17-902589c347bf.jpg?v=1707295743"),btnEl.textContent="Added",btnEl.classList.add("added");const card=document.getElementById("cart-pkg-upsell");card&&(card.style.opacity=".5",card.style.pointerEvents="none")}
35function renderSubtotalWithDiscount(){const subEl=document.getElementById("cart-subtotal-price"),origEl=document.getElementById("cart-subtotal-orig"),saveEl=document.getElementById("cart-savings-line");if(!subEl)return;const qty=getTotalQty(),subtotal=getSubtotal();let discPct=0;if(qty>=5?discPct=.2:qty>=3&&(discPct=.15),discPct>0){const saving=subtotal*discPct,discounted=subtotal-saving;subEl.textContent=CURRENCY+discounted.toFixed(2),subEl.style.color="var(--ink)",subEl.style.fontWeight="600",origEl&&(origEl.textContent=CURRENCY+subtotal.toFixed(2),origEl.style.display="inline",origEl.style.color="var(--ink-4)",origEl.style.textDecoration="line-through"),saveEl&&(saveEl.textContent=`You save ${CURRENCY}${saving.toFixed(2)}`,saveEl.style.display="block",saveEl.style.color="var(--green)")}else if(qty>0){if(subEl.textContent=CURRENCY+subtotal.toFixed(2),subEl.style.color="",subEl.style.fontWeight="",origEl&&(origEl.textContent="",origEl.style.display="none"),saveEl){const piecesNeeded=qty<3?3-qty:5-qty,nextDisc=qty<3?"15%":"20%";piecesNeeded>0?(saveEl.textContent=`Add ${piecesNeeded} more item${piecesNeeded>1?"s":""} to unlock ${nextDisc} off`,saveEl.style.display="block",saveEl.style.color="var(--ink-3)"):saveEl.style.display="none"}}else subEl.textContent=CURRENCY+subtotal.toFixed(2),subEl.style.color="",subEl.style.fontWeight="",origEl&&(origEl.textContent="",origEl.style.display="none"),saveEl&&(saveEl.style.display="none")}function handleCheckout(){alert("Redirecting to checkout\u2026")}const _origHandleATC=handleATC;function handleATC(){if(!activeSize){document.getElementById("size-error").classList.add("show"),document.getElementById("size-btns").scrollIntoView({behavior:"smooth",block:"center"});return}if(activeOOS){const btn=document.getElementById("atc-btn");btn.textContent="We'll notify you",btn.classList.add("added"),setTimeout(()=>{btn.textContent="Notify Me When Available",btn.classList.remove("added")},2400)}else{const colour=document.getElementById("colour-name").textContent;addToCart("Classic Baby Onesie",colour,activeSize,34.9,(COLOURS.find(c=>c.name===colour)||{}).img);const btn=document.getElementById("atc-btn"),sb=document.getElementById("sticky-atc-btn");btn.textContent="Added to Cart",btn.classList.add("added"),sb.textContent="Added",sb.classList.add("added"),setTimeout(()=>{btn.textContent="Add to cart",btn.classList.remove("added"),sb.textContent="Add to cart",sb.classList.remove("added")},2e3)}}function openDrawer(){document.getElementById("mobileDrawer").classList.add("open"),document.body.style.overflow="hidden"}function closeDrawer(){document.getElementById("mobileDrawer").classList.remove("open"),document.body.style.overflow=""}document.addEventListener("keydown",e=>{e.key==="Escape"&&closeDrawer()});function setPersonaliseCTALink(){const newDynamicUrl=window.location.pathname+"-personalised",ctaButton=document.querySelector(".personalise-button");ctaButton&&(ctaButton.href=newDynamicUrl)} 36//# sourceMappingURL=/cdn/shop/t/166/assets/website-custom.js.map?v=172454054816646150571788509372
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.