import{d as e,bb as n,W as t,aw as r,av as i,cL as o,de as a,df as s,ac as l}from"./4b4bc88f.z1yoAwwH.js";import{d as c}from"./f67abd2c.nPTvXZJz.js";import{T as d,h as u,v as m,G as h,u as p,a8 as f,M as y,F as v,g,o as b,m as P}from"./2c1ab0fe.Dbn2KvkT.js";import{d1 as _,Y as x,k as C,f as T,S,c2 as z,bK as L,b as w,c5 as E,N as k,ao as I}from"./164ad2e3.FTBuhkTQ.js";import{g as D,p as M,T as B}from"./9ce08e25.CVFGyfHb.js";function A(){const{shop:{asyncDeliveryPromiseExperienceEnabled:r},observability:i,checkout:{negotiator:o}}=e(),{value:a}=o.current.fields.deliveryExpectations,s=n("deliveryExpectations").value,{value:l}=o.current.fields.deliveryNext,c=n("deliveryNext").value,m=d();return u(()=>{if(!s&&"filled"===l?.status&&"filled"===a?.status&&m.current&&(m.current(),m.current=void 0),"filled"===l?.status&&s){const e=performance.now();m.current=()=>{const n=performance.now()-e;i.histogram({name:"delivery_expectations_loading_duration",value:n})}}},[a?.status,l?.status,c,s,i]),{deliveryExpectationLines:(()=>{const e=a?.deliveryExpectationLines?.some(({brandedPromise:e})=>e?.handle===t.BuyWithPrime);if("filled"===a?.status&&(r||e))return a?.deliveryExpectationLines})(),deliveryExpectationLinesLoading:void 0===a,status:a?.status}}function O(e){if(e.length<2)return!1;const n=e.map(e=>{const n=r(e);return n?i(n):void 0}),[t]=n;return Boolean(t&&n.every(e=>e===t))}function W(e){const n=[],t=new Map;for(const r of e){const e=o(r)??r.methods[0],a=e&&i(e),s=a?t.get(a):void 0;if(s)s.push(r);else{const e=[r];a&&t.set(a,e),n.push(e)}}return n.length===e.length?e:n.map(e=>{const n=e[0];return 1===e.length&&n?n:function(e){const n=a(e.map((e,n)=>({index:n,rate:e})),N).rate,t=e.flatMap(e=>e.targetMerchandiseLines??[]),r=o(n)??n.methods[0];return{...n,methods:r&&r!==n.methods[0]?[r,...n.methods.filter(e=>e!==r)]:n.methods,targetMerchandiseLines:t.length?t:n.targetMerchandiseLines}}(e)})}function N(e){const n=o(e)??e.methods[0],t=n?.priceBreakdown?.map(({amount:e})=>e.amount);return t?.length?Math.max(...t):n?.cost.amount??0}function U(e){const n=new Map;for(const t of e){const e=t.fields.id.value,r=t.fields.deliveryMethodHandle.value;e&&r&&n.set(e,r)}return n}function $(e,n){return e.map(e=>{const t=e.id?n.get(e.id):void 0;return{line:e,method:e.methods.find(({handle:e})=>e===t)}})}function j(e,n,t=(e,n)=>i(n)){const r=n.map(({line:e,method:n},r)=>({lineIndex:r,amountCombinabilityToken:n?t(e,n):void 0,amount:n?.cost.amount})),o=new Set;return e.forEach((e,n)=>{for(const i of e.methods){const a=i.cost.amount,s=t(e,i);s&&(r.some(e=>e.lineIndex!==n&&e.amountCombinabilityToken===s&&void 0!==e.amount&&(e.amount>a||e.amount===a&&e.lineIndex({costBeforeDiscounts:e.cost.amount,cost:e.costAfterDiscounts.amount,amountCombinabilityToken:i(e)})));return{totalCost:{amount:t,currencyCode:n.cost.currencyCode},totalCostAfterDiscounts:{amount:r,currencyCode:n.costAfterDiscounts.currencyCode}}}function F(e){const n=m(()=>D(e),[e]);return{theme:m(()=>M(n),[n])}}function X({brandedPromise:e,useCompactLogo:n}){const t=d(null),[r,i]=h(null);u(()=>{i(t.current)},[t]);const{theme:o}=F(r),a=K(o,e,t,n);return p("div",{ref:t,className:"Hlr02",children:a})}const K=(e,n,t,r)=>{if(e&&t.current){const t=R(e,n,r);if(t)return p(_,{src:t,alt:n.name,aspectRatio:"auto",className:q(n,t,r)})}return null},R=(e,n,t)=>{const r=e===B.Dark?"dark":"light";return n[`${r}Theme${t?"CompactLogoUrl":"LogoUrl"}`]||n[`${r}ThemeLogoUrl`]||n.logoUrl||""},q=(e,n,t)=>{if(((e,n)=>"shop_promise"===e.handle&&n.includes("shop_promise_2026"))(e,n))return t?"jrKZE":"TtorW"};function G({methodTitle:e,price:n,showInterpunct:t=!1,sellingPlan:r}){const i=p("bdi",{children:e});return p(V,n&&t&&r?{children:[i,x,n,p(C,{type:"strong",children:r})]}:t&&n?{children:[i,x,n]}:{children:i})}function V({children:e}){const n=f.toArray(e).flatMap((e,n,t)=>nP,x=e=>e?p(C,{accessibilityVisibility:"exclusive",children:e}):null,T=({cost:e,accessibilityContext:n,isOriginalPrice:t=!1})=>{const r=0===e.amount;let o=m;return t&&(o=i?"base":"small"),p(y,r?{children:[x(n),p(C,{type:g,size:o,letterCase:f,children:d.translate("shipping.free_rate_label")})]}:{children:[x(n),p(C,{type:t?"redundant":g,color:t?"subdued":void 0,size:o,translate:!1,children:d.formatCurrency(e.amount,{currency:e.currencyCode})})]})},L=T({cost:t,accessibilityContext:_?d.translate("order_summary.price_after_discount_aria_text"):void 0});if(r&&P>0){const e=T({cost:t,accessibilityContext:d.translate("order_summary.original_price"),isOriginalPrice:!0}),n=p(z,{size:m,strong:h});return p(S,i?{direction:"inline",display:"inline",gap:l(v),alignItems:"baseline",children:[e,n]}:{gap:l(v),alignItems:"end",children:[e,n]})}if(o)return T({cost:n,accessibilityContext:d.translate("order_summary.original_price")});if(_){const e=T({cost:n,accessibilityContext:d.translate("order_summary.original_price"),isOriginalPrice:!0});return p(S,i?{direction:"inline",display:"inline",gap:l(v),alignItems:"baseline",children:[e,L]}:{gap:l(v),alignItems:"end",children:[e,L]})}return L}var ee=(e=>(e.Sync="Sync",e.Async="Async",e))(ee||{});const ne=new Map([[t.BuyWithPrime,"Sync"],["shop_promise","Async"]]);function te({show:e,children:n,from:t={opacity:0},to:r={opacity:1},options:i={duration:500,fill:"forwards"},onStart:o,onEnd:a,animateOnShow:s=!0,animateOnHide:l=!0,unmountOnHide:c=!0}){const m=d(null),[f,y]=h(e),g=()=>{y(!1),a?.()},b={duration:500,fill:"forwards",...i};return v(()=>{if(f&&s){const e=m.current;if(e&&"function"==typeof e.animate)try{e.animate([t,r],b)}catch{}}},[f,s]),u(()=>{const n=m.current;if(e)o?.(),y(!0);else if(l&&n&&"function"==typeof n.animate)try{const e=n.animate([r,t],b);e&&(e.onfinish=g)}catch{g()}else g()},[e,l]),f||!c?p("div",{ref:m,children:n}):null}const re=g(function({timeInTransit:e,price:n,textSize:t,paragraphColor:r}){const i=L()(e);return null===i?null:p(T,{color:r,size:t,children:[p("bdi",{children:n?`(${i})`:i}),n?` · ${n}`:null]})});function ie({title:e,price:n,textSize:t,paragraphColor:r}){return p(T,!e&&n?{color:r,children:n}:{color:r,size:t,children:[p("bdi",{children:n?`(${e})`:e}),n?` · ${n}`:null]})}const oe=g(function({timeInTransit:e,title:n,price:t,textSize:r,paragraphColor:i}){return n?p(ie,{title:n,price:t,textSize:r,paragraphColor:i}):e?p(re,{timeInTransit:e,price:t,textSize:r,paragraphColor:i}):t?p(T,{color:i,size:r,children:t}):null});function ae(n,t){const{i18n:r}=e(),{brandedPromise:i}=t||{},{deliveryPromisePresentmentTitle:o}=n,{deliveryExpectationPresentmentTitle:a}=t||{},s=o?.short||"",l=o?.long||"",c=(e,n)=>n?e?.handle?n:r.translate("delivery_promise.estimated_delivery_format",{date:n}):"",d=c(i,a?.short),u=c(i,i?.handle?a?.long:a?.short);return{shouldDisplayPlaceholderTitle:Boolean((l||s)&&!u&&!d),deliveryPromiseTitle:u,deliveryPromiseTitleShort:d,deliveryPromisePlaceholderTitle:l,deliveryPromisePlaceholderTitleShort:s}}const se={ShopPromiseWrapper:"x45Lq",WrapperHeightSmall:"m39UP",Branded:"_5XR55",Unbranded:"PWTWF"};function le({deliveryMethod:n,deliveryExpectationLine:t,estimatedTimeInTransit:r,hideDescription:i,formatContent:o=e=>e,paragraphColor:a,size:s}){const{deliveryPromiseTitle:l,deliveryPromisePlaceholderTitleShort:c,deliveryPromisePlaceholderTitle:m,deliveryPromiseTitleShort:f,shouldDisplayPlaceholderTitle:v}=ae(n,t),[g,P]=h(Boolean(l)),_=d(v),x=d(!1),C=d(null),[z,L]=h(null),{theme:k}=F(z),{observability:I,checkout:D}=e(),{shippingAddress:M}=D.negotiator.parts,B="shop_promise"===t?.brandedPromise?.handle,A=ce(k,t?.brandedPromise?.handle),O=D.configuration.layout.isOnePage.value,{short:W,long:N}=t?.deliveryExpectationPresentmentTitle||{};u(()=>{L(C.current)},[C]),u(()=>{if(!x.current&&(W||N)){x.current=!0;const e=M.value.countryCode;I.counter({name:"estimated_delivery_date_rendered",value:1,attributes:{branded:String(B),...e&&{country_code:e}}})}},[W,N,B,M,I]);const U=l||f,$=m||c,j=n.description?.trim()||void 0;return U||$||B||j&&!i?o(p(S,{children:[(U||$||B)&&p("div",{className:b(se.ShopPromiseWrapper,"small"===s?se.WrapperHeightSmall:void 0),ref:C,children:[p(te,{show:v&&!l,options:{duration:300},onEnd:()=>P(!0),animateOnShow:!1,children:$&&r||!r?p(y,{children:c&&p(T,{color:a,size:s,children:p(E,{children:c})})}):p(oe,{timeInTransit:r,textSize:O?void 0:"small",paragraphColor:a})}),p(te,{animateOnShow:_.current,show:g,from:{opacity:0,transform:"translateX(-10px)"},to:{opacity:1,transform:"translateX(0)"},children:p("div",{className:se[A],children:p(S,{direction:"inline",gap:"small-300",alignItems:"center",children:[p(w,{display:"@media (inline-size >= small) auto, none",children:l&&p(T,{color:a,size:s,children:l})}),p(w,{display:"@media (inline-size >= small) none, auto",children:f&&p(T,{color:a,size:s,children:f})}),B&&t?.brandedPromise&&p(X,{brandedPromise:t.brandedPromise,useCompactLogo:"small"===s})]})})})]}),j&&!i?p(T,{color:a,size:s,children:p("bdi",{children:j})}):null]})):null}const ce=(e,n)=>"shop_promise"===n?e===B.Light?"Branded":"":"Unbranded";function de({deliveryExpectationLine:n,deliveryMethod:t,formatContent:r=e=>e,size:i}){const{observability:o,checkout:a}=e(),s=P(()=>function({identity:e}){return"shopPay"===e.current.value}(a)),{deliveryPromiseTitle:l,deliveryPromiseTitleShort:c,deliveryPromisePlaceholderTitle:h,deliveryPromisePlaceholderTitleShort:f}=ae(t,n),{deliveryExpectationLinesLoading:v}=A(),g=m(()=>l||c?{long:l,short:c,fallback:!1}:h||f?{long:h,short:f,fallback:!0}:{long:"",short:"",fallback:!1},[h,f,l,c]),b=d(v);return u(()=>{b.current&&!v&&"buy_with_prime"===t.brandedPromise?.handle&&g.fallback&&(o.log("synch_branding_delivery_content_fallback_promise_shown","Fallback delivery promise shown",{is_shop_pay:s.value}),o.counter({name:"membership_fallback_delivery_promise_text_shown",value:1,attributes:{is_shop_pay:s.value}}))},[v,t.brandedPromise?.handle,b,s,o,g.fallback]),r(p(S,{direction:"inline",gap:"none small-400",alignItems:"center",children:[v?p(k,{inlineSize:"small"}):p(y,{children:[p(I,{below:"small",children:p(T,{size:i,children:g.long})}),p(I,{above:"extraSmall",children:p(T,{size:i,children:g.short})})]}),t.brandedPromise&&p(X,{brandedPromise:t.brandedPromise,useCompactLogo:"small"===i})]}))}function ue(e){const{deliveryMethod:n,deliveryExpectationLine:t}=e,r=n.brandedPromise?.handle??t?.brandedPromise?.handle;return(r?ne.get(r):ee.Async)===ee.Sync?p(de,{...e}):p(le,{...e})}export{X as B,ue as E,G as S,Q as a,j as b,H as c,W as d,oe as e,O as i,U as p,$ as s,A as u};