1import{u as e,w as a,g as t,q as s,h as n,o as l,m as o,k as i,p as r,L as c,s as p,S as d}from"./2c1ab0fe.RaLGJvq2.js";import{a as u,bY as m,_ as b,bZ as v,aJ as h,v as f}from"./f67abd2c.C46XWaN_.js";import{S as y,ce as _,G as P,cf as j,cg as S,W as g,be as w,b as A,f as k,L,i as C,B as E,aJ as N,a0 as z,H as x,M,a as Y,ch as H,ci as W,s as q,t as I}from"./164ad2e3.CFfy82JW.js";import{A as B}from"./d4ea2faa.CWip83cs.js";import{T as R}from"./7b0c98ea.FTfWhjfA.js";import{S as J,d as O}from"./e3e348f2.BPc4qUS2.js";import{c as F}from"./31cc568e.95lmLO5k.js";import{e as G}from"./1d34c07e.h4dJAaCz.js";import{s as K}from"./dffdfb34.CHBeKG8E.js";import"./app.tqmx-w8m.js";import"./d0bb51ec.J_EOosAq.js";import"./60a453ce.BDU_ws-c.js";import"./e12db40c.mIeTs0Fw.js";import"./9dba8418.B8kf8LtI.js";import"./71ae3d5c.DH8uwl0W.js";import"./3ca8ef7e.vFUF4jyH.js";import"./1f5e7811.BX-tJdOw.js";import"./2fdb3dd3.BeencKAu.js";import"./22345fd4.MHNxKXFg.js";import"./0e67bd3b.Cn4Ls_oX.js";import"./74835653.B3I-NlXD.js";import"./2495faa4.DxVlDpSd.js";import"./a9fa9fda.-Ml-d3Ge.js";import"./ca3e798e.BWruLT5k.js";import"./47b970b2.CyfePLc5.js";import"./064f6ac1.DtwFC3xO.js";import"./efa0389a.BJsVfRJM.js";import"./4b1c22b7.CBznZX-z.js";import"./17425706.DYx1euOe.js";import"./55098bf1.B1TtF7KT.js";import"./cb5cf153.Vt0wO2Fu.js";import"./cb38e5c2.ERLvoZyd.js";import"./78ab3dd0.CLnAKxte.js";import"./ed9f2238.CzBSXgC_.js";import"./6fb6f9d8.m6-Q4TVO.js";import"./1444e6bd.3dT0WTfN.js";import"./0b8657b8.1L9PQQIa.js";import"./a422df8c.BfFjcAUk.js";import"./79974aab.B6la8WQu.js";import"./d22d2b80.CBcbeQxk.js";import"./f49d4216.BWUEesJN.js";function T({body:a}){return e(j,{children:e(P,{dangerouslySetInnerHTML:{__html:a.value??""},scrollableContent:"all"})})}function X({body:t,loading:s,error:n}){const{i18n:l}=u();return e(a,{when:n,fallback:e(a,{when:s,fallback:e(T,{body:t}),children:e(y,{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:l.translate("bad_request.title")})}const Q="JtAjb",U="otCH1";function V({id:i,canConfirm:r,onConfirm:c,onHide:p,onShow:d}){const{i18n:b,shop:v,checkout:{negotiator:h}}=u(),{checkoutProtocolModalEventSignal:f}=h.context,_=b.translate("payment.purchase_options_cancellation_policy_label"),P=v.merchantPolicies.find(({handle:e})=>e===J),j={handle:J,shopId:v.id,shopName:v.name,squareLogo:v.brandSettings?.squareLogo,name:_,url:P?.url??""},Y=m(S,{defaultPolicy:j,policies:[j]}),H=t(!1),W=s(()=>{H.current&&"applePaySubscriptionConsent"===f.value&&(f.value="none"),H.current=!1},[f]);n(()=>W,[W]);const q=l(!1),I=l(!1),B=t(null),G=g(),K=w(q.value,"slow"),T=q.value||I.value,V=!q.value||I.value,Z=s(e=>{B.current=e,e&&(e.dataset.inertSupported=String("inert"in e))},[]),D=b.translate("wallets.continue_with",{walletName:b.translate("brand.apple_pay")}),$=q.value?F(_):b.translate("payment.purchase_options_subscription_confirmation_title"),ee=s(()=>{Y.show(),q.value=!0},[Y,q]),ae=s(()=>{Y.hide(),q.value=!1},[Y,q]),te=s(()=>{I.value=!0,Y.hide(),W(),p()},[I,Y,W,p]),se=s(()=>{q.value=!1,I.value=!1,H.current=!0,f.value="applePaySubscriptionConsent",d()},[q,I,f,d]);return e(M,{id:i,heading:e(y,{direction:"inline",alignItems:"center",gap:"base",children:[e(a,{when:q,children:e(N,{type:"button",padding:"small-400",borderRadius:"base",accessibilityLabel:b.translate("account_management.back"),onClick:ae,children:e(z,{type:"arrow-left",size:"base"})})}),e(x,{level:1,autoFocus:!0,children:$},q.value?"policy":"consent")]}),accessibilityLabel:$,onShow:se,onHide:te,actionLayout:"stacked",primaryAction:e(E,{variant:"primary",type:"button",inlineSize:"fill",disabled:!r.value,onClick:c,children:D}),children:e(A,{className:"VqsW7",children:e(R,{contentRef:B,children:e(A,{ref:Z,className:"c1X76",padding:"small-200",overflow:"hidden",children:[e(a,{when:()=>G?!q.value:"entered"!==K,children:e(A,{className:o(Q,q.value&&U),"data-side":"backward","data-visible":!q.value&&(G||"exit"!==K),position:q.value?"absolute":"relative",inert:T,children:e(k,{children:e(O,{buttonLabel:D,cancellationPolicyLink:P?e(L,{tone:"monochrome",onClick:ee,children:e(C,{children:_})}):void 0})})})}),e(a,{when:()=>G?q.value:"exited"!==K,children:e(A,{className:o(Q,!q.value&&U),"data-side":"forward","data-visible":q.value&&(G||"enter"!==K),position:q.value?"relative":"absolute",inert:V,children:e(X,{body:Y.policyBody,loading:Y.loading,error:Y.error})})})]})})})})}const Z=I("ApplePaySubscriptionConsentModal");function D({supportedNetworks:m,color:y}){const{acceleratedWalletPaymentMethods:_,applePaySessionHandler:P,inMemoryApplePayParts:{buttonStatus:j,paymentSheetError:S}}=b(),g=i(()=>{const e=P.value;return null==e?.createSession||null==e.showApplePayPaymentSheet?null:{createSession:e.createSession,openApplePayPaymentSheet:e.showApplePayPaymentSheet}}),w=t({status:"rendered"});r(()=>{const e=null!=g.value,a=j.value;e&&"not_rendered"===a.status?c(()=>{j.value=w.current}):e||a!==w.current||c(()=>{j.value={status:"not_rendered"}})}),n(()=>()=>{j.value===w.current&&(j.value={status:"not_rendered"})},[j]);const A=Y(),k=t(null),{observability:L,i18n:C,checkout:E}=u(),{wallets:N}=E,z=p(H()),x=i(()=>v({hasSubscription:h({checkout:E}),isApplePayAvailable:_.value.some(({name:e})=>
1"APPLE_PAY"===e),variant:z.value})),{showOverlay:M,hideOverlay:I}=W(),R=q(void 0,Z),J=l(!1),O=s(()=>{J.value=!0,L.log("apple_pay_subscription_consent_modal_opened","Apple Pay subscription consent modal opened")},[J,L]),F=s((e="dismissed")=>{J.value&&(J.value=!1,L.log("apple_pay_subscription_consent_modal_closed","Apple Pay subscription consent modal closed",{reason:e}))},[J,L]),T=()=>{L.log("apple_pay_button_clicked_while_loading","Apple Pay button clicked while already loading the payment sheet. Ignoring click.")},X=()=>{L.error(new B("Apple Pay button clicked without a ready session handler."))},Q=e=>{const a=N.activeSession.value;if("APPLE_PAY"===a?.wallet)return void T();const t=g.value;if(t)try{t.openApplePayPaymentSheet(t.createSession({supportedNetworks:m,...e&&{subscriptionConsent:e}}).session),"explicit_modal"===e&&"APPLE_PAY"===N.activeSession.value?.wallet&&L.log("apple_pay_subscription_consent_session_started","Apple Pay session started after subscription consent")}catch(s){const e={error:s,errorName:s instanceof Error?s.name:"Unknown",errorMessage:s instanceof Error?s.message:String(s),...s instanceof Error&&s.stack&&{errorStack:s.stack}};L.leaveErrorBreadcrumb("Failed to create Apple Pay session",e),S.value={type:"failed_to_create_session"},"APPLE_PAY"===N.activeSession.value?.wallet&&N.clearActiveSession({invokingWallet:"APPLE_PAY"})}else X()},U=i(()=>"explicit_modal"===x.value),D=i(()=>J.value&&U.value&&null!=g.value&&null==N.activeSession.value);r(()=>{J.value&&(!U.value||null==g.value||null!=N.activeSession.value)&&(F("invalidated"),I(R))});const $=null!=g.value;return e(d,{children:[e("button",{ref:e=>{k.current=e,A("apple_pay")(e)},className:o(K.ApplePayButton,K[y],G.borderRadius,f({focusRing:"base"})),lang:C.locale,disabled:!$,onClick:()=>{const e=N.activeSession.value;if("APPLE_PAY"===e?.wallet)return void T();const a=x.value;if(U.value)return e?void L.log("apple_pay_subscription_consent_blocked_by_active_wallet","Apple Pay subscription consent blocked by another active wallet.",{activeWallet:e.wallet,requestedWallet:"APPLE_PAY"}):g.value?(k.current?.focus({preventScroll:!0}),void M(R)):void X();Q(a)},type:"button","aria-label":C.translate("brand.apple_pay"),"aria-haspopup":U.value?"dialog":void 0}),e(a,{when:()=>U.value||J.value,children:e(V,{id:R,canConfirm:D,onShow:O,onHide:F,onConfirm:()=>{D.value&&(L.log("apple_pay_subscription_consent_confirmed","Apple Pay subscription consent confirmed"),F("confirmed"),I(R),Q("explicit_modal"))}})})]})}export{D 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.