import{gT as me,x as X,e as _,ao as O,gU as Pe,dK as Z,bM as I,gV as ee,gW as Se,br as b,i as ye,a as t,as as M,gX as E,eB as te,aW as ae,aR as se,gY as ne,gZ as ge,g_ as ke,ei as fe,g$ as Ee,h0 as _e,h1 as be,ef as Ae,h2 as Ce,h3 as W,ak as B,q as R,h4 as ve,aV as oe,h5 as We,h6 as H,h7 as Le,f$ as P,B as N,ax as re,a6 as D,b0 as Be,b3 as ie,cD as Me,h8 as K,h9 as De,ha as Te,fX as we,ab as x,hb as q,aE as xe,hc as Oe,D as Re,G as He,hd as Ie,ap as Ne,d as L,he as Ge,aq as Fe,bP as Ye,I as ze,U as Ue,ar as le,hf as Ve,bO as Xe,hg as Ke,hh as qe,hi as $e,hj as je,t as Je,hk as Qe,dL as Ze,hl as et,aC as ce,k as tt,hm as at,R as st,a1 as nt,hn as ot,ho as rt,hp as it,hq as ue,hr as lt,hs as ct,b as ut,S as $,aD as dt,az as pt,a2 as ht,aj as mt,ht as Pt,dh as St,dz as yt}from"./app.owqgWGYv.js";import{u as gt,a as de,S as kt}from"./useEditorShopPayNavigation.Ua6ZvAgB.js";import{P as ft}from"./VaultedPayment.Bfd-gj_8.js";import{P as Et}from"./PaymentButtons.BvmHXI7E.js";const _t=["GooglePay","PayPal","Venmo"];function ma({id:e}){return me({id:e,stage:({pendingComponents:a})=>_t.some(s=>a.has(s))?X.Usable:X.Complete}),null}const bt="vT2w7",At="f1x20",Ct="hKWGx",j={ApplePayButton:bt,dark:At,light:Ct};function vt({supportedNetworks:e,color:a}){const n=_(),{locale:s}=O().i18n,o=Pe(),c=Z(),r=I(ee),i=Se(),{paymentSheetError:d}=b().inMemoryApplePayParts,m=ye(),{wallets:p}=O(),k=()=>{try{i(o({supportedNetworks:e}).session)}catch(S){m.leaveBreadcrumb("Failed to create Apple Pay session",{error:S}),d.value={type:"failed_to_create_session"},p.activeSession==="APPLE_PAY"&&p.clearActiveSession({invokingWallet:"APPLE_PAY"})}};return t("button",{ref:c("apple_pay"),className:M(j.ApplePayButton,j[a],E.borderRadius,E.focusOutline,{[E.shadow]:r}),lang:s,onClick:k,type:"button","aria-label":n("brand.apple_pay")})}const Wt="Xicuw",J={Button:Wt,"Button--contrast":"oHCaH"},Lt="shop-pay-button";function Bt(){const e=te(),a=ae(),{id:n}=se(),s=ne(),o=gt({foregroundColor:ge}),c=ke(),r=fe(),i=Ee(c,r),d=_e(be.DirectCheckoutCheckout),m=Z(),p=I(ee),k=Ae(),{wallets:S}=O(),f=Ce(W.ShopifyPay),{setEditorShopPay:y}=de();B(()=>{a.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:"SHOP_PAY",status:"success"}})},[a]);const g=R(()=>{const C=parseInt(oe(n),10),v=We(W.ShopifyPay,H.Success,C,s);e&&v&&e.record(v),f(),S.setActiveSession({newValue:"SHOP_PAY"}),S.clearActiveSession({invokingWallet:"SHOP_PAY"})},[n,e,s,S,f]),u=R(C=>{if(y){C.preventDefault(),y(!0);return}g()},[g,y]),A=M(J.Button,{[J["Button--contrast"]]:!o&&!i},E.borderRadius,E.focusOutline,{[E.shadow]:p});return t("a",{id:Lt,href:d,ref:m("shop_pay"),className:A,"aria-label":"Shop Pay",onClick:u,children:k.logoBrand==="shop"?t(ve,{size:"medium"}):t(kt,{size:"medium"})})}const Mt="o1z23",Dt="_4aXW0",Tt="DUnBb",wt="kTI19",xt="JH5oc",Ot="pUo2R",Rt="_5SdgT",Ht="RKgRy",It="iRnuh",Nt="QKTth",Gt="Pnahu",Ft="OTERX",Yt="WTXfy",zt="qLVAT",Ut="XHLFs",l={Header:Mt,Text:Dt,Layout:Tt,StackWrapper:wt,SkeletonWrapper:xt,ButtonWrapper:Ot,loading:Rt,subsequentLoad:Ht,Stack:It,SimulatedWalletStack:Nt,ShopPayEmphasis:Gt,Container:Ft,DrawerLink:Yt,InnerDrawerLink:zt,DrawerHideButtons:Ut};function Vt(){const e=b();return Le.map(n=>Xt(e,n)).some(Boolean)}function Xt(e,a){const n=!!e.acceleratedWalletPaymentMethods.find(o=>o.name===a),s=(()=>{switch(a){case"PAYPAL_EXPRESS":return e.inMemoryPayPalParts.acceleratedCheckoutButtonStatus.peek();case"GOOGLE_PAY":return e.inMemoryGooglePayParts.buttonStatus.peek();case P.AmazonPay:case P.BuyWithPrime:return e.inMemoryAmazonPayParts.buttonStatus.peek();default:return}})();return n&&s?.status==="not_rendered"}function Kt(){const e=_();return t(Be,{open:!0,blocking:!0,accessibilityLabel:e("wallets.payment_in_progress_title"),padding:"none",children:t(N,{spacing:"loose",padding:"large200",children:[t(re,{level:1,children:e("wallets.payment_in_progress_title")}),t(D,{children:e("wallets.payment_in_progress_body")})]})})}function qt(){const e=ie(),a=Me(),{walletUsedForSubmissionSignal:n,receiptErrorSignal:s,inMemoryApplePayParts:{asPaymentMethod:o}}=b(),c=K(De()),r=K(Te()),i=we(a?.status==="failed"&&a.failure.type==="payment"&&e?a?.failure:void 0);B(()=>{if(a?.status==="processing"||a?.status==="polling_for_order")return;const d=n.value;if(d){if(a?.status!=="failed"){s.value=void 0;return}d==="APPLE_PAY"&&r.current(),a.failure.type==="payment"&&d&&!o.value&&c.current(),(d==="APPLE_PAY"&&!o.value||d==="GOOGLE_PAY")&&(s.value=i)}},[a,s,n,o,r,i,c]),B(()=>function(){s.value=void 0},[s])}const $t="express-checkout-wallets-wrapper",jt=/(iPhone|iPod|iPad|Mac OS)/i,Jt=/((iPhone|iPod|iPad).*AppleWebKit(?!.*(Safari|instagram|FBAV|FB_IAB)))/i,Qt=/(ShopifyCheckoutSDK|CheckoutSheetProtocol)/i;function Zt(){const{userAgent:e}=Ve(),a=Jt.test(e);return!(jt.test(e)&&Qt.test(e)||a)}function ea(){const{inMemoryPayPalParts:e,inMemoryVenmoParts:a,inMemoryGooglePayParts:n,inMemoryAmazonPayParts:s,acceleratedWalletPaymentMethods:o}=b(),c=Xe(()=>o.flatMap(r=>{switch(r.name){case"PAYPAL_EXPRESS":{const i=[{name:W.PayPalV6,buttonStatusSignal:e.acceleratedCheckoutButtonStatus}];return r.venmoEnabled&&i.push({name:W.Venmo,buttonStatusSignal:a.buttonStatus}),i}case"GOOGLE_PAY":return{name:W.GooglePay,buttonStatusSignal:n.buttonStatus};case P.AmazonPay:return{name:P.AmazonPay,buttonStatusSignal:s.buttonStatus};case P.BuyWithPrime:return{name:P.BuyWithPrime,buttonStatusSignal:s.buttonStatus};default:return[]}}),[o,n.buttonStatus,s.buttonStatus,e.acceleratedCheckoutButtonStatus,a.buttonStatus]);Ke(c,qe)}function ta({buttonCount:e,children:a,waitUntilLoaded:n=!0,walletPaymentMethods:s}){const[o,c]=x(q()),[r,i]=x(!0),d=Zt(),m=xe(),p=_(),{inMemoryApplePayParts:{paymentSheetError:k}}=b(),S=Vt();ea();const f=I(Oe),y=Re(),g=n?S:!1,[u,A]=x(!1),C=He(),{id:v}=se(),T=te(),G=ne(),F=ae();Ie(s,e);const Y=R((h,w)=>{const he=parseInt(oe(v),10),V=je({state:w,shopId:he,nascarData:{...h,walletsRenderedCount:e},paymentMethods:s});T&&V&&T.record(V)},[v,T,e,s]),z=s.some(h=>h.name==="SHOP_PAY")&&d;qt(),!g&&!u&&(A(!0),c(h=>q()-h)),B(()=>{u&&F.histogram({name:"wallets_container_render_time",value:o,attributes:{PCIv4:s.some(h=>h.name===P.AmazonPay||h.name===P.BuyWithPrime||h.name==="GOOGLE_PAY"||h.name==="PAYPAL_EXPRESS")}})},[u,F,o]);const U=p("alternative_payment_method_banner.express_checkout"),pe=Ne("worker-version")!=="fast";return t(le,{accessibilityLabel:U,children:[t(L,{className:l.Container,"data-count":e,children:[t("div",{className:l.Header,children:t(Ge,{className:l.Text,children:U})}),t("div",{className:l.StackWrapper,children:[t("div",{className:l.Layout,children:[t(aa,{loading:g||!m,hideWallets:r,shopPayEmphasis:z,children:[...Array(e).keys()].filter((h,w)=>w<=3).map(h=>t(Fe,{delay:pe},h))}),t("div",{id:$t,className:M(l.Stack,l.ButtonWrapper,{[l.loading]:g,[l.subsequentLoad]:g&&u,[l.DrawerHideButtons]:r,[l.ShopPayEmphasis]:z}),children:m&&a})]}),t("div",{className:l.DrawerLink,children:t(Ye,{accessibilityLive:"polite",textDecoration:"none",onClick:()=>{r?(i(!1),Y(G,H.NascarDrawerOpen)):(i(!0),Y(G,H.NascarDrawerClose))},children:t("div",{className:l.InnerDrawerLink,children:[t(D,{children:p(r?"alternative_payment_method_banner.show_more_options":"alternative_payment_method_banner.hide_more_options")}),t(ze,{type:r?"chevron-down":"chevron-up",size:"small-200"})]})})}),C&&t(Et,{isForExpressCheckout:!0}),f&&!!y.value&&t(N,{padding:["large100","none","none","none"],children:t(Ue,{textProps:{color:"subdued",size:"small"},expressCheckout:!0})})]})]}),k?.value?.type==="payment_cancelled_while_processing"&&t(Kt,{})]})}function aa({children:e,loading:a=!1,hideWallets:n,shopPayEmphasis:s}){return $e(a,"base")==="exited"?null:t("div",{className:M(l.Stack,l.SkeletonWrapper,{[l.ShopPayEmphasis]:s,[l.DrawerHideButtons]:n}),children:e})}const sa="_2SmAP",na="eFu6h",Q={MessageWrapper:sa,SimulatedWalletWrapper:na},oa=e=>e;function Pa(){const e=Je("simulated"),a=_(),{inMemoryVenmoParts:{buttonStatus:n},acceleratedWalletPaymentMethods:s,buttonCount:o}=b(),c=Qe(),r=Ze(),{setEditorShopPay:i}=de(),d=et(s,n.value),{expressCheckout:{button:{cornerRadius:m}={}}}=ce(),p=tt("Checkout::Dynamic::Render","WALLETS1"),k=at(),S=e&&k&&!s.length;if(!r)return null;const f=!e;let y=s.map(u=>t(ia,{method:u,triggerProgression:c},u.name));if(d){const u=la({triggerProgression:c});y=[...y,u]}const g=S?t(L,{padding:"large200",cornerRadius:"base",blockAlignment:"center",inlineAlignment:"center",minInlineSize:"fill",className:Q.MessageWrapper,children:t(D,{color:"subdued",children:a("payment.simulated_express_checkout")})}):y.map((u,A)=>u.key==="VENMO"?null:u.key==="SHOP_PAY"&&i?u:t(L,{className:Q.SimulatedWalletWrapper,children:t(L,{className:M([l.walletButton,l.Stack,l.SimulatedWalletStack]),inert:!0,children:u})},u.key??A));return t("div",{style:{...ra(m)},children:[t(st,{extensions:p,spacing:"large200",render:oa}),p.length>0&&t(nt,{spacing:"large200"}),t(ta,{buttonCount:S?1:o,waitUntilLoaded:f,walletPaymentMethods:s,children:e?g:y})]})}function ra(e){return e&&{"--x-express-checkout-button-border-radius":lt(ct.borderRadius)(e)}}function ia({method:e,triggerProgression:a}){const n=ot();switch(e.name){case"APPLE_PAY":return t(vt,{supportedNetworks:e.supportedNetworks,color:n});case"PAYPAL_EXPRESS":return t(ue,{progressToNextPage:a});case"SHOP_PAY":return t(Bt,{});case"GOOGLE_PAY":return t(it,{});case P.AmazonPay:return t(rt,{});case P.BuyWithPrime:return t(ft,{wallet:P.BuyWithPrime});default:return null}}function la({triggerProgression:e}){return t(ue,{fundingSource:"venmo",buttonColor:"blue",progressToNextPage:e},"VENMO")}function Sa(){const e=_(),{divider:{borderStyle:a,borderWidth:n}}=ut(),{main:{divider:{borderStyle:s=a,borderWidth:o=n}={},section:c,spacing:r}}=ce(),i=$.default(["large100","none","large300","none"]),m=dt(c)?$.default([r??"base","none"]).when({viewportInlineSize:{min:"extraSmall"}},[r??"large200","none"]):i;return t(L,{padding:m,children:t(pt,{borderStyle:s,borderWidth:o,children:t(ht,{textAlign:"center",children:t(D,{color:"subdued",children:e("alternative_payment_method_banner.or")})})})})}function ya(e){const a=mt(null),{expressCheckoutHeightSignal:n,expressCheckoutFirstLoadsSignal:s}=Pt(),o=n.value,c=St(),r=s.value;return B(()=>{const i=a.current?.clientHeight,d=i!==void 0&&i!==o&&!r,m=e.map(p=>p.name);d&&c("expressCheckoutSetChange",{timestamp:new Date,paymentMethods:m}),s.value=!1,n.value=i||0},[o,e,c,r,s,n]),a}function ga(){const a=_()("contact.delivery_option_title"),n=yt(),s=ie();return n?t(le,{accessibilityLabel:a,children:t(N,{children:[s?null:t(re,{level:1,children:a}),n]})}):null}export{ga as D,Pa as E,ma as P,Sa as a,ya as u};