import{d as e,a4 as o,W as a,p8 as r,nB as t,ae as n,dW as s}from"./4b4bc88f.z1yoAwwH.js";import{t as i,w as c,m as u}from"./2c1ab0fe.Dbn2KvkT.js";import{a4 as l,hZ as p,fs as d,q as h,iW as y}from"./164ad2e3.FTBuhkTQ.js";function f(){const{shopPay:o}=e();return o}const m=()=>{const{shop:{hasStorefront:o,partnerStorefrontUrl:a},observability:r,url:t}=e();return{replaceShopPayInHistory:i(e=>{"undefined"!=typeof window&&(e?window.location.replace(e):o?(r.log("shop_pay_in_history_storefront_redirected","[Shop Pay] Redirecting to storefront url, as replacementUrl is not provided"),window.location.replace(a??t.storefront())):(r.counter({name:"shop_pay_cannot_replace_browser_history",value:1}),r.log("shop_pay_cannot_replace_browser_history","[Shop Pay] Unable to replace Shop Pay in browser history",{replacementUrl:e,storefrontUrl:t.storefront()})))},[o,a,r,t])}};function _(){const{clearForcedCheckoutLayout:e}=l(),{inMemoryAmazonPayParts:{serializedAmazonParams:t,buyerDetails:n}}=o(),s=i(()=>{e({wallet:a.AmazonPay}),r(t),n.value={loading:!1,error:!1,details:void 0}},[e,t,n]);return p({shouldResetCustomerInfo:!0,skipRedirect:!0,shouldRemovePaymentLine:!0,onClick:s})}function v(){const{isOnePage:o}=e().checkout.configuration.layout,a=t(),r=d();return i(()=>{o.value?r({shouldResetCustomerInfo:!0}):a()},[o,a,r])}const w=()=>{const{checkout:o}=e(),a=o.configuration.visibility.showAside,r=n(),t=h({base:!0,medium:!1}),s=c(a),i=c(t),l=y();return u(()=>!l.value&&!(s.value&&!i.value&&r.value))};var b=(e=>(e.Generic="generic",e.SignInFailed="sign_in_failed",e.ContinueWithShopPay="continue_with_shop_pay",e))(b||{});function P(){const{observability:o,source:a,shopPay:r}=e();return{openModal:i(e=>{r.user.isUnauthenticatedUser.value?r.session.unstable_setUnauthenticatedErrorModal(e):o.error(new s("Cannot open an unauthenticated error modal outside of the unauthenticated flow",{groupingHash:"ShopPayError::UnauthenticatedErrorModal"}),{severity:"error",metadata:{source:{type:a.type},checkout:{token:a.checkoutSessionIdentifier||a.sourceId},event:{modalType:e.type,shopPayFlow:r.user.flow.value}}})},[o,a,r])}}export{b as U,f as a,w as b,_ as c,P as d,v as e,m as u};