PageSourceSearch

https://store.sixshooterrecords.com/cdn/shopifycloud/checkout-web/…/hooks-useUpdateCheckoutAddress.BhapmoFI.js

js sixshooterrecords.com collected 2026-09-24 18:39:29 UTC 5,758 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.DQ9BNaJe.js";import{bV as le,as as ce,a5 as $,bW as pe,bX as ye,T as M,W as j,bY as me,V as Q,bZ as he,b_ as Pe,b$ as V,c0 as ve,c1 as fe,c2 as Ce,c3 as ge,c4 as Se,c5 as be,c6 as W,I as Ae,c7 as Me,c8 as Te,aU as _e}from"./addresses-is-address-empty.BB1pvxM5.js";import{f as ee,c as ke,br as G,bs as Ie}from"./hydrate.D4A9Cb0p.js";import{h as Le}from"./hooks-useShopPayExternalAppContext.xiQcN-hk.js";import{s as Fe,i as we}from"./helpers-derivations.D2KtNl4E.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=$(),p=o.paymentMethods,{value:s}=pe(),{negotiate:i}=ee(),P=o.paymentLines,g=ye(),{checkout:{identity:l},observability:c,userEvents:m,shop:te}=M(),{currencyCode:T,id:U,paymentMethodAutoSelectionDisabled:ne}=te,v=l.current.value==="shopPay",S=!v,y=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=ke(),k=J(!1),O=J(!1),b=v?d.value.find(u=>u.method.type===Q.CreditCard)?.method.type:void 0;K(()=>{!b||O.current||(O.current=!0,c.counter({name:"shop_pay_unsupported_customer_card_on_payline",value:1,attributes:{payment_method_type:b}}),c.error(new De("Shop Pay proposed payment line contains an unsupported Customer Account saved card"),{severity:"warning",metadata:{value:{paymentMethodType:b}}}))},[c,b]);const f=E(()=>{const u=y.find(he);if(S&&u&&Pe(d.value))return V(u);const C=d.value.filter(h=>ve(h,y,{identity:l})||fe(h)),L=Ce(C),[A]=L;return A!==void 0?A:(c.leaveErrorBreadcrumb("Unexpected: Selected payment method is empty because `paymentLines` array is empty",{displayedPaymentMethods:JSON.stringify(y),displayedProposedPaymentLines:JSON.stringify(C)}),"")},[y,l,c,d.value,S]),I=Z((u,C,{rebuild:L=!1,buyerInitiated:A=!1}={})=>{const h=d.value,F=Y(t??p.value??[],v),w=X(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:L,paymentTermsTemplateType:q?.type,preserveShopPayApproval:S});C?d.value=Ee(D,C):d.value=D;const N=X(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,p,P.value?.lines,r,x,g.value?.amount,_,d,m,n.value.defaultAttributes?.uniqToken,U,T,i,q,H,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&&!Le(d.value)&&!(ne&&y.length>1)){const u=V(R);c.leaveErrorBreadcrumb("rebuilding payment lines on missing selected payment line",{displayedPaymentMethods:JSON.stringify(y),selectedPaymentMethod:u}),I(u,void 0,{rebuild:!0}),k.current=!0}return E(()=>[f,I],[f,I])}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 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 Ue({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(Ae(t),10),userToken:e,checkoutToken:r||"",shopCurrencyCode:n,checkoutPresentmentCurrencyCode:a,priorPaymentMethodHandle:z(o),priorPaymentType:G(o?.type||""),newPaymentMethodHandle:z(p),newPaymentType:G(p?.type||""),isPriorPaymentMethodMc:W(a,o),isNewPaymentMethodMc:W(a,p)}}}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 Ve({isApplePayAvailable:e}){const{checkout:{identity:t},shopPay:n}=M(),a=$(),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: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:_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"),!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,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.