PageSourceSearch

https://static-ca-prod.castlery.com/assets/web/_next/static/chunks/1131.2f33d77976758d04.js

js castlery.com collected 2026-09-25 15:13:04 UTC 30,779 bytes, 2 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2f5d6b1c-688e-4548-a7fc-06cd77943d1b",e._sentryDebugIdIdentifier="sentry-dbid-2f5d6b1c-688e-4548-a7fc-06cd77943d1b")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1131],{21131:function(e,t,o){"use strict";o.r(t),o.d(t,{CampaignInfoModal:function(){return V},ChooseCampaignGiftModal:function(){return e_.h},ChooseCouponGiftModal:function(){return ej.E},ChooseFreeGift:function(){return q},ChooseFreeGiftDeliveryModalBase:function(){return em.D},ChooseGiftGallery:function(){return eI.O},ChoosePromotionGiftModal:function(){return eC},CollapsibleContent:function(){return M},GiftGallery:function(){return ek.j},GiftItem:function(){return el.b},PosChooseCouponGiftModal:function(){return ew},PosChooseFreeGiftDeliveryModal:function(){return z},PosChooseFreeGiftDeliveryModalV2:function(){return eg.s},PosPromotionHint:function(){return et},PromotionHint:function(){return er.l},TagIcon:function(){return K},YotpoScript:function(){return en.j},YotpoWidget:function(){return ei},useCampaignGifts:function(){return ec.e},useCouponGifts:function(){return ef},usePriceBreakCampaign:function(){return J.U},usePromotionData:function(){return ed}});var n=o(63056),i=o(26759),r=o(87845),l=o(49187),a=o(97465),s=o(99632),d=o(57443),c=o(66504),u=o(58746),p=o(87420),x=o(9671),h=o(85588),f=o(68853);let g=e=>{let{isChangeGift:t,isOpen:o,onToggle:r,onChangeClose:l}=e;return(0,n.jsxs)(i.Z,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:t?"default":"pointer"},onClick:()=>{t||null==r||r()},children:[(0,n.jsxs)(i.Z,{sx:{display:"flex",gap:2,alignItems:"center"},children:[(0,n.jsx)(u.V,{children:"Free"}),(0,n.jsx)(p.C,{level:"body2",children:"Choose your free gift "})]}),(0,n.jsx)(x.h,{color:"neutral",sx:{"--Icon-fontSize":24,minWidth:24,minHeight:24,width:24,height:24,"--Icon-color":e=>e.palette.brand.maroonVelvet[500],"&:hover":{"--Icon-color":"var(--fortress-palette-brand-mono-900)"},svg:{width:24,height:24}},onClick:()=>{t&&(null==l||l())},children:t?(0,n.jsx)(h.x,{}):(0,n.jsx)(f.Z,{sx:{color:"inherit",transform:"rotate(".concat(o?0:180,"deg)"),transition:"transform 0.5s ease"}})})]})};var m=o(29257),v=o(17523),b=o(26342),y=o(30662),C=o(41845),j=o(5788),w=o(90499),_=o(96884),k=o(87259),I=o(45625),T=e=>{var t,o;let{gift:r,mobileLayout:a=!1,lazy:s=!0,posSelectDeliveryModal:d,isCouponModule:c}=e,u=(0,y.C)(b.zT),h=r.variant,f=r.gift_pool_id,g=(0,y.C)(I.Nh),m=(0,l.useCallback)(async()=>{if(!g){let e=Array.from(document.querySelectorAll("button")).find(e=>{var t;return null===(t=e.textContent)||void 0===t?void 0:t.includes("Search for a customer")});null==e||e.click();return}if(d){null==d||d(r);return}},[r,d]),T=((null==u?void 0:null===(t=u.line_items)||void 0===t?void 0:t.filter(e=>!!e.gift_id))||[]).find(e=>e.gift_id===f&&e.variant.id===r.variant.id),E=(null==r?void 0:r.state)==="OUT_OF_STOCK",Z=(null==r?void 0:r.state)==="UNAVAILABLE",S=(null==r?void 0:r.state)==="IN_STOCK",N=!!T||E||Z||!S,F="".concat(h.product_slug),G=!isNaN(+h.price)&&+h.price!=+h.list_price,P={width:"100%",height:"52px",boxShadow:"none",color:"#877445",borderRadius:0,"& svg":{color:"#877445"}},D={"--IconButton-size":"32px",minWidth:"32px",minHeight:"32px",width:c?"100%":"32px",height:"32px",padding:"6px",display:"flex",alignItems:"center",borderRadius:"50%",border:"1px solid var(--fortress-palette-brand-wheat-700)",background:"var(--fortress-palette-brand-charcoal-0)",boxShadow:"0px 4px 8px 1px rgba(0, 0, 0, 0.15)","& svg":{width:"20px",height:"20px",fill:"var(--fortress-palette-brand-wheat-700)"}};return(0,n.jsxs)(i.Z,{sx:{display:"flex",flexDirection:"column",gap:1,width:a?"120px":"200px",height:"auto",flexShrink:0,flex:"0 0 auto"},children:[(0,n.jsx)(_.CustomLink,{href:F,children:(0,n.jsx)(i.Z,{children:(null===(o=h.images)||void 0===o?void 0:o.length)>
10?(0,n.jsx)(k.FortressImage,{sx:{width:"100%",height:a?"81px":"135px"},src:h.images[0].links.feed,alt:h.product_name,lazy:s}):(0,n.jsx)(k.FortressImage,{sx:{width:"100%",height:a?"81px":"135px"},alt:h.product_name,src:""})})}),(0,n.jsx)(v.rU,{sx:{textDecoration:"none",display:"flex",flexDirection:"column",alignItems:"center","&:hover":{textDecoration:"none",color:"red"}},href:F,children:(0,n.jsx)(p.C,{level:"caption1",textAlign:"center",sx:{color:S?e=>e.palette.brand.charcoal[800]:e=>e.palette.brand.charcoal[400],"&:hover":{textDecoration:"none",color:"#a45b37"}},children:h.product_name})}),(0,n.jsx)(i.Z,{sx:{mt:-1},children:h.variant_option_values&&h.variant_option_values.map(e=>(0,n.jsxs)(p.C,{level:"caption1",textAlign:"center",sx:{color:S?e=>e.palette.brand.wheat[500]:e=>e.palette.brand.charcoal[400]},children:[e.option_type_presentation,": ",e.presentation]},e.option_value_id))}),(0,n.jsx)(i.Z,{children:G?(0,n.jsxs)(i.Z,{sx:{display:"flex",gap:1,alignItems:"center",justifyContent:"center"},children:[(0,n.jsx)(p.C,{level:"caption1",textAlign:"center",sx:{color:e=>e.palette.brand.terracotta[500]},"aria-label":"Sale Price: ".concat((0,w.pU)(+h.price,!0)),children:(0,w.pU)(+h.price,!0)}),(0,n.jsx)(p.C,{level:"caption1",textAlign:"center",sx:{color:e=>e.palette.brand.charcoal[500],textDecoration:"line-through"},"aria-label":"Regular Price: ".concat((0,w.pU)(+h.list_price,!0)),children:(0,w.pU)(+h.list_price,!0)})]}):(0,n.jsx)(p.C,{level:"caption1",textAlign:"center",sx:{color:e=>e.palette.brand.charcoal[800]},"aria-label":"Price: ".concat((0,w.pU)(+h.price,!0)),children:(0,w.pU)(+h.price,!0)})}),(0,n.jsx)(i.Z,{sx:{mb:1,mx:c?"none":"auto",mt:c?"auto":"none"},children:(0,n.jsx)(()=>Z||E?(0,n.jsx)(i.Z,{sx:{width:"100%",p:"3px",border:"1px solid var(--fortress-palette-brand-terracotta-300)",display:"flex",alignItems:"center",justifyContent:"center",...c&&{height:"52px"}},children:(0,n.jsx)(p.C,{level:"caption2",sx:{textAlign:"center",...c&&{fontSize:"16px"},color:e=>e.palette.brand.terracotta[300]},children:Z?"Unavailable":"Fully redeemed"})}):T?(0,n.jsx)(x.h,{variant:"plain","data-selenium":"free-gift-modal-button",disabled:!0,sx:{...D,"&:disabled":{background:"var(--fortress-palette-brand-chai-300)",boxShadow:"0px 4px 8px 1px rgba(0, 0, 0, 0.15)",border:"1px solid var(--fortress-palette-brand-wheat-500)"}},children:(0,n.jsx)(C.J,{})}):(0,n.jsx)(x.h,{variant:"outlined","data-selenium":"free-gift-modal-button",disabled:N,onClick:m,color:"neutral",sx:{...c?P:D},children:c?(0,n.jsx)(p.C,{level:"body2",children:"Add to Cart"}):(0,n.jsx)(j.Z,{})}),{})})]})},E=o(19624),Z=o(85553),S=o(63031),N=o(68351),F=o(12973),G=o(30963),P=o(36564),D=o(37907),O=o(2415),U=o(19091),B=o(12524),A=o(35097),L=o(24831),W=o(79601);let z=e=>{let{open:t,onClose:o,gift:r,code:s}=e,d=null==r?void 0:r.promotionId,u=null==r?void 0:r.controlType,x=(0,a.C)(b.zT),f=(0,a.T)(),g=(0,a.C)(U.pO),[m,v]=(0,l.useState)(!1),[y,C]=(0,l.useState)(["Delivery"]),[j,w]=(0,l.useState)(!1),[_,k]=(0,l.useState)(""),[I,T]=(0,l.useState)(null),[E,z]=(0,l.useState)(!1),Y=(0,a.C)(b.Y$),[R,M]=(0,l.useState)(""),{currentData:H,isLoading:q}=(0,B.TY)(g,{skip:!g}),K=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if((null==x?void 0:x.number)&&!m){v(!0),M("");try{let t=((await f(c.yG.initiate({orderNumber:x.number,...e&&H&&{stockLocationId:e},...s&&{coupon_code:s}}))).data||[]).find(e=>e.promotion_id===d),o=null==t?void 0:t.gifts.find(e=>{var t;let{variant:o}=e;return o.id===(null==r?void 0:null===(t=r.variant)||void 0===t?void 0:t.id)});(null==o?void 0:o.state)==="IN_STOCK"?w(!0):(M("Out of Stock"),w(!1))}catch(o){var t;w(!1),W.logger.error("Failed to verify gift stock",{error:o,giftId:null==r?void 0:r.gift_pool_id,variantId:null==r?void 0:null===(t=r.variant)||void 0===t?void 0:t.id,location:e})}finally{v(!1)}}};(0,l.useEffect)(()=>{t&&H&&H.length>0&&!E?(k(H[0].id),T(null),w(!1),K(H[0].id),z(!0)):!t||H||E||(k("Warehouse"),T(null),w(!1),K(""),z(!0))},[t,H,E]),(0,l.useEffect)(()=>{t||z(!1)},[t]);let X=(0,l.useCallback)(async()=>{var e,t,n;if(!r)return;try{A.dt.track(L.y.EVENT_GWP_ADD_TO_CART_CLICK)({giftId:null===(t=r.variant)||void 0===t?void 0:t.id})}catch(e){W.logger.error("Failed to track GWP add to cart event",{error:e,giftId:null===(n=r.variant)||void 0===n?void 0:n.id})}v(!0);let i={orderNumber:(null==x?void 0:x.number)||"",gift_id:r.gift_pool_id,variant_id:null===(e=r.variant)||void 0===e?void 0:e.id,quantity:(null==r?void 0:r.quantity)||1,..._&&H&&{options:{preferred_self_collection:"Cash & Carry"===I,preferred_stock_location_id:_}}};1!==u&&s&&(i.coupon_code=s),await f(c.w_.initiate(i)),o(!1),v(!1)},[f,x,r,o,u,s,I,_]),V=e=>{if(t&&(k(e),T(null),w(!1),K(e),H)){let t=H.find(t=>
1t.id===e);t&&t.support_self_collection?C(["Cash & Carry","Delivery"]):C(["Delivery"])}};return(0,n.jsx)(Z.u_,{"aria-labelledby":"modal-title","aria-describedby":"modal-desc",open:t,sx:{display:"flex",alignItems:"center",justifyContent:"center",height:"100vh","&:focus-visible":{outline:"none"}},children:(0,n.jsxs)(S.Z,{sx:{width:576,px:4,py:3,position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,n.jsx)(i.Z,{onClick:()=>o(!0),sx:{position:"absolute",top:24,right:16,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:40,height:40},children:(0,n.jsx)(h.x,{sx:{width:24,height:24,fill:e=>e.palette.brand.wheat[500]}})}),(0,n.jsx)(p.C,{id:"modal-title",level:"h2",textAlign:"center",sx:{mt:3},children:"Gift will be added to cart."}),(0,n.jsx)(p.C,{id:"modal-desc",level:"body2",sx:{textAlign:"center",color:"text.primary",mt:1,width:"100%"},children:"Please choose a collection or delivery method."}),(0,n.jsxs)(i.Z,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:2,py:2,mb:3},children:[(0,n.jsxs)(N.Z,{required:!0,children:[(0,n.jsx)(F.Z,{children:(0,n.jsx)(p.C,{sx:{color:e=>e.palette.brand.charcoal[500],marginBottom:1},children:"Location"})}),(0,n.jsx)(G.Z,{name:"location",value:_,variant:"borderplain",disabled:m,onChange:(e,t)=>
1{V(t)},slotProps:{listbox:{}},sx:{boxShadow:"none"},children:H&&H.length>0?(0,n.jsx)(n.Fragment,{children:null==H?void 0:H.map(e=>{let{id:t,name:o}=e;return(0,n.jsx)(P.Z,{value:t+"",children:o},t)})}):(0,n.jsx)(P.Z,{value:"Warehouse",children:"Warehouse"},"Warehouse")})]}),(0,n.jsxs)(N.Z,{required:!0,children:[(0,n.jsx)(F.Z,{children:(0,n.jsx)(p.C,{sx:{color:e=>e.palette.brand.charcoal[500],marginBottom:1},children:"Collection/Delivery Method"})}),(0,n.jsx)(G.Z,{name:"deliveryMethod",variant:"borderplain",value:I,onChange:(e,t)=>{T(t)},sx:{boxShadow:"none"},children:y.map(e=>(0,n.jsx)(P.Z,{value:e,children:e},e))})]})]}),(0,n.jsxs)(D.ZP,{direction:"row",spacing:2,width:"100%",children:[(0,n.jsx)(O.z,{variant:"secondary",color:"neutral",fullWidth:!0,onClick:()=>o(!0),sx:{py:1.5,fontSize:"body1.fontSize"},children:"Cancel"}),(0,n.jsx)(O.z,{loading:m||Y,variant:"solid",color:"primary",fullWidth:!0,type:"submit",disabled:!j||!I,onClick:X,sx:{py:1.5,fontSize:"body1.fontSize","&:hover":{bgcolor:"primary.dark"}},children:R||"Add To Cart"})]})]})})};var Y=o(16598),R=o(35228);let M=e=>{let{isOpen:t,mobileLayout:o,gifts:r,curCode:s}=e,{desktop:d}=(0,m.Z)(),[u,x]=(0,l.useState)(null),[h,f]=(0,l.useState)(!1),g=(0,a.T)(),y=(0,a.C)(b.zT),C=e=>{x(e),f(!0)};return(0,n.jsxs)(i.Z,{sx:{width:"100%",maxWidth:d?"calc(66.3vw - 162px)":"100vw",margin:"0 auto",maxHeight:t?1e3:0,overflow:"hidden",transition:"all 0.5s ease-in-out"},children:[(0,n.jsxs)(p.C,{level:"caption1",sx:{my:2},children:["Note: Gifts are subject to stock availability.",(0,n.jsx)(v.rU,{component:"button",underline:"always",sx:{color:"var(--fortress-palette-brand-burntOrange-500) !important",textDecorationColor:"var(--fortress-palette-brand-burntOrange-500) !important"},onClick:()=>{window.open("https://www.castlery.com/".concat(Y.EcEnv.NEXT_PUBLIC_COUNTRY.toLowerCase(),"/promo-terms"),"_blank")},children:"T&Cs apply."})]}),(0,n.jsx)(E.ScrollWrapper,{scrollTrackHeight:8,sx:{width:"100%",py:0,gap:2,"& > .MuiStack-root":{marginTop:"0 !important"}},children:(0,n.jsx)(i.Z,{sx:{display:"flex",gap:1},children:null==r?void 0:r.map(e=>(0,n.jsx)(T,{gift:e,mobileLayout:o,posSelectDeliveryModal:C},e.giftPoolId))})}),R.C0&&(0,n.jsx)(z,{open:h,onClose:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];f(!1),x(null),(null==y?void 0:y.number)&&e&&g(c.fD.initiate({orderNumber:y.number}))},gift:u,code:s})]})};var H=o(43071);let q=e=>{var t;let{onRemoveFreeGift:o,onChangeClose:u,changeGiftId:p}=e,{desktop:x}=(0,m.Z)(),h=(0,H.usePathname)(),f=(0,a.T)(),v=(0,a.C)(b.zT),y=!h.includes("cart")||!x,C=!!p,[j,w]=(0,l.useState)(C),{validCampaignGiftPromotion:_,allFreeGiftCampaignPromotion:k,allFreeGiftValidPromotion:I}=(0,a.C)(s.M),T=(0,a.C)(d.hA);(0,l.useEffect)(()=>{if(C&&j&&v){var e;f(c.fD.initiate({orderNumber:null==v?void 0:v.number,coupon_code:null==v?void 0:null===(e=v.coupon)||void 0===e?void 0:e.code}))}},[C,j,v,f]);let E=null;E=C?(e=>{for(let o of I){var t;if(null===(t=o.gifts)||void 0===t?void 0:t.find(t=>t.gift_pool_id===e))return o}return null})(p):_||k[0];let Z=C&&(null==E?void 0:E.control_type)===2?null==v?void 0:null===(t=v.coupon)||void 0===t?void 0:t.code:void 0,S=null==E?void 0:E.gifts;return(0,n.jsxs)(i.Z,{sx:{position:"relative",px:2,py:y?1:2,borderRadius:"4px",background:"var(--fortress-palette-brand-flour-100, #FFF8EB)"},children:[T&&j&&(0,n.jsx)(r.Z,{sx:{position:"absolute",top:"50%",left:"50%",zIndex:9}}),(0,n.jsx)(g,{isChangeGift:C,mobileLayout:y,isOpen:j,onToggle:()=>{if(C)null==o||o();else{if(!j)try{A.dt.track(L.y.EVENT_GWP_BANNER_CLICK)({})}catch(e){W.logger.error("Failed to track GWP banner click event",{error:e})}w(!j)}},onChangeClose:u}),(0,n.jsx)(M,{isOpen:j,mobileLayout:y,gifts:S,curCode:Z})]})},K=e=>{let{text:t,color:o,w:r,h:l,sx:a,textSx:s,useMobile:d=!1}=e,{mobile:c}=(0,m.Z)(),u=d||c;return(0,n.jsx)(i.Z,{sx:{color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",background:e=>o||e.palette.brand.terracotta[500],width:r||(u?42:46),height:l||(u?25:29),...a},children:(0,n.jsx)(p.C,{level:d?"caption2":"caption1",sx:{textAlign:"center",color:e=>e.palette.brand.charcoal[0],...s},children:t})})};var X=o(33578);let V=e=>{let{title:t,description:o,cancelText:r="Okay",confirmText:l,onConfirm:a,open:s,onClose:d}=e;return(0,n.jsx)(Z.u_,{"aria-labelledby":"modal-title","aria-describedby":"modal-desc",disableEscapeKeyDown:!0,hideBackdrop:!1,open:s,onClose:(e,t)=>{"backdropClick"!==t&&d()},slotProps:{backdrop:{onClick:e=>{console.log("backdrop click"),e.stopPropagation(),e.preventDefault()}}},children:(0,n.jsxs)(X.Z,{sx:{px:6,py:7,width:"640px"},children:[(0,n.jsx)(Z.A3,{sx:{zIndex:9}}),(0,n.jsxs)(i.Z,{sx:{width:"100%",mb:6},children:[(0,n.jsx)(p.C,{id:"modal-title",level:"h3",textAlign:"center",children:t}),(0,n.jsx)(p.C,{id:"modal-desc",level:"body2",textAlign:"center",sx:{mt:3},children:o})]}),(0,n.jsxs)(D.ZP,{direction:"row",spacing:3,width:"100%",children:[(0,n.jsx)(O.z,{variant:"secondary",fullWidth:!0,onClick:d,children:r}),(0,n.jsx)(O.z,{color:"primary",fullWidth:!0,onClick:a||d,children:l})]})]})})};var $=o(31966),J=o(22402),Q=o(14939),ee=o(81273);let et=l.memo(()=>{var e,t,o,r;let{desktop:d}=(0,m.Z)(),c=(0,a.T)(),u=(0,a.C)(b.zT),{currentPriceBreakCampaign:x,priceBreakCampaign:h}=(0,J.U)(),{orderCampaignGift:f,allFreeGiftCampaignPromotion:g,validCampaignGiftPromotion:v}=(0,a.C)(e=>(0,s.M)(e)),{item_total_exclude_gift:y=0,item_count_exclude_gift:C=0,line_items:j}=null!=u?u:{},_=null!==(o=null==u?void 0:null===(e=u.shipments)||void 0===e?void 0:e.filter(e=>{var t;return null===(t=e.manifest)||void 0===t?void 0:t.some(e=>{let t=null==j?void 0:j.find(t=>
1t.id===e);return t&&!t.preferred_self_collection})}))&&void 0!==o?o:[],k=j.reduce((e,t)=>e+Number(t.preferred_self_collection?t.price:0),0),I=Number(y),T=Number(C),E=Math.max(0,I-Number(k)),Z=(0,l.useMemo)(()=>({progressBarContainer:{backgroundColor:"#F3EFE7",height:"8px",width:"100%",position:"relative",marginTop:"21px"},progressBarFill:{backgroundColor:e=>e.palette.brand.terracotta[500],display:"block",height:"100%",transition:"width 0.5s cubic-bezier(0.35, 0.95, 0.67, 0.99)"},badgeContainer:{position:"absolute",right:-1,top:"50%",transform:"translate(0, -50%)",backgroundColor:"#fff",borderRadius:"50%",width:"17px",height:"17px",display:"flex",justifyContent:"center",alignItems:"center"},badgeIcon:{height:"17px",width:"17px",fill:e=>e.palette.brand.wheat[500],stroke:e=>e.palette.brand.wheat[500]},textLabelBase:{position:"absolute",top:"-100%",display:{xs:"none",sm:"block"},backgroundColor:e=>e.palette.brand.terracotta[500],color:"#fff",padding:"2px 6px",fontSize:"12px",lineHeight:"17px",fontWeight:600,whiteSpace:"nowrap",borderRadius:"2px"},arrowBase:{content:'""',display:"block",position:"absolute",bottom:0,width:0,height:0,border:"3px solid transparent",borderBottom:"none",borderTopColor:e=>e.palette.brand.terracotta[500]},mobileStyles:{"@media (max-width: 768px)":{left:"auto",right:"-10px",transform:"translate(0, -10px)","&::after":{left:"auto",right:"10px",transform:"translate(-100%, 100%)"}}}}),[]),S=(0,l.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return{...Z.textLabelBase,left:e?"-70%":"50%",transform:e?"translate(0, -10px)":"translate(-50%, -10px)","&::after":{...Z.arrowBase,left:e?"83%":"50%",transform:e?"translate(-100%, 100%)":"translate(-50%, 100%)"},...Z.mobileStyles}},[Z]),N=g.length>0,F="SG"===Y.EcEnv.NEXT_PUBLIC_COUNTRY,G=(0,ee.e)({thresholds:null!==(r=null===(t=F?null==u?void 0:u.shipments:_)||void 0===t?void 0:t.map(e=>null==e?void 0:e.free_shipping_threshold))&&void 0!==r?r:[],currentAmount:E,enableFallback:F,fallbackLimit:500,thresholdOffset:F?.01:0});G.limit;let P=G.show,D=G.complete;(0,l.useEffect)(()=>{if(!P&&x){var e;c((0,$.Y)({campaignName:null!==(e=null==h?void 0:h.campaignName)&&void 0!==e?e:"",discount:x.label}))}},[c,h,x,P]),P&&D&&(x||N)&&(P=!1);let O=!1;!f&&v&&(O=!0);let U=!f&&v,B=(0,l.useCallback)((e,t)=>{if(!e.link)return!1;try{A.dt.track(L.y.EVENT_CAMPAIGN_PROGRESS_BAR_LINK_CLICK)({campaignName:e.campaignName,discount:t.label})}catch(o){W.logger.error("Failed to track campaign progress bar link click",{error:o,campaignName:e.campaignName,discount:t.label})}},[]),z=e=>{if(!e)return!0;if(l.isValidElement(e)&&e.type===l.Fragment){let t=l.Children.toArray(e.props.children);return 0===t.length||t.every(z)}return!1},R=null;if(P)R=(0,n.jsxs)(i.Z,{children:[(0,n.jsxs)(p.C,{level:"caption1",sx:{marginBottom:"5px",color:"#323433"},children:[U&&(0,n.jsx)(i.Z,{component:"span",sx:{color:"#323433",mr:1},children:"Free gift unlocked!"}),D?(0,n.jsxs)(n.Fragment,{children:["Congrats, you can now enjoy ",(0,n.jsx)("strong",{children:"Free Shipping"}),"!"]}):(0,n.jsxs)(n.Fragment,{children:["You are ",(0,n.jsx)("strong",{children:(0,w.pU)(G.gap)})," away from Free Shipping!"]})]}),(0,n.jsxs)(i.Z,{sx:Z.progressBarContainer,children:[(0,n.jsx)(i.Z,{sx:{...Z.progressBarFill,width:"".concat(D?"100%":"".concat(G.width,"%"))}}),(0,n.jsxs)(i.Z,{sx:Z.badgeContainer,children:[(0,n.jsx)(Q.f,{sx:Z.badgeIcon}),(0,n.jsx)(i.Z,{sx:S(!1),children:"FREE!"})]})]})]});else if(x)R=(0,n.jsxs)(i.Z,{children:[(0,n.jsxs)(p.C,{level:"caption1",sx:{marginBottom:"5px",color:e=>e.palette.brand.terracotta[500],"& a":{textDecoration:"none",cursor:"pointer","&:hover":{textDecoration:"underline"}}},children:[U&&(0,n.jsx)(i.Z,{component:"span",sx:{color:"#323433",mr:1},children:"Free gift unlocked!"}),(0,n.jsx)(i.Z,{component:"a",onClick:e=>{e.preventDefault(),B(h,x);let t="production"===Y.EcEnv.NEXT_PUBLIC_PRODUCTION_ENV?"https://www.castlery.com":"https://www-test.castlery.com",o="".concat(t,"/").concat(Y.EcEnv.NEXT_PUBLIC_COUNTRY.toLowerCase()).concat(null==h?void 0:h.link);window.open(o,"_blank")},children:(0,n.jsx)("strong",{children:null==h?void 0:h.campaignName})}),(0,n.jsx)(i.Z,{component:"span",children:":"}),(0,n.jsxs)(i.Z,{component:"span",sx:{color:e=>e.palette.brand.charcoal[800],ml:"4px"},children:[(0,w.pU)(Math.max(0,x.limit-I))," more to get"," ",x.label,"!"]})]}),(0,n.jsxs)(i.Z,{sx:Z.progressBarContainer,children:[(0,n.jsx)(i.Z,{sx:{...Z.progressBarFill,width:"".concat(Math.min(100,I/x.limit*100),"%")}}),(0,n.jsxs)(i.Z,{sx:Z.badgeContainer,children:[x.icon&&(0,n.jsx)("svg",{role:"img","aria-label":x.icon,children:(0,n.jsx)("use",{xlinkHref:"#".concat(x.icon)})}),x.label&&(0,n.jsx)(i.Z,{sx:{...S((null==x?void 0:x.mode)==="long"),fontSize:"10px",padding:"1px 2px"},children:x.label})]})]})]});else if(N&&!v){let{quantity:e,amount:t,purchaseType:o}=g[0].min_spend,r=1===o?+(null==t?void 0:t.value):+e,l=1===o?I:T,a=r-l;r>0&&a>0&&(R=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(p.C,{level:"caption1",children:(0,n.jsxs)(i.Z,{children:[d?"Only ":"",(0,n.jsx)("strong",{children:1===o?(0,w.pU)(a):"Quantity ".concat(a," ")}),"more to unlock Free Gift"]})}),(0,n.jsx)(i.Z,{sx:Z.progressBarContainer,children:(0,n.jsx)(i.Z,{sx:{...Z.progressBarFill,width:"".concat(r>0?l/r*100:0,"%")}})})]}))}return z(R)&&!O?null:(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(i.Z,{children:[(0,n.jsx)(i.Z,{sx:{padding:"0 6px"},children:R}),O&&(0,n.jsxs)(i.Z,{sx:{marginTop:z(R)?0:"10px"},children:[!x&&!P&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(p.C,{level:"caption1",sx:{mb:1},children:"Congratulations, you have unlocked a Free Gift!"}),(0,n.jsx)(i.Z,{sx:{...Z.progressBarContainer,mb:1},children:(0,n.jsx)(i.Z,{sx:{...Z.progressBarFill,width:"100%"}})})]}),(0,n.jsx)(q,{})]})]})})});var eo=o(91082),en=o(12428);let ei=e=>{let{yopto_id:t,user:o}=e;return(0,n.jsxs)(eo.W2,{disableGutters:!0,sx:{width:"100%",img:{width:"auto"}},children:[(0,n.jsx)(en.j,{user:o}),(0,n.jsx)("div",{className:"yotpo-widget-instance","data-yotpo-instance-id":t})]})};var er=o(98969),el=o(87765),ea=o(33806),es=o(48486);function ed(e){let t=(0,l.useMemo)(()=>"checkout"===e?es.f4:ea.AD,[e]);return{couponList:(0,y.C)(t),giftPools:(0,y.C)(ea.ps)}}var ec=o(64258),eu=o(31931),ep=o(89742),ex=o(92937),eh=o(9828);function ef(e){let[t,{isLoading:o}]=(0,eu.ze)(),n=(0,y.C)(ep.selectFilteredCouponGifts),i=(null==e?void 0:e.voucherType)===ex.$f.FREE_GIFT,r=(0,l.useCallback)(async()=>{!(!(null==e?void 0:e.code)||!i||(0,eh.tx)(e.code))&&((await t(e.code)).error||(0,eh.MR)(e.code))},[null==e?void 0:e.code,i,t]);return{couponGifts:n,isFreeGiftCoupon:i,isLoading:o,fetchCouponGifts:r}}var eg=o(18316),em=o(95528),ev=o(15431),eb=o(21507),ey=o(10899);function eC(e){let{open:t,onClose:o,gifts:l,loading:a=!1}=e,{mobile:s}=(0,m.Z)();return(0,n.jsx)(Z.u_,{open:t,onClose:o,children:(0,n.jsxs)(X.Z,{sx:{minWidth:s?"90vw":600,maxWidth:s?"90vw":800,maxHeight:"90vh"},children:[(0,n.jsx)(Z.A3,{}),(0,n.jsx)(ev.Z,{children:"Choose Your Free Gift"}),(0,n.jsx)(eb.Z,{children:(0,n.jsxs)(p.C,{level:"caption1",children:["Note: Gifts are subject to stock availability."," ",(0,n.jsx)(v.rU,{href:"/promo-terms",target:"_blank",underline:"always",children:"T&C's apply."})]})}),(0,n.jsx)(ey.iz,{}),a?(0,n.jsx)(i.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:(0,n.jsx)(r.Z,{})}):(0,n.jsx)(i.Z,{sx:{display:"grid",gridTemplateColumns:s?"repeat(2, 1fr)":"repeat(3, 1fr)",gap:2,p:2,maxHeight:"60vh",overflowY:"auto"},children:l.length>0?l.map(e=>(0,n.jsx)(T,{gift:e,mobileLayout:s},e.variantId)):(0,n.jsx)(i.Z,{sx:{gridColumn:s?"span 2":"span 3",textAlign:"center",py:4},children:(0,n.jsx)(p.C,{level:"body2",color:"neutral",children:"No gifts available at the moment"})})})]})})}var ej=o(32370);let ew=e=>{let{open:t,onClose:o,code:d}=e,[u,x]=(0,l.useState)(null),[f,g]=(0,l.useState)(!1),m=(0,a.T)(),y=(0,a.C)(b.zT),[C,j]=(0,l.useState)(!1),[w,_]=(0,l.useState)(!1),{validCouponGiftPromotion:k}=(0,a.C)(s.M),I=(null==k?void 0:k.gifts)||[],E=e=>{x(e),g(!0)},N=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(g(!1),x(null),e){if(null==y?void 0:y.number){j(!0);try{await m(c.yG.initiate({orderNumber:y.number,coupon_code:d})).unwrap()}catch(e){W.logger.error("Failed to fetch gifts after choosing",{error:e,orderNumber:y.number,code:d})}finally{j(!1)}}}else o()};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Z.u_,{"aria-labelledby":"modal-title","aria-describedby":"modal-desc",disableEscapeKeyDown:!0,open:t,sx:{dis
1play:"flex",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw","&:focus-visible":{outline:"none"}},children:(0,n.jsxs)(S.Z,{sx:{p:3,width:700,maxWidth:"90vw",maxHeight:"90vh",position:"relative",display:"flex",flexDirection:"column",alignItems:"center",height:"100%"},children:[C&&(0,n.jsx)(r.Z,{sx:{position:"absolute",top:"50%",left:"50%",zIndex:1e3}}),(0,n.jsx)(i.Z,{onClick:()=>{_(!0)},sx:{position:"absolute",top:16,right:16,cursor:"pointer",display:"flex",alignItems:"center",width:40,height:40},children:(0,n.jsx)(h.x,{sx:{width:24,height:24,fill:e=>e.palette.brand.wheat[500]}})}),(0,n.jsx)(p.C,{id:"modal-title",level:"h3",textAlign:"center",sx:{fontWeight:600,lineHeight:"175%",fontFamily:"Poppins"},children:"Choose Your Free Gift"}),(0,n.jsxs)(p.C,{level:"caption1",textAlign:"center",sx:{color:"var(--fortress-palette-brand-mono-300)"},children:["Note: Gifts are subject to stock availability."," ",(0,n.jsx)(v.rU,{component:"button",underline:"always",sx:{color:"var(--fortress-palette-brand-burntOrange-500) !important",textDecorationColor:"var(--fortress-palette-brand-burntOrange-500) !important"},onClick:()=>{window.open("https://www.castlery.com/".concat(Y.EcEnv.NEXT_PUBLIC_COUNTRY.toLowerCase(),"/promo-terms"),"_blank")},children:"T&Cs apply."})]}),(0,n.jsx)(i.Z,{sx:{width:"100%",height:"1px",m:3,background:e=>e.palette.brand.wheat[500]}}),(0,n.jsx)(i.Z,{sx:{width:"100%",display:"flex",gap:6,flexWrap:"wrap",maxHeight:"80vh",overflowY:"auto",overflowX:"hidden",padding:1},children:null==I?void 0:I.map(e=>(0,n.jsx)(T,{gift:e,posSelectDeliveryModal:E,isCouponModule:!0},e.id))})]})}),(0,n.jsx)(z,{open:f,onClose:N,gift:u,code:d}),(0,n.jsx)(V,{open:w,onClose:()=>_(!1),title:"Don't miss your free gift!",description:"Closing this pop-up will remove the applied gift code.",cancelText:"Cancel",confirmText:"Continue",onConfirm:()=>{_(!1),o()}})]})};var e_=o(50321),ek=o(17848),eI=o(61210)},12428:function(e,t,o){"use strict";o.d(t,{j:function(){return s}});var n=o(63056),i=o(16598),r=o(64273),l=o(49187),a=o(79601);let s=e=>{let{getApi:t=!1,user:o}=e,[s,d]=(0,l.useState)("");return((0,l.useEffect)(()=>{(async()=>{if(!(null==o?void 0:o.email)||!i.EcEnv.NEXT_PUBLIC_YOTPO_API_KEY){d("");return}try{let e=new TextEncoder().encode(o.email.toLowerCase()+i.EcEnv.NEXT_PUBLIC_YOTPO_API_KEY),t=await crypto.subtle.digest("SHA-256",e),n=Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,"0")).join("");d(n)}catch(e){a.logger.error("Failed to generate Yotpo token",{error:e,userId:o.id}),d("")}})()},[null==o?void 0:o.email]),(0,l.useEffect)(()=>{let e=e=>{var t,o,n;if((null===(t=e.message)||void 0===t?void 0:t.includes("trackShown"))||(null===(o=e.filename)||void 0===o?void 0:o.includes("yotpo.com"))||(null===(n=e.filename)||void 0===n?void 0:n.includes("widget-referral-widget")))return e.preventDefault(),e.stopImmediatePropagation(),a.logger.warn("Caught Yotpo initialization error - widget may not be fully loaded",{message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno}),!1};return window.addEventListener("error",e,!0),()=>{window.removeEventListener("error",e,!0)}},[]),i.EcEnv.NEXT_PUBLIC_YOTPO_ENABLED&&i.EcEnv.NEXT_PUBLIC_YOTPO_GUID)?(0,n.jsxs)(n.Fragment,{children:[(null==o?void 0:o.id)&&(null==o?void 0:o.email)&&(0,n.jsx)("div",{id:"swell-customer-identification","data-authenticated":"true","data-email":o.email,"data-id":o.id,"data-tags":'["wholesale"]',style:{display:"none"},"data-token":s}),t?(0,n.jsx)(r.default,{id:"yotpo-api-script",src:"https://cdn-loyalty.yotpo.com/loader/".concat(i.EcEnv.NEXT_PUBLIC_YOTPO_GUID,".js"),strategy:"afterInteractive",async:!0}):(0,n.jsx)(r.default,{id:"yotpo-widget-script",src:"https://cdn-widgetsrepository.yotpo.com/v1/loader/".concat(i.EcEnv.NEXT_PUBLIC_YOTPO_GUID),async:!0,onReady:()=>{let e=0,t=()=>{try{var o,n,i,r;let l=null!==document.querySelector("[data-yotpo-widget-id]")||null!==document.querySelector("[data-yotpo-instance-id]")||null!==document.querySelector(".yotpo-widget-instance"),s=(null===(n=window)||void 0===n?void 0:null===(o=n.yotpoWidgetsContainer)||void 0===o?void 0:o.initWidgets)&&"function"==typeof window.yotpoWidgetsContainer.initWidgets;s&&(l||"complete"===document.readyState)?null===(r=window.yotpoWidgetsContainer)||void 0===r||null===(i=r.initWidgets)||void 0===i||i.call(r):e<50?(e++,setTimeout(t,100)):a.logger.warn("Yotpo widgets initialization timeout after max retries",{hasWidgetContainers:l,isYotpoReady:s})}catch(t){a.logger.error("Failed to initialize Yotpo widgets",{error:t,retryCount:e})}};requestAnimationFrame(()=>{setTimeout(t,200)})}})]}):null}},66504:function(e,t,o){"use strict";o.d(t,{fD:function(){return r},w_:function(){return l},yG:function(){return a}});var n=o(5922),i=o(78700);let{getGiftsByOrderNumberV2:r,addGiftsByOrderNumberV2:l,getGiftsByOrderNumberSilent:a}=n.h.injectEndpoints({endpoints:e=>({getGiftsByOrderNumberV2:e.query({query:e=>{let t=null==e?void 0:e.orderNumber;return{url:"v2/orders/".concat(t,"/promotions/gift"),params:{stock_location_id:null==e?void 0:e.stockLocationId,coupon_code:null==e?void 0:e.coupon_code}}},transformResponse:e=>e.filter(e=>2===e.control_type||e.gifts.some(e=>"OUT_OF_STOCK"!==e.state)).map(e=>({...e,gifts:e.gifts.map(t=>({...t,controlType:e.control_type,promotionId:e.promotion_id.toString()}))})),providesTags:[i.U.Gift],forceRefetch:()=>!0}),getGiftsByOrderNumberSilent:e.query({query:e=>{let t=null==e?void 0:e.orderNumber;return{url:"v2/orders/".concat(t,"/promotions/gift"),params:{stock_location_id:null==e?void 0:e.stockLocationId,coupon_code:null==e?void 0:e.coupon_code}}},transformResponse:e=>e.filter(e=>2===e.control_type||e.gifts.some(e=>"OUT_OF_STOCK"!==e.state)).map(e=>({...e,gifts:e.gifts.map(t=>({...t,controlType:e.control_type,promotionId:e.promotion_id.toString()}))})),providesTags:[{type:i.U.Gift,id:"SILENT"}],forceRefetch:()=>!0}),addGiftsByOrderNumberV2:e.mutation({query:e=>{let{orderNumber:t,...o}=e;return{url:"checkouts/".concat(t,"/gift_v2"),method:"PUT",body:{...o}}}})})}).endpoints},89742:function(e,t,o){"use strict";var n=o(15544);o.o(n,"selectFilteredCouponGifts")&&o.d(t,{selectFilteredCouponGifts:function(){return n.selectFilteredCouponGifts}});var i=o(28320);o.o(i,"selectFilteredCouponGifts")&&o.d(t,{selectFilteredCouponGifts:function(){return i.selectFilteredCouponGifts}})},28320:function(){},15544:function(){}}]);
2//# sourceMappingURL=1131.2f33d77976758d04.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.