PageSourceSearch

https://shop.netgate.com/cdn/shopifycloud/checkout-web/assets/c1/hooks-useUpdateCheckoutAddress.4zyjtqEx.js

js netgate.com collected 2026-09-24 08:29:23 UTC 5,733 bytes, 1 lines download raw bytes

1import{A as V,h as J,T as D,q as Z,l as de,f as ue}from"./esnext-vendor.D7ldIee_.js";import{aT as le,an as ce,$ as j,bX as ye,a0 as Q,bY as pe,N as M,bZ as me,O as ee,b_ as he,V as te,b$ as Pe,c0 as ve,c1 as Y,c2 as fe,c3 as Ce,c4 as ge,c5 as Se,c6 as Ae,c7 as be,c8 as Me,c9 as G,B as Te,ca as _e,cb as Le,cc as ke}from"./addresses-is-address-empty.-MuOhIyI.js";import{c as Fe,bK as W,bL as Ie}from"./hydrate.ByRIsqvd.js";import{s as Ee,i as Ne}from"./utilities-shopCashMoney.B9eyOzz9.js";class we extends Error{constructor(){super(...arguments),this.name="UnsupportedShopPayCustomerCardError"}}function Ve({allowPreselect:e=!0,displayedPaymentMethods:t}={}){const n=le(),{hasNegotiatedAlternativePaymentCurrencySignal:a,newCardSignal:r}=ce(),o=j(),y=o.paymentMethods,{value:s}=ye(),{negotiate:i}=Q(),P=o.paymentLines,g=pe(),{checkout:{identity:l},observability:c,userEvents:m,shop:O}=M(),{currencyCode:T,id:H,paymentMethodAutoSelectionDisabled:ne}=O,v=l.current.value==="shopPay",S=!v&&O.hasFlagEnabled(me),p=$(t??s,v),{value:ae}=o.buyerIdentity,d=ee().paymentLines,{value:U}=o.deferredTotal,{value:x}=o.paymentFlexibilityPaymentTermsTemplate,R=he(),_=ae?.presentmentCurrency||T,oe=Fe(),L=V(!1),q=V(!1),A=v?d.value.find(u=>u.method.type===te.CreditCard)?.method.type:void 0;J(()=>{!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 we("Shop Pay proposed payment line contains an unsupported Customer Account saved card"),{severity:"warning",metadata:{value:{paymentMethodType:A}}}))},[c,A]);const f=D(()=>{const u=p.find(Pe);if(S&&u&&ve(d.value))return Y(u);const C=d.value.filter(h=>fe(h,p,{identity:l})||Ce(h)),F=ge(C),[b]=F;return b!==void 0?b:(c.leaveErrorBreadcrumb("Unexpected: Selected payment method is empty because `paymentLines` array is empty",{displayedPaymentMethods:JSON.stringify(p),displayedProposedPaymentLines:JSON.stringify(C)}),"")},[p,l,c,d.value,S]),k=Z((u,C,{rebuild:F=!1,buyerInitiated:b=!1}={})=>{const h=d.value,I=$(t??y.value??[],v),E=X(h,I),se=h.some(ie=>ie.method.type==="direct"),N=Se([u],[...h,...!se&&r.value?[{method:r.value}]:[]],I,{negotiatedPaymentLines:P.value?.lines,deferredTotal:U,hasPayableDeposit:!!g.value?.amount,hasFixedSellingPlan:R.value,rebuild:F,paymentTermsTemplateType:x?.type,preserveShopPayApproval:S});C?d.value=Oe(N,C):d.value=N;const w=X(N,I),K=Ae(E,w,_);K&&(a.value=!0,m.monorailEvent(He({uniqueToken:n.value.defaultAttributes?.uniqToken||"",shopGid:H,shopCurrencyCode:T,presentmentCurrencyCode:_,previousPaymentMethod:E,currentPaymentMethod:w})));const re=b&&be(E,w);(K||re)&&i({})},[a,y,P.value?.lines,r,U,g.value?.amount,_,d,m,n.value.defaultAttributes?.uniqToken,H,T,i,x,R,t,v,S]);J(()=>{oe&&!f&&d.value.length===0&&(L.current=!1)},[f]);const B=p.at(0);if(e&&!f&&!L.current&&B&&!Me(d.value)&&!(ne&&p.length>1)){const u=Y(B);c.leaveErrorBreadcrumb("rebuilding payment lines on missing selected payment line",{displayedPaymentMethods:JSON.stringify(p),selectedPaymentMethod:u}),k(u,void 0,{rebuild:!0}),L.current=!0}return D(()=>[f,k],[f,k])}function $(e,t){return t?e.filter(n=>n.type!==te.CreditCard):e}function De(e,t){return e.method.type===t.type?{...e,method:{...e.method,...t}}:e}function Oe(e,t){return e.map(n=>De(n,t))}function z(e){if(e===void 0)return"";const t="name"in e&&e.name||void 0,n="paymentMethodIdentifier"in e&&e.paymentMethodIdentifier||void 0;return Ie(e.type,t,n)}function He({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(Te(t),10),userToken:e,checkoutToken:r||"",shopCurrencyCode:n,checkoutPresentmentCurrencyCode:a,priorPaymentMethodHandle:z(o),priorPaymentType:W(o?.type||""),newPaymentMethodHandle:z(y),newPaymentType:W(y?.type||""),isPriorPaymentMethodMc:G(a,o),isNewPaymentMethodMc:G(a,y)}}}function X(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 Je({isApplePayAvailable:e}){const{checkout:{identity:t},shopPay:n}=M(),a=j(),r=de(e);return D(()=>Ee({identity:t,shopPay:n,negotiatedFields:a},{isApplePayAvailable:r}),[t,r,a,n])}function Ye(){const{shop:e}=M(),t=e.hasFlagEnabled(_e),n=Le();return ue(()=>!t&&n.value)}function Ge(){const e=ee(),{negotiate:t}=Q(),{shopPay:n,checkout:a,observability:r}=M(),o=a.configuration.addressSettings.nonBillingAddressSettings;return{updateCheckoutAddress:Z(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:ke(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=Ne(s??e.shippingAddress.value,i??e.billingAddress.value);n.user.hasCreditCards.value&&(c?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{Ye as a,Ge as b,Je as c,Ve 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.