import{x as E,dj as de,aa as T,eG as pe,aj as F,am as L,s as he,gd as me,q as B,a as t,ge,gf as Pe,B as z,aL as ye,gg as Se,gh as $,ag as j,gi as J,gj as fe,bE as k,a7 as be,ai as W,gk as _,dF as Q,gl as Z,gm as ke,gn as Ee,dm as Ce,go as _e,gp as ve,gq as Ae,gr as We,gs as v,cI as ee,gt as Le,gu as x,gv as Be,fL as y,af as te,b0 as ae,a5 as D,b9 as Me,bc as se,al as De,gw as U,gx as we,gy as xe,fH as Te,y as M,gz as Y,aP as Ie,I as Oe,bA as Re,gA as Ne,o as He,d as A,gB as Ge,aM as Fe,aV as ze,a4 as Ue,U as Ye,aN as ne,gC as Ve,T as Xe,gD as Ke,gE as qe,gF as $e,gG as je,w as Je,gH as Qe,gI as Ze,gJ as et,d7 as oe,a9 as tt,gK as at,ae as st,a1 as nt,gL as ot,gM as rt,gN as it,gO as re,gP as lt,gQ as ct,b as ut,S as V,gR as dt,b2 as pt,a2 as ht,A as mt,gS as gt,cP as Pt,gT as yt}from"./app.Dqw-tRcr.js";import{u as St,a as ie,S as ft}from"./useEditorShopPayNavigation.DyaZ2_Hs.js";import{P as bt}from"./VaultedPayment.CwjfiUBb.js";function pa(){const e=E(),a=de(),{shopPayEnabled:n}=T(),{value:s}=pe(),o=F().rememberMe,l=!!s?.rememberMe||o.value,[r,i]=L(l),{negotiate:d}=he(),h=me()?.saveShippingAddressCheckboxEnabled??!0,S=!!a,f=F().shippingAddress.value,P=!n&&h&&!S&&!f.oneTimeUse,m=B(b=>{i(b),o.value=b,d({})},[d,o]);return P?t(ge,{id:"save_shipping_information",name:"save_shipping_information",checked:r,onChange:m,children:e("customer_account.save_my_information_label","Save this information for next time")}):null}const kt=["GooglePay","PayPal","Venmo"];function ha({id:e}){return Pe({id:e,stage:({pendingComponents:a})=>kt.some(s=>a.has(s))?z.Usable:z.Complete}),null}const Et="vT2w7",Ct="f1x20",_t="hKWGx",X={ApplePayButton:Et,dark:Ct,light:_t};function vt({supportedNetworks:e,color:a}){const n=E(),{locale:s}=ye().i18n,o=Se(),l=$(),r=j(J),i=fe(),{paymentSheetError:d}=k().inMemoryApplePayParts,u=be(),h=()=>{try{i(o({supportedNetworks:e}).session)}catch(S){u.leaveBreadcrumb("Failed to create Apple Pay session",{error:S}),d.value={type:"failed_to_create_session"}}};return t("button",{ref:l("apple_pay"),className:W(X.ApplePayButton,X[a],_.borderRadius,_.focusOutline,{[_.shadow]:r}),lang:s,onClick:h,type:"button","aria-label":n("brand.apple_pay","Apple Pay")})}const At="Xicuw",K={Button:At,"Button--contrast":"oHCaH"},Wt="shop-pay-button";function Lt(){const e=Q(),{id:a}=T(),n=Z(),s=St({foregroundColor:ke}),o=Ee(),l=Ce(),r=_e(o,l),{telemetry:{lastClickedWallet:i}}=k(),d=ve(Ae.DirectCheckoutCheckout),u=$(),h=j(J),S=We(v.ShopifyPay),{setEditorShopPay:f}=ie(),P=B(()=>{const p=parseInt(ee(a),10),C=Le(v.ShopifyPay,x.Success,p,n);e?.record(C),S(),i.value="SHOP_PAY"},[a,e,n,i,S]),m=B(p=>{if(f){p.preventDefault(),f(!0);return}P()},[P,f]),b=W(K.Button,{[K["Button--contrast"]]:!s&&!r},_.borderRadius,_.focusOutline,{[_.shadow]:h});return t("a",{id:Wt,href:d,ref:u("shop_pay"),className:b,"aria-label":"Shop Pay",onClick:m,children:t(ft,{size:"medium"})})}const Bt="o1z23",Mt="_4aXW0",Dt="DUnBb",wt="kTI19",xt="JH5oc",Tt="pUo2R",It="_5SdgT",Ot="RKgRy",Rt="iRnuh",Nt="QKTth",Ht="Pnahu",Gt="OTERX",Ft="WTXfy",zt="qLVAT",Ut="XHLFs",c={Header:Bt,Text:Mt,Layout:Dt,StackWrapper:wt,SkeletonWrapper:xt,ButtonWrapper:Tt,loading:It,subsequentLoad:Ot,Stack:Rt,SimulatedWalletStack:Nt,ShopPayEmphasis:Ht,Container:Gt,DrawerLink:Ft,InnerDrawerLink:zt,DrawerHideButtons:Ut};function Yt(){const e=k();return Be.map(n=>Vt(e,n)).some(Boolean)}function Vt(e,a){const n=!!e.walletPaymentMethods.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 y.AmazonPay:case y.BuyWithPrime:return e.inMemoryAmazonPayParts.buttonStatus.peek();default:return}})();return n&&s?.status==="not_rendered"}function Xt(){const e=E();return t(Me,{open:!0,blocking:!0,accessibilityLabel:e("wallets.payment_in_progress_title","Payment in progress"),padding:"none",children:t(te,{spacing:"loose",padding:"large200",children:[t(ae,{level:1,children:e("wallets.payment_in_progress_title","Payment in progress")}),t(D,{children:e("wallets.payment_in_progress_body","Your payment is being processed. Your order will be completed soon.")})]})})}function Kt(){const e=se(),a=De(),{walletUsedForSubmissionSignal:n,receiptErrorSignal:s}=k(),o=U(we()),l=U(xe()),{inMemoryApplePayParts:{asPaymentMethod:r}}=k(),i=r.peek(),d=Te(a?.status==="failed"&&a.failure.type==="payment"&&e?a?.failure:void 0);M(()=>{if(a?.status==="processing"||a?.status==="polling_for_order")return;const u=n.peek();if(u){if(n.value=void 0,a?.status!=="failed"){s.value=void 0;return}u==="APPLE_PAY"&&l.current(),a.failure.type==="payment"&&u&&!i&&o.current(),(u==="APPLE_PAY"||u==="GOOGLE_PAY")&&(s.value=d)}},[a,s,n,i,l,d,o]),M(()=>function(){s.value=void 0},[s])}const qt="express-checkout-wallets-wrapper",$t=/(iPhone|iPod|iPad|Mac OS)/i,jt=/((iPhone|iPod|iPad).*AppleWebKit(?!.*(Safari|instagram|FBAV|FB_IAB)))/i,Jt=/(ShopifyCheckoutSDK|CheckoutSheetProtocol)/i;function Qt(){const{userAgent:e}=Ve(),a=jt.test(e);return!($t.test(e)&&Jt.test(e)||a)}function Zt(){const{inMemoryPayPalParts:e,inMemoryVenmoParts:a,inMemoryGooglePayParts:n,inMemoryAmazonPayParts:s,walletPaymentMethods:o}=k(),l=Xe(()=>o.flatMap(r=>{switch(r.name){case"PAYPAL_EXPRESS":{const i=[{name:v.PayPalV6,buttonStatusSignal:e.acceleratedCheckoutButtonStatus}];return r.venmoEnabled&&i.push({name:v.Venmo,buttonStatusSignal:a.buttonStatus}),i}case"GOOGLE_PAY":return{name:v.GooglePay,buttonStatusSignal:n.buttonStatus};case y.AmazonPay:return{name:y.AmazonPay,buttonStatusSignal:s.buttonStatus};case y.BuyWithPrime:return{name:y.BuyWithPrime,buttonStatusSignal:s.buttonStatus};default:return[]}}),[o,n.buttonStatus,s.buttonStatus,e.acceleratedCheckoutButtonStatus,a.buttonStatus]);Ke(l,qe)}function ea({buttonCount:e,children:a,waitUntilLoaded:n=!0,walletPaymentMethods:s}){const[o,l]=L(Y()),[r,i]=L(!0),d=Qt(),u=Ie(),h=E(),{inMemoryApplePayParts:{paymentSheetError:S}}=k(),f=Yt();Zt();const P=n?f:!1,[m,b]=L(!1),p=Oe(),{id:C}=T(),I=Q(),O=Z(),R=Re();Ne(s,e);const N=B((g,w)=>{const ce=parseInt(ee(C),10),ue=je({state:w,shopId:ce,nascarData:{...g,walletsRenderedCount:e},paymentMethods:s});I?.record(ue)},[C,I,e,s]),H=s.some(g=>g.name==="SHOP_PAY")&&d;Kt(),!P&&!m&&(b(!0),l(g=>Y()-g)),M(()=>{m&&R.histogram({name:"wallets_container_render_time",value:o,attributes:{PCIv4:s.some(g=>g.name===y.AmazonPay||g.name===y.BuyWithPrime||g.name==="GOOGLE_PAY"||g.name==="PAYPAL_EXPRESS")}})},[m,R,o]);const G=h("alternative_payment_method_banner.express_checkout","Express checkout"),le=He("worker-version")!=="fast";return t(ne,{accessibilityLabel:G,children:[t(A,{className:c.Container,"data-count":e,children:[t("div",{className:c.Header,children:t(Ge,{className:c.Text,children:G})}),t("div",{className:c.StackWrapper,children:[t("div",{className:c.Layout,children:[t(ta,{loading:P||!u,hideWallets:r,shopPayEmphasis:H,children:[...Array(e).keys()].filter((g,w)=>w<=3).map(g=>t(Fe,{delay:le},g))}),t("div",{id:qt,className:W(c.Stack,c.ButtonWrapper,{[c.loading]:P,[c.subsequentLoad]:P&&m,[c.DrawerHideButtons]:r,[c.ShopPayEmphasis]:H}),children:u&&a})]}),t("div",{className:c.DrawerLink,children:t(ze,{accessibilityLive:"polite",textDecoration:"none",onClick:()=>{r?(i(!1),N(O,x.NascarDrawerOpen)):(i(!0),N(O,x.NascarDrawerClose))},children:t("div",{className:c.InnerDrawerLink,children:[t(D,{children:r?h("alternative_payment_method_banner.show_more_options","Show more options"):h("alternative_payment_method_banner.hide_more_options","Hide more options")}),t(Ue,{type:r?"chevron-down":"chevron-up",size:"small-200"})]})})}),p&&t(Ye,{isForExpressCheckout:!0})]})]}),S?.value?.type==="payment_cancelled_while_processing"&&t(Xt,{})]})}function ta({children:e,loading:a=!1,hideWallets:n,shopPayEmphasis:s}){return $e(a,"base")==="exited"?null:t("div",{className:W(c.Stack,c.SkeletonWrapper,{[c.ShopPayEmphasis]:s,[c.DrawerHideButtons]:n}),children:e})}const aa="_2SmAP",sa="eFu6h",q={MessageWrapper:aa,SimulatedWalletWrapper:sa},na=e=>e;function ma(){const e=Je("simulated"),a=E(),{inMemoryVenmoParts:{buttonStatus:n},walletPaymentMethods:s,buttonCount:o}=k(),l=Qe(),r=Ze(),{setEditorShopPay:i}=ie(),d=et(s,n.value),{expressCheckout:{button:{cornerRadius:u}={}}}=oe(),h=tt("Checkout::Dynamic::Render","WALLETS1"),S=at(),f=e&&S&&!s.length;if(!r)return null;const P=!e;let m=s.map(p=>t(ra,{method:p,triggerProgression:l},p.name));if(d){const p=ia({triggerProgression:l});m=[...m,p]}const b=f?t(A,{padding:"large200",cornerRadius:"base",blockAlignment:"center",inlineAlignment:"center",minInlineSize:"fill",className:q.MessageWrapper,children:t(D,{color:"subdued",children:a("payment.simulated_express_checkout","Wallets are unavailable in the editor preview due to your region or browser")})}):m.map((p,C)=>p.key==="VENMO"?null:p.key==="SHOP_PAY"&&i?p:t(A,{className:q.SimulatedWalletWrapper,children:t(A,{className:W([c.walletButton,c.Stack,c.SimulatedWalletStack]),inert:!0,children:p})},p.key??C));return t("div",{style:{...oa(u)},children:[t(st,{extensions:h,spacing:"large200",render:na}),h.length>0&&t(nt,{spacing:"large200"}),t(ea,{buttonCount:f?1:o,waitUntilLoaded:P,walletPaymentMethods:s,children:e?b:m})]})}function oa(e){return e&&{"--x-express-checkout-button-border-radius":lt(ct.borderRadius)(e)}}function ra({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(re,{progressToNextPage:a});case"SHOP_PAY":return t(Lt,{});case"GOOGLE_PAY":return t(it,{});case y.AmazonPay:return t(rt,{});case y.BuyWithPrime:return t(bt,{wallet:y.BuyWithPrime});default:return null}}function ia({triggerProgression:e}){return t(re,{fundingSource:"venmo",buttonColor:"blue",progressToNextPage:e},"VENMO")}function ga(){const e=E(),{divider:{borderStyle:a,borderWidth:n}}=ut(),{main:{divider:{borderStyle:s=a,borderWidth:o=n}={},section:l,spacing:r}}=oe(),i=V.default(["large100","none","large300","none"]),u=dt(l)?V.default([r??"base","none"]).when({viewportInlineSize:{min:"extraSmall"}},[r??"large200","none"]):i;return t(A,{padding:u,children:t(pt,{borderStyle:s,borderWidth:o,children:t(ht,{textAlign:"center",children:t(D,{color:"subdued",children:e("alternative_payment_method_banner.or","OR")})})})})}function Pa(e){const a=mt(null),{expressCheckoutHeightSignal:n,expressCheckoutFirstLoadsSignal:s}=gt(),o=n.value,l=Pt(),r=s.value;return M(()=>{const i=a.current?.clientHeight,d=i!==void 0&&i!==o&&!r,u=e.map(h=>h.name);d&&l("expressCheckoutSetChange",{timestamp:new Date,paymentMethods:u}),s.value=!1,n.value=i||0},[o,e,l,r,s,n]),a}function ya(){const a=E()("contact.delivery_option_title","Delivery method"),n=yt(),s=se();return n?t(ne,{accessibilityLabel:a,children:t(te,{children:[s?null:t(ae,{level:1,children:a}),n]})}):null}export{ya as D,ma as E,ha as P,pa as S,ga as a,Pa as u};