PageSourceSearch

https://www.hairbro.co.uk/cdn/shopifycloud/checkout-web/assets/c1/hooks-useUpdateCheckoutAddress.4MSJT9xw.js

js hairbro.co.uk collected 2026-09-29 10:05:31 UTC 5,750 bytes, 1 lines download raw bytes

1import{A as J,h as K,T as E,q as z,l as de,f as ue}from"./esnext-vendor.7EcvH7tF.js";import{c6 as le,aY as ce,a2 as X,c7 as pe,c8 as ye,Q as b,S as Z,b0 as me,V as $,c9 as he,b2 as Pe,ca as G,cb as ve,cc as fe,cd as ge,ce as Ce,cf as Se,cg as Ae,ch as V,H as Me,ci as be,cj as Te,aO as _e}from"./utilities-previous.BNOUhCqt.js";import{f as ee,c as ke,bQ as Y,bR as Le}from"./hydrate.CvWSYK3c.js";import{h as Ie}from"./hooks-useShopPayExternalAppContext.DJNBHtP3.js";import{s as Fe,i as we}from"./helpers-derivations.BE31Cdos.js";class De extends Error{constructor(){super(...arguments),this.name="UnsupportedShopPayCustomerCardError"}}function Ke({allowPreselect:e=!0,displayedPaymentMethods:t}={}){const n=le(),{hasNegotiatedAlternativePaymentCurrencySignal:a,newCardSignal:r}=ce(),o=X(),p=o.paymentMethods,{value:s}=pe(),{negotiate:i}=ee(),P=o.paymentLines,C=ye(),{checkout:{identity:l},observability:c,userEvents:m,shop:te}=b(),{currencyCode:T,id:x,paymentMethodAutoSelectionDisabled:ne}=te,v=l.current.value==="shopPay",S=!v,y=Q(t??s,v),{value:ae}=o.buyerIdentity,d=Z().paymentLines,{value:U}=o.deferredTotal,{value:H}=o.paymentFlexibilityPaymentTermsTemplate,O=me(),_=ae?.presentmentCurrency||T,oe=ke(),k=J(!1),q=J(!1),A=v?d.value.find(u=>u.method.type===$.CreditCard)?.method.type:void 0;K(()=>{!A||q.current||(q.current=!0,c.counter({name:"shop_pay_unsupported_customer_card_on_payline",value:1,attributes:{payment_method_type:A}}),c.error(new De("Shop Pay proposed payment line contains an unsupported Customer Account saved card"),{severity:"warning",metadata:{value:{paymentMethodType:A}}}))},[c,A]);const f=E(()=>{const u=y.find(he);if(S&&u&&Pe(d.value))return G(u);const g=d.value.filter(h=>ve(h,y,{identity:l})||fe(h)),I=ge(g),[M]=I;return M!==void 0?M:(c.leaveErrorBreadcrumb("Unexpected: Selected payment method is empty because `paymentLines` array is empty",{displayedPaymentMethods:JSON.stringify(y),displayedProposedPaymentLines:JSON.stringify(g)}),"")},[y,l,c,d.value,S]),L=z((u,g,{rebuild:I=!1,buyerInitiated:M=!1}={})=>{const h=d.value,F=Q(t??p.value??[],v),w=j(h,F),se=h.some(ie=>ie.method.type==="direct"),D=Ce([u],[...h,...!se&&r.value?[{method:r.value}]:[]],F,{negotiatedPaymentLines:P.value?.lines,deferredTotal:U,hasPayableDeposit:!!C.value?.amount,hasFixedSellingPlan:O.value,rebuild:I,paymentTermsTemplateType:H?.type,preserveShopPayApproval:S});g?d.value=Ee(D,g):d.value=D;const N=j(D,F),B=Se(w,N,_);B&&(a.value=!0,m.monorailEvent(xe({uniqueToken:n.value.defaultAttributes?.uniqToken||"",shopGid:x,shopCurrencyCode:T,presentmentCurrencyCode:_,previousPaymentMethod:w,currentPaymentMethod:N})));const re=M&&Ae(w,N);(B||re)&&i({})},[a,p,P.value?.lines,r,U,C.value?.amount,_,d,m,n.value.defaultAttributes?.uniqToken,x,T,i,H,O,t,v,S]);K(()=>{oe&&!f&&d.value.length===0&&(k.current=!1)},[f]);const R=y.at(0);if(e&&!f&&!k.current&&R&&!Ie(d.value)&&!(ne&&y.length>1)){const u=G(R);c.leaveErrorBreadcrumb("rebuilding payment lines on missing selected payment line",{displayedPaymentMethods:JSON.stringify(y),selectedPaymentMethod:u}),L(u,void 0,{rebuild:!0}),k.current=!0}return E(()=>[f,L],[f,L])}function Q(e,t){return t?e.filter(n=>n.type!==$.CreditCard):e}function Ne(e,t){return e.method.type===t.type?{...e,method:{...e.method,...t}}:e}function Ee(e,t){return e.map(n=>Ne(n,t))}function W(e){if(e===void 0)return"";const t="name"in e&&e.name||void 0,n="paymentMethodIdentifier"in e&&e.paymentMethodIdentifier||void 0;return Le(e.type,t,n)}function xe({uniqueToken:e,shopGid:t,shopCurrencyCode:n,presentmentCurrencyCode:a,checkoutSessionIdentifier:r,previousPaymentMethod:o,currentPaymentMethod:p}){return{schemaId:"multi_currency_checkout_payment_method_change/2.0",payload:{shopId:parseInt(Me(t),10),userToken:e,checkoutToken:r||"",shopCurrencyCode:n,checkoutPresentmentCurrencyCode:a,priorPaymentMethodHandle:W(o),priorPaymentType:Y(o?.type||""),newPaymentMethodHandle:W(p),newPaymentType:Y(p?.type||""),isPriorPaymentMethodMc:V(a,o),isNewPaymentMethodMc:V(a,p)}}}function j(e,t){return t.find(n=>e.find(a=>"paymentMethodIdentifier"in a.method&&"paymentMethodIdentifier"in n?a.method.paymentMethodIdentifier===n.paymentMethodIdentifier:a.method.type==="wallet"&&n.type==="wallet"?a.method.name===n.name:a.method.type===n.type))}function Ge({isApplePayAvailable:e}){const{checkout:{identity:t},shopPay:n}=b(),a=X(),r=de(e);return E(()=>Fe({identity:t,shopPay:n,negotiatedFields:a},{isApplePayAvailable:r}),[t,r,a,n])}function Ve(){const{shop:e}=b(),t=e.hasFlagEnabled(be),n=Te();return ue(()=>!t&&n.value)}function Ye(){const e=Z(),{negotiate:t}=ee(),{shopPay:n,checkout:a,observability:r}=b(),o=a.configuration.addressSettings.nonBillingAddressSettings;return{updateCheckoutAddress:z(async({shippingAddress:s,billingAddress:i,fallbackPhoneNumber:P},C=!1)=>
1{if(!s&&!i)return;const l=[];if(s){l.push("shippingAddress");const m=o.value.isRequired("phone",{countryCode:s.countryCode,useMerchantSettings:!0})&&!s.phone?P:s.phone;r.log("wallets_shipping_address_update","useUpdateCheckoutAddress: update with Shop Pay vaulted address",{isPostalCodePadded:_e(s.postalCode,s.countryCode),countryCode:s.countryCode}),e.shippingAddress.value={...s,phone:m,oneTimeUse:s.oneTimeUse||!1}}if(i){l.push("billingAddress");const m=o.value.isRequired("phone",{countryCode:i.countryCode,useMerchantSettings:!0})&&!i.phone?P:i.phone;e.billingAddress.value={...i,phone:m}}const c=we(s??e.shippingAddress.value,i??e.billingAddress.value);n.user.hasCreditCards.value&&(c?e.billingAddressOption.value="shipping":e.billingAddressOption.value="custom"),!C&&await t({include:l,silenceViolations:["non-stock"],fieldsToResolve:l})},[t,e.shippingAddress,e.billingAddress,e.billingAddressOption,o,n.user,r])}}export{Ve as a,Ye as b,Ge as c,Ke as u};

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.