"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[73],{182:(t,n,i)=>{var o=i(0),e=i(4),r=i(93),a=i(2);(0,i(1).createEntrypoint)("product_yotpo",(({publicKey:t,defaultMultiplier:n,icon:i})=>{const{selectedVariant:s,product:c}=(0,e.c)((t=>({selectedVariant:t.selectedVariant,product:t.product}))),{loggedIn:d}=(0,r.a)(),l=((t,n,i,o)=>{var e;const[r,s]=(0,a.useState)([]);(0,a.useEffect)((()=>{var i,o,e,r;(null==t?void 0:t.id)&&n&&(i=void 0,o=void 0,r=function*(){var i;try{const o={product_potential_points:{variants:null===(i=t.variants)||void 0===i?void 0:i.map((t=>({id:t.variantId,price:Math.round(100*Number(t.price))}))),product_id:t.id,product_type:t.productType}},e=`https://storefront.yotpo.com/loyalty/v3/stores/${n}/product_potential_points`,r=yield fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(o)});if(!r.ok)throw new Error(`YOTPO API Request failed with status ${r.status}`);const a=yield r.json();s(a.product_potential_points.variants_with_points)}catch(t){console.error("Failed to fetch Yotpo loyalty points:",t),s([])}},new((e=void 0)||(e=Promise))((function(t,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function s(t){try{c(r.throw(t))}catch(t){n(t)}}function c(n){var i;n.done?t(n.value):(i=n.value,i instanceof e?i:new e((function(t){t(i)}))).then(a,s)}c((r=r.apply(i,o||[])).next())})))}),[t,n]);const c=null===(e=null==t?void 0:t.variants)||void 0===e?void 0:e.find((t=>t.variantId===i));return((t,n,i,o)=>{if(!t)return;const e=i.find((n=>n.id===t));return e?e.points:n?Math.round(Number(n)*o):void 0})(i,null==c?void 0:c.price,r,o)})(c,t,null==s?void 0:s.variantId,n);return(0,o.jsx)(o.Fragment,{children:(0,o.jsx)("div",{class:"CVmqa4F0",children:"number"==typeof l?(0,o.jsxs)("span",{children:[(0,o.jsx)("img",{src:null==i?void 0:i.url,width:null==i?void 0:i.width,height:null==i?void 0:i.height,alt:null==i?void 0:i.altText})," ",!0===d?(0,o.jsxs)(o.Fragment,{children:["Loyalty Customers: You will earn ",l," points on this purchase"]}):(0,o.jsxs)(o.Fragment,{children:["Earn ",l," points for this product."," ",(0,o.jsx)("a",{href:"/account/login",class:"QLe9Vzj5",children:"Login or signup"})]})]}):(0,o.jsx)("span",{children:" "})})})}))}},t=>{t.O(0,[1,2,3,4,6,5],(()=>t(t.s=182))),t.O()}]);