1import{u as e,i as A,A as q,q as y,h as J,e as F,g as O,f as N,o as V,G as $,l as K,S as Z}from"./esnext-vendor.7EcvH7tF.js";import{Q as D,aY as ee,bF as te,ac as ne,co as ae,b3 as oe,cp as se,aF as ie}from"./utilities-previous.BNOUhCqt.js";import{k as U,c2 as _,a5 as le,c3 as re,c4 as ce,i as ue,b2 as pe,B as z,P as de,L as me,l as ye,j as ve,az as he,I as be,m as Pe,bx as Se,a4 as fe,c5 as _e,c6 as ge,C as Ae,J as Ce}from"./hydrate.CvWSYK3c.js";import{A as we}from"./app.9pOKhaB_.js";import{T as ke}from"./TransitionHeight.BQH3tbCb.js";import{S as j,b as Le}from"./hooks-useWalletsTimeout.CvRsT5TD.js";import{c as Me}from"./localization-index.8vJFxOS9.js";import{s as G}from"./components-VatNumberValidationField.B3PhNjwY.js";import"./shared-negotiation-input-redeemable.nWvx5Mgl.js";import"./shared-permissions.FyWsJaGm.js";import"./hooks-useShopPayExternalAppContext.DJNBHtP3.js";import"./Page.iFMNx-gv.js";import"./useShopPayButtonClassName.D12YSXlR.js";import"./addresses-is-address-empty.ChTbY4tb.js";import"./hooks-useShowShopPayOptin.COfgoH5j.js";import"./AddressPresenter.mAxMJOkn.js";import"./hooks-useShouldRevealCustomization.xDutk-8T.js";import"./hooks-useForceShopPayUrl.Bj-sC8MR.js";import"./ChangeCompanyLocationLink.D2yMha9m.js";import"./BillingAddressForm.BLCoRu_E.js";import"./components-RedirectionNotice.module.wDj6pdp6.js";import"./amazon-pay-useAmazonPayPaymentLine.Dzl9q1le.js";import"./PhoneField.z-nvF4Oi.js";import"./hooks-useSuppressShopPayModalOnLoad.C3rujIgw.js";import"./Popover.snh8_-Id.js";import"./business-customer-constants.D2XM6iUD.js";import"./Choice.CmWf9O2o.js";import"./utilities-publishMessage.BFG4jKHA.js";import"./Checkbox.BcOmMA-W.js";import"./ImpressionEventCapture.DHoHQcSz.js";import"./ShopPayLogo.Cv8_PxcC.js";import"./hooks-useWalletsMonorailTrack.D-8b2KUL.js";import"./crypto-constants.wrSwcTv4.js";import"./shop-pay-installments-monorail.B28AmH4_.js";import"./hooks-usePickupPoints.Dc_AUzii.js";import"./AutocompleteField-hooks.B3HDb4t8.js";import"./PendingShipping.7OdN0MKO.js";function xe({body:v}){return e(re,{children:e(le,{dangerouslySetInnerHTML:{__html:v.value??""},scrollableContent:"all"})})}function Ee({body:v,loading:C,error:w}){const{i18n:S}=D();return e(A,{when:w,fallback:e(A,{when:C,fallback:e(xe,{body:v}),children:e(U,{gap:"base",children:[e(_,{lines:2,lastLineSize:"large"}),e(_,{lines:3,lastLineSize:"small"}),e(_,{lines:2,lastLineSize:"base"}),e(_,{size:"extraLarge",lastLineSize:"large",lines:1}),e(_,{lines:7,lastLineSize:"small"}),e(_,{lines:3,lastLineSize:"base"})]})}),children:S.translate("bad_request.title")})}const He="VqsW7",Ie="c1X76",Be="JtAjb",g={SubscriptionConsentModal:He,Views:Ie,Pane:Be,"Pane-outgoing":"otCH1"};function Re({id:v,canConfirm:C,onConfirm:w,onHide:S,onShow:r}){const{i18n:h,shop:i}=D(),{checkoutProtocolModalEventSignal:c}=ee(),k=h.translate("payment.purchase_options_cancellation_policy_label"),L=i.merchantPolicies.find(({handle:m})=>m===j),a={handle:j,shopId:i.id,shopName:i.name,squareLogo:i.brandSettings?.squareLogo,name:k,url:L?.url??""},o=te(ce,{defaultPolicy:a,policies:[a]}),f=q(!1),s=y(()=>{f.current&&c.value==="applePaySubscriptionConsent"&&(c.value="none"),f.current=!1},[c]);J(()=>s,[s]);const n=F(!1),u=F(!1),I=q(null),b=ue(),p=pe(n.value,"slow"),l=n.value||u.value,Y=!n.value||u.value,M=y(m=>{I.current=m,m&&(m.dataset.inertSupported=String("inert"in m))},[]),x=h.translate("wallets.continue_with",{walletName:h.translate("brand.apple_pay")}),E=n.value?Me(k):h.translate("payment.purchase_options_subscription_confirmation_title"),B=y(()=>{o.show(),n.value=!0},[o,n]),P=y(()=>{o.hide(),n.value=!1},[o,n]),R=y(()=>{u.value=!0,o.hide(),s(),S()},[u,o,s,S]),T=y(()=>{n.value=!1,u.value=!1,f.current=!0,c.value="applePaySubscriptionConsent",r()},[n,u,c,r]);return e(Se,{id:v,heading:e(U,{direction:"inline",alignItems:"center",gap:"base",children:[e(A,{when:n,children:e(he,{type:"button",padding:"small-400",borderRadius:"base",accessibilityLabel:h.translate("account_management.back"),onClick:P,children:e(be,{type:"arrow-left",size:"base"})})}),e(Pe,{level:1,autoFocus:!0,children:E},n.value?"policy":"consent")]}),accessibilityLabel:E,onShow:T,onHide:R,actionLayout:"stacked",primaryAction:e(ve,{variant:"primary",type:"button",inlineSize:"fill",disabled:!C.value,onClick:w,children:x}),children:e(z,{className:g.SubscriptionConsentModal,children:e(ke,{c
1ontentRef:I,children:e(z,{ref:M,className:g.Views,padding:"small-200",overflow:"hidden",children:[e(A,{when:()=>b?!n.value:p!=="entered",children:e(z,{className:O(g.Pane,n.value&&g["Pane-outgoing"]),"data-side":"backward","data-visible":!n.value&&(b||p!=="exit"),position:n.value?"absolute":"relative",inert:l,children:e(de,{children:e(Le,{buttonLabel:x,cancellationPolicyLink:L?e(me,{tone:"monochrome",onClick:B,children:e(ye,{children:k})}):void 0})})})}),e(A,{when:()=>b?n.value:p!=="exited",children:e(z,{className:O(g.Pane,!n.value&&g["Pane-outgoing"]),"data-side":"forward","data-visible":n.value&&(b||p!=="enter"),position:n.value?"relative":"absolute",inert:Y,children:e(Ee,{body:o.policyBody,loading:o.loading,error:o.error})})})]})})})})}const Ne=Ce("ApplePaySubscriptionConsentModal");function St({supportedNetworks:v,color:C}){const{acceleratedWalletPaymentMethods:w,applePaySessionHandler:S,inMemoryApplePayParts:{buttonStatus:r,paymentSheetError:h}}=ne(),i=N(()=>{const t=S.value;return t?.createSession==null||t.showApplePayPaymentSheet==null?null:{createSession:t.createSession,openApplePayPaymentSheet:t.showApplePayPaymentSheet}}),c=q({status:"rendered"});V(()=>{const t=i.value!=null,H=r.value;t&&H.status==="not_rendered"?$(()=>{r.value=c.current}):!t&&H===c.current&&$(()=>{r.value={status:"not_rendered"}})}),J(()=>()=>{r.value===c.current&&(r.value={status:"not_rendered"})},[r]);const k=fe(),L=q(null),{observability:a,i18n:o,checkout:f}=D(),{wallets:s}=f,n=K(_e()),u=N(()=>ae({hasSubscription:oe({checkout:f}),isApplePayAvailable:w.value.some(({name:t})=>t==="APPLE_PAY"),variant:n.value})),{showOverlay:I,hideOverlay:b}=ge(),p=Ae(void 0,Ne),l=F(!1),Y=y(()=>{l.value=!0,a.log("apple_pay_subscription_consent_modal_opened","Apple Pay subscription consent modal opened")},[l,a]),M=y((t="dismissed")=>{l.value&&(l.value=!1,a.log("apple_pay_subscription_consent_modal_closed","Apple Pay subscription consent modal closed",{reason:t}))},[l,a]),x=()=>{a.log("apple_pay_button_clicked_while_loading","Apple Pay button clicked while already loading the payment sheet. Ignoring click.")},E=()=>{a.error(new we("Apple Pay button clicked without a ready session handler."))},B=t=>{if(s.activeSession.value?.wallet==="APPLE_PAY"){x();return}const W=i.value;if(!W){E();return}try{W.openApplePayPaymentSheet(W.createSession({supportedNetworks:v,...t&&{subscriptionConsent:t}}).session),t==="explicit_modal"&&s.activeSession.value?.wallet==="APPLE_PAY"&&a.log("apple_pay_subscription_consent_session_started","Apple Pay session started after subscription consent")}catch(d){const X={error:d,errorName:d instanceof Error?d.name:"Unknown",errorMessage:d instanceof Error?d.message:String(d),...d instanceof Error&&d.stack&&{errorStack:d.stack}};a.leaveErrorBreadcrumb("Failed to create Apple Pay session",X),h.value={type:"failed_to_create_session"},s.activeSession.value?.wallet==="APPLE_PAY"&&s.clearActiveSession({invokingWallet:"APPLE_PAY"})}},P=N(()=>u.value==="explicit_modal"),R=N(()=>l.value&&P.value&&i.value!=null&&s.activeSession.value==null);V(()=>{if(!l.value)return;(!P.value||i.value==null||s.activeSession.value!=null)&&(M("invalidated"),b(p))});const T=()=>{const t=s.activeSession.value;if(t?.wallet==="APPLE_PAY"){x();return}const H=u.value;if(P.value){if(t){a.log("apple_pay_subscription_consent_blocked_by_active_wallet","Apple Pay subscription consent blocked by another active wallet.",{activeWallet:t.wallet,requestedWallet:"APPLE_PAY"});return}if(!i.value){E();return}L.current?.focus({preventScroll:!0}),I(p);return}B(H)},m=()=>{R.value&&(a.log("apple_pay_subscription_consent_confirmed","Apple Pay subscription consent confirmed"),M("confirmed"),b(p),B("explicit_modal"))},Q=i.value!=null;return e(Z,{children:[e("button",{ref:t=>{L.current=t,k("apple_pay")(t)},className:O(G.ApplePayButton,G[C],ie.borderRadius,se({focusRing:"base"})),lang:o.locale,disabled:!Q,onClick:T,type:"button","aria-label":o.translate("brand.apple_pay"),"aria-haspopup":P.value?"dialog":void 0}),e(A,{when:()=>P.value||l.value,children:e(Re,{id:p,canConfirm:R,onShow:Y,onHide:M,onConfirm:m})})]})}export{St as ApplePayButton};
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.