import{m as t}from"./shop-pay-FullScreenBackground.DlV2XN9a.js";class l extends Error{constructor(){super(...arguments),this.name="StaleNegotiationError"}}class o extends Error{constructor(){super(...arguments),this.name="MissingNegotiationDataError"}}class u extends Error{constructor(){super(...arguments),this.name="UnactionableGraphQLExecutionError"}}class d extends Error{constructor(r,n){super(r),this.name="NegotiationFailedError",this.reportable=n}}class m extends Error{constructor(){super(...arguments),this.name="GenericError"}}class c extends Error{constructor(){super(...arguments),this.name="UnexpectedNegotiationResult"}}class f extends Error{constructor(){super(...arguments),this.name="EmptyMerchandiseLinesNegotiationResult"}}function p(e){const{__typename:r,...n}=e;return n}function y(e){const r=e?.attributions.find(n=>n.__typename==="DraftOrderAttributions");if(r)return{draftOrder:{userId:r.userIdentifier,locationId:r.locationIdentifier,sourceName:r.sourceName}}}function g(e){if(e?.attributions&&e?.attributions.length!==0){const r=[];return e?.attributions.forEach(n=>{let a;n.recipient.__typename==="Location"?a={location:{id:n.recipient.id}}:n.recipient.__typename==="StaffMember"?a={staffMember:{id:n.recipient.id}}:n.recipient.__typename==="PointOfSaleDevice"&&(a={pointOfSaleDevice:{id:n.recipient.id}}),a&&r.push({recipient:a,targetMerchandiseLines:i(n.targetMerchandiseLines)})}),{attributions:r}}}function i(e){return e.__typename==="FilledMerchandiseLineTargetCollection"?{lines:e.linesV2.reduce((r,n)=>n.__typename!=="MerchandiseLine"&&n.__typename!=="MerchandiseBundleLineComponent"?r:[...r,{stableId:n.stableId}],[])}:e.__typename==="AnyMerchandiseLineTargetCollection"?{any:e.any}:{}}function v({deliveryExpectations:e}){switch(e?.__typename){case void 0:case"PendingTerms":return;case"UnavailableTerms":return{status:"unavailable",deliveryExpectationLines:null};case"FilledDeliveryExpectationTerms":return{status:"filled",deliveryExpectationLines:e.deliveryExpectations}}}function b(e){switch(e.__typename){case"FilledMembershipTerms":return{status:"filled",memberships:e.memberships.map(r=>({apply:r.apply,handle:r.handle}))};case"PendingTerms":return{status:"pending"};case"UnavailableTerms":return{status:"unavailable"}}}function _(e){if(e)switch(e.__typename){case"PendingTerms":return{status:"pending",taskId:e.taskId??void 0,pollDelay:e.pollDelay??void 0};case"FilledShopCashBalance":return{status:"filled",availableBalance:t(e.availableBalance),eligible:e.eligible??void 0,nonEligibleReason:e.nonEligibleReason,redeemableBalance:e.redeemableBalance?t(e.redeemableBalance):void 0};case"UnavailableTerms":return{status:"unavailable"};default:return}}function E(e){if(e)switch(e.__typename){case"PendingTerms":return{status:"pending",taskId:e.taskId??void 0,pollDelay:e.pollDelay??void 0};case"FilledShopPromotion":return{status:"filled",promotions:e.promotions.map(r=>({promotionId:r.promotionId,availableBalance:t(r.availableBalance)}))??[]};case"UnavailableTerms":return{status:"unavailable"};default:return}}function I(e){if(e)switch(e.__typename){case"PendingTerms":return{status:"pending",taskId:e.taskId??void 0,pollDelay:e.pollDelay??void 0};case"FilledShopDiscountOffer":return{status:"filled",discountOffer:{adType:e.discountOffer?.adType??null,campaignHandle:e.discountOffer?.campaignHandle??null,offerAmount:e.discountOffer?.offerAmount?t(e.discountOffer.offerAmount):t({amount:"0",currencyCode:"USD",__typename:"Money"}),minimumOrderValue:e.discountOffer?.minimumOrderValue?t(e.discountOffer?.minimumOrderValue):null,minimumOrderValueRemainder:e.discountOffer?.minimumOrderValueRemainder?t(e.discountOffer?.minimumOrderValueRemainder):null,minimumOrderValueSatisfied:e.discountOffer?.minimumOrderValueSatisfied??!1}};case"UnavailableTerms":return{status:"unavailable"};default:return}}export{f as E,m as G,o as M,d as N,l as S,c as U,v as a,p as b,_ as c,y as d,E as e,I as f,u as g,b as m,g as s};
