PageSourceSearch

https://www.rpseeds.co.uk/cdn/shopifycloud/checkout-web/assets/c1/f7742f92.DVoCmk3A.js

js rpseeds.co.uk collected 2026-10-07 02:55:56 UTC 56,973 bytes, 1 lines download raw bytes

1import{k as e,L as t,T as a,s as r,o,q as n,g as s,p as i,h as l,u as d,m as u,S as c}from"./2c1ab0fe.Bywc2Brn.js";import{fD as g,fC as p,cx as m,g1 as y,g2 as _,g3 as h,fj as v,v as E,k as P,f2 as b,fq as A,g4 as I,g5 as S,aI as f,g6 as R,fH as N,fG as C,b as O,c as T,g7 as D}from"./164ad2e3.Bn4mVc0u.js";import{d8 as M,g0 as G,g1 as w,d2 as L,e9 as k,g2 as H,at as Y,aq as U,c as B,c1 as V,aP as F,g3 as x,a5 as z,aE as j,aF as Z,S as q,g4 as W,d7 as $,d6 as Q,g5 as K,g6 as X,aS as J,aa as ee,cz as te,g7 as ae,g8 as re,b3 as oe,g9 as ne,aQ as se}from"./9dba8418.nSn06qNc.js";import{c as ie}from"./71ae3d5c.BAoM4Tq1.js";import{g as le,u as de}from"./cb8fcd45.CCT1Tog5.js";import{u as ue,a as ce}from"./3a819064.DtPrVsKT.js";import{u as ge,W as pe}from"./8536083a.BCOoZZTD.js";import{v as me}from"./2210eadb.DF0gIp_2.js";import{a as ye,b as _e}from"./f67abd2c.BiDTv4D9.js";import{f as he,g as ve,s as Ee,r as Pe,B as be,P as Ae,T as Ie,U as Se,V as fe,D as Re,N as Ne,a as Ce,b as Oe,c as Te,d as De,e as Me,h as Ge,E as we,I as Le,i as ke,j as He,k as Ye,l as Ue,u as Be,m as Ve,n as Fe,o as xe,p as ze,q as je,t as Ze,S as qe,v as We}from"./13b13169.DSoYR-ir.js";import{a as $e,g as Qe}from"./e12db40c.xtsrYBcz.js";import{a as Ke,c as Xe,b as Je}from"./78ab3dd0.B6GdoLl_.js";import{b as et}from"./ed9f2238.CxMZHf9i.js";import{S as tt}from"./app.B7Ohb9rB.js";import{g as at,a as rt,u as ot}from"./33464469.B5TenHDD.js";import{S as nt}from"./ee2bb050.BEm-5zUF.js";import{r as st}from"./d25d1b95.DYZp1r1X.js";import"./d0bb51ec.up41EQh6.js";import"./60a453ce.BI5dm7PK.js";import"./1d34c07e.h4dJAaCz.js";import"./22345fd4.WnqyUJVG.js";import"./cdfd59e6.BkhR01aC.js";import"./7fc410e0.D5WO5kXK.js";import"./17e57de1.B_nQLFIZ.js";import"./ca3e798e.Dc9DtEXz.js";const it=/^[A-Z]{1,2}[0-9]{1,2}[A-Z]?$/,lt=/^[A-Z][0-9][A-Z]$/,dt={apiVersion:2,apiVersionMinor:0};function ut(e,t){const a=e.find(e=>"ONE_TIME_PURCHASE"===e.deliveryLine.type),r=e.find(e=>"SUBSCRIPTION"===e.deliveryLine.type);let o="";if(r){if("PICK_UP"===r.methodType||"LOCAL"===r.methodType)return r.title;o=r.title}const n=[a?.title??"",o].filter(Boolean),[s,i]=n;return void 0===s?"":void 0===i?s:2===n.length?t.combineTwoShippingTitles(s,i):t.combineMultipleShippingTitles(n)}function ct(e){return gt(JSON.stringify(e))}function gt(e){return e.replace(/["']/g,"%")}function pt({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:i,labels:l,i18nCurrency:d,checkoutTotal:u,deferredTotal:c,hasPayableDeposit:g,googlePayTransactionId:p,merchandiseLines:m,shouldWalletDecelerateForSubscriptions:y=!1,discountsZeroValueUXEnabled:_=!1}){const h=e?he(e.amount):"0",v=g&&u&&c,E=v?he(u.amount):void 0,P=v?he(c.amount.amount):void 0,b=Boolean(m?.lines?.length),A=[];m?.lines&&m.lines.forEach(e=>{A.push({label:ve(e),type:"LINE_ITEM",price:he(e.totalPrice.amount)}),function(e,t){const a=new Map;return e.lineAllocations.forEach(e=>{e.allocations.filter(mt).forEach(e=>{const{title:t}=e.discountDetails;a.set(t,(a.get(t)??0)+e.amount.amount)})}),Array.from(a).filter(([,e])=>!t||0!==e).map(([e,t])=>({label:e,type:"LINE_ITEM",price:0===t?he(t):w(he(t))}))}(e,_).forEach(e=>{A.push(e)})}),t&&A.push({label:l.subtotal,type:"SUBTOTAL",price:he(t.amount)}),function(e,t){return e?e.flatMap(e=>{if(!ye(e))return[];if(!G(e))return[];const a=e.amount?.amount;if(void 0===a)return[];if(t&&0===a)return[];const r=he(a);return[{label:e.title,type:"LINE_ITEM",price:0===a?r:w(r)}]}):[]}(n?.lines,_).forEach(e=>{A.push(e)});const I=M(o).reduce((e,t)=>e+t.method.cost.amount,0);return A.push({label:l.shipping,type:"LINE_ITEM",price:he(I)}),a&&"available_total"===a?.status&&0!==a?.totalDuty.amount&&A.push({label:l.duties,type:"LINE_ITEM",price:he(a.totalDuty.amount)}),r&&"available_total"===r.status&&0!==r.totalTax.amount&&A.push({label:l.taxes,type:"LINE_ITEM",price:he(r.totalTax.amount)}),n?.lines.forEach(e=>{if(ye(e)){if(b&&"LINE"===e.discount.presentationLevel&&"delivery"!==e.sourceTerm)return;if(G(e))return;const t=e.amount?.amount;t&&A.push({label:e.title,type:"LINE_ITEM",price:w(he(t))})}}),i?.lines.filter(e=>
1"giftCard"===e.method.type).forEach(e=>{e.cost&&A.push({label:`${l.giftCard} ${L(e.method).toUpperCase()}`,type:"LINE_ITEM",price:w(he(e.cost.amount))})}),s?.forEach(e=>{A.push({label:l.tip,type:"LINE_ITEM",price:he(e.amount.amount)})}),E&&A.push({label:l.deposit,type:"LINE_ITEM",price:E}),P&&A.push({label:l.totalDueLater,type:"LINE_ITEM",price:P}),{totalPrice:E||h,currencyCode:t?.currencyCode||d,totalPriceStatus:"ESTIMATED",totalPriceLabel:E?l.totalDueToday:l.total,displayItems:A,...p&&{transactionId:p},...y&&{checkoutOption:"CONTINUE_TO_REVIEW"}}}function mt(e){return _e(e.discountDetails.discount)&&"LINE"===e.discountDetails.discount.presentationLevel}function yt({googleAddress:e,isFirstNameRequired:t}){let a=e.iso3166AdministrativeArea||void 0,r=e.locality||void 0,o=e.countryCode;"AE"===e.countryCode&&(r=e.administrativeArea),e.countryCode&&H.includes(e.countryCode)&&(a=e.countryCode,o="US");const n={city:r,postalCode:e.postalCode||void 0,zoneCode:a,countryCode:o};if("name"in e){const[a,...r]=(e.name||"").split(" ");0===r.length?(n.lastName=a,t&&(n.firstName=n.lastName)):(n.firstName=a,n.lastName=r.join(" "))}return"address1"in e&&(n.address1=e.address1),"address2"in e&&(n.address2=e.address2),"phoneNumber"in e&&(n.phone=e.phoneNumber),n}function _t({costAfterDiscounts:e,deliveryPromisePresentmentTitle:t}){const{short:a}=t||{};return`${a?`(${a}) `:""}${he(e.amount)} ${e.currencyCode}`}function ht(e,t){e.log("google_pay_authorization_decelerated","Google Pay authorization decelerated",t)}function vt(){const{i18n:e}=B();return a(()=>({total:e.translate("order_summary.total_label"),subtotal:e.translate("order_summary.subtotal_label"),shipping:e.translate("order_summary.shipping_label"),duties:e.translate("order_summary.duties_label"),taxes:e.translate("order_summary.estimated_taxes_label"),giftCard:e.translate("order_summary.gift_card_label"),tip:e.translate("order_summary.tip_label"),deposit:e.translate("order_summary.deposit_label"),totalDueToday:e.translate("order_summary.total_due_today_label"),totalDueLater:e.translate("order_summary.total_due_later_label")}),[e])}function Et(){const{shop:{name:t,myshopifyDomain:a}}=B(),r=g("GOOGLE_PAY");return e(()=>{const e=r.value;return void 0===e?void 0:{merchantName:t,merchantId:e.merchantId,merchantOrigin:a,authJwt:e.authJwt}})}const Pt="GOOGLE_PAY";class bt extends tt{constructor(){super(...arguments),this.name="GooglePayGenericError"}}class At extends tt{constructor(){super(...arguments),this.name="GooglePayCreateButtonError"}}class It extends tt{constructor(){super(...arguments),this.name="GooglePayDeveloperError"}}class St extends tt{constructor(){super(...arguments),this.name="GooglePayUnexpectedStatusCodeError"}}class ft extends tt{constructor(){super(...arguments),this.name="GooglePaySubmissionError"}}class Rt extends tt{constructor(){super(...arguments),this.name="GooglePayInvalidError"}}class Nt extends tt{constructor(){super(...arguments),this.name="GooglePayNegotiationError"}}function Ct({currentPage:e,plan:t},a){const r=new Set;if(!e)return r;const o=t.greenPath.findIndex(t=>_(t,e));for(const n of t.greenPath.slice(0,o+1))for(const e of h(n,a))r.add(e);return r}class Ot extends be{constructor(e,t,a){super(),this.observability=e,this.translated=t,this.reportAddressRequirementMismatch=a}get negotiationResultMapper(){return null}validatePaymentCurrency({initialCurrencyCode:e,currentCurrencyCode:t}){return null==e||null==t?(this.observability.leaveErrorBreadcrumb("[GooglePay] validatePaymentCurrency skipped currency comparison, missing currency code",{initialCurrencyCode:e,currentCurrencyCode:t}),{}):e===t?(this.observability.log("google_pay_validate_payment_currency_succeeded","[GooglePay] validatePaymentCurrency succeeded, currency codes match",{currencyCode:t}),{}):(this.observability.leaveErrorBreadcrumb("[GooglePay] validatePaymentCurrency blocking submission, currency change",{initialCurrencyCode:e,currentCurrencyCode:t}),this.observability.counter({name:"wallet_action_generator_handled_error",value:1,attributes:{violationCode:"CURRENCY_CHANGE",WalletName:Ke.GooglePay}}),{paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.currencyChangeError}]}})}get completionResultMapper(){return new Ae({success:({result:e})=>"receipt"in e?{action:"submit"}:{action:"abort"},rejected:({result:e,violationActions:t,options:a})=>{const r=e.violations??[];
1this.getUnhandledErrors(r,t).forEach(e=>{this.observability.error(new ft(`submitForCompletion in ${this.isRedesign()?"redesign":"3-page"} Google Pay failed due to unhandled error ${e.code}`,{groupingHash:`GooglePaySubmissionError::SubmitForCompletion::UnhandledError::${e.code}`}),{severity:"error"})});const{firstPaymentSheetAction:o,violationCode:n}=this.getMergedPaymentSheetAction({resultViolations:r,violationActions:t});return n&&this.observability.counter({name:"wallet_action_generator_handled_error",value:1,attributes:{violationCode:n,WalletName:Ke.GooglePay}}),this.reportAddressRequirementMismatch({violationCode:n,wallet:Ke.GooglePay,asPaymentMethod:Boolean(a?.asPaymentMethod),outcome:this.isRedesign()?"decelerate":o?.action??"abort"}),this.logCompletionDeceleration({asPaymentMethod:Boolean(a?.asPaymentMethod),layout:a?.layout,violationCode:n??r.at(0)?.code??"unknown",violations:r.map(e=>e.code).join(",")}),o||{action:"abort"}},invalid:({result:e,options:t})=>{const a={reasons:JSON.stringify(e.reasons),action:"invalid"};return this.observability.counter({name:"WalletsPlatform_google_pay_payment_sheet_unexpected_action",value:1,attributes:a}),this.logCompletionDeceleration({asPaymentMethod:Boolean(t?.asPaymentMethod),layout:t?.layout,violationCode:e.reasons.at(0)??"unknown",violations:e.reasons.join(",")}),{action:"abort"}},denied:()=>({action:"abort"}),throttled:()=>({action:"abort"}),tooManyRequests:()=>({action:"abort"}),alreadyCompleted:()=>({action:"abort"}),fetch_failed:()=>(this.observability.counter({name:"WalletsPlatform_google_pay_payment_sheet_unexpected_action",attributes:{action:"fetch_failed"},value:1}),{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.genericError}]})},e=>this.mapUnhandledStatus(e),(e,t)=>this.getCompletionViolationActions(e,t))}logCompletionDeceleration(e){this.isRedesign()&&ht(this.observability,{reason:"submitForCompletion",...e})}mapUnhandledStatus(e){return this.observability.error(new ft(`Unhandled completion status: ${e.status}`,{groupingHash:`GooglePaySubmissionError::UnhandledCompletionStatus::${e.status}`})),{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_AUTHORIZATION",message:this.translated.genericError}]}}}class Tt extends Ot{constructor(e,t,a,r){super(e,t,r),this.inMemoryGooglePayParts=a}validateBilling(e){const t=e.paymentMethodData.info?.billingAddress;return t?{shouldPersist:!0}:this.genericPaymentMethodError()}validateShipping(e,t){const a=e.shippingAddress;return t?a?{shouldPersist:!0}:this.genericPaymentMethodError():{shouldPersist:!1}}isRedesign(){return!0}getCompletionViolationActions(e,t){return[{violations:[...q,"MERCHANDISE_NOT_APPLICABLE",W,...Ie,...Se,...fe,"LOCALIZATION_EXTENSION_FIELD_ERROR",...Re,...Ne,"DELIVERY_WRONG_NUMBER_OF_DELIVERY_LINES",...Ce,...Oe,...Te,...$,"PAYMENTS_METHOD_REQUIRED","PAYMENTS_METHOD",...De,...Me,...Q,"PAYMENTS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN","BUYER_IDENTITY_MISSING_CONTACT_METHOD",...Ge,"BUYER_IDENTITY_EMAIL_REQUIRED",...we,...Le,...K],generateAction:()=>({action:"abort"})},{violations:[...ke,"BUYER_IDENTITY_CONTACT_INFO_DOES_NOT_MATCH_CUSTOMER_PROFILE"],generateAction:()=>({action:"abort",effects:[()=>{this.inMemoryGooglePayParts.paymentSheetError.value={type:"unexpected_terminal_error"}}]})},{violations:["DELIVERY_ZONE_NOT_FOUND"],generateAction:()=>({action:"abort",effects:[()=>this.logZoneCompletionFailure(t,"DELIVERY_ZONE_NOT_FOUND")]})},{violations:["DELIVERY_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>({action:"abort",effects:[()=>this.logZoneCompletionFailure(t,"DELIVERY_ZONE_REQUIRED_FOR_COUNTRY")]})}]}genericPaymentMethodError(){return{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_METHOD",message:this.translated.genericError}]}}}logZoneCompletionFailure(e,t){const{shippingZone:a,shippingCountry:r}=He(e);this.observability.log("redesign_payment_sheet_action_generator_payment_completion_failed","google_pay_payment_completion_failed",{reason:t,shippingZone:a,shippingCountry:r,result:e})}}class Dt extends Ot{constructor(e,t,a,r){super(e,t,r),this.inMemoryGooglePayParts=a}validateBilling(e){const t=e.paymentMethodData.info?.billingAddress;return t?{shouldPersist:!0}:{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_METHOD",message:this.translated.genericError}]}}}validateShipping(e,t,a){const r=e.shippingAddress;return t?r?a&&!r.address2?{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.translated.addressLine2MissingError}]}}:{shouldPersist:!0}:{shouldPersist:!1,paymentSheetAction:{action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"PAYMENT_METHOD",message:this.translated.genericError}]}}:{shouldPersist:!1}}isRedesign(){return!1}getCompletionViolationActions(e,t){return[{violations:[...q,"MERCHANDISE_NOT_APPLICABLE",W,...Ie,...Se,...fe,"LOCALIZATION_EXTENSION_FIELD_ERROR","DELIVERY_WRONG_NUMBER_OF_DELIVERY_LINES","DELIVERY_STRATEGY_CONDITIONS_NOT_SATISFIED",...Le,...K],generateAction:()=>({action:"abort"})},{violations:[...ke,"BUYER_IDENTITY_MISSING_CONTACT_METHOD","BUYER_IDENTITY_CONTACT_INFO_DOES_NOT_MATCH_CUSTOMER_PROFILE"],generateAction:()=>({action:"abort",effects:[()=>{this.inMemoryGooglePayParts.paymentSheetError.value={type:"unexpected_terminal_error"}}]})},{violations:Re,generateAction:()=>({action:"abort",effects:[()=>{this.inMemoryGooglePayParts.paymentSheetError.value={type:"unusable_partial_address"}}]})},{violations:Ne,generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:"SHIPPING_ADDRESS",message:this.translated.addressUnserviceableError}]})},{violations:["DELIVERY_FIRST_NAME_REQUIRED"],generateAction:()=>Mt(this.translated.firstNameMissingError)},{violations:["DELIVERY_LAST_NAME_REQUIRED"],generateAction:()=>Mt(this.translated.lastNameMissingError)},{violations:["DELIVERY_ADDRESS1_REQUIRED"],generateAction:()=>Mt(this.translated.addressLine1MissingError)},{violations:["DELIVERY_ADDRESS2_REQUIRED"],generateAction:()=>Mt(this.translated.addressLine2MissingError)},{violations:["DELIVERY_PHONE_NUMBER_REQUIRED","DELIVERY_OPTIONS_PHONE_NUMBER_REQUIRED"],generateAction:()=>Mt(this.translated.phoneMissingError)},{violations:["DELIVERY_POSTAL_CODE_REQUIRED"],generateAction:()=>Mt(this.translated.zipMissingError)},{violations:["DELIVERY_CITY_REQUIRED"],generateAction:()=>Mt(this.translated.cityMissingError)},{violations:["DELIVERY_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.translated.zoneMissingError}],effects:[()=>{const{shippingZone:e,shippingCountry:a}=He(t);this.observability.log("three_page_payment_sheet_action_generator_payment_completion_failed","google_pay_payment_completion_failed",{reason:"DELIVERY_ZONE_REQUIRED_FOR_COUNTRY",shippingZone:e,shippingCountry:a,result:t})}]})},{violations:["DELIVERY_ZONE_NOT_FOUND"],generateAction:()=>{const{shippingZone:e,shippingCountry:a}=He(t);return{action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_OPTION",message:this.translated.zoneInvalidError}],effects:[()=>{this.observability.log("three_page_payment_sheet_action_generator_payment_completion_failed","google_pay_payment_completion_failed",{reason:"DELIVERY_ZONE_NOT_FOUND",shippingZone:e,shippingCountry:a,result:t})}]}}},{violations:[...we,"BUYER_IDENTITY_EMAIL_REQUIRED"],generateAction:()=>Mt(this.translated.emailInvalidError)},{violations:["DELIVERY_COMPANY_REQUIRED","DELIVERY_ADDRESS1_CONTAINS_EMOJIS","DELIVERY_ADDRESS1_CONTAINS_HTML_TAGS","DELIVERY_ADDRESS1_CONTAINS_MATHEMATICAL_SYMBOLS","DELIVERY_LAST_NAME_CONTAINS_URL"],generateAction:()=>Mt(this.translated.addressInvalid)},{violations:[...Ge,"DELIVERY_OPTIONS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN","DELIVERY_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN"],generateAction:()=>Mt(this.translated.phoneInvalidError)},{violations:["DELIVERY_INVALID_POSTAL_CODE_FOR_ZONE","DELIVERY_INVALID_POSTAL_CODE_FOR_COUNTRY"],generateAction:()=>
1Mt(this.translated.zipInvalidError)},{violations:["PAYMENTS_METHOD_REQUIRED","PAYMENTS_METHOD"],generateAction:()=>Gt(this.translated.genericError)},{violations:["PAYMENTS_FIRST_NAME_REQUIRED"],generateAction:()=>Gt(this.translated.billingAddressFirstNameMissingError)},{violations:["PAYMENTS_LAST_NAME_REQUIRED"],generateAction:()=>Gt(this.translated.lastNameMissingError)},{violations:["PAYMENTS_ADDRESS1_REQUIRED"],generateAction:()=>Gt(this.translated.billingAddressLine1MissingError)},{violations:["PAYMENTS_CITY_REQUIRED"],generateAction:()=>Gt(this.translated.billingAddressCityMissingError)},{violations:["PAYMENTS_ZONE_REQUIRED_FOR_COUNTRY"],generateAction:()=>Gt(this.translated.billingAddressZoneMissingError)},{violations:["PAYMENTS_POSTAL_CODE_REQUIRED"],generateAction:()=>Gt(this.translated.billingAddressZipMissingError)},{violations:["PAYMENTS_PHONE_NUMBER_DOES_NOT_MATCH_EXPECTED_PATTERN"],generateAction:()=>Gt(this.translated.billingAddressPhoneInvalidError)},{violations:[Ye],generateAction:()=>Gt(this.translated.billingAddressZipInvalidError)},{violations:[Ue],generateAction:()=>Gt(this.translated.billingAddressZoneInvalidError)},{violations:["PAYMENTS_INVALID_POSTAL_CODE_FOR_ZONE"],generateAction:()=>Gt(this.translated.billingZipInvalidError)},{violations:["PAYMENTS_ADDRESS1_CONTAINS_HTML_TAGS","PAYMENTS_CITY_CONTAINS_HTML_TAGS","PAYMENTS_LAST_NAME_CONTAINS_URL"],generateAction:()=>Gt(this.translated.billingAddressInvalid)}]}}function Mt(e){return{action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:e}]}}function Gt(e){return{action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",intent:"PAYMENT_METHOD",message:e}]}}function wt(){const{persistedGooglePaySignal:e}=z(),{observability:t,checkout:a}=B(),r=x({availableDeliveryAddresses:a.negotiator.current.fields.availableDeliveryAddresses?.value,mustSelectProvidedAddress:a.negotiator.current.fields.mustSelectProvidedAddress?.value}),o=a.configuration.addressSettings.nonBillingAddressSettings.value,{deliveryLines:s,email:i,shippingAddress:l,paymentLines:d}=a.negotiator.parts;return n(()=>{t.leaveErrorBreadcrumb("[GooglePay] useClearGooglePayProposedState clearing proposed state");const a=X(d.value);d.value=a,i.value="",e.value={...e.value,description:void 0},r||(I(s,void 0),l.value=J({countryCode:o.defaultShippingDetails.country.code,zoneCode:o.defaultShippingDetails.zone.code}))},[o.defaultShippingDetails,r,e,s,i,d,l,t])}const Lt={paymentMethod:{walletPaymentMethod:{name:"GOOGLE_PAY",walletContent:{googlePayWalletContent:{signature:"",signedMessage:"",protocolVersion:""}}}},amount:{any:!0}};function kt({googlePayTransactionId:t}){const r=vt(),{checkout:o,i18n:s,observability:i,shop:l}=B(),{deliveryLines:d,shippingAddress:u}=o.negotiator.parts,c=o.configuration.addressSettings.nonBillingAddressSettings,g=wt(),{persistedGooglePaySignal:p}=z(),m=je(),{value:_}=o.negotiator.current.fields.deliveryNext,h=o.negotiator.current.fields.availableDeliveryAddresses?.value,v=o.negotiator.current.fields.mustSelectProvidedAddress?.value,E=x({availableDeliveryAddresses:h,mustSelectProvidedAddress:v}),P=o.isShippingRequired.value&&!E,b=y(l),A=o.configuration.layout.isOnePage.value,S=l.hasFlagEnabled(V),f=A||S,R=e(()=>f&&F({checkout:o})),N=n(e=>e.reduce((t,a,r)=>r===e.length-1?s.translate("shipping.shipping_method_combinations.combination",{rest:t,current:a}):s.translate("shipping.shipping_method_combinations.with_separator",{rest:t,current:a}),""),[s]),C=a(()=>({businessDays:e=>s.translate("shipping.estimated_delivery_date",{count:e}),businessDaysRange:(e,t)=>
1s.translate("shipping.estimated_delivery_date_range",{minimum:e,maximum:t}),subscriptionsOnlyShippingTitle:s.translate("shipping.subscription_shipping"),combineTwoShippingTitles:(e,t)=>s.translate("shipping.shipping_method_combinations.combination",{rest:e,current:t}),combineMultipleShippingTitles:N}),[s,N]),O=n(({intent:e,trigger:t,result:a})=>{if(a.errors.some(e=>q.has(e.code)))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, stock problems"),{reason:"OTHER_ERROR",intent:e,message:s.translate("wallets.errors.detour.stock_problems",{walletName:s.translate("brand.google_pay")})};if(a.errors.some(e=>e.code===W))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, price mismatch"),{reason:"OTHER_ERROR",intent:e,message:s.translate("wallets.errors.detour.price_change",{walletName:s.translate("brand.google_pay")})};if(a.errors.some(e=>ae.has(e.code)))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, delivery zone not found",{zoneCode:a.negotiated.shippingAddress?.zoneCode,countryCode:a.negotiated.shippingAddress?.countryCode}),{reason:"SHIPPING_ADDRESS_INVALID",intent:e,message:s.translate("wallets.errors.invalid.zone")};if(a.errors.some(e=>Ne.includes(e.code)))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, no delivery strategy",{zoneCode:a.negotiated.shippingAddress?.zoneCode,countryCode:a.negotiated.shippingAddress?.countryCode}),{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:e,message:s.translate("wallets.errors.unsupported.address")};if(!re(a.negotiated.paymentMethods,"GOOGLE_PAY"))return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, google pay unavailable"),{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:e,message:s.translate("wallets.errors.unsupported.wallet_is_unavailable",{walletName:s.translate("brand.google_pay")})};const r=p.value;if(r?.initialCurrencyCode!==a.negotiated.subtotal?.currencyCode)return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, currency change",{beforeCurrencyCode:r?.initialCurrencyCode,afterCurrencyCode:a.negotiated.subtotal?.currencyCode}),{reason:"OTHER_ERROR",intent:e,message:s.translate("wallets.errors.detour.currency_change",{walletName:s.translate("brand.google_pay")})};const o="INITIALIZE"===t;return a.errors.some(e=>Re.includes(e.code))&&!o?(i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiation error, delivery line changed"),{reason:"SHIPPING_OPTION_INVA
1LID",intent:e,message:s.translate("wallets.errors.outdated.shipping_method")}):void 0},[p,s,i]),T=n(({result:e,intent:a,trigger:o,resolve:n,reject:l,shippingOptionId:d,destinationCountry:u,destinationRegion:c,abortSignal:p})=>{function m(){return l({reason:"OTHER_ERROR",message:s.translate("wallets.errors.generic",{walletName:s.translate("brand.google_pay")}),intent:a})}if(p.aborted)return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged result arrived after the session was aborted"),m();switch(i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged received negotiation result",{status:e.status,intent:a,trigger:o}),e.status){case"success":{if(null==e.negotiated.paymentDue)return i.error(new bt("Missing negotiated paymentDue",{groupingHash:"GooglePayGenericError::MissingNegotiatedPaymentDue"})),m();const l=ne(e.negotiated.deliveryNext),g=t.value,p=function({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:i,checkoutTotal:l,deferredTotal:d,labels:u,i18nCurrency:c,translations:g,selectedShippingId:p,deliveryMacros:m,paymentFlexibilityPaymentTermsTemplate:y,googlePayTransactionId:_,merchandiseLines:h,shouldWalletDecelerateForSubscriptions:v=!1,discountsZeroValueUXEnabled:E=!1}){const P=m?.length?function(e){return e.map(({totalTitle:e,totalCostAfterDiscounts:t,deliveryPromisePresentmentTitle:a,deliveryMethodHandles:r})=>({id:ct(r),label:e,description:_t({costAfterDiscounts:t,deliveryPromisePresentmentTitle:a})}))}(m):function(e,t){const a=Y(e).filter(U).map($e);return Qe(a).filter(e=>e.length).map(e=>{return{id:(a=e,gt(Ee(a))),label:ut(e,t),description:e.map(_t).join(", ")};var a})}(o,g),b=pt({paymentDue:e,subtotal:t,duties:a,taxes:r,deliveryNext:o,discountLines:n,tipLines:s,paymentLines:i,labels:u,i18nCurrency:c,checkoutTotal:l,deferredTotal:d,hasPayableDeposit:Boolean(k({deferredTotal:d,checkoutTotal:l,paymentFlexibilityPaymentTermsTemplate:y})?.amount),googlePayTransactionId:_,merchandiseLines:h,shouldWalletDecelerateForSubscriptions:v,discountsZeroValueUXEnabled:E}),A=P.find(e=>e.id===p)?.id??P[0]?.id;return{...P.length>0?{newShippingOptionParameters:{shippingOptions:P,defaultSelectedOptionId:A}}:{},newTransactionInfo:b}}({...e.negotiated,labels:r,i18nCurrency:s.currency,translations:C,selectedShippingId:d,deliveryMacros:l,googlePayTransactionId:g,shouldWalletDecelerateForSubscriptions:R.value,discountsZeroValueUXEnabled:b});if(p.error=O({intent:a,trigger:o,result:e}),P&&!p.newShippingOptionParameters&&!p.error){const t=e.negotiated.deliveryNext&&"unavailable"!==e.negotiated.deliveryNext.status?e.negotiated.deliveryNext.lines:[],r={wallet:"google_pay",intent:a,trigger:o,googlePayTransactionId:g,destinationCountry:u,destinationRegion:c,deliveryNextStatus:e.negotiated.deliveryNext?.status,deliveryLineCount:t.length,deliveryLineStatuses:t.map(e=>e.status).join(",")};i.log("google_pay_missing_shipping_options","wallet_missing_shipping_options",r),i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged resolved with no shipping options and no error",r)}return i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged handleNegotiationResult",{result:e.status,intent:a,trigger:o,transactionInfo:p.newTransactionInfo?JSON.stringify(p.newTransactionInfo):"MISSING"}),n(p)}case"throttled":return g(),l({reason:"OTHER_ERROR",message:s.translate("wallets.errors.detour.queue",{walletName:s.translate("brand.google_pay")}),intent:a});case"tooManyRequests":case"denied":case"alreadyCompleted":return g(),m();case"invalid":return e.reasons.includes(oe.SubmittedForCompletion)?(i.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"invalid",intent:a,trigger:o,reasons:e.reasons}),i.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"invalid"}}
1)):i.error(new Rt("Received unhandled invalid result",{groupingHash:"GooglePayInvalidError::UnhandledInvalidResult"}),{metadata:{request:{reasons:e.reasons}}}),m();case"stale":return i.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"stale",intent:a,trigger:o}),i.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"stale"}}),m();case"fetch_failed":return i.log("payment_data_changed_negotiation_rejected","wallet_rejected_negotiation",{wallet:"google_pay",reason:"fetch_failed",intent:a,trigger:o,fetchFailureReason:e.reason,isActionable:e.isActionable,networkError:e.networkError??!1}),i.counter({name:"wallet_rejected_negotiation",value:1,attributes:{wallet:"google_pay",reason:"fetch_failed"}}),m();case"unexpected_error":return i.error(new Nt("Negotiation threw during the Google Pay session",{groupingHash:"GooglePayNegotiationError::NegotiationThrew",cause:e.error}),{metadata:{request:{intent:a,trigger:o,error:String(e.error)}}}),m();default:return i.error(new bt(`Unhandled negotiation status: ${e.status}`,{groupingHash:"GooglePayGenericError::UnhandledNegotiationStatus"}),{metadata:{request:{intent:a,trigger:o,violations:e.violations.map(e=>e.code)}}}),m()}},[g,s,r,C,O,i,R,P,t,b]),D=n((e,t,a)=>t?new Promise((r,o)=>{se(_)||I(d,void 0);const n="INITIALIZE"===a?e.initiallySelectedShippingOptionId:void 0,s=function({googleAddress:e,isFirstNameRequired:t}){return function(e){const{countryCode:t,postalCode:a}=e;if(null==a)return e;const r=a.trim().toUpperCase();return"CA"===t&&lt.test(r)?e.postalCode=`${r} 0Z0`:"GB"===t&&it.test(r)&&(e.postalCode=`${r} 0ZZ`),e}(yt({googleAddress:e,isFirstNameRequired:t}))}({googleAddress:t,isFirstNameRequired:c.value.isRequired("firstName")});i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiating for handleShippingAddressSelected",{trigger:a,city:t.locality,administrativeArea:t.administrativeArea,countryCode:t.countryCode}),E||(u.value=s),m({abortSignal:e.abortController.signal,fieldsToResolve:["deliveryNext","taxes"],customizeNegotiation:e=>({...Ze(e,s,{interfaceFlow:"GOOGLE_PAY",isConstrainedAddress:E,availableDeliveryAddresses:h,negotiatedDelivery:_}),payment:{...e.payment,totalAmount:{any:!0},paymentLines:st(e.payment?.paymentLines,Lt)}}),observability:i,walletName:Ke.GooglePay,onComplete:s=>T({result:s,intent:"SHIPPING_ADDRESS",trigger:a,resolve:r,reject:o,destinationCountry:t.countryCode,destinationRegion:t.administrativeArea,...n&&{shippingOptionId:n},abortSignal:e.abortController.signal}),logPrefix:"GooglePay::usePaymentDataChanged::handleShippingAddressSelected"}).catch(n=>{T({result:n instanceof qe?{status:"stale"}:{status:"unexpected_error",error:n},intent:"SHIPPING_ADDRESS",trigger:a,resolve:r,reject:o,destinationCountry:t.countryCode,destinationRegion:t.administrativeArea,abortSignal:e.abortController.signal})})}):Promise.resolve({}),[c,T,u,d,m,i,_,E,h]),M=n((e,t,a)=>new Promise((r,o)=>{let n;try{n=We(function(e){const t=new RegExp("[%]","g");return e.replace(t,'"')}(t))}catch{return i.error(new bt(`Invalid shippingOptionId format: ${t}`,{groupingHash:"GooglePayGenericError::InvalidShippingOptionId"}
1)),r({error:{reason:"SHIPPING_OPTION_INVALID",message:s.translate("general.choose_delivery_strategy"),intent:"SHIPPING_OPTION"}})}I(d,n);const l=u.value;i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged negotiating for handleShippingMethodSelected",{trigger:a}),m({abortSignal:e,fieldsToResolve:["deliveryNext","taxes"],customizeNegotiation:e=>({...Ze(e,l,{interfaceFlow:"GOOGLE_PAY",isConstrainedAddress:E,availableDeliveryAddresses:h,negotiatedDelivery:_}),payment:{...e.payment,totalAmount:{any:!0},paymentLines:st(e.payment?.paymentLines,Lt)}}),observability:i,walletName:Ke.GooglePay,onComplete:n=>T({result:n,intent:"SHIPPING_OPTION",trigger:a,resolve:r,reject:o,shippingOptionId:t,abortSignal:e}),logPrefix:"GooglePay::usePaymentDataChanged::handleShippingMethodSelected"}).catch(n=>{T({result:n instanceof qe?{status:"stale"}:{status:"unexpected_error",error:n},intent:"SHIPPING_OPTION",trigger:a,resolve:r,reject:o,shippingOptionId:t,abortSignal:e})})}),[T,s,u,d,m,i,E,h,_]);return n(async({sessionData:e,intermediatePaymentData:t})=>{function a(e,t,a){return{error:{reason:e,message:t,intent:a}}}const{shippingAddress:r,shippingOptionData:o,callbackTrigger:n}=t;switch(n){case"INITIALIZE":case"SHIPPING_ADDRESS":return D(e,r,n);case"SHIPPING_OPTION":return o?.id?M(e.abortController.signal,o.id,n):a("SHIPPING_OPTION_INVA
1LID",s.translate("general.choose_delivery_strategy"),"SHIPPING_OPTION");default:return i.error(new bt(`Could not recognize the intent: ${n}`,{groupingHash:"GooglePayGenericError::CannotRecognizeIntent"})),i.leaveErrorBreadcrumb("[GooglePay] usePaymentDataChanged could not recognize the intent",{callbackTrigger:n}),a("OTHER_ERROR",s.translate("wallets.errors.generic",{walletName:s.translate("brand.google_pay")}),"SHIPPING_ADDRESS")}},[D,M,i,s])}function Ht({asPaymentMethod:_=!1}){const h=s(null),M=o(null),G=s(!1),w=s(0),{isScrimOpen:L,closePopupWindowsAndScrim:H}=de({endpoint:M,invokingWallet:"GOOGLE_PAY"}),Y=R(),U=Et(),q=g("GOOGLE_PAY").value,{i18n:$,observability:Q,checkout:{wallets:K,proposal:X,negotiator:J},client:{userAgent:ae},shop:re}=B(),{value:oe}=J.current.fields.deliveryNext,ne=s({abortController:Ut(),initiallySelectedShippingOptionId:void 0}),ye=o(void 0),{inMemoryGooglePayParts:{sdkStatus:_e,buttonStatus:he}}=z(),{markAsLoaded:ve}=ie(),Ee=s(!0),be=s(!1),Ae=function({asPaymentMethod:a}){const o=Et(),n=function(){const{checkout:a}=B(),r=g("GOOGLE_PAY");return e(()=>{const e=r.value;if(void 0===e)return[];const o=a.configuration.addressSettings.nonBillingAddressSettings.value,n=t(()=>o.isRequired("phone")),{allowedAuthMethods:s,allowedCardNetworks:i,gateway:l,gatewayMerchantId:d}=e;return[{type:"CARD",parameters:{allowedAuthMethods:s,allowedCardNetworks:i,billingAddressRequired:!0,billingAddressParameters:{format:"FULL-ISO3166",phoneNumberRequired:n}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:l??"",gatewayMerchantId:d??""}}}]})}(),{checkout:s,i18n:i,shop:l}=B(),d=s.negotiator,u=p(),c=vt(),{locationAddress:_}=s.negotiator.parts,h=m(),v=y(l),E=s.configuration.layout.isOnePage.value,P=l.hasFlagEnabled(V),b=E||P,A=e(()=>b&&F({checkout:s})),I=r(a);return e(()=>{const e=!I.value&&!x({availableDeliveryAddresses:s.negotiator.current.fields.availableDeliveryAddresses?.value,mustSelectProvidedAddress:s.negotiator.current.fields.mustSelectProvidedAddress?.value})&&s.isShippingRequired.value,a=e?["PAYMENT_AUTHORIZATION","SHIPPING_ADDRESS","SHIPPING_OPTION"]:["PAYMENT_AUTHORIZATION"],r=Pe(d,{includeShopPromotion:!1}),g=h.value&&_.fields.countryCode.value?[_.fields.countryCode.value]:l.shippingCountries?.map(e=>e.value),p=n.value,m=o.value;if(0===p.length||!m||!g||0===g.length&&e||null==r.paymentDue||null==r.subtotal)return null;const y=s.configuration.addressSettings.nonBillingAddressSettings.value,E=t(()=>y.isRequired("phone")),P=Boolean(k({deferredTotal:r.deferredTotal,checkoutTotal:r.checkoutTotal,paymentFlexibilityPaymentTermsTemplate:r.paymentFlexibilityPaymentTermsTemplate})?.amount);return{...dt,allowedPaymentMethods:p,merchantInfo:m,callbackIntents:a,emailRequired:u.value,shippingAddressParameters:{format:"FULL-ISO3166",allowedCountryCodes:g,phoneNumberRequired:E},shippingAddressRequired:e,shippingOptionRequired:e,transactionInfo:pt({labels:c,i18nCurrency:i.currency,...r,hasPayableDeposit:P,shouldWalletDecelerateForSubscriptions:A.value,discountsZeroValueUXEnabled:v})}})}({asPaymentMethod:_}),Ie=s(null),{checkoutCardsinkCallerIdentificationSignature:Se}=X.negotiated.fields,fe=a(()=>{if(!re.cardsinkUrl)return;const e=window.location.host;return{isLocalDev:e.endsWith("checkout.my.shop.dev")||e.endsWith("checkout.shop.dev"),cardsinkUrl:re.cardsinkUrl,callerIdentificationJwt:Se.value}},[re.cardsinkUrl,Se]),Re=_?$.translate("wallets.call_to_action",{walletName:""}):void 0,Ne=$.translate("brand.google_pay"),Ce=function({endpoint:e,isTerminated:t,color:a,config:r,merchantInfo:o,buttonLabel:s,ariaLabel:i,markAsLoaded:l,sdkStatus:d,sdkStatusRef:u,buttonStatus:c,paymentDataRequest:g,containerRef:p,asPaymentMethod:m,isFirstRender:y,updateSdkStatus:_,connectedNullPaymentDataRequest:h,cardsinkConfig:v}){const{observability:E,source:P}=B();return n(async n=>{if(t.current)return void E.leaveErrorBreadcrumb("[GooglePay] useOnConnect skipped - sandbox already terminated");E.leaveErrorBreadcrumb("[GooglePay] useOnConnect starting configuration"),g.value||(h.current=!0),e.value=n;const b=await n.call.configure({isDark:"dark"===a,environment:r?.environment,merchantInfo:o,buttonLabel:s,ariaLabel:i,paymentDataRequest:g.value,style:{borderRadius:le(p.current)},cardsinkConfig:v,sourceId:P.sourceId});y.current=!1,l(),b.status===nt.Success?(E.leaveErrorBreadcrumb("[GooglePay] useOnConnect configuration successful"),_({status:"available"},d,u),"error"!==c.value.status&&(c.value={status:"rendered"},E.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:Pt,status:"success",isPaymentMethodFlow:m}}))):(E.leaveErrorBreadcrumb("[GooglePay] useOnConnect configuration failed",{status:b.status}),b.status===nt.Error&&function({result:{type:e,name:t,message:a},observability:r}){"createButton"===e&&r.error(new At(a,{cause:{name:t,message:a}}),{metadata:{additionalKey:{name:t,message:a}}})}({result:b,observability:E}),c.value={status:"error"},E.counter({name:"checkout_wallet_button_rendered",value:1,attributes:{wallet_name:Pt,status:"error",isPaymentMethodFlow:m,reason:b.status===nt.ScriptLoadError?"script_load_error":"sandbox_error"}}),_({status:"error"},d,u))},[e,t,a,r?.environment,o,s,i,l,d,u,c,g,p,E,m,y,_,h,v,P.sourceId])}({endpoint:M,isTerminated:G,color:Y,config:q,merchantInfo:U.value,buttonLabel:Re,ariaLabel:Ne,markAsLoaded:ve,sdkStatus:_e,sdkStatusRef:h,buttonStatus:he,paymentDataRequest:Ae,containerRef:Ie,asPaymentMethod:_,isFirstRender:Ee,updateSdkStatus:Yt,connectedNullPaymentDataRequest:be,cardsinkConfig:fe}),Oe=function({paymentDataRequest:e,asPaymentMethod:t,isScrimOpen:a,containerRef:r,endpoint:s}){const i=v(),{negotiate:l}=E(),d=P(),{observability:u,checkout:{wallets:c,proposal:g},client:{userAgent:p}}
1=B(),m=j(p)?.name,y="Safari"===m,_=Z(p),h=o(!1),I=o(!1),{inMemoryGooglePayParts:{paymentSheetError:S,paymentSheetOpenPromise:f,paymentSheetOpenPromiseResolve:R,sdkStatus:N},persistedGooglePaySignal:C}=z(),O=et(Ke.GooglePay),T=b(Ke.GooglePay),D=A(Ke.GooglePay);return n(async()=>{i(r);try{if(t){if(h.value)return;h.value=!0,y&&(s.value?.call.updateValidationLock({status:"success"}),a.value=!0),await new Promise((e,t)=>{const a=d.value,r=g.negotiated.value;l({negotiationStage:"completion",silenceViolations:at({journey:a,negotiated:r,fieldsToValidate:[...Ct(a,r)]}),runListenersOnError:!0,onComplete:a=>{"success"===a?.status?e():t()}})})}if(a.value=!0,c.activeSession.value)return u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - active session exists"),a.value=!1,void s.value?.call.updateValidationLock({status:"failure"});const r=N.value;if("available"!==r?.status)return u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - SDK not available",{sdkStatus:r?.status}),a.value=!1,void s.value?.call.updateValidationLock({status:"failure"});c.setActiveSession({newValue:"GOOGLE_PAY",asPaymentMethod:t});try{T();const r=e.value;if(null===r||null==r.callbackIntents||0===r.callbackIntents.length)return u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick early return - invalid payment data request",{paymentDataRequest:null===r?"null":"invalid"}),c.clearActiveSession({invokingWallet:"GOOGLE_PAY"}),S.value={type:"config_missing_required_fields"},a.value=!1,void s.value?.call.updateValidationLock({status:"failure"});D(),O(Xe.Success,t?Je.PaymentMethod:Je.Express),u.counter({name:"wallet_sheet_clicked",value:1,attributes:{instrument:Ke.GooglePay}}),I.value||(u.counter({name:"wallet_attempt_to_open_payment_sheet",value:1,attributes:{os:_,browser:m}}),I.value=!0),C.value={initialCurrencyCode:r.transactionInfo.currencyCode,receiptIdForPaymentFailure:C.value?.receiptIdForPaymentFailure},u.log("handle_click_button_clicked","Google Pay button clicked",{allowedAuthMethods:r.allowedPaymentMethods.map(e=>e.parameters.allowedAuthMethods)}),f.value=new Promise(e=>{R.value=e}),s.value?.call.updateValidationLock({status:"success"})}catch(o){throw c.clearActiveSession({invokingWallet:"GOOGLE_PAY"}),a.value=!1,o}}catch(o){u.leaveErrorBreadcrumb("[GooglePay] useHandleClick onClick error handling",{error:o}),y&&t?(s.value?.call.closePopupWindows(),a.value=!1):t&&y||(a.value=!1),s.value?.call.updateValidationLock({status:"failure"})}finally{h.value&&(h.value=!1)}},[t,m,r,i,D,T,s,I,y,a,h,d,l,_,e,S,f,R,C,g,N,u,O,c])}({paymentDataRequest:Ae,asPaymentMethod:_,isScrimOpen:L,containerRef:Ie,endpoint:M}),Te=function(e){const t=et(Ke.GooglePay),a=o(!1),{persistedGooglePaySignal:r,inMemoryGooglePayParts:{sdkStatus:s,buttonStatus:i,paymentSheetError:l,paymentSheetOpenPromiseResolve:d,paymentSheetOpenPromise:u}}=z(),{observability:c,checkout:{wallets:g},client:{userAgent:p}}=B(),m=j(p)?.name,y=Z(p);return n(o=>{c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler onResponse",{response:o}),e.value=!1;const{response:n,error:p}=o;if(n)d.value?.(void 0);else if(p){switch("CANCELED"===p.name?c.counter({name:"wallet_sheet_cancelled",value:1,attributes:{instrument:Ke.GooglePay}}):c.counter({name:"wallet_sheet_failed",value:1,attributes:{instrument:Ke.GooglePay}}),p.name){case"CANCELED":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: CANCELED"),t(Xe.Cancelled);break;case"DEVELOPER_ERROR":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: DEVELOPER_ERROR",{errorMessage:p.message}),t(Xe.Failure),l.value={type:"invalid_config"},c.error(new It(`loadPaymentData failed: ${p.message}`,{groupingHash:"GooglePayDeveloperError::LoadPaymentDataFailed"}));break;case"BUYER_ACCOUNT_ERROR":case"MERCHANT_ACCOUNT_ERROR":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: ACCOUNT_ERROR",{errorType:p.name,errorMessage:p.message}),t(Xe.Failure),i.value={status:"error"},s.value={status:"error"},c.log("google_pay_response_handler_session_unavailable","Google Pay is unavailable for this session",{reason:p.name});break;case"INTERNAL_ERROR":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: INTERNAL_ERROR",{errorMessage:p.message}),t(Xe.Failure),l.value={type:"unexpected_terminal_error"},c.log("google_pay_response_handler_internal_error","Google Pay internal server error occurred",{errorMessage:p.message});break;case"VALIDATION_TIMEOUT":c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: VALIDATION_TIMEOUT"),t(Xe.Failure);break;case"FAILED_TO_OPEN_WINDOW":a.value||(c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: FAILED_TO_OPEN_WINDOW"),t(Xe.Failure),c.counter({name:"wallet_failed_to_open_window",value:1,attributes:{os:y,browser:m}}),a.value=!0);break;default:c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler error: UNEXPECTED_STATUS",{errorName:p.name,errorMessage:p.message}),c.error(new St(`loadPaymentData failed with unexpected status code: [${p.name}] ${p.message}`,{groupingHash:`GooglePayUnexpectedStatusCodeError::UnexpectedStatus::${p.name}`}))}d.value?.(void 0)}c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler cleanup complete"),"GOOGLE_PAY"===g.activeSession.value?.wallet?g.clearActiveSession({invokingWallet:"GOOG
1LE_PAY"}):c.leaveErrorBreadcrumb("[GooglePay] useGooglePayResponseHandler cleanup complete, but activeSession is not Google Pay",{activeSession:g.activeSession.value}),u.value=void 0,r.value={initialCurrencyCode:void 0}},[m,y,u,r,d,c,t,l,i,s,a,e,g])}(L),De=kt({googlePayTransactionId:ye}),Me=function({asPaymentMethod:t}){const{progress:r}=E(),{shop:o,checkout:s,observability:i}=B(),{deliveryLines:l,email:d,shippingAddress:u,billingAddress:c,paymentLines:p}=s.negotiator.parts,m=s.configuration.addressSettings.nonBillingAddressSettings,y=ee(),_=s.negotiator.current.fields.availableDeliveryAddresses?.value,h=s.negotiator.current.fields.mustSelectProvidedAddress?.value,v=x({availableDeliveryAddresses:_,mustSelectProvidedAddress:h}),P=s.negotiator,b=s.configuration.layout.isOnePage.value,A=s.configuration.layout.baseName,R=o.hasFlagEnabled(V),N=!b&&R,C=e(()=>s.configuration.layout.isOnePage.value||R),O=e(()=>C.value&&F({checkout:s})),T=g("GOOGLE_PAY"),D=function({supportsOnePage:e=!1}={}){const{i18n:t,observability:r}=B(),{inMemoryGooglePayParts:o}=z(),n=Be(),s=a(()=>({genericError:t.translate("wallets.errors.generic",{walletName:t.translate("brand.google_pay")}),shippingMethodError:t.translate("wallets.errors.outdated.shipping_method"),currencyChangeError:t.translate("wallets.errors.detour.currency_change",{walletName:t.translate("brand.google_pay")}),addressUnserviceableError:t.translate("wallets.errors.unsupported.address"),addressInvalid:t.translate("wallets.errors.invalid.shipping_address"),phoneInvalidError:t.translate("wallets.errors.invalid.phone"),zipInvalidError:t.translate("wallets.errors.invalid.postal_code"),zoneInvalidError:t.translate("wallets.errors.invalid.zone"),firstNameMissingError:t.translate("wallets.errors.missing.first_name"),lastNameMissingError:t.translate("wallets.errors.missing.last_name"),addressLine1MissingError:t.translate("wallets.errors.missing.address1"),addressLine2MissingError:t.translate("wallets.errors.missing.address2"),zipMissingError:t.translate("wallets.errors.missing.zip"),zoneMissingError:t.translate("wallets.errors.missing.province"),cityMissingError:t.translate("wallets.errors.missing.city"),emailInvalidError:t.translate("wallets.errors.invalid.email"),phoneMissingError:t.translate("wallets.errors.missing.phone"),billingAddressInvalid:t.translate("wallets.errors.invalid.billing_address"),billingAddressPhoneInvalidError:t.translate("wallets.errors.invalid.billing_phone"),billingAddressZipInvalidError:t.translate("wallets.errors.invalid.billing_zip"),billingAddressZoneInvalidError:t.translate("wallets.errors.invalid.billing_zone"),billingZipInvalidError:t.translate("wallets.errors.invalid.billing_zip"),billingAddressLine1MissingError:t.translate("wallets.errors.missing.billing_address1"),billingAddressFirstNameMissingError:t.translate("wallets.errors.missing.billing_first_name"),billingAddressCityMissingError:t.translate("wallets.errors.missing.billing_city"),billingAddressZipMissingError:t.translate("wallets.errors.missing.billing_zip"),billingAddressZoneMissingError:t.translate("wallets.errors.missing.billing_province")}),[t]);return a(()=>e?new Tt(r,s,o,n):new Dt(r,s,o,n),[r,e,s,o,n])}({supportsOnePage:C.value||O.value}),M=wt(),G=Ve(),w=S(),L=f(),k=function(){const{walletUsedForSubmissionSignal:e,inMemoryGooglePayParts:{paymentSheetError:t}}=z(),a=wt();return n(()=>{t.value=void 0,e.value=void 0,a()},[t,e,a])}(),H=rt({flag:V,onAbort:k,onError:k}),{inMemoryGooglePayParts:{paymentSheetOpenPromise:Y,paymentSheetError:U},persistedGooglePaySignal:j,walletUsedForSubmissionSignal:Z}=z(),{trackAttempt:q,trackComplete:$}=ot(Ke.GooglePay),Q=n(async({reason:e})=>{N?await H({wallet:"GOOGLE_PAY",reason:e,asPaymentMethod:!1,announceSubscriptionReviewLayoutSwitch:"subscriptions"===e}):(s.wallets.setEscalatedWallet("GOOGLE_PAY"),L?.dispatch("addressReplaced"))},[H,N,L,s.wallets]);return n(({isShippingRequired:e,paymentData:a,cardsinkResult:o})=>new Promise(n=>{const g=performance.now();i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, attempting completion",{shippingAddressCity:a.shippingAddress?.locality??"MISSING",shippingAddressAdministrativeArea:a.shippingAddress?.administrativeArea??"MISSING",shippingAddressCountryCode:a.shippingAddress?.countryCode??"MISSING",billingAddressCity:a.paymentMethodData.info?.billingAddress?.locality??"MISSING",billingAddressAdministrativeArea:a.paymentMethodData.info?.billingAddress?.administrativeArea??"MISSING",billingAddressCountryCode:a.paymentMethodData.info?.billingAddress?.countryCode??"MISSING"}),q();const _=()=>{$({result:"failed",durationMs:performance.now()-g})},h=a.shippingAddress,E=a.paymentMethodData.info?.billingAddress,b=a.paymentMethodData,S=m.value.isRequired("address2"),f=D.validatePaymentCurrency({initialCurrencyCode:j.value?.initialCurrencyCode,currentCurrencyCode:P.current.fields.subtotal?.value?.currencyCode}
1),R=D.validateBilling(a),L=D.validateShipping(a,e,S);if(i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized: validation results",{paymentValidationResult:f,billingValidationResult:R,shippingValidationResult:L}),f.paymentSheetAction)return _(),X(f.paymentSheetAction);if(R.paymentSheetAction)return _(),X(R.paymentSheetAction);if(L.paymentSheetAction)return _(),X(L.paymentSheetAction);if(R.shouldPersist&&E&&(c.value=yt({googleAddress:E,isFirstNameRequired:m.value.isRequired("firstName")})),L.shouldPersist&&h){const e=h.iso3166AdministrativeArea;w({postalCode:h.postalCode,countryCode:h.countryCode,city:h.locality,zoneCode:e},"GOOGLE_PAY"),v||(u.value=yt({googleAddress:h,isFirstNameRequired:m.value.isRequired("firstName")}))}const k=s.negotiator.current.fields.buyerIdentity.value?.customerProfile?.email||a.email;k&&(d.value=k),G(),j.value={...j.value,description:b.description,receiptIdForPaymentFailure:void 0};const H=p.value,{signature:B,signedMessage:V,protocolVersion:F}=a.paymentMethodData.tokenizationData.token?JSON.parse(a.paymentMethodData.tokenizationData.token):{signature:"",signedMessage:"",protocolVersion:""};let x=0;const z=Fe(P.current.fields.deliveryNext?.value),K=async()=>{let e=!1;i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment authorized completion attempt",{attemptNumber:x}),await r("google-pay-payment-authorized",async a=>{i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment authorized completion result",{result:{status:a.status,violations:("violations"in a?a.violations:[])||[],errors:("errors"in a?a.errors:[])||[]}}),"success"===a.status&&(Z.value="GOOGLE_PAY"),"denied"!==a.status&&"throttled"!==a.status&&"tooManyRequests"!==a.status||M();const r=a,o="rejected"===r.status&&r.violations.some(e=>e.code===W),{shouldRetry:n,retryReason:s,updatedDeliveryMethodHandles:d}=function(e,t,a,r){const o={shouldRetry:!1,retryReason:"",updatedDeliveryMethodHandles:void 0};if(t>=1)return o;if("stale"===e.status)return{shouldRetry:!0,retryReason:"stale",updatedDeliveryMethodHandles:void 0};if("fetch_failed"===e.status)return{shouldRetry:!0,retryReason:"fetch_failed",updatedDeliveryMethodHandles:void 0};if("rejected"===e.status&&e.violations?.length){const t=ze(e,a.current.fields.deliveryNext?.peek(),r);if(t)return{shouldRetry:!0,retryReason:"delivery_option_mismatch",updatedDeliveryMethodHandles:t}}return o}(r,x,P,z);if(d&&I(l,d),n&&!o)return x++,i.counter({name:"wallet_submit_for_completion_retry",value:1,attributes:{retry_reason:s,retry_count:x,status:r.status,instrument:Ke.GooglePay}}),i.log("payment_authorized_completion_retried",`GooglePay::usePaymentAuthorized: Retrying ${s} completion`,{attemptNumber:x}),void K();const u=D.completionResultMapper.mapResultToPaymentSheetAction(r,{options:{asPaymentMethod:t,layout:A}});i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, payment sheet action mapper result",{paymentSheetAction:u});const c="show_error"===u.action||"abort"===u.action?"failed":"success";try{await X(u)}finally{$({result:c,durationMs:performance.now()-g,attributes:{retry_count:x>0?x.toString():void 0}}),i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, authorization result",{authorizationResult:c}),!C.value||"rejected"!==a.status&&"invalid"!==a.status||(U.value||(U.value={type:"recovery_notice"}),N?e=!0:Q({reason:"submitForCompletion"}))}},{skipToCompletion:!0,customizeCompletion:xe}),e&&Q({reason:"submitForCompletion"})};async function X(e){if(e.effects?.forEach(e=>e()),"show_error"===e.action)return i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, resolving with error",{paymentSheetAction:e}),void n({transactionState:"ERROR",error:e.errors?.[0]});i.leaveErrorBreadcrumb("[GooglePay] usePaymentAuthorized, resolving with success"),n({transactionState:"SUCCESS"}),await Y.value}(()=>{const e=P.current.fields.paymentDue.value,t=e&&e.amount>0||y.value;return o?(e=>{if(e){if(o&&"error"in o)return i.leaveErrorBreadcrumb("[GooglePay] Cardsink deposit failed in sandbox",{error:o.error}),i.counter({name:"wallet_authorization_cardsink",value:1,attributes:{status:"failed",instrument:Ke.GooglePay}}),X({action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",message:"Failed to process payment",intent:"PAYMENT_AUTHORIZATION"}]}),!1;o&&"sessionId"in o&&(i.leaveErrorBreadcrumb("[GooglePay] Using sessionId from sandbox cardsink",{sessionId:o.sessionId}),i.counter({name:"wallet_authorization_cardsink",value:1,attributes:{status:"success",instrument:Ke.GooglePay}}),p.value=te(H,{method:{type:"wallet",name:"GOOGLE_PAY",walletContent:{protocolVersion:"",signature:"",signedMessage:"",sessionId:o.sessionId,paymentMethodIdentifier:T.value?.paymentMethodIdentifier}}}))}return!0})(t):(t&&(p.value=te(H,{method:{type:"wallet",name:"GOOGLE_PAY",walletContent:{signature:B,signedMessage:V,protocolVersion:F,paymentMethodIdentifier:T.value?.paymentMethodIdentifier}}})),!0)})()&&(O.value?(ht(i,{reason:"subscriptions",asPaymentMethod:t,layout:A}),X({action:"decelerate",effects:[()=>{U.value=void 0}]}).finally(()=>Q({reason:"subscriptions"})).catch(e=>{i.leaveErrorBreadcrumb("[Google Pay] Failed to handle payment sheet action:",{err:e})})):K())}),[m,t,M,T,s.negotiator.current.fields,y,P,Y,D,j,r,c,l,d,p,u,Z,w,i,U,G,v,C,O,Q,N,q,$,A])}({asPaymentMethod:_}),Ge=ge(),we=ue();function Le(e){Q.log("google_pay_callback_timing","[GooglePay] callback progress",e,{requiresKeepalive:!0});const{scope:t,callback:a,outcome:r,durationMs:o}=e;if("progress"===r)return;const n={scope:t,callback:a,outcome:r};Q.counter({name:"google_pay_callback_events",value:1,attributes:n}
1),"resolved"!==r&&"rejected"!==r||Q.histogram({name:"google_pay_callback_duration",value:o,unit:"ms",attributes:n})}function ke(e,t){let a=!1;return function({log:e,stage:t,...a}){try{let r=function(t){try{"resolved"!==t&&"rejected"!==t||clearTimeout(i),e({...a,callbackId:o,stage:s,outcome:t,durationMs:performance.now()-n,visibilityState:document.visibilityState})}catch{}};const o=me(),n=performance.now();let s=t;const i=setTimeout(()=>r("pending"),25e3);return r("started"),{stage(e){s!==e&&(s=e,r("progress"))},observe(e){try{return e().then(e=>(r("resolved"),e),e=>{throw r("rejected"),e})}catch(t){throw r("rejected"),t}}}}catch{return{stage(){},observe:e=>e()}}}({scope:"host",callback:e,stage:"checkout",trigger:t,googlePayTransactionId:ye.peek(),log:e=>{"started"===e.outcome?(a=!0,w.current++):!a||"resolved"!==e.outcome&&"rejected"!==e.outcome||(a=!1,w.current--),Le(e)}})}function He(e){try{Q.log("google_pay_sandbox_lifecycle","[GooglePay] sandbox lifecycle",{stage:e,googlePayTransactionId:ye.peek(),pendingHostCallbacksInComponent:w.current},{requiresKeepalive:!0})}catch{}}const Ye=ce({onPaymentAuthorized:e=>ke("authorization").observe(()=>Me(e)),onPaymentDataChanged:e=>ke("shipping",e.callbackTrigger).observe(()=>De({sessionData:ne.current,intermediatePaymentData:e})),onClick:async({transactionId:e}={})=>(e&&(ye.value=e),se(oe)&&(ne.current.initiallySelectedShippingOptionId=ct(D({proposedDeliveryLines:X.proposed.deliveryLines}))),await Oe()),onResponse:e=>{He("wallet_response_received");const t=ne.current.abortController;ne.current={abortController:Ut(),initiallySelectedShippingOptionId:void 0};const a=Te(e);return t.abort(),a},telemetry:Ge,breadcrumb:e=>{var t;if("[GooglePay Sandbox] callback progress"!==e.message&&"[GooglePay Sandbox] loadPaymentData started"!==e.message&&"[GooglePay Sandbox] loadPaymentData resolved"!==e.message)we(e);else try{"[GooglePay Sandbox] callback progress"===e.message?(t=e.attributes,"host"!==t?.scope&&"sandbox"!==t?.scope||"shipping"!==t.callback&&"authorization"!==t.callback||"checkout"!==t.stage&&"cardsink"!==t.stage&&"host_rpc"!==t.stage||"started"!==t.outcome&&"progress"!==t.outcome&&"pending"!==t.outcome&&"resolved"!==t.outcome&&"rejected"!==t.outcome||"string"!=typeof t.callbackId||"number"!=typeof t.durationMs||!Number.isFinite(t.durationMs)||"visible"!==t.visibilityState&&"hidden"!==t.visibilityState||void 0!==t.googlePayTransactionId&&"string"!=typeof t.googlePayTransactionId||void 0!==t.trigger&&"string"!=typeof t.trigger||Le(e.attributes)):Q.log("google_pay_sheet_progress",e.message,e.attributes,{requiresKeepalive:!0})}catch{}}});i(()=>{const e=!Ee.current||be.current;M.value&&Ae.value&&e&&(be.current=!1,M.value.call.updatePaymentDataRequest(Ae.value))}),l(()=>(Yt({status:"loading"},_e,h),()=>{const e=_e.value,t=he.value;e===h.current&&"error"!==t.status&&(_e.value={status:"idle"},he.value={status:"not_rendered"},"GOOGLE_PAY"===K.activeSession.value?.wallet&&K.clearActiveSession({invokingWallet:"GOOGLE_PAY"}))}),[]);const Ue=_?"54px":void 0,je=d(O,{inlineAlignment:"center",children:d(T,{size:"large"})}),Ze=!function(e=window.navigator.userAgent){return/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+(?: Mobile)? Safari\/537\.36$/.test(e)||/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+ Safari\/537\.36 Edg\/[\d.]+$/.test(e)||/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/[\d.]+(?: Mobile)? Safari\/537\.36 Vivaldi\/[\d.]+$/.test(e)}(ae),qe=r(!Ze),We=d(C,{isOpen:L,isInvisible:qe,onClick:H,children:Ze&&d(N,{handleClose:H,walletName:$.translate("brand.google_pay")})}),$e=d(c,{children:[d(pe,{wallet:Pt,onConnect:Ce,onTerminate:()=>{He("endpoint_terminated"),G.current=!0,M.value=null},hostMethods:Ye,ref:Ie,height:Ue}),We]}),Qe=_&&"rendered"!==he.value.status&&"error"!==he.value.status;return _?d(c,{children:[Qe&&je,d(O,{className:u(Qe&&"QIbE6"),children:$e})]}):$e}function Yt(e,t,a){a.current=e,t.value=a.current}function Ut(){return new AbortController}export{Ht as default};

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.