1import{f as S}from"./esnext-vendor.BBoIVOQW.js";import{n as C,T as I,a5 as T,aE as k,b4 as x,aP as B,b5 as c}from"./addresses-is-address-empty.ZJ1ThpFy.js";import{aB as G,ad as D}from"./hydrate.Tsur0pib.js";import{p as w,s as E,a as P,b as A}from"./EstimatedDeliveryContent.B6SO5ZZV.js";function $(t){if(t===void 0)return;if(typeof t=="number")return{lower:t,upper:t};const{lower:n,upper:e}=t;if(!(n===void 0||e===void 0))return{lower:n,upper:e}}function N(t){let n,e;for(const{estimatedTimeInTransit:o}of t){const r=$(o);if(!r)return;n=n===void 0?r.lower:Math.min(n,r.lower),e=e===void 0?r.upper:Math.max(e,r.upper)}if(!(n===void 0||e===void 0))return n===e?n:{lower:n,upper:e}}function F(t,n){if(!t)return`unresolved:${n}`;const e=t.deliveryPresentationGroupToken;return e?`token:${e}`:`no-token:${n}:${t.handle}`}function g(t){const n=new Map;return t.forEach(({line:e,method:o},r)=>{const s=F(o,e.id??`index-${r}`);let i=n.get(s);i||(i={key:s,methods:[],merchandiseLines:[],mergedTimeInTransit:void 0,availableOn:e.availableOn},n.set(s,i)),o&&i.methods.push(o),e.targetMerchandiseLines&&i.merchandiseLines.push(...e.targetMerchandiseLines)}),[...n.values()].map(e=>({...e,merchandiseLines:G(e.merchandiseLines),mergedTimeInTransit:N(e.methods)}))}function j(t){const n=t.map(o=>({line:o,method:C(o)})),e=n.filter(v);return{groups:g(e),nonShippableCount:n.length-e.length}}function v({line:t,method:n}){return n?n.methodType==="SHIPPING"||n.methodType==="LOCAL":t.methods.length===0||t.methods.some(({methodType:e})=>e==="SHIPPING"||e==="LOCAL")}function q(t){return{...t,included:!0}}function J(t,n){return[...t.filter(e=>!n(e)),...t.filter(n)]}function O({line:t,method:n,localShopId:e,marketDrivenShippingEnabled:o,remoteShopsConfigMap:r,remoteMerchandiseDetails:s}){const i=c(n);if(!i)return;const a=L(t,s,e);if(H({lineShopId:a,localShopId:e,marketDrivenShippingEnabled:o,remoteShopsConfigMap:r,method:n}))return`${a}:${i}`}function R({line:t,localShopId:n,marketDrivenShippingEnabled:e,remoteShopsConfigMap:o,remoteMerchandiseDetails:r}){const s=L(t,r,n);if(s===n)return e;const i=o?.get(s);return i?i.marketDrivenShippingEnabled:t.methods.some(a=>!!c(a))}function Q(){const{shop:{id:t,marketDrivenShippingEnabled:n,remoteShopsConfigMap:e}}=I(),{deliveryNext:o,remoteMerchandiseDetails:r}=T(),{parts:s}=k();return S(()=>{const i={includedMethods:new Set,total:void 0,presentsConsolidatedShipping:!1,groups:[]},a=o.value;if(!a||a.status!=="filled")return i;const{oneTimePurchaseLines:d}=D(x(a).filter(B));if(d.length<2)return i;const f=(u,l)=>O({line:u,method:l,localShopId:t,marketDrivenShippingEnabled:n,remoteShopsConfigMap:e,remoteMerchandiseDetails:r.value}),h=d.some(u=>R({line:u,localShopId:t,marketDrivenShippingEnabled:n,remoteShopsConfigMap:e,remoteMerchandiseDetails:r.value}));if(!h)return i;const b=w(s.deliveryLines.value),p=E(d,b),m=p.filter(u=>!!u.method),M=m.length===d.length?P(m.map(({line:u,method:l})=>({...l,amountCombinabilityToken:f(u,l)}))):void 0,y=g(p.filter(v));return{includedMethods:A(d,p,f),total:M,presentsConsolidatedShipping:h,groups:y}})}function L(t,n,e){const o=t.targetMerchandiseLines?.[0]?.stableId;return o&&n?.stableIdToShopId.get(o)||e}function H({lineShopId:t,localShopId:n,marketDrivenShippingEnabled:e,remoteShopsConfigMap:o,method:r}){if(t===n)return e;const s=o?.get(t);return s?s.marketDrivenShippingEnabled:r?!!c(r):!1}export{q as a,j as b,g as c,v as i,N as m,J as o,O as r,F as s,Q 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.