PageSourceSearch

https://omwboards.com/cdn/shopifycloud/checkout-web/assets/c1/hooks-useUpdateCheckoutAddress.C4NXzSJo.js

js omwboards.com collected 2026-09-29 00:15:22 UTC 5,750 bytes, 1 lines download raw bytes

1import{A as K,h as J,T as E,q as X,l as de,f as ue}from"./esnext-vendor.DDpcaSqU.js";import{b7 as le,a$ as pe,a5 as Z,bU as ye,bV as ce,T as M,W as j,b3 as me,V as Q,bW as he,b5 as Pe,bX as V,bY as ve,bZ as fe,b_ as Ce,b$ as ge,c0 as Se,c1 as be,c2 as W,I as Ae,c3 as Me,c4 as Te,aR as _e}from"./utilities-previous.Cnwy8G2v.js";import{e as ee,u as Le,bK as G,bL as ke}from"./hydrate.BcfGVx0L.js";import{h as Ie}from"./hooks-useShopPayExternalAppContext.R6pnDxYu.js";import{s as Fe,i as we}from"./helpers-derivations.K4r9DEFp.js";class De extends Error{constructor(){super(...arguments),this.name="UnsupportedShopPayCustomerCardError"}}function Je({allowPreselect:e=!0,displayedPaymentMethods:t}={}){const n=le(),{hasNegotiatedAlternativePaymentCurrencySignal:a,newCardSignal:r}=pe(),o=Z(),y=o.paymentMethods,{value:s}=ye(),{negotiate:i}=ee(),P=o.paymentLines,g=ce(),{checkout:{identity:l},observability:p,userEvents:m,shop:te}=M(),{currencyCode:T,id:U,paymentMethodAutoSelectionDisabled:ne}=te,v=l.current.value==="shopPay",S=!v,c=Y(t??s,v),{value:ae}=o.buyerIdentity,d=j().paymentLines,{value:x}=o.deferredTotal,{value:q}=o.paymentFlexibilityPaymentTermsTemplate,H=me(),_=ae?.presentmentCurrency||T,oe=Le(),L=K(!1),O=K(!1),b=v?d.value.find(u=>u.method.type===Q.CreditCard)?.method.type:void 0;J(()=>{!b||O.current||(O.current=!0,p.counter({name:"shop_pay_unsupported_customer_card_on_payline",value:1,attributes:{payment_method_type:b}}),p.error(new De("Shop Pay proposed payment line contains an unsupported Customer Account saved card"),{severity:"warning",metadata:{value:{paymentMethodType:b}}}))},[p,b]);const f=E(()=>{const u=c.find(he);if(S&&u&&Pe(d.value))return V(u);const C=d.value.filter(h=>ve(h,c,{identity:l})||fe(h)),I=Ce(C),[A]=I;return A!==void 0?A:(p.leaveErrorBreadcrumb("Unexpected: Selected payment method is empty because `paymentLines` array is empty",{displayedPaymentMethods:JSON.stringify(c),displayedProposedPaymentLines:JSON.stringify(C)}),"")},[c,l,p,d.value,S]),k=X((u,C,{rebuild:I=!1,buyerInitiated:A=!1}={})=>{const h=d.value,F=Y(t??y.value??[],v),w=z(h,F),se=h.some(ie=>ie.method.type==="direct"),D=ge([u],[...h,...!se&&r.value?[{method:r.value}]:[]],F,{negotiatedPaymentLines:P.value?.lines,deferredTotal:x,hasPayableDeposit:!!g.value?.amount,hasFixedSellingPlan:H.value,rebuild:I,paymentTermsTemplateType:q?.type,preserveShopPayApproval:S});C?d.value=Ee(D,C):d.value=D;const N=z(D,F),B=Se(w,N,_);B&&(a.value=!0,m.monorailEvent(Ue({uniqueToken:n.value.defaultAttributes?.uniqToken||"",shopGid:U,shopCurrencyCode:T,presentmentCurrencyCode:_,previousPaymentMethod:w,currentPaymentMethod:N})));const re=A&&be(w,N);(B||re)&&i({})},[a,y,P.value?.lines,r,x,g.value?.amount,_,d,m,n.value.defaultAttributes?.uniqToken,U,T,i,q,H,t,v,S]);J(()=>{oe&&!f&&d.value.length===0&&(L.current=!1)},[f]);const R=c.at(0);if(e&&!f&&!L.current&&R&&!Ie(d.value)&&!(ne&&c.length>1)){const u=V(R);p.leaveErrorBreadcrumb("rebuilding payment lines on missing selected payment line",{displayedPaymentMethods:JSON.stringify(c),selectedPaymentMethod:u}),k(u,void 0,{rebuild:!0}),L.current=!0}return E(()=>[f,k],[f,k])}function Y(e,t){return t?e.filter(n=>n.type!==Q.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 $(e){if(e===void 0)return"";const t="name"in e&&e.name||void 0,n="paymentMethodIdentifier"in e&&e.paymentMethodIdentifier||void 0;return ke(e.type,t,n)}function Ue({uniqueToken:e,shopGid:t,shopCurrencyCode:n,presentmentCurrencyCode:a,checkoutSessionIdentifier:r,previousPaymentMethod:o,currentPaymentMethod:y}){return{schemaId:"multi_currency_checkout_payment_method_change/2.0",payload:{shopId:parseInt(Ae(t),10),userToken:e,checkoutToken:r||"",shopCurrencyCode:n,checkoutPresentmentCurrencyCode:a,priorPaymentMethodHandle:$(o),priorPaymentType:G(o?.type||""),newPaymentMethodHandle:$(y),newPaymentType:G(y?.type||""),isPriorPaymentMethodMc:W(a,o),isNewPaymentMethodMc:W(a,y)}}}function z(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 Ve({isApplePayAvailable:e}){const{checkout:{identity:t},shopPay:n}=M(),a=Z(),r=de(e);return E(()=>Fe({identity:t,shopPay:n,negotiatedFields:a},{isApplePayAvailable:r}),[t,r,a,n])}function We(){const{shop:e}=M(),t=e.hasFlagEnabled(Me),n=Te();return ue(()=>!t&&n.value)}function Ge(){const e=j(),{negotiate:t}=ee(),{shopPay:n,checkout:a,observability:r}=M(),o=a.configuration.addressSettings.nonBillingAddressSettings;return{updateCheckoutAddress:X(async({shippingAddress:s,billingAddress:i,fallbackPhoneNumber:P},g=!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 p=we(s??e.shippingAddress.value,i??e.billingAddress.value);n.user.hasCreditCards.value&&(p?e.billingAddressOption.value="shipping":e.billingAddressOption.value="custom"),!g&&await t({include:l,silenceViolations:["non-stock"],fieldsToResolve:l})},[t,e.shippingAddress,e.billingAddress,e.billingAddressOption,o,n.user,r])}}export{We as a,Ge as b,Ve as c,Je 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.