PageSourceSearch

https://2xu.com/cdn/shop/t/896/assets/tagalys-CeVU8Ps1.js

js 2xu.com collected 2026-10-03 19:37:52 UTC 9,186 bytes, 60 lines download raw bytes

1const H="en-US",Q=()=>{var e;return((e=globalThis.window)==null?void 0:e.Shopify)||globalThis.Shopify||{}},B=(e="USD")=>{const t=String(e||"USD").trim().toUpperCase();try{return new Intl.NumberFormat(H,{style:"currency",currency:t}),t}catch{return"USD"}},j=()=>{var e;return B((e=Q().currency)==null?void 0:e.active)},V=(e=j())=>{var n;const t=Q().locale;return e==="MYR"?"en-MY":t||((n=globalThis.navigator)==null?void 0:n.language)||H},U=(e,t=j(),{compact:n=!1,stripTrailingZeros:r=!1}={})=>{if(e==null||e==="")return"";const a=Number(e);if(!Number.isFinite(a))return"";const o=B(t),f=V(o),c={style:"currency",currency:o};r&&Number.isInteger(a)&&(c.minimumFractionDigits=0,c.maximumFractionDigits=0);const s=new Intl.NumberFormat(f,c).format(a);return n?s.replace(/\s+/g,"").trim():s},Y=e=>U(e,j(),{compact:!0,stripTrailingZeros:!0});function ee(e,t,n={}){var p,i,l,d;const r=(i=(p=e.images)==null?void 0:p[0])==null?void 0:i.src,a=(d=(l=e.images)==null?void 0:l[1])==null?void 0:d.src,o=(e.variants||[]).map(y=>({name:y.option2||y.title,id:String(y.id),available:!!y.available})).filter((y,_,k)=>y.name&&k.findIndex(w=>w.name===y.name)===_),f=`/products/${e.handle}`,c=J(e,n),s=te(e),m=ne(e),h=re(e,t);return{id:e.id,title:e.title,handle:e.handle,price:Y(e.price),compare_at_price:Y(e.compare_at_price),available:!!e.available,description:s,url:f,rating:m,swatches:h,sizes:o,featuredImage:r,secondaryImage:a,badges:c}}function J(e,t={}){var r,a,o,f,c,s,m,h,v,p,i,l,d,y,_,k,w,T,E;const n=[];try{const u=((o=(a=(r=e.variants)==null?void 0:r.edges)==null?void 0:a[0])==null?void 0:o.node)||((f=e.variants)==null?void 0:f[0]);if(u?.compare_at_price>0||parseFloat(((c=u?.compareAtPrice)==null?void 0:c.amount)||"0")>0){const b=u.compare_at_price||parseFloat(((s=u?.compareAtPrice)==null?void 0:s.amount)||"0"),P=parseFloat(((m=u?.price)==null?void 0:m.amount)||"0")||u.price,x=Math.floor((b-P)/b*100),A=Math.floor(x/5)*5;A>=5&&n.push({type:"sale_percentage",text:`-${A}%`,variant:"dark"})}const C=((p=(v=(h=e.metafields)==null?void 0:h.custom)==null?void 0:v.sale_badge)==null?void 0:p.value)||((d=(l=(i=e.metafields)==null?void 0:i.find)==null?void 0:l.call(i,b=>b?.key==="sale_badge"))==null?void 0:d.value);C!=null&&C.text&&t.sale_badge===!0&&n.push({type:"sale_custom",text:C.text,variant:(C.variant||"dark").toLowerCase()});const S=((k=(_=(y=e.metafields)==null?void 0:y.custom)==null?void 0:_.secondary_sale_badge)==null?void 0:k.value)||((E=(T=(w=e.metafields)==null?void 0:w.find)==null?void 0:T.call(w,b=>b?.key==="secondary_sale_badge"))==null?void 0:E.value);S!=null&&S.text&&t.secondary_sale_badge===!0&&n.push({type:"sale_secondary",text:S.text,variant:(S.variant||"dark").toLowerCase()})}catch(u){return console.warn("Error generating badges:",u),[]}return n}function te(e){var t,n;try{const r=(t=e.metafields)==null?void 0:t.custom;return(n=r?.short_description)==null?void 0:n.value}catch(r){return console.warn("Error extracting description:",r),e.body_html||e.description||null}}function ne(e){var t,n;try{const r=(t=e.metafields)==null?void 0:t.reviews;return((n=r?.rating)==null?void 0:n.value)||""}catch(r){return console.warn("Error extracting rating:",r),""}}function re(e,t){var n,r,a,o,f,c,s,m,h,v,p,i,l,d,y,_,k,w,T,E,u,C,S,b,P,x,A,I,D,N,z,R;try{if(!((n=t?.products)!=null&&n.length))return[];const L=t.products,$=[];for(const g of L){const F=se(g);if(!F)continue;const O=oe(g);if(!O)continue;const M=(o=(a=(r=g.images)==null?void 0:r.nodes)==null?void 0:a[0])==null?void 0:o.url,q=(s=(c=(f=g.images)==null?void 0:f.nodes)==null?void 0:c[1])==null?void 0:s.url,W=ce(g),X=g.id.split("/").pop()===String(e.id),Z=ie(F),K=J(g);$.push({productId:g.id.split("/").pop(),title:O,url:`/products/${g.handle}`,active:X,image:M?G(M):null,secondaryImage:q?G(q):null,sizes:W,colors:Z,badges:K,price:U((i=(p=(v=(h=(m=g.variants)==null?void 0:m.edges)==null?void 0:h[0])==null?void 0:v.node)==null?void 0:p.price)==null?void 0:i.amount,(k=(_=(y=(d=(l=g.variants)==null?void 0:l.edges)==null?void 0:d[0])==null?void 0:y.node)==null?void 0:_.price)==null?void 0:k.currencyCode),compareAtPrice:(C=(u=(E=(T=(w=g.variants)==null?void 0:w.edges)==null?void 0:T[0])==null?void 0:E.node)==null?void 0:u.compareAtPrice)!=null&&C.amount?U((A=(x=(P=(b=(S=g.variants)==null?void 0:S.edges)==null?void 0:b[0])==null?void 0:P.node)==null?void 0:x.compareAtPrice)==null?void 0:A.amount,(R=(z=(N=(D=(I=g.variants)==null?void 0:I.edges)==null?void 0:D[0])==null?void 0:N.node)==null?void 0:z.compareAtPrice)==null?void 0:R.currencyCode):null})}return $.sort((g,F)=>g.active&&!F.active?-1:!g.active&&F.active?1:0),$}catch(L){return console.warn("Error generating swatches:",L),[]}}function ae(e,t){var n;try{const r=(n=e.metafields)==null?void 0:n.find(a=>a.key===t);return r?.value}catch{return null}}function se(e){var t;try{const n=ae(e,"colour_codes");if(n)return n;const r=(t=e.tags)==null?void 0:t.find(a=>a.toLowerCase().includes("colour:"));return r?r.toLowerCase().replace("colour:","").trim():null}catch{return null}}function oe(e){var t,n,r;try{const a=(r=(n=(t=e.variants)==null?void 0:t.edges)==null?void 0:n[0])==null?void 0:r.no
1de;if(a!=null&&a.title){const o=a.title.split(" / ");if(o.length>1)return o[0]}return e.title}catch{return e.title||""}}function ce(e){var t;try{const n=((t=e.variants)==null?void 0:t.edges)||[],r=[],a=new Set;for(const o of n){const f=o.node,c=f.title.split(" / "),s=c.length>1?c[1]:c[0];s&&!a.has(s)&&(r.push({name:s,id:f.id.split("/").pop(),available:f.availableForSale}),a.add(s))}return r}catch{return[]}}function ie(e){try{if(!e)return{};if(e.includes("|")){const t=e.split("|");return{primary:t[0],secondary:t[1]}}else return{primary:e}}catch{return{}}}function G(e){try{if(e&&!e.includes("width=")){const t=e.includes("?")?"&":"?";return`${e}${t}width=600`}return e}catch{return e}}async function ue(e){const t={};return await Promise.all(e.map(async n=>{if(!(!(n!=null&&n.id)||!(n!=null&&n.handle)))try{const r=await fetch(`/products/${n.handle}?view=badge-status`);if(!r.ok){t[n.id]={sale_badge:!1,secondary_sale_badge:!1};return}const a=await r.json();t[n.id]={sale_badge:a.sale_badge===!0,secondary_sale_badge:a.secondary_sale_badge===!0}}catch(r){console.warn(`Error checking badge status for product ${n.id}:`,r),t[n.id]={sale_badge:!1,secondary_sale_badge:!1}}})),t}function de(e,t,n={}){return e.map(r=>{const a=t?t[r.id]:{};return ee(r,a,n[r.id]||{})})}async function fe(e,t){const n=e.reduce((o,f)=>{const c=f.tags.find(s=>s.startsWith("Stitch-"));return c&&(o[f.id]=c.toLowerCase()),o},{}),r=t.getPlatformConfiguration().storefrontAPI;return Object.keys(n).length===0?{}:await le(n,r.accessToken,r.myShopifyDomain)}async function le(e,t,n){const r=`https://${n}/api/2024-04/graphql.json`,a=[...new Set(Object.values(e))],o=[{key:"short_description",namespace:"custom"},{key:"sale_badge",namespace:"custom"},{key:"secondary_sale_badge",namespace:"custom"},{key:"rating",namespace:"reviews"},{key:"swatches_heading",namespace:"custom"},{key:"colour_codes",namespace:"custom"}],c=`
2    query {
3      ${a.map((s,m)=>`
4    collection${m}: collection(handle: "${s}") {
5      handle
6      title
7      products(first: 100) {
8        nodes {
9          id
10          title
11          handle
12          tags
13          availableForSale
14          images(first: 2) {
15            nodes {
16              url
17              altText
18            }
19          }
20          metafields(identifiers: [${o.map(h=>`{namespace: "${h.namespace}", key: "${h.key}"}`).join(",")}]
21          ) {
22            key
23            value
24            reference {
25              ... on Metaobject {
26                id
27                type
28                fields {
29                  key
30                  value
31                }
32              }
33            }
34          }
35          variants(first: 20) {
36            edges {
37              node {
38                id
39                availableForSale
40                title
41                price {
42                  amount
43                }
44                compareAtPrice {
45                  amount
46                }
47                image {
48                  url
49                }
50              }
51            }
52          }
53        }
54      }
55    }
56  `).join(`
57`)}
58    }
59  `;try{const m=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t},body:JSON.stringify({query:c})})).json();m.errors&&console.warn("GraphQL errors:",m.errors),m.data&&Object.keys(m.data).forEach(p=>{const i=m.data[p];i&&i.products&&i.products.nodes&&i.products.nodes.forEach(l=>{l.metafields&&l.metafields.forEach(d=>{if(d&&d.reference&&d.reference.fields){const y={id:d.reference.id,type:d.reference.type};d.reference.fields.forEach(_=>{y[_.key]=_.value}),d.value=y,d.getField=_=>d.value[_]||null}})})});const h={};a.forEach((p,i)=>{const l=m.data[`collection${i}`];l&&(h[p]=l)});const v={};return Object.entries(e).forEach(([p,i])=>{const l=h[i];l&&(v[p]={title:l.title,handle:l.handle,products:l.products.nodes})}),v}catch(s){return console.warn("Error getting stitched product details:",s),{}}}export{ue as a,Y as f,fe as g,de as n};
60//# sourceMappingURL=/cdn/shop/t/896/assets/tagalys-CeVU8Ps1.js.map

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.