PageSourceSearch

https://www.swansonvitamins.com/cdn/shop/t/578/assets/swan-chunk-useBaseProductCard-CsAWc4pg.js

js swansonvitamins.com collected 2026-10-02 03:32:22 UTC 23,139 bytes, 1 lines download raw bytes

1import{L as e,P as t,U as n,V as r,j as i}from"./swan-chunk-compat.module-BTXuq6JP.js";import{t as a}from"./swan-chunk-_virtual_sage-react-with-use-DzTYFVQE.js";var o=class{static variantSelected=`variant:selected`;static variantUpdate=`variant:update`;static cartUpdate=`cart:update`;static cartError=`cart:error`;static mediaStartedPlaying=`media:started-playing`;static quantitySelectorUpdate=`quantity-selector:update`;static megaMenuHover=`megaMenu:hover`;static zoomMediaSelected=`zoom-media:selected`;static discountUpdate=`discount:update`;static FilterUpdate=`filter:update`},s=class e extends Event{constructor(t,n,r){super(e.eventName,{bubbles:!0}),this.detail={resource:t,sourceId:n,data:{...r}}}static eventName=o.cartUpdate},c=class extends Event{constructor(e,t,n){super(o.cartUpdate,{bubbles:!0}),this.detail={resource:e,sourceId:t,data:{...n}}}},l=class extends Event{constructor(e,t){super(o.cartError,{bubbles:!0}),this.detail={sourceId:e,data:{message:t}}}},u=`https://ac.cnstrc.com`,d=`cio-dom-tracker-1.0`,f=`ConstructorioID_client_id`,p=`ConstructorioID_session_id`,m=`ConstructorioID_session`,h=`_constructorio_search_client_id`,g=`_constructorio_search_session`,_=1800*1e3,v=365*24*60*60;function y(e){if(typeof document>`u`)return null;try{let t=`${e}=`,n=document.cookie.split(`;`);for(let e of n){let n=decodeURIComponent(e).trim();if(n.startsWith(t))return n.slice(t.length)}}catch{}return null}function b(e,t,n){if(!(typeof document>`u`))try{let r=location.protocol===`https:`?`; Secure`:``;document.cookie=`${e}=${t}; Path=/; Max-Age=${n}; SameSite=Lax${r}`}catch{}}function x(e){try{return localStorage.getItem(e)}catch{return null}}function S(e,t){try{localStorage.setItem(e,t)}catch{}}function C(){let e=y(f)||x(h);return e||=`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)}),b(f,e,v),S(h,e),e}function w(e){if(!e)return null;try{let t=JSON.parse(e),n=Number(t.sessionId??t.id),r=Number(t.lastTime??t.ts);if(Number.isFinite(n)&&n>0&&Number.isFinite(r)&&r>0)return{id:n,ts:r}}catch{}return null}function ee(){let e=w(y(m));if(e)return e;let t=w(x(g));if(t)return t;let n=Number(y(p));return Number.isFinite(n)&&n>0?{id:n,ts:Date.now()}:null}function T(){let e=Date.now(),t=ee(),n;return n=!t||e-t.ts>_?{id:(t?.id||0)+1,ts:e}:{id:t.id,ts:e},b(p,String(n.id),_/1e3),b(m,JSON.stringify({sessionId:n.id,lastTime:n.ts}),v),S(g,JSON.stringify(n)),n.id}function E(e,t,n,r,i){let a=new URLSearchParams;return a.set(`key`,e),a.set(`i`,t),a.set(`s`,String(n)),a.set(`c`,d),r&&a.set(`ui`,r),i?.length&&i.forEach(e=>a.append(`us`,e)),a}function D(){try{let{host:e,pathname:t,search:n}=window.location;if(!e)return null;let r=`${e}${t}`;if(n){let e=[];new URLSearchParams(n).forEach((t,n)=>{n.startsWith(`utm_`)&&e.push(`${n}=${t}`)}),e.length&&(r+=`?${e.join(`&`)}`)}return r}catch{return null}}function O(e){return encodeURIComponent(e.replace(/\s/g,` `).trim()).replace(/[!'()*]/g,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase())}function te(e,t){Object.entries(t).forEach(([t,n])=>{Array.isArray(n)?n.forEach(n=>e.append(`filters[${t}][]`,String(n))):n!=null&&e.append(`filters[${t}][]`,String(n))})}function k(e,t){Object.entries(t).forEach(([t,n])=>{Array.isArray(n)?n.forEach(n=>e.append(`fmt_options[${t}]`,String(n))):n!=null&&e.append(`fmt_options[${t}]`,String(n))})}function ne(e){return e.replace(/[A-Z]/g,e=>`_`+e.toLowerCase())}function re(e){let{apiKey:t}=e,{userId:n=null,segments:r=[]}=e,i=C();function a(e){r=e}async function o(e,a={}){let o=E(t,i,T(),n,r),{filters:s,fmtOptions:c,itemIds:l,userSegments:d,...f}=a;Object.entries(f).forEach(([e,t])=>{t!=null&&o.set(ne(e),String(t))}),s&&typeof s==`object`&&te(o,s),c&&typeof c==`object`&&k(o,c),Array.isArray(l)&&l.forEach(e=>o.append(`item_id[]`,e)),Array.isArray(d)&&d.length&&d.forEach(e=>o.append(`us`,e));let p=`${u}${e}?${o.toString()}`,m=await fetch(p,{credentials:`omit`});if(!m.ok)throw Error(`Constructor API error ${m.status}: ${e}`);return m.json()}function s(){let e=E(t,i,T(),n,r);e.set(`_dt`,String(Date.now()));let a=D();return a&&e.set(`origin_referrer`,a),e}
1function c(e,t,n){try{let r={method:t,mode:`cors`,credentials:`omit`,keepalive:!0};t===`POST`&&n!==void 0&&(r.headers={"Content-Type":`text/plain`},r.body=typeof n==`string`?n:JSON.stringify(n)),fetch(e,r)}catch{}}return{setSegments:a,tracker:{trackAutocompleteSelect(e,t={}){if(!e)return;let n=s();t.originalQuery&&n.set(`original_query`,t.originalQuery),t.section&&n.set(`section`,t.section),t.tr&&n.set(`tr`,t.tr),t.itemId&&n.set(`item_id`,t.itemId),c(`${u}/autocomplete/${O(e)}/select?${n.toString()}`,`GET`)},trackSearchSubmit(e,t={}){if(!e)return;let n=s();t.originalQuery&&n.set(`original_query`,t.originalQuery),c(`${u}/autocomplete/${O(e)}/search?${n.toString()}`,`GET`)},trackRecommendationClick(e){if(!e.podId)return;let a=s(),o={pod_id:e.podId,key:t,i,s:T(),c:d,_dt:Date.now()};n&&(o.ui=n),r.length&&(o.us=r);let l=D();l&&(o.origin_referrer=l),e.itemId&&(o.item_id=e.itemId),e.variationId&&(o.variation_id=e.variationId),e.resultId&&(o.result_id=e.resultId),e.resultCount!==void 0&&(o.result_count=e.resultCount),e.resultPage!==void 0&&(o.result_page=e.resultPage),e.resultPositionOnPage!==void 0&&(o.result_position_on_page=e.resultPositionOnPage),e.numResultsPerPage!==void 0&&(o.num_results_per_page=e.numResultsPerPage),e.strategyId&&(o.strategy_id=e.strategyId),e.section&&(o.section=e.section),c(`${u}/v2/behavioral_action/recommendation_result_click?${a.toString()}`,`POST`,o)}},getSearchResults(e,t={}){return o(`/search/${encodeURIComponent(e)}`,t)},getBrowseResults(e,t,n={}){return o(`/browse/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n)},getBrowseGroups(e={}){return o(`/browse/groups`,e)},getRecommendations(e,t={}){return o(`/recommendations/v1/pods/${encodeURIComponent(e)}`,t)},getAutocompleteResults(e,t={}){return o(`/autocomplete/${encodeURIComponent(e)}`,t)}}}function ie(){if(typeof document>`u`)return;let e=document.querySelector(`[id^="shopify-section-template--"][id$="__main"]`);return e?.id?e.id.replace(/^shopify-section-/,``):void 0}const A=async(e,t={})=>{let n=await Promise.all(e.map(async({product:e,variant:t,qty:n=1,properties:r={}})=>{let i=t?.variantId||e.variantId;if(!i){if(!e.url)throw Error(`No Variant ID and no URL found for product: `+JSON.stringify(e));let t=await fetch(`${e.url}.json`);if(!t.ok)throw Error(`Failed to fetch product for product: `+JSON.stringify(e));let n=await t.json();n?.product?.variants?.[0]?.id&&(i=n.product.variants[0].id)}if(!i)throw Error(`No Variant ID found for product: `+JSON.stringify(e));let a=n,o=r;return(t??e).hasBOGO&&(a=n*2,o._bogo=`1`),{id:typeof i==`string`?i.replace(/^gid:\/\/shopify\/ProductVariant\//,``):i,quantity:a,properties:o}})),r=document.querySelectorAll(`cart-items-component`),i=[];r.forEach(e=>{e instanceof HTMLElement&&e.dataset.sectionId&&i.push(e.dataset.sectionId)});let a=[...i];if(t.includePageMainSection){let e=ie();e&&a.unshift(e)}let o=await fetch(Theme.routes.cart_add_url,{method:`POST`,headers:{"Content-Type":`application/json`}
1,body:JSON.stringify({items:n,sections:[...new Set(a)].join(`,`)})});if(!o.ok){console.error(`Failed to add items to cart:`,e);try{let e=await o.json();return{success:!1,error:e.message||e.description||`Failed to add items to cart`}}catch{return{success:!1,error:`Failed to add items to cart`}}}let c=await o.json();if(c.status)return document.dispatchEvent(new l(`cio-atc`,c.message)),c.message&&(c.message.includes(`Only`)&&c.message.includes(`were added`)||c.message.includes(`due to availability`))&&await ae(`cio-atc`,`constructor-add-to-cart`),{success:!1,error:c.message};{for(let t of n){let n=e.find(e=>(e.variant?.variantId||e.product.variantId)===t.id),r=n?.product,i=n?.variant,a=null;i?.sku&&i.variantId===t.id?a=i.sku:r&&(a=r.variationId?r.variationId:r.sku),document.dispatchEvent(new s(c,`cio-atc`,{source:`constructor-add-to-cart`,itemCount:t.quantity,productId:r?.productId,variantId:t.id,sku:a,sections:c.sections}))}t.openCartDrawer&&typeof document<`u`&&document.querySelector(`cart-drawer-component`)?.open?.();let r=document.querySelector(`free-shipping-progress`);return r&&typeof r.handleCartUpdate==`function`&&r.handleCartUpdate(),{success:!0}}};var ae=async(e,t)=>{try{let n=await fetch(`${Theme.routes.cart_url}.js`);if(!n.ok){console.warn(`Failed to fetch cart data for refresh`);return}let r=await n.json(),i=r.item_count||0;document.dispatchEvent(new c(r,e,{itemCount:i,source:t+`-refresh`,sections:{}}))}catch(e){console.error(`Error refreshing cart state:`,e)}},oe=[`@DO`,`ND1`,`D40`,`N9J`,`9EM`],se=`N9J`,j=()=>typeof Theme<`u`&&Theme.hide_offer_price===!0;const M=e=>e?oe.includes(e)?!0:e.length===3&&e.startsWith(`D3`):!1,N=e=>j()?M(e)?e:se:e,ce=(e,t,n)=>!j()||M(e)||!Number.isFinite(t)||!Number.isFinite(n)?!1:n>t,P={bogo:`Buy One, Get One`,onsalenow:`On Sale Now`,new_prod:`New Arrivals`,overstock:`Overstock`,lastchance:`L
1ast Chance`},le={new:`new_prod`},F=e=>le[e]??e,ue=e=>{let t=F(e.name);return/^(new_prod|onsalenow_.+|bogo_.+|overstock_.+|lastchance_.+)$/i.test(t)},de=e=>{let t=F(e.name);return t===`new_prod`?t:t.replace(/(.+)_\w+$/,`$1`)},fe=e=>ue(e)?`Special Offers`:e.displayName||e.name,pe=(e,t)=>{let n=t.displayName||t.value,r=de(e);return r in P&&P[r]&&(n=P[r]),n};var I=[`onsalenow`,`overstock`,`bogo`,`lastchance`],L=[`onsalenow`,`price`,`bogo`];const R=e=>{let t=F(e);return I.some(e=>t===e||t.startsWith(`${e}_`))},z=e=>{let t=F(e);for(let e of I)if(t.startsWith(`${e}_`)||t===e)return e;return t},me=(e,t)=>{let n=F(z(e));return I.includes(n)?`${n}_${t}`:n},B=e=>L.some(t=>e===t||e.startsWith(`${t}_`)),he=e=>{for(let t of L)if(e.startsWith(`${t}_`)||e===t)return t;return e},ge=(e,t)=>{let n=he(e);return L.includes(n)?n===`price`&&t===`N9J`?`${n}_@DO`:`${n}_${t}`:n};function V(){let e=String(Theme.products_per_page||``).trim().split(`,`).map(e=>Number(String(e).trim())).filter(e=>Number.isFinite(e)&&e>0);return e.length?e:[24]}const _e=e=>{let t=N(e);return{hidden_fields:[`bogo_${t}`,`price_@DO`,`price_${t}`,`onsalenow_${t}`,`overstock_${t}`,`toolow_${t}`,`lastchance_${t}`,...t===`N9J`?[]:[`price_N9J`],...t===`ND1`?[]:[`price_ND1`]],hidden_facets:[`bogo_${t}`,`price_${t}`,`onsalenow_${t}`,`overstock_${t}`,`lastchance_${t}`]}},H=Object.freeze({query:`q`,page:`page`,offset:`offset`,resultsPerPage:`numResults`,filters:`filters`,sortBy:`sortBy`,sortOrder:`sortOrder`,section:`section`}),U=`sr_page`,ve=e=>{if(typeof window>`u`)return;let t=new URL(window.location.href);t.searchParams.has(`facet.group_id`)&&(t.searchParams.delete(`facet.group_id`),history.replaceState({},``,t.toString()))},ye=e=>{let t={},n=/^facet\.(.*)/,r=Theme.offer_code||void 0;return e?.forEach((e,i)=>{let a=i?.match(n)?.[1];if(a){let n=F(a),i=R(n)?z(n):n,o=R(n)?me(i,r):n,s=t[o];s?Array.isArray(s)?s.includes(e)||s.push(e):t[o]=s===e?s:[s,e]:t[o]=[e]}}),Object.keys(t).length?t:void 0},be=(e,t)=>{if(t)for(let[n,r]of Object.entries(t)??[]){let t=F(n);if(t===`group_id`&&String(r)===`0`)continue;let i=R(t)?z(t):t;if(Array.isArray(r))for(let t of r)e.append(`facet.${i}`,String(t));else e.append(`facet.${i}`,String(r))}},xe=(e,t)=>{let n=new URL(e),r=n.searchParams,i=decodeURI(n.pathname.replace(/\/$/,``))?.split(`/`),a=r.get(H.query),o=Theme.offer_code||void 0,s,c;if(i.length>0&&i[1]===`ncat1`&&(i[1]=`collections`,i[2]=i.slice(2).filter(e=>!/(ncat\d+|q)/.test(e)).join(`-`).toLowerCase().replace(/\+/g,`-`),i.splice(3,i.length-2)),!a&&i.length>0){let e=i[i.length-1];e&&(Theme.collection_custom_id[e]?(s=`group_id`,c=Theme.collection_custom_id[e]===`0`&&r.has(`facet.group_id`)?String(r.get(`facet.group_id`)):Theme.collection_custom_id[e]):e.startsWith(`brand-`)?(s=`brand`,c=t||e.replace(`brand-`,``)):(s=`collection_id`,c=e))}let l={};for(let[e,t]of Object.entries(H)){let n=r.get(t);n!=null&&(e===`sortBy`&&B(n)?l[e]=ge(n,o):l[e]=n)}if(n.pathname.startsWith(`/search`)){l.page=`1`;let e=r.get(U);e&&(l.page=e)}let u=ye(r),{page:d,offset:f,resultsPerPage:p,fmtOptions:m,hiddenFacets:h,hiddenFields:g,variationsMap:_,preFilterExpression:v,...y}=l;if(s===`group_id`&&String(c)===`0`&&u&&Object.keys(u).length>0){let e=Object.keys(u)[0],t=u[e];c&&(u.group_id=c),s=e,c=Array.isArray(t)?String(t[0]):String(t)}let b={...y,...l};if(d&&(b.page=Number(d)),f&&(b.offset=Number(f)),u&&Object.keys(u).length>0&&(b.filters=u),s&&(b.filterName=s,b.filterValue=c),p)b.resultsPerPage=Number(p);else{let e=localStorage.getItem(`productsPerPage`);e&&/^\d+$/.test(e)?b.resultsPerPage=Number(e):b.resultsPerPage=V()[0]}return b},Se=(e,t)=>{let{pathname:n}=new URL(t);if(n=n.replace(/\/$/,``),e.filterName&&e.filterValue&&[`group_id`,`groupId`,`collection_id`,`collectionId`].includes(e.filterName)){let t=e.filterValue;if([`group_id`,`groupId`].includes(e.filterName)){let n=window.location.pathname.replace(/\/$/,``).split(`/`).pop();t=Theme.collection_custom_id&&n?n:e.filterValue}n.match(/^\/(collections)\/[^/]+$/i)?n=n.replace(/^\/(collections)\/[^/]+$/i,`/$1/${t}`):e.filterName===`collection_id`&&(n=`/collections/${t}`)}let r=new URLSearchParams;for(let[t,n]of Object.entries(e)){if(H[t]===void 0)continue;let i=``;t===`filters`&&e.filters?be(r,e.filters):i=t===`sortBy`&&typeof n==`string`?B(n)?he(n):n:typeof n==`string`?n:JSON.stringify(n),i&&r.set(H[t],i)}return n.startsWith(`/search`)&&(r.set(U,String(e.page||1)),r.delete(H.page)),`${n}?${r.toString()}`},Ce=()=>{if(!(typeof window>`u`))return window.location.href},we=e=>{if(typeof window>`u`)return;let t=new URLSearchParams(window.location.search),n=new URL(e,window.location.origin);t.forEach((e,t)=>{t===H.query||t.startsWith(`facet.`)||n.searchParams.has(t)||n.searchParams.append(t,e)});let r=n.searchParams.get(H.resultsPerPage);if(r){let e=Number(r),t=V();t.length>0&&e===t[0]&&n.searchParams.delete(H.resultsPerPage)}let i=n.toString(),a=i.includes(`#`)?i:`${i}${window.location.hash}`;history.pushState({},``,a),window.dispatchEvent(new Event(`cio-plp-url-update`))},Te=`/apps/shp`;var Ee=/^\/apps\/[a-z0-9-]+$/;function De(e=Oe()){if(!e)return Te;try{let t=JSON.parse(e)?.base;return typeof t==`string`&&Ee.test(t)?t:Te}catch{return Te}}function Oe(){if(!(typeof document>`u`||!document.body))return document.body.dataset.accountPaths}var ke=`sw_compare_meta_v3_session`,Ae=`sw:compare:meta-change`,W=`sw_offer_code`,je=`sw:offer-code-change`,Me=`sw:compare:refresh`,G=`INT999`,K=typeof window<`u`,Ne=()=>{if(!K)return null;try{return window.localStorage}catch{return null}},Pe=e=>{if(!e)return{};try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?{}:t}catch{return{}}},Fe=e=>{let t=Ne();t&&t.setItem(ke,JSON.stringify(e))},q=()=>{let e=Ne();return e?Pe(e.getItem(ke)):{}},J=()=>{K&&document.dispatchEvent(new CustomEvent(Ae))},Y=()=>{K&&(window.SWCompareMeta||(window.SWCompareMeta={set:e=>{let t=String(e.handle||``).trim();if(!t)return;let n=q();n[t]=e,Fe(n),J()},remove:e=>{let t=String(e||``).trim();if(!t)return;let n=q();
1t in n&&(delete n[t],Fe(n),J())},get:e=>{let t=String(e||``).trim();return t?q()[t]??null:null},all:()=>q(),_emit:()=>{J()},clear:()=>{let e=Ne();e&&(e.removeItem(ke),J())}}))};const Ie=e=>{K&&(Y(),window.SWCompareMeta?.remove(e))};var X=e=>(e?.trim()??``)||null;const Z=()=>{if(!K)return G;try{return X(window.localStorage.getItem(W))??G}catch(e){return console.error(`Error getting cached offer code`,e),G}};var Le=e=>{if(K)try{let t=Z(),n=X(e)??G;if(n===t)return;n?window.localStorage.setItem(W,n):window.localStorage.removeItem(W),document.dispatchEvent(new CustomEvent(je,{detail:{offerCode:n}}))}catch(e){console.error(`Error setting cached offer code`,e)}},Q=null,Re=e=>{let t=e?.discount_codes?.[0]?.code;return X(t)?.toUpperCase()??`INT999`},ze=async()=>{if(K){if(Q)return Q;if(!X(window.localStorage.getItem(W)))return Q=(async()=>{try{let e=await fetch(`/cart.js`,{method:`GET`,credentials:`same-origin`,cache:`no-store`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Network response was not ok: ${e.status} ${e.statusText}`);let t=Re(await e.json());if(!t)return;Le(t)}catch(e){console.error(`Error hydrating offer code from /cart.js`,e)}})(),Q}},Be=`https://compare-app-cf-worker.swansonvitamins.workers.dev/compare-meta`,$=new Map,Ve=e=>e?`items`in e&&Array.isArray(e.items)?e.items:e.data&&typeof e.data==`object`?[e.data]:[]:[],He=e=>{let t={};for(let n of e){let e=String(n?.requestedHandle||``).trim();e&&(t[e]=n)}return t},Ue=async(e,t)=>{if(!K)return{};let n=e.map(e=>String(e||``).trim()).filter(Boolean);if(!n.length)return{};let r=t||Z(),i=Theme?.hide_offer_price&&Theme.price_offer_code||r,a=await fetch(Be,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},credentials:`omit`,body:JSON.stringify({handles:n,offerCode:i})}),o=await a.json();if(!a.ok||o.ok!==!0)throw Error(o?.error||`compare-meta failed: ${a.status} ${a.statusText}`);return He(Ve(o))};const We=async e=>{if(!K)return null;Y();let t=String(e||``).trim();if(!t)return null;let n=window.SWCompareMeta?.get(t);if(n)return n;if($.has(t))return $.get(t);let r=(async()=>{try{let e=await Ue([t]),n=e[t]??Object.values(e)[0]??null;return n?(window.SWCompareMeta?.set(n),n):null}catch(e){return console.error(`Error building compare card (worker)`,e),null}finally{$.delete(t)}})();return $.set(t,r),r};var Ge=`#quick-view-dialog, #quick-add-dialog`;const Ke=()=>{if(!K)return null;for(let e of document.querySelectorAll(`sc-dynamic-compare`))if(e instanceof HTMLElement&&!e.closest(Ge)&&typeof e.containsProduct==`function`)return e;return null};var qe=()=>Ke(),Je=()=>{let e=qe();if(!e||typeof e.getHandles!=`function`)return[];let t=e.getHandles();return Array.isArray(t)?t.map(e=>String(e||``).trim()).filter(Boolean):[]},Ye=async(e,t=3)=>{if(!K)return;Y();let n=e.map(e=>String(e||``).trim()).filter(Boolean);if(!n.length)return;let r=await Z();await Promise.all(Array.from({length:Math.min(t,n.length)},async()=>{for(;n.length;){let e=n.shift();try{let t=await Ue([e],r),n=t[e]??Object.values(t)[0];n&&window.SWCompareMeta?.set(n)}catch(t){console.error(`[compare-meta] refresh failed`,{handle:e,e:t})}}}))},Xe=()=>{if(K)try{X(window.localStorage.getItem(W))||window.localStorage.setItem(W,G)}catch(e){console.error(`Error ensuring default offer code`,e)}};if(K){Xe(),Y();let e=async e=>{let t=Je();if(await new Promise(e=>setTimeout(e,250)),!t.length){console.warn(`[compare] offer code changed but no compare handles yet; skipping refresh`);return}window.SWCompareMeta?.clear(),Le(e.detail.offerCode),await Ye(t),window.SWCompareMeta?._emit?.()};document.addEventListener(je,async t=>await e(t)),document.addEventListener(Me,async t=>await e(t)),ze()}a();const Ze=[`B`,`V`,`W`,`T`],Qe=e=>[`I`,...Ze].includes(e??`I`),$e=({product:a,onAddToCart:s,onClick:c,showCompare:l=!1,showAddToCart:u=!0})=>{let{handle:d,price:f,originalPrice:p,stockStatus:m=`I`,variants:h=[]}=a,g=`sw:compare:change`,_=h.find(e=>e.variantId&&e.variantId===a.variantId)||h.find(e=>Qe(e.stockStatus))||h[0]||null,v=i(null),[y,b]=e(!1),[x,S]=e(!1),C=i(null),[w,ee]=e(0),T=()=>{document.dispatchEvent(new CustomEvent(g))},E=()=>Ke(),D=e=>e?typeof e.getCount==`function`?e.getCount():typeof e.getHandles==`function`&&e.getHandles()?.length||0:0,O=r(()=>{if(!l||!d)return;let e=E();e&&(b(e.containsProduct(d)),ee(D(e)))},[l,d]),te=t(()=>l&&!!d&&!y&&w>=3,[l,d,y,w]),k=t(()=>Qe(m),[m]),ne=t(()=>k?window.SHP?.buy_it_again?.includes(d)?`Buy it Again`:`Add to Cart`:`See other options`,[d,k]),re=t(()=>a.toolow?h.length?h.every(e=>e.toolow):a.toolow:!1,[a.toolow,h]),ie=t(()=>a.hidePrice?h.length?h.every(e=>
1e.hidePrice):a.hidePrice:!1,[a.hidePrice,h]),A=t(()=>{let e=e=>e.reduce((e,t)=>({min:Math.min(e.min,t),max:Math.max(e.max,t)}),{min:e[0],max:e[0]});if(!h.length){let e=(a.toolow||a.hidePrice)&&p?.amount?p:f;return{price:{from:e,to:e},originalPrice:{from:p,to:p}}}let t=h.map(e=>(e.toolow||e.hidePrice)&&e.originalPrice?.amount?e.originalPrice.amount:e.price?.amount).filter(e=>e!==void 0),n=h.map(e=>e.originalPrice?.amount).filter(e=>e!==void 0),r=(a.toolow||a.hidePrice)&&p?.amount?p.amount:f?.amount,i=r?[r,...t]:t,o=p?.amount?[p.amount,...n]:n;return{price:i.length===0?null:(()=>{let{min:t,max:n}=e(i);return{from:{amount:t,currencyCode:f?.currencyCode||`USD`},to:{amount:n,currencyCode:f?.currencyCode||`USD`}}})(),originalPrice:o.length===0?null:(()=>{let{min:t,max:n}=e(o);return{from:{amount:t,currencyCode:p?.currencyCode||`USD`},to:{amount:n,currencyCode:p?.currencyCode||`USD`}}})()}},[f,p,h,a.toolow,a.hidePrice]),ae=t(()=>{if(!(a.toolow||h.some(e=>e.toolow))&&(a.hidePrice||h.some(e=>e.hidePrice)))return null;if(a.toolow&&!h.length&&p?.amount&&f?.amount)return p.amount>f.amount?Math.round((p.amount-f.amount)/p.amount*100):null;if(h.length>0&&h.some(e=>e.toolow)){let e=0;for(let t of h)if(t.originalPrice?.amount&&t.price?.amount&&t.originalPrice.amount>t.price.amount){let n=Math.round((t.originalPrice.amount-t.price.amount)/t.originalPrice.amount*100);e=Math.max(e,n)}return e>0?e:null}if(!A.originalPrice?.from?.amount||!A.price?.from?.amount)return null;let e=A.originalPrice.from.amount,t=A.price.from.amount;return e<=t?null:Math.round((e-t)/e*100)},[A,h,a.toolow,a.hidePrice,p,f]),oe=t(()=>{if(!h||h.length<2)return!1;let e=[];for(let t of h){if(!t.originalPrice?.amount||!t.price?.amount)return!1;t.originalPrice.amount<=t.price.amount?e.push(0):e.push(Math.round((t.originalPrice.amount-t.price.amount)/t.originalPrice.amount*100))}return e.every(t=>t===e[0])},[h]),se=r(e=>{if(e.preventDefault(),e.stopPropagation(),!(!k||!u||x)){if(a.requiresAgeVerification){let t=window.ageVerificationService;if(t){t.requestVerification(()=>{S(!0),C.current=setTimeout(()=>{S(!1)},5e3),s&&s(e,a,_)});return}}S(!0),C.current=setTimeout(()=>{S(!1)},5e3),s&&s(e,a,_)}},[x,k,u,s,a,_]),j=e=>{c&&c(e,a)},M=r(async e=>{if(e.preventDefault(),e.stopPropagation(),!l||!d)return;let t=E();if(!t)return;await Z(),await We(d).catch(console.error);let n=t.containsProduct(d),r=D(t);!n&&r>=3||(t.toggleProduct(d),window.setTimeout(()=>{O(),T()},0))},[l,d,O]);n(()=>{if(!l)return;let e=()=>{O()};return document.addEventListener(g,e),()=>document.removeEventListener(g,e)},[l,O]);let N=r(e=>{l&&(e.detail?.productHandle===d&&(b(!1),Ie(d)),O(),T())},[l,d]);return n(()=>{if(l)return O(),document.addEventListener(`sc:dynamic-compare:remove`,N),()=>{document.removeEventListener(`sc:dynamic-compare:remove`,N)}},[l,O,N]),n(()=>{let e=e=>{let t=e;C.current&&t.detail?.data?.productId===a.productId&&(S(!1),clearTimeout(C.current))};return document.addEventListener(o.cartUpdate,e),()=>{document.removeEventListener(o.cartUpdate,e),C.current&&clearTimeout(C.current)}},[]),{product:a,firstAvailableVariant:_,addToCartButtonRef:v,isInCompare:y,isAddingToCart:x,isAvailable:k,ATCLabel:ne,priceSet:A,savingPercentage:ae,hasUniformDiscount:oe,allToolow:re,allHidePrice:ie,handleAddToCart:se,handleProductClick:j,handleCompareButtonClick:M,isCompareButtonDisabled:te}};export{ce as C,o as E,N as S,re as T,we as _,H as a,ue as b,me as c,xe as d,Ce as f,U as g,B as h,ve as i,ge as l,R as m,$e as n,_e as o,Se as p,De as r,z as s,Qe as t,V as u,fe as v,A as w,F as x,pe as y};

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.