PageSourceSearch

https://goodearth.com/cdn/shopifycloud/checkout-web/assets/c1/56bd1136.BNLT44gz.js

js goodearth.com collected 2026-10-03 22:06:25 UTC 25,257 bytes, 1 lines download raw bytes

1import{q as e,l as a,m as t,s as r,T as n,u as o,t as i,U as s,V as l,x as u,S as c}from"./2c1ab0fe.GMbxnz74.js";import{fu as d,fv as m,fw as p,au as y,fx as h,B as v,fy as f,fz as _,d3 as g,fA as P,i as w,eM as b,fB as A,fC as k,R as x,fD as S,fE as E,fF as z,a1 as I,fG as B,bH as C,d4 as W,fH as D,e as M,fI as T,fJ as F,fK as N,bB as L,fL as O,fM as R,f4 as U,u as j,fN as q,eJ as H,fO as $,eL as J,fP as G,fQ as Y,fR as Q}from"./164ad2e3.B4L1MRYB.js";import{S as V,a1 as X,cf as K,a9 as Z,T as ee,W as ae,fn as te,fo as re,fp as ne,fq as oe,fr as ie,fs as se,ft as le,fu as ue,fv as ce,J as de,a_ as me,bh as pe,fw as ye,y as he,bG as ve,fx as fe,aa as _e,fy as ge}from"./4c290a1e.DMQ9xOwP.js";import{S as Pe}from"./3a819064.DvJdzPv7.js";import{u as we,W as be}from"./8536083a.mfSjjx3G.js";import{S as Ae}from"./app.DGSHpWaV.js";import{I as ke,a as xe,B as Se}from"./4aab4b34.WC8lWpKa.js";import{u as Ee}from"./ac5a19ff.BchXgW63.js";import"./9f047e05.DwjCPgK0.js";import"./0a7dffce.BcNpdEJk.js";import"./5fda1420.BLaDhoyL.js";import"./60a453ce.Cg9T1Gj2.js";import"./21cc90a2.Ccyorzx_.js";import"./bb728e1c.CHt2JlPY.js";function ze({formContainer:e,url:a,requestPayload:t}){const r=document.createElement("form");r.action=a,r.method="POST",r.style.display="none";const n=JSON.parse(t);return Object.entries(n).forEach(([e,a])=>{const t=document.createElement("input");t.type="hidden",t.name=e,t.value=a,r.appendChild(t)}),e.appendChild(r),r}class Ie extends Ae{constructor(){super(...arguments),this.name="AmazonPaySandboxError"}}function Be(){const{observability:e}=V(),{persistedAmazonSignal:a}=Z(),{onClick:t}=f();return r(r=>{e.counter({name:"WalletsPlatform_buy_with_prime_terminal_error_count",value:1,attributes:{reason:r}}),e.log("use_handle_buy_with_prime_terminal_error_detected",`Buy with Prime is not available because ${r}`,{cause:r,severity:"warning"}),t?.(()=>_(a,{primeError:r}))},[e,t,a])}function Ce(e,a){return async t=>e.measureAsync({name:"WalletsPlatform_buyer_details_latency",attributes:{wallet:a},functionToMeasure:t})}function We(e){return!ke.has(e)}function De({walletName:e,excludedErrorTypes:a=[]}){const{observability:t}=V();return r((r,n="error")=>{a.some(e=>r instanceof e)||t.error(r,{severity:n}),t.log(`${e}_error_notified`,r.message,{severity:n,cause:r.cause,errorType:r.name})},[a,t,e])}const Me={id:"55a240bbf1386e2987f86781b73e076031d227ebda7d438859a61d65c2305518",type:"query",name:"WalletsPlatformBuyerDetails",source:""};class Te extends Ae{constructor(){super(...arguments),this.name="BuyerDetailsContractError",this.terminalErrorReason="buyer_details_contract_error"}}class Fe extends Ae{constructor(){super(...arguments),this.name="BuyerDetailsAPIError",this.terminalErrorReason="buyer_details_api_error"}}class Ne extends Error{constructor(){super(...arguments),this.name="BuyerDetailsMissingAmazonExternalIdError",this.terminalErrorReason="buyer_details_missing_amazon_external_id"}}class Le extends Error{constructor(){super(...arguments),this.name="BuyerDetailsMissingAmazonExternalIdUnsupportedSourceError",this.terminalErrorReason="buyer_details_missing_amazon_external_id_unsupported_source"}}const Oe=async({walletName:e,graphql:a,token:t,observability:r,telemetryEventName:n,expressWalletInCheckout:o})=>{let i="";const u=async()=>{const{data:r,error:n}=await a.staticQuery(Me,{cache:!1,variables:i?{pendingTask:{taskId:i}}:{buyerDetailsCreate:{token:t,walletName:e,walletInstrumentation:{expressWalletInCheckout:o}}}});if(null!=n)throw new Fe(`fetchBuyerDetails failed ${n.message} on ${e}`,{groupingHash:"BuyerDetailsAPIError::fetchBuyerDetails::GraphQLError"});if(null==r)throw new Fe(`fetchBuyerDetails returned no data on ${e}`,{groupingHash:"BuyerDetailsAPIError::fetchBuyerDetails::NoData"});return r};let c=0;for(;;){const{walletsPlatformBuyerDetails:e}=await u();switch(e.__typename){case"PendingTask":if(i=e.taskId,c+=1,c>=5)throw new Fe("fetchBuyerDetails exceeded max polling",{groupingHash:"BuyerDetailsAPIError::fetchBuyerDetails::MaxPollingExceeded"});await l(e.pollDelay);break;case"WalletsPlatformBuyerDetailsFetchFailed":throw r.counter({name:n,value:1,attributes:{result:"false"}}),new Fe(`fetchBuyerDetails failed ${e.code}`,{groupingHash:"BuyerDetailsAPIError::fetchBuyerDetails::FetchFailed"});case"WalletsPlatformBuyerDetailsFetchSuccess":return r.counter({name:n,value:1,attributes:{result:"true"}}),e;default:s(e)}}};function Re(){const{shop:e,observability:a,checkout:t}=V(),{negotiate:n}=w(),{onClick:o}=b(),i=A(),s=e.hasFlagEnabled(se),l=t.isCheckoutLayoutForcedToOnePage;return r(async e=>{a.counter({name:"WalletsPlatform_amazon_pay_terminal_error_count",value:1,attributes:{reason:e}}),a.log("use_handle_amazon_pay_terminal_error_detected",`Amazon Pay is not available because ${e}`,{cause:e,severity:"warning"}),s&&l.value?o?.():(i(),await n({}))},[a,o,i,s,l,n])}function Ue(){const{checkout:e,shop:a}=V(),r=e.configuration.layout.isOnePage.value,n=Re(),o=a.hasFlagEnabled(se),i=D(),s=e.extensibility.ui.hasAtRiskPlacement.value;return function(){const e=Ee(),{progressing:a}=w(),r=a.value,{currentDetour:n}=M().value,o=Re(),{observability:i}=V();t(()=>{if(!e.value||n||r)return;const{expiration_timestamp:a}=T(e.value.method.walletParams);!a||Date.now()<new Date(a).getTime()||(i.counter({name:"WalletsPlatform_amazon_pay_session_expired_count",value:1}),o("session_expired"))},[e.value,n,r,o,i])}(),function(){const e=function(){const e=ae().paymentLines.value,[a]=ce(e,[X.AmazonPay]);return!a}(),a=k(),{nextPage:r}=x(),{inMemoryAmazonPayParts:{buyerDetails:n}}=Z(),{progress:o,negotiate:i}=w(),s=Re(),[l,c]=u(!1),{clearError:d}=S(),{setBlocking:m}=E(),p=P(),y=p[le],h=p[oe],{checkout:v,router:f,observability:_,graphql:{coreGraphql:g}}=V(),b=v.configuration.layout.isOnePage.value,A=v.isCheckoutLayoutForcedToOnePage.value,{searchParams:C}=f.currentUrl.value,W=function(){const{observability:e}=V();
1return function(a){if("InvalidWalletPrefillingAddress"===a.prefillingShippingAddress?.__typename){const t=a.prefillingShippingAddress.validationErrors.filter(({code:e})=>We(e)).map(e=>e.code).join(", ");t&&e.counter({name:"WalletsPlatform_buyer_details_invalid_wallet_prefilling_shipping_address",value:1,attributes:{wallet:X.AmazonPay,errorCode:t}})}if("InvalidWalletPrefillingAddress"===a.prefillingBillingAddress?.__typename){const t=a.prefillingBillingAddress.validationErrors.filter(({code:e})=>We(e)).map(e=>e.code).join(", ");t&&e.counter({name:"WalletsPlatform_buyer_details_invalid_wallet_prefilling_billing_address",value:1,attributes:{wallet:X.AmazonPay,errorCode:t}})}return{buyerDetails:a}}}(),D=De({walletName:X.AmazonPay,excludedErrorTypes:[Fe]}),M=z(X.AmazonPay);I({active:l});const T=B();t(()=>{if(!y)return;e&&v.unstable_overwriteLatestReceipt(void 0);const t="true"!==C.get("storefront_wallet");if(T({keep:A?["wallet"]:[]}),h)return;v.wallets.setEscalatedWallet(X.AmazonPay);const l=()=>b&&v.wallets.escalatedWallet.value!==X.AmazonPay;c(!0),(async()=>{v.wallets.setActiveSession({newValue:X.AmazonPay,asPaymentMethod:!1}),await(async()=>{m(!0,xe),n.value={...n.value,loading:!0};const e=Ce(_,X.AmazonPay),s=await e(()=>Oe({walletName:X.AmazonPay,graphql:g,token:y,observability:_,telemetryEventName:"WalletsPlatform_buyer_details_count",expressWalletInCheckout:t}));if(l())return;const u=W(s);d(),n.value={...n.value,details:u.buyerDetails},t&&M(),a(X.AmazonPay,u.buyerDetails),m(!1,xe),v.wallets.clearActiveSession({invokingWallet:X.AmazonPay}
1),b||"thankYou"===r.id?await i({}):await o("amazon-pay-buyer-details-loaded")})().then(()=>{n.value={...n.value,error:!1}}).catch(e=>{D(e),l()||(n.value={...n.value,error:!0},s("buyer_details_failure"))}).finally(()=>{v.wallets.clearActiveSession({invokingWallet:X.AmazonPay}),m(!1,xe),n.value={...n.value,loading:!1},c(!1)})})()},[])}(),function(){const e=V().checkout.latestReceipt.value?.id,a=Re(),{hasError:r}=C(ue),n=Boolean(W(X.AmazonPay).value),o=B(),i=D(),{persistedAmazonSignal:s,inMemoryAmazonPayParts:{buyerDetails:l}}=Z();t(()=>{n&&(r&&s.value?.receiptIdForAupError!==e?(_(s,{receiptIdForAupError:e}),a("aup")):i&&(o({only:["amazon_cancelled"]}),l.value={...l.value,error:!0},a("amazon_cancelled")))},[r,n,e,l,i,s.value?.receiptIdForAupError,s,o,a])}(),t(()=>{!o||r||i||s||n("3p_deceleration_to_1p")},[]),null}class je extends Error{constructor(){super(...arguments),this.name="BuyWithPrimeAddressUpdatedNoPromiseIdError",this.terminalErrorReason="buyer_details_address_updated_no_promise_id_error"}}const qe=[je,Ne,Le,Te,Fe];function He(){const e=k(),a=function(){const{externalDeliveryIds:e}=ae();return function(a){e.value=a}}(),n=function(){const{attributes:e}=ae();return()=>{const a=e.peek();e.value=fe(a??[])}}(),{persistedAmazonSignal:o,inMemoryAmazonPayParts:{buyerDetails:i}}=Z(),{client:s,observability:l,checkout:{wallets:c},graphql:{coreGraphql:d}}=V(),{negotiate:m}=w(),p=Be(),[y,h]=u(!1),{clearError:v}=S(),f=ae().interfaceFlow,g=function(){const{externalDeliveryIds:e}=ae();return r(()=>e.value,[e])}(),{amazonCheckoutSessionId:b,promiseId:A}=P(),x=function(){const{observability:e,source:{type:a}}=V(),t=!F().value;return function(r,n){let o;if((!r||!n)&&t){const t=[];r||t.push("amazonCheckoutSessionId"),n||t.push("promiseId"),function(e){return!["abandonedCart","other"].includes(e)}(a)?(e.counter({name:"WalletsPlatform_buyer_details_buy_with_prime_missing_external_ids_count",value:1,attributes:{missing_promise_id:String(!n),missing_amazon_checkout_session_id:String(!r)}}),o=new Ne(`Amazon external ids are missing: ${t.join(", ")}`)):o=new Le(`Amazon external ids are missing: ${t.join(", ")}. Unsupported source detected: ${a}`)}return{externalCheckoutSessionId:r,externalPromiseId:n,error:o}}}(),E=function(){const{observability:e}=V(),{persistedAmazonSignal:a}=Z();return r((t,r,n)=>{if(!t.walletParams)return e.counter({name:"WalletsPlatform_buyer_details_missing_wallet_params_count",value:1,attributes:{wallet:X.BuyWithPrime}}),{error:new Te("Buyer details returned do not contain 'walletParams'.",{groupingHash:"BuyerDetailsContractError::BuyerDetailsMissing::WalletParams"})};if("InvalidWalletPrefillingAddress"===t.prefillingShippingAddress?.__typename){const a=t.prefillingShippingAddress.validationErrors.filter(({code:e})=>We(e)).map(e=>e.code).join(", ");a&&(e.log("buy_with_prime_invalid_wallet_prefill_address_detected",`Buyer details shipping address has an InvalidWalletPrefillingAddress: ${a}`,{severity:"warning"}),e.counter({name:"WalletsPlatform_buyer_details_invalid_wallet_prefilling_shipping_address",value:1,attributes:{wallet:X.BuyWithPrime}}))}if("InvalidWalletPrefillingAddress"===t.prefillingBillingAddress?.__typename){const a=t.prefillingBillingAddress.validationErrors.filter(({code:e})=>We(e)).map(e=>e.code).join(", ");a&&(e.log("buy_with_prime_invalid_wallet_prefill_address_detected",`Buyer details billing address has an InvalidWalletPrefillingAddress: ${a}`,{severity:"warning"}),e.counter({name:"WalletsPlatform_buyer_details_invalid_wallet_prefilling_billing_address",value:1,attributes:{wallet:X.BuyWithPrime}}))}if(t.prefillingShippingAddress){const n=(o=t.prefillingShippingAddress,JSON.stringify(o)),i=a.value?.lastRecordedAddressToken;if(i&&i!==n&&!r)return e.counter({name:"WalletsPlatform_buyer_details_buy_with_prime_address_updated_no_promise_id_count",value:1,attributes:{wallet:X.BuyWithPrime}}),{error:new je("Received updated address but no promise ID")};_(a,{lastRecordedAddressToken:n})}var o;const i=T(t.walletParams).external_customer_id??n?.externalCustomerId;return i?{buyerDetails:t,externalCustomerId:i}:(e.counter({name:"WalletsPlatform_buyer_details_missing_external_customer_id_count",value:1,attributes:{wallet:X.BuyWithPrime}}),{error:new Te("Buyer details returned do not contain 'external_customer_id'.",{groupingHash:"BuyerDetailsContractError::BuyerDetailsMissing::ExternalCustomerId"})})},[e,a])}(),z=s.unstable_getSerialization("forcedRedesignWallet");I({active:y});const C=B(),W=De({walletName:X.BuyWithPrime,excludedErrorTypes:qe});t(()=>{const t=g(),r=A??t?.externalPromiseId;
1C(z?{keep:["wallet"]}:void 0),c.setEscalatedWallet(X.BuyWithPrime),_(o,{primeError:void 0}),h(!0),i.value={...i.value,loading:!0},(async()=>{await(async()=>{const{error:t,externalCheckoutSessionId:o,externalPromiseId:i}=x(b,r);if(t)return W(t),void p("buyer_details_failure_on_validate_required_ids");if(!o||!i)return;const s=Ce(l,X.BuyWithPrime),u=await s(()=>Oe({walletName:X.BuyWithPrime,graphql:d,token:o,observability:l,telemetryEventName:"WalletsPlatform_buyer_details_count",expressWalletInCheckout:!1})),y=E(u,A);if(y.error)return W(y.error),void p("buyer_details_failure_on_validate_data");T(u.walletParams).external_promise_id=i,v(),n(),c.setActiveSession({newValue:X.BuyWithPrime,asPaymentMethod:!1}),c.clearActiveSession({invokingWallet:X.BuyWithPrime}),e(X.BuyWithPrime,y.buyerDetails),f.value="BUY_WITH_PRIME",a({externalCheckoutSessionId:b,externalCustomerId:y.externalCustomerId,externalPromiseId:r}),await m({legacyFiltering:{include:["paymentLines"]},force:!1,fieldsToResolve:["taxes","paymentMethods"],silenceViolations:he(["paymentLines"])})})().catch(e=>{var a;W(e),p("terminalErrorReason"in(a=e)?a.terminalErrorReason:"buyer_details_failure")}).finally(()=>{h(!1),i.value={...i.value,loading:!1}})})()},[])}function $e(){const{promiseDate:e}=function(){const{i18n:e}=V(),{inMemoryAmazonPayParts:{buyerDetails:a}}=Z(),{value:t}=me(),r=pe("deliveryNext").value,{value:n}=ye(),o=pe("deliveryExpectations").value,i=N(t??[]),s=L(n??[],i?.handle),{maxDeliveryDateTime:l,deliveryExpectationPresentmentTitle:u}=s||{},{short:c}=u||{},{type:d}=O();let m;return m=c||("no delivery strategy"===d?e.translate("shipping.different_shipping_method_summary"):e.translate("delivery_promise.buy_with_prime.default")),{promiseDate:l,promiseText:m,loading:a.value.loading||o||r}}(),a=_e(),n=U(),{shop:{currencyCode:o,marketDrivenShippingEnabled:s},source:l,i18n:{locale:u}}=V(),c=j(),d=function(){const e=ee();return i(()=>{const a=e.customAttributes.value,t=e.paymentMethods.value;let r;try{const e=a?.find(e=>e.key===Se)?.value;e&&(r=de(e))}catch{}if(!r){const e=t?.find(e=>"walletsPlatform"===e.type&&e.name===X.BuyWithPrime);r=e?.configurationParams&&(e?.configurationParams).appId||r}return r})}(),{isThankYouPage:m}=q(),p=H(),y=r(()=>{d.value&&n.publishCustomEvent(`shopify:app:pixels:load:${d.value}`,{},{sendTo:"PIXEL-LOADER"})},[d,n]),h=r(()=>{if(d.value){const e=$({negotiated:a,source:l,locale:u,shopCurrencyCode:o,marketDrivenShippingEnabled:s});n.publishCustomEvent("bwp_checkout_started",{checkout:e},{sendTo:d.value})}},[a,l,u,n,d,o,s]),v=r(()=>{if(!c)return;if(p.shouldPrevent())return;const t=$({negotiated:a,source:l,orderId:c.orderIdentity.id||void 0,locale:u,shopCurrencyCode:o,marketDrivenShippingEnabled:s});d.value&&(p.markAsEmitted(),requestAnimationFrame(()=>n.publishCustomEvent("bwp_checkout_completed",{checkout:t,deliveryPromiseTimestamp:e},{sendTo:d.value})))},[c,a,l,u,d,n,e,o,s,p]);return J(r(e=>{"initiate_checkout"!==e.type||m||h()},[h,m])),J(r(e=>{"complete_checkout"===e.type&&v()},[v])),t(()=>{y()},[y]),null}function Je(){const{isThankYouPage:e}=q();return o(c,{children:[o($e,{}),!e&&o(Ge,{})]})}function Ge(){const e=Be(),a=V().checkout.configuration.layout.isOnePage.value,{value:r}=ee().merchandiseLines,n=Y(),o=function(){const e=ee().deliveryNext,a=pe("deliveryNext"),t=ee().paymentLines,r=ee().deliveryExpectations,n=pe("deliveryExpectations"),o=G(),s=ge(o);return i(()=>{const i=e.value,l=a.value,u=t.value,c=r.value,d=n.value,m=u?.lines.some(e=>"walletsPlatformPaymentMethod"===e.method.type&&e.method.name===X.BuyWithPrime),p=Boolean(i&&"filled"===i.status&&i.sourceIsBuyerProposal);if(l||p||d||!m)return;if("unavailable"===i?.status){if(o.value||s.value)return;return"delivery_next_unavailable"}const y=i?.lines.some(e=>"available"===e.status&&e.methods.some(e=>e.brandedPromise?.handle===X.BuyWithPrime));return y?"unavailable"===c?.status?"delivery_expectations_unavailable":void 0:"missing_shipping_option"})}(),s=M(),l=r?.lines?.length??0;return function(){const{hasError:e}=C(ue),{persistedAmazonSignal:a}=Z(),r=V().checkout.latestReceipt.value?.id,n=Be();t(()=>{e&&a.value?.receiptIdForAupError!==r&&n("aup")},[e,r,a.value?.receiptIdForAupError,n])}(),function(){const e=F(),{progressing:a}=w(),r=a.value,{currentDetour:n}=M().value,{observability:o}=V(),i=Be();t(()=>{if(!e.value||n||r)return;const{expiration_timestamp:a}=T(e.value.method.walletParams);a&&Date.now()>new Date(a).getTime()&&(o.counter({name:"WalletsPlatform_buy_with_prime_session_expired_count",value:1}),i("session_expired"))},[e.value,i,n,o,r])}(),He(),function(){const{observability:e}=V(),a=R(X.BuyWithPrime),r=ae().merchandiseLines.value,[n,o]=u(!1),{value:i}=ee().deliveryNext,s=ve(i),l=pe("deliveryNext").value;t(()=>{n||!l&&"filled"===i?.status&&!s&&a.value&&r&&r.filter(e=>e.requiresShipping).length>1&&(e.counter({name:"WalletsPlatform_buy_with_prime_multi_line_checkout_detected_count",value:1}),e.log("buy_with_prime_multi_line_checkout_detected","Multi line Buy with Prime checkout detected"),o(!0))},[a.value,l,i,n,s,r,e])}(),t(()=>{a||e("three_page_detected")},[]),t(()=>{!s.value.currentDetour&&o.value&&e(o.value)},[s,e,o.value]),t(()=>{!n.value&&l>1&&e("unsupported_split")},[e,n.value,l]),null}
1class Ye extends Error{constructor(){super(...arguments),this.name="PortableWalletsSandboxError"}}const Qe=function({isSdkOnly:i=!1}){const{i18n:s,observability:l}=V(),u=e(null),{isScrimOpen:c,closePopupWindowsAndScrim:f}=d({endpoint:u,invokingWallet:X.AmazonPay}),_=a(null),g=a(null),P=m(),{value:w}=K(),b=w?.amount?.toFixed(2),A=w?.currencyCode,{inMemoryAmazonPayParts:{buttonStatus:k,sdkStatus:x}}=Z();t(()=>()=>{i||"error"===k.value.status||(k.value={status:"not_rendered"})},[k,i]);const{value:S}=ee().paymentMethods,E=S?.find(e=>"walletsPlatform"===e.type&&e.name===X.AmazonPay),{configurationParams:z}=E||{},I=r(({errorMessage:e})=>l.error(new Ie(e,{groupingHash:"AmazonPaySandboxError::reportError::SandboxError"})),[l]),B=r(async e=>{const a=p(g.current)||0;u.value=e;const t={...z,...b&&A&&{estimatedOrderAmount:{amount:b,currencyCode:A}},style:{buttonBorderRadius:`${a}px`}};x.value={status:y.Loading};const r=await e.call.configure({configurationParams:t,onlySdk:i});r?.status===Pe.Success?(x.value=function(e){return{status:y.Available,sdk:{Pay:{changePaymentMethod:({amazonCheckoutSessionId:a,isDeclined:t})=>{if(e.value){if(!a)throw new Ie("Missing amazonCheckoutSessionId",{groupingHash:"AmazonPaySandboxError::changePaymentMethod::MissingSessionId"});e.value.call.changePaymentMethod({amazonCheckoutSessionId:a,isDeclined:t})}},changeShippingAddress:({amazonCheckoutSessionId:a})=>{if(e.value){if(!a)throw new Ie("Missing amazonCheckoutSessionId",{groupingHash:"AmazonPaySandboxError::changeShippingAddress::MissingSessionId"});e.value.call.changeShippingAddress(a)}},initCheckout:()=>{throw new Ie('Unexpected invocation of "initCheckout"',{groupingHash:"AmazonPaySandboxError::initCheckout::UnexpectedInvocation"})},renderButton:()=>{throw new Ie('Unexpected invocation of "renderButton"',{groupingHash:"AmazonPaySandboxError::renderButton::UnexpectedInvocation"})}},buywithprime:{changePaymentMethod:()=>{throw new Ie('Unexpected invocation of buywithprime "changePaymentMethod" in AmazonPay flow')},changeShippingAddress:()=>{throw new Ie('Unexpected invocation of buywithprime "changeShippingAddress" in AmazonPay flow')},initCheckout:()=>{throw new Ie('Unexpected invocation of buywithprime "initCheckout" in AmazonPay flow')},renderButton:()=>{throw new Ie('Unexpected invocation of buywithprime "renderButton" in AmazonPay flow')}}}}}(u),i||(k.value={status:"rendered"},l.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:X.AmazonPay,status:"success",isPaymentMethodFlow:!1}}))):(r?.status===Pe.Error&&I({errorMessage:r?.message}),x.value={status:y.Error},i||(k.value={status:"error"},l.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:X.AmazonPay,status:"error",reason:r?.status===Pe.ScriptLoadError?"script_load_error":"sandbox_error",isPaymentMethodFlow:!1}})))},[b,k,z,A,u,i,I,x,l]),C=r(()=>{c.value=!1},[c]),W=r(({redirectUrl:e,requestPayload:a})=>{try{if(a){if(!_.current)return void l.error(new Ie("Form container not found",{groupingHash:"AmazonPaySandboxError::onSendCheckoutAction::FormContainerNotFound"}));ze({formContainer:_.current,url:e,requestPayload:a}).submit()}else window.location.href=e}catch(t){l.error(t)}},[l]),D=r(()=>{c.value=!0,P(g),u.value.call.open()},[u,c,P]),M=we(),T=n(()=>({clicked:D,closed:C,redirect:W,reportError:I,telemetry:M}),[D,C,W,I,M]);return o("div",{className:"J29Tp",children:[o(be,{wallet:X.AmazonPay,onConnect:B,onTerminate:()=>u.value=null,hostMethods:T,isSdkOnly:i,ref:g}),o(h,{isOpen:c,walletName:s.translate("brand.amazon_pay"),handleClose:f}),o(v,{ref:_,display:"none"})]})},Ve=function(){const{buyerDetailsContentLoaded:e}=Z().inMemoryAmazonPayParts,a=function(){const e=ee().paymentMethods,a=ae().paymentLines,t=P();return i(()=>ne({paymentLines:a.value,paymentMethods:e.value,urlParams:{wallet:t[ie]??null,amazon_cancelled:t[oe]??null}}))}(),n=g(),{searchParams:s,isThankYouPage:l}=q(),u=F();t(()=>{e.value=!0},[e]);const{progressing:c}=w(),d=c.value,m=Be(),p=Boolean(s.amazon_cancelled);t(()=>{d||n.value||!u.value||m("eligibility_lost")},[d,n.value,u.value,m]);const y=B();return t(()=>{n.value||a.value||!p||y()},[n.value,a.value,p,y]),function(){const e=g(),a=function(){const{attributes:e}=ae();return r(()=>{const a=e.value;e.value=a?te(a):a},[e])}(),{externalDeliveryIds:n,attributes:o}=ae(),i=n.value,s=o.value?.find(({key:e,value:a})=>e===re&&a===X.BuyWithPrime)?.value;t(()=>{e.value||(i&&(n.value=void 0),s&&a())},[i,n,s,e.value,a])}(),n.value?o(Je,{}):!l&&a.value?o(Ue,{}):null},Xe=function({wallet:i,isSdkOnly:s=!1}){const{i18n:l,shop:u,source:c,observability:p}=V(),{id:v}=u,{value:f}=ee().buyerIdentity,{countryCode:_,presentmentCurrency:g}=f??{},P=Q(i),w=P.value?.configurationParams,b=e(null),{isScrimOpen:A,closePopupWindowsAndScrim:k}=d({endpoint:b,invokingWallet:i}),{inMemoryAmazonPayParts:{buyWithPrimeButtonStatus:x,sdkStatus:S}}=Z();t(()=>()=>{s||"error"===x.value.status||(x.value={status:"not_rendered"})},[x,s]);const E=a(null),z=a(null),I=m(),B=r(({errorMessage:e})=>
1p.error(new Ye(e)),[p]),C=e(!1),W=r(async e=>{S.value={status:y.Loading};const a=await e.call.configure({configurationParams:w,buyerCountry:_,buyerCurrency:g,shopId:v,cartId:c.sourceId,onlySdk:s});a?.status===Pe.Success?(S.value=function(e,a){return{status:y.Available,sdk:{buywithprime:{changePaymentMethod:({amazonPayOptions:t})=>{if(!t.amazonCheckoutSessionId)throw new Ye("Missing amazonCheckoutSessionId");a.value?.call.changePaymentMethod({wallet:e,changePaymentParams:{amazonCheckoutSessionId:t.amazonCheckoutSessionId,isDeclined:t.isDeclined}})},changeShippingAddress:({amazonCheckoutSessionId:t})=>{if(!t)throw new Ye("Missing amazonCheckoutSessionId");a.value?.call.changeShippingAddress({wallet:e,changeShippingParams:{amazonCheckoutSessionId:t}})},initCheckout:()=>{throw new Ye('Unexpected invocation of "initCheckout"')},renderButton:()=>{throw new Ye('Unexpected invocation of "renderButton"')}},Pay:{changePaymentMethod:()=>{throw new Ye('Unexpected invocation of AmazonPay "changePaymentMethod" in BWP flow')},changeShippingAddress:()=>{throw new Ye('Unexpected invocation of AmazonPay "changeShippingAddress" in BWP flow')},initCheckout:()=>{throw new Ye('Unexpected invocation of AmazonPay "initCheckout" in BWP flow')},renderButton:()=>{throw new Ye('Unexpected invocation of AmazonPay "renderButton" in BWP flow')}}}}}(i,b),s||(x.value={status:"rendered"},p.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:i,status:"success",isPaymentMethodFlow:!1}}))):(a?.status===Pe.Error&&B({errorMessage:a?.message}),S.value={status:y.Error},s||(x.value={status:"error"},p.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:i,status:"error",isPaymentMethodFlow:!1}})))},[w,_,v,g,c.sourceId,s,i,B,S,x,b,p]);C.value&&f?.countryCode&&f?.presentmentCurrency&&b.value&&(C.value=!1,W(b.value));const D=we(),M=n(()=>({clicked:e=>{var a,t;A.value=!0,I(z),e&&(a=e.skus,t=e.apiClientId,window.Shopify?.analytics?.publish&&(window.Shopify.analytics.publish(`shopify:app:pixels:load:${t}`,{},{sendTo:"PIXEL-LOADER"}),window.Shopify.analytics.publish("bwp_checkout_widget_click",{skus:a},{sendTo:t})))},closed:()=>A.value=!1,redirect:({redirectUrl:e,requestPayload:a})=>{try{if(a){if(!E.current)return void p.error(new Ie("Form container not found",{groupingHash:"AmazonPaySandboxError::PortableWalletsPCIButton::FormContainerNotFound"}));ze({formContainer:E.current,url:e,requestPayload:a}).submit()}else window.location.assign(e)}catch(t){p.error(t)}},reportError:B,telemetry:D}),[A,B,p,I,D]);return o("div",{className:"uaDLn",children:[o("div",{ref:E,style:{display:"none"}}),o(be,{wallet:i,onConnect:e=>{b.value=e,C.value=!0},onTerminate:()=>b.value=null,hostMethods:M,isSdkOnly:s,ref:z}),o(h,{isOpen:A,walletName:l.translate("brand.buy_with_prime"),handleClose:k})]})};export{Ve as AmazonBuyerDetailsContent,Qe as AmazonPayButtonContent,Xe as PortableWalletsPCIButtonContent};

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.