1import{f as u,c as m,A as y}from"./esnext-vendor.D7ldIee_.js";import{$ as d,O as S,b4 as R,N as O}from"./addresses-is-address-empty.-MuOhIyI.js";import{E as l,S as b,t as A,a as M}from"./utilities-shopCashMoney.B9eyOzz9.js";const P=e=>e.method.type==="redeemable"&&e.method.redemptionSource==="SHOP_CASH",f=e=>{if(!e)return l;if(!e.method.redemptionContent?.details)return l;const t={...l};for(const o of e.method.redemptionContent.details){const n=b.find(r=>r===o.redemptionType);if(n===void 0)continue;const a={id:o.redemptionId??n,promotionId:n==="SHOP_PROMOTION"?o.redemptionId:void 0,type:n,destinationAmount:M(o.destinationAmount),sourceAmount:A(o.sourceAmount)};n==="SHOP_PROMOTION"?t.SHOP_PROMOTION=[...t.SHOP_PROMOTION,a]:t[n]=a}return t},K=(e,t)=>{const o=e[t];return Array.isArray(o)?o.length>0:o!=null},D=()=>{const{paymentLines:e}=d();return u(()=>f(e.value?.lines.find(P)))},k=()=>{const{paymentLines:e}=S();return u(()=>f(e.value?.find(P)))},i=(e,t=2)=>Math.round(e*10**t)/10**t,h=e=>({...e,amount:i(e.amount,m(e.currencyCode))}),v={USD:.5,AED:2,ARS:.5,AUD:.5,BRL:.5,CAD:.5,CHF:.5,COP:.5,CZK:15,DKK:2.5,EUR:.5,GBP:.3,HKD:4,HUF:175,IDR:.5,ILS:.5,INR:.5,JPY:50,KRW:50,MXN:10,MYR:2,NOK:3,NZD:.5,PHP:.5,PLN:2,RON:2,RUB:.5,SEK:3,SGD:.5,THB:10,ZAR:.5},p=.5,T=e=>e?v[e]??p:p,N=()=>{const e=d().subtotalAfterMerchandiseDiscounts,t=R(),o=I(),n=H();return u(()=>{const a=t.value,r=a?{amount:i(a.amount-o.value-n.value,m(a.currencyCode)),currencyCode:a.currencyCode}:void 0;return{orderTotal:a,orderSubtotal:e.value,redeemableTotal:r}})},E=e=>e.method.type==="giftCard",_=e=>e.method.type==="redeemable",B=e=>e.method.redemptionSource==="SHOP_CASH",I=()=>{const{paymentLines:e}=d();return u(()=>(e.value?.lines??[]).reduce((o,n)=>n.cost&&(E(n)||_(n)&&!B(n))?o+n.cost.amount:o,0))},H=()=>{const e=D();return u(()=>Object.values(e.value).flatMap(t=>Array.isArray(t)?t:[t]).reduce((t,o)=>!o||o.type==="SHOP_CASH_BALANCE"?t:t+o.destinationAmount.amount,0))};function F(){const e=y([]),t=N(),{checkout:o}=O(),n=o.proposal.negotiated.fields.shopPromotion;return u(()=>{const{orderTotal:a}=t.value,r=n.value;return r?.status==="filled"?e.current=r.promotions:r?.status==="unavailable"&&(e.current=[]),C(e.current,a)})}function C(e,t){if(!t)return e;const o=[];let n=t;for(const a of e){if(n.amount<=0)break;const r=a.availableBalance;if(!r||r.amount<=0)continue;const s=r.amount>=n.amount?{...a,availableBalance:n}:a;o.push(s),n=h({amount:n.amount-s.availableBalance.amount,currencyCode:n.currencyCode})}return U(o,n)}function x(e,t){return!e||!t?e:C([e],t)[0]??null}function U(e,t){const o=T(t.currencyCode);if(t.amount<=0||t.amount>=o)return e;const n=m(t.currencyCode),a=[...e];let r=i(o-t.amount,n);for(;r>0;){const s=a.pop();if(!s)break;const c=s.availableBalance;c.amount>r?(a.push({...s,availableBalance:h({amount:c.amount-r,currencyCode:c.currencyCode})}),r=0):r=i(r-c.amount,n)}return a}export{D as a,N as b,x as c,h as d,F as e,T as g,K as h,P as i,i as r,k as u};
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.