import{Pt as o,Qt as e,Xt as t}from"./630ba094.L_X-5TXi.js";import{IS as n,LS as a,RS as r,_E as s,_b as i,lE as l,tx as p,xO as y,yb as c}from"./6ec9a0fa.rdcQt2v8.js";var u=i("CheckoutSheetProtocolSchemaContext"),h=i("MobileCheckoutSdkSchemaContext");function P(){const o=e(u),t=e(h);if(!o&&!t)throw new c("No Checkout Sheet Protocol or Mobile Checkout SDK Schema context found");return o||t}var f=()=>{const{schema:{postMessageHandler:o}}=P(),{observability:e}=y();return{handleViolationEvent:t((t,n)=>{e.log("checkout_sheet_protocol_violation_event_emitted","Emitting event: `violation`."),o({type:"violation",flowType:n,violationErrors:t})},[o,e]),handleJourneyProgressionErrorEvent:t((t,n)=>{e.log("checkout_sheet_protocol_journey_progression_error_event_emitted","Emitting event: `journeyProgressionError`."),o({type:"journeyProgressionError",flowType:n,reasons:t})},[o,e])}},d=[{brand:"APPLE_PAY",flowType:"applePay"},{brand:"GOOGLE_PAY",flowType:"googlePay"},{brand:"PAYPAL_EXPRESS",flowType:"payPal"},{brand:"SHOPIFY_INSTALLMENTS",flowType:"shopifyInstallments"},{brand:s.AmazonPay,flowType:"amazonPay"},{brand:s.BuyWithPrime,flowType:"buyWithPrime"}];function m(){const{checkout:{identity:e,negotiator:t},router:n,shopPay:a}=y(),r=t.parts.paymentLines;return o(()=>{const o="shopPay"===e.current.value,t=n.currentUrlMatches("/shoppay_login"),i=r.value,y="SHOPIFY_INSTALLMENTS"===a.session.paymentMethodOption.value?.name.toUpperCase(),c=d.map(({brand:o,flowType:e})=>{return{condition:(t=o,Object.values(s).includes(t)?Boolean(p(i,o)):Boolean(l(i,o))),flowType:e};var t});return[{condition:t,flowType:"shopPayLogin"},{condition:y,flowType:"shopifyInstallments"},{condition:o,flowType:"shopPay"},...c].find(({condition:o})=>o)?.flowType??"regular"})}function _(o,e){o.postMessageToConsumer(e)}export{h as a,P as i,m as n,u as o,f as r,_ as t};