PageSourceSearch

https://www.riversol.com/cdn/shop/t/781/assets/build-routine-section.js?v=14870266401418218481778282053

js riversol.com collected 2026-09-25 20:30:08 UTC 16,763 bytes, 2 lines download raw bytes

1(function(global){"use strict";const SLOT_IDS=[1,2,3,4],productsJsonUrl=handle=>{const rootPath=typeof global.Shopify<"u"&&global.Shopify.routes?.root||"/";return`${rootPath.endsWith("/")?rootPath:`${rootPath}/`}products/${encodeURIComponent(handle)}.js`},formatMoney=cents=>typeof global.FoxTheme<"u"&&global.FoxTheme.Currency?.formatMoney==="function"?global.FoxTheme.Currency.formatMoney(cents,global.FoxTheme.settings?.moneyFormat):(Number(cents)/100).toFixed(2),variantPriceToCents=v=>{if(!v||v.price==null)return 0;const p=v.price;if(typeof p=="number")return Math.round(p);const s=String(p).trim();if(s.includes("."))return Math.round(parseFloat(s)*100);const n=parseInt(s,10);return Number.isNaN(n)?0:n},variantImageSrc=(variant,product)=>{let src="";return variant?.featured_image?.src?src=variant.featured_image.src:product?.featured_image?.src&&(src=product.featured_image.src),src?.startsWith("//")&&(src=`https:${src}`),src||""},getProductOptionName=(product,index)=>{if(!product?.options||index<0||index>=product.options.length)return"";const o=product.options[index];return typeof o=="string"?o:o&&typeof o=="object"&&o.name?String(o.name):""},formatOptionValueForDisplay=(raw,optionName,countryIso)=>{if(raw==null)return"";const val=String(raw).trim();if(!val)return"";if(optionName==="Size"&&val.includes("|")){const parts=val.split("|").map(p=>p.trim()).filter(Boolean);return parts.length?countryIso==="US"?parts[parts.length-1]:parts[0]:val}return val},formatVariantSelectOption1Label=(v,product,countryIso)=>{if(!v)return"";const firstName=getProductOptionName(product,0);let raw=v.option1!=null&&String(v.option1).trim()!==""?String(v.option1).trim():"";return!raw&&v.title&&(raw=String(v.title).trim()),formatOptionValueForDisplay(raw,firstName,countryIso)||v.public_title&&String(v.public_title).trim()||raw||`#${v.id}`},variantHasMeaningfulOptions=v=>v?[v.option1,v.option2,v.option3].some(x=>{if(x==null)return!1;const str=String(x).trim();return str!==""&&str!=="Default Title"}):!1,isUsablePanelVariantLabel=text=>{const s=text!=null?String(text).trim():"";return s!==""&&s!=="Default Title"},formatVariantPanelLabel=(v,product,countryIso)=>{if(!v)return"";const parts=[],vals=[v.option1,v.option2,v.option3];for(let i=0;i<vals.length;i++){if(vals[i]==null||String(vals[i]).trim()==="")continue;const oname=getProductOptionName(product,i),disp=formatOptionValueForDisplay(String(vals[i]).trim(),oname,countryIso);!disp||disp==="Default Title"||parts.push(disp)}const joined=parts.join(" \xB7 ").trim();let t=v.public_title&&String(v.public_title).trim()||v.title&&String(v.title).trim()||"";t==="Default Title"&&(t="");const out=(joined||t).trim();return!out||product?.variants?.length===1&&!variantHasMeaningfulOptions(v)?"":out},newRoutineBundleGroupId=()=>`routine-${Date.now()}-${Math.floor(Math.random()*1e9)}`;global.mountBuildRoutineSection=function(rawCfg){if(!global.Vue?.createApp){console.warn("[BuildRoutine] Vue not found; skipping mount.");return}const cfg=rawCfg||{},{sectionId}=cfg;if(!sectionId)return;const bridge=document.getElementById(`BuildRoutineVueBridge-${sectionId}`);if(!bridge)return;const root=document.getElementById(`BuildRoutine-${sectionId}`),drawer=document.getElementById(`BuildRoutineDrawer-${sectionId}`);if(!root||!drawer)return;const shopCountryIso=(cfg.shopCountryIso||"").trim().toUpperCase(),bundleParentVariantId=Number(cfg.bundleParentVariantId),bundleDiscountPercent=Math.min(100,Math.max(0,Number(cfg.bundleDiscountPercent)||10)),collectionTitles=cfg.collectionTitles||{},slotTitles=cfg.slotTitles||{},soldOutLabel=cfg.soldOutLabel||"Sold out",chooseOptionsPrefix=cfg.chooseOptionsPrefix||"Choose options",placeholderSummaryText=cfg.placeholderSummary||"Select product",placeholderPanelText=cfg.placeholderPanel||String(placeholderSummaryText).toUpperCase(),{createApp,reactive,ref,onMounted,onUnmounted}=global.Vue;createApp({name:"BuildRoutineSection",setup(){const selections=reactive({1:null,2:null,3:null,4:null}),currentSlot=ref(null),drawerTitle=drawer.querySelector("[data-drawer-title]"),addWrap=root.querySelector("[data-add-wrap]"),addBtn=root.querySelector("[data-add-to-cart]"),filledSlotCount=()=>SLOT_IDS.filter(s=>selections[s]).length,sumSelectedPrices=()=>SLOT_IDS.reduce((sum,s)=>sum+(selections[s]?selections[s].price:0),0),setSlotAccessibility=(s,includeOptionalSuffix)=>{const title=slotTitles[String(s)]||`Slot ${s}`;let al=`${chooseOptionsPrefix} ${title}${includeOptionalSuffix?" (Optional)":""}`;const sel=selections[s];sel&&isUsablePanelVariantLabel(sel.variantLabel)&&(al+=`, ${String(sel.variantLabel).trim()}`);const panel=root.querySelector(`.build-routine__panel[data-slot="${s}"]`);panel&&panel.setAttribute("aria-label",al);const sumBtn=root.querySelector(`.build-routine__summary-item-${s}`)?.querySelector("[data-drawer-trigger]");sumBtn&&sumBtn.setAttribute("aria-label",al)},updateOptionalHints=()=>{const n=filledSlotCount(),emptySlots=SLOT_IDS.filter(s=>!selections[s]),optionalSlot=n>=3&&emptySlots.length===1?emptySlots[0]:null;for(const s of SLOT_IDS){const show=optionalSlot===s,hintPanel=root.querySelector(`.build-routine__panel[data-slot="${s}"]`)?.querySelector("[data-optional-hint]");hintPanel&&(hintPanel.hidden=!show);const hintSum=root.querySelector(`.build-routine__summary-item-${s}`)?.querySelector("[data-optional-hint]");hintSum&&(hintSum.hidden=!show),setSlotAccessibility(s,show)}},openDrawer=slot=>{currentSlot.value=slot,drawer.querySelectorAll("[data-drawer-panel]").forEach(panel=>{panel.classList.toggle("is-active",parseInt(panel.getAttribute("data-drawer-panel"),10)===slot)}),drawerTitle&&(drawerTitle.textContent=collectionTitles[String(slot)]||`Slot ${slot}`),drawer.classList.add("is-open"),document.body.classList.add("modal-show")},closeDrawer=()=>{drawer.classList.remove("is-open"),document.body.classList.remove("modal-show"),currentSlot.value=null},updateSlotDisplay=slot=>{const s=selections[slot];if(!s)return;const panel=root.querySelector(`.build-routine__panel[data-slot="${slot}"]`),panelImg=root.querySelector(`.build-routine__panel-img-${slot}`),panelProductName=root.querySelector(`.build-routine__panel-product-name-${slot}`),panelVariant=root.querySelector(`.build-routine__panel-variant-${slot}`),summaryItem=root.querySelector(`.build-routine__summary-item-${slot}`),summaryThumb=root.querySelector(`.build-routine__summary-thumb-${slot}`),summaryTitle=root.querySelector(`.build-routine__summary-title-${slot}`),summaryPrice=root.querySelector(`.build-routine__summary-price-${slot}`);if(panel){if(panel.classList.add("has-selection"),panelImg&&s.imageSrc&&(panelImg.src=s.imageSrc,panelImg.alt=s.title,panelImg.removeAttribute("hidden")),panelProductName&&(panelProductName.textContent=s.title),panelVariant){const vl=s.variantLabel&&String(s.variantLabel).trim()||"";isUsablePanelVariantLabel(vl)?(panelVariant.textContent=vl,panelVariant.hidden=!1):(p
1anelVariant.textContent="",panelVariant.hidden=!0)}const priceLive=panel.querySelector("[data-panel-price-live]"),priceVal=root.querySelector(`.build-routine__panel-price-value-${slot}`);priceLive&&priceVal&&(s.price>0?(priceVal.textContent=formatMoney(s.price),priceLive.hidden=!1):(priceVal.textContent="",priceLive.hidden=!0))}summaryItem&&summaryItem.classList.add("has-selection"),summaryThumb&&s.imageSrc&&(summaryThumb.src=s.imageSrc,summaryThumb.alt=s.title,summaryThumb.removeAttribute("hidden")),summaryTitle&&(summaryTitle.textContent=s.title),summaryPrice&&s.price>0&&(summaryPrice.textContent=formatMoney(s.price))},resetBundleSelections=()=>{for(const slot of SLOT_IDS){selections[slot]=null;const panel=root.querySelector(`.build-routine__panel[data-slot="${slot}"]`);panel&&panel.classList.remove("has-selection");const panelImg=root.querySelector(`.build-routine__panel-img-${slot}`);panelImg&&(panelImg.setAttribute("src",""),panelImg.alt="",panelImg.setAttribute("hidden",""));const panelProductName=root.querySelector(`.build-routine__panel-product-name-${slot}`);panelProductName&&(panelProductName.textContent=placeholderPanelText);const panelVariant=root.querySelector(`.build-routine__panel-variant-${slot}`);panelVariant&&(panelVariant.textContent="",panelVariant.hidden=!0);const priceLive=panel?.querySelector("[data-panel-price-live]"),priceVal=root.querySelector(`.build-routine__panel-price-value-${slot}`);priceLive&&(priceLive.hidden=!0),priceVal&&(priceVal.textContent="");const summaryItem=root.querySelector(`.build-routine__summary-item-${slot}`);summaryItem&&summaryItem.classList.remove("has-selection");const summaryThumb=root.querySelector(`.build-routine__summary-thumb-${slot}`);summaryThumb&&(summaryThumb.setAttribute("src",""),summaryThumb.alt="",summaryThumb.setAttribute("hidden",""));const summaryTitle=root.querySelector(`.build-routine__summary-title-${slot}`);summaryTitle&&(summaryTitle.textContent=placeholderSummaryText);const summaryPrice=root.querySelector(`.build-routine__summary-price-${slot}`);summaryPrice&&(summaryPrice.textContent="");const row=root.querySelector(`[data-variant-row="${slot}"]`),select=row?.querySelector("[data-variant-select]");select&&(select.innerHTML=""),row&&(row.hidden=!0)}recalculateTotals()},recalculateTotals=()=>{const totalOriginal=root.querySelector("[data-bundle-total-original]"),totalDiscounted=root.querySelector("[data-bundle-total-discounted]"),coreSelected=filledSlotCount()>=3;if(addWrap&&addWrap.classList.toggle("is-visible",!!coreSelected),addBtn&&(addBtn.disabled=!coreSelected),coreSelected&&totalOriginal&&totalDiscounted){const total=sumSelectedPrices(),discountFactor=1-bundleDiscountPercent/100,discounted=Math.round(total*discountFactor);totalOriginal.textContent=formatMoney(total),totalDiscounted.textContent=formatMoney(discounted)}else totalOriginal&&totalDiscounted&&(totalOriginal.textContent="",totalDiscounted.textContent="");updateOptionalHints()},applyVariantFromJson=(slot,variantId)=>{const s=selections[slot];if(!s?.productJson?.variants)return;const v=s.productJson.variants.find(x=>String(x.id)===String(variantId));if(!v)return;s.variantId=v.id,s.variantLabel=formatVariantPanelLabel(v,s.productJson,shopCountryIso),s.price=variantPriceToCents(v);const img=variantImageSrc(v,s.productJson);img&&(s.imageSrc=img),updateSlotDisplay(slot),recalculateTotals()},fetchProductVariants=slot=>{const s=selections[slot],row=root.querySelector(`[data-variant-row="${slot}"]`),select=row?.querySelector("[data-variant-select]");!s?.handle||!row||!select||(row.hidden=!0,select.innerHTML="",fetch(productsJsonUrl(s.handle)).then(res=>{if(!res.ok)throw new Error("product");return res.json()}).then(product=>{if(!(!selections[slot]||selections[slot].handle!==product.handle)){if(selections[slot].productJson=product,!product.variants||product.variants.length<=1){row.hidden=!0,product.variants?.length===1&&applyVariantFromJson(slot,product.variants[0].id);return}for(const v of product.variants){const opt=document.createElement("option");opt.value=String(v.id);const label=formatVariantSelectOption1Label(v,product,shopCountryIso);opt.textContent=v.available?label:`${label} \u2014 ${soldOutLabel}`,opt.disabled=!v.available,select.appendChild(opt)}if(select.value=String(s.variantId),select.value)applyVariantFromJson(slot,select.value);else{const firstAvail=product.variants.find(x=>x.available);firstAvail&&(select.value=String(firstAvail.id),applyVariantFromJson(slot,firstAvail.id))}row.hidden=!1}}).catch(()=>{selections[slot]?.handle===s.handle&&(row.hidden=!0)}))},setSelection=(slot,variantId,title,imageSrc,price,productHandle,variantTitle)=>{const priceNum=price?Number(price):0;let vLabel=variantTitle!=null?String(variantTitle).trim():"";vLabel==="Default Title"&&(vLabel=""),selections[slot]={variantId,title,variantLabel:vLabel,imageSrc:imageSrc||"",price:priceNum,handle:productHandle||"",productJson:null},updateSlotDisplay(slot),recalculateTotals(),fetchProductVariants(slot)},onRootClick=e=>{const trigger=e.target.closest("[data-drawer-trigger]");if(trigger){e.preventDefault();const slot=parseInt(trigger.getAttribute("data-slot"),10);slot&&openDrawer(slot)}},onRootChange=e=>{const sel=e.target.closest("[data-variant-select]");if(!sel)return;const slot=parseInt(sel.getAttribute("data-variant-select"),10);slot&&applyVariantFromJson(slot,sel.value)},onDrawerClick=e=>{if(e.target.closest("[data-drawer-close]")){e.preventDefault(),closeDrawer();return}const card=e.target.closest("[data-select-product]");card&&currentSlot.value&&(e.preventDefault(),e.stopPropagation(),setSelection(currentSlot.value,card.getAttribute("data-variant-id"),card.getAttribute("data-product-title"),card.getAttribute("data-image-src")||"",card.getAttribute("data-price")||"",card.getAttribute("data-product-handle")||"",card.getAttribute("data-variant-title")||""),closeDrawer())},onDocumentKeydown=e=>{e.key==="Escape"&&drawer.classList.contains("is-open")&&closeDrawer();const card=e.target.closest("[data-select-product]");card&&currentSlot.value&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),setSelection(currentSlot.value,card.getAttribute("data-variant-id"),card.getAttribute("data-product-title"),card.getAttribute("data-image-src")||"",card.getAttribute("data-price")||"",card.getAttribute("data-product-handle")||"",card.getAttribute("data-variant-title")||""),closeDrawer())},parseAddResponse=res=>res.text().then(bodyText=>{let data=null;try{data=bodyText?JSON.parse(bodyText):null}catch{}if(!res.ok||data?.status&&Number(data.status)>=400){let msg=data?.description||data?.message||"";throw!msg&&bodyText&&(msg=bodyText.slice(0,240)),msg||(msg="Could not add bundle to cart."),console.error("[BuildRoutine] cart/add.js failed",{status:res.status,statusText:res.statusText,responseBody:bodyText,parsed:data}),new Error(`Add to cart failed (${res.status}): ${msg}`)}return data}),afterBundleAddedToCart=()=>{if(global.FoxTheme?.settings?.cartType==="drawer"){global.document.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0,detail:{open:!0}}));return}const cartBase=global.FoxTheme?.routes?.cart_url||"/cart";fetch(`${cartBase}.js`,{headers:{Accept:"application/json"}}).then(res=>{if(!res.ok)throw new Error("cart");return res.json()}).then(cartJson=>{global.FoxTheme?.pubsub?.publish(global.FoxTheme.pubsub.PUB_SUB_EVENTS.cartUpdate,{cart:cartJson})}).catch(()=>{})}
1,bundleComponentProperties=(slot,bundleGroupId,bundleParentVariantGid)=>({_bundle_parent_variant_id:bundleParentVariantGid,_bundle_group_id:bundleGroupId,_bundle_kind:"routine",_bundle_role:"component",_bundle_slot:String(slot)}),onAddClick=()=>{const slotsToAdd=SLOT_IDS.filter(s=>selections[s]);if(slotsToAdd.length<3)return;if(!bundleParentVariantId||Number.isNaN(bundleParentVariantId)){global.alert("Bundle parent variant is not configured.");return}if(!addBtn)return;addBtn.disabled=!0,addBtn.classList.add("btn--loading"),addBtn.setAttribute("aria-busy","true");const bundleParentVariantGid=`gid://shopify/ProductVariant/${bundleParentVariantId}`,addUrl=global.Shopify?.routes?.root!=null?`${global.Shopify.routes.root}cart/add.js`:"/cart/add.js",postAdd=bodyPayload=>fetch(addUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(bodyPayload)}).then(parseAddResponse),bundleGroupId=newRoutineBundleGroupId(),payload={items:slotsToAdd.map(slot=>({id:Number(selections[slot].variantId),quantity:1,properties:bundleComponentProperties(slot,bundleGroupId,bundleParentVariantGid)}))};postAdd(payload).then(()=>{addBtn.classList.remove("btn--loading"),addBtn.removeAttribute("aria-busy"),addBtn.disabled=!1,resetBundleSelections(),afterBundleAddedToCart()}).catch(err=>{console.error("[BuildRoutine] add failed",{message:err?.message??err,parentVariantId:bundleParent
1VariantId,selectedVariants:{slot1:selections[1]?.variantId,slot2:selections[2]?.variantId,slot3:selections[3]?.variantId,slot4:selections[4]?.variantId}}),err?.message&&global.alert(err.message),addBtn.classList.remove("btn--loading"),addBtn.removeAttribute("aria-busy"),addBtn.disabled=!1})};return onMounted(()=>{root.addEventListener("click",onRootClick),root.addEventListener("change",onRootChange),drawer.addEventListener("click",onDrawerClick),global.document.addEventListener("keydown",onDocumentKeydown),addBtn&&addBtn.addEventListener("click",onAddClick),recalculateTotals()}),onUnmounted(()=>{root.removeEventListener("click",onRootClick),root.removeEventListener("change",onRootChange),drawer.removeEventListener("click",onDrawerClick),global.document.removeEventListener("keydown",onDocumentKeydown),addBtn&&addBtn.removeEventListener("click",onAddClick)}),()=>null}}).mount(bridge)}})(typeof window<"u"?window:this);
2//# sourceMappingURL=/cdn/shop/t/781/assets/build-routine-section.js.map?v=14870266401418218481778282053

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.