PageSourceSearch

https://cheekycocktails.co/cdn/shopifycloud/checkout-web/assets/c1/hooks-useUpdateCheckoutAddress.DUYbpduS.js

js cheekycocktails.co collected 2026-09-28 08:30:30 UTC 5,758 bytes, 1 lines download raw bytes

1import{A as J,h as K,T as E,q as X,l as de,f as ue}from"./esnext-vendor.B9Da21W6.js";import{bO as le,an as pe,a4 as Z,bP as ye,bQ as ce,S as M,T as $,bR as me,V as j,bS as he,bT as Pe,bU as V,bV as ve,bW as fe,bX as Ce,bY as ge,bZ as Se,b_ as be,b$ as G,H as Ae,c0 as Me,c1 as Te,aP as _e}from"./addresses-is-address-empty.Bn2lNY_L.js";import{f as ee,c as ke,bC as W,bD as Le}from"./hydrate.DZ4YTm7p.js";import{h as Ie}from"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";import{s as Fe,i as De}from"./helpers-derivations.Dug6X2_v.js";class we extends Error{constructor(){super(...arguments),this.name="UnsupportedShopPayCustomerCardError"}}function Ke({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=$().paymentLines,{value:x}=o.deferredTotal,{value:H}=o.paymentFlexibilityPaymentTermsTemplate,O=me(),_=ae?.presentmentCurrency||T,oe=ke(),k=J(!1),q=J(!1),b=v?d.value.find(u=>u.method.type===j.CreditCard)?.method.type:void 0;K(()=>{!b||q.current||(q.current=!0,p.counter({name:"shop_pay_unsupported_customer_card_on_payline",value:1,attributes:{payment_method_type:b}}),p.error(new we("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]),L=X((u,C,{rebuild:I=!1,buyerInitiated:A=!1}={})=>{const h=d.value,F=Y(t??y.value??[],v),D=Q(h,F),se=h.some(ie=>ie.method.type==="direct"),w=ge([u],[...h,...!se&&r.value?[{method:r.value}]:[]],F,{negotiatedPaymentLines:P.value?.lines,deferredTotal:x,hasPayableDeposit:!!g.value?.amount,hasFixedSellingPlan:O.value,rebuild:I,paymentTermsTemplateType:H?.type,preserveShopPayApproval:S});C?d.value=Ee(w,C):d.value=w;const N=Q(w,F),B=Se(D,N,_);B&&(a.value=!0,m.monorailEvent(Ue({uniqueToken:n.value.defaultAttributes?.uniqToken||"",shopGid:U,shopCurrencyCode:T,presentmentCurrencyCode:_,previousPaymentMethod:D,currentPaymentMethod:N})));const re=A&&be(D,N);(B||re)&&i({})},[a,y,P.value?.lines,r,x,g.value?.amount,_,d,m,n.value.defaultAttributes?.uniqToken,U,T,i,H,O,t,v,S]);K(()=>{oe&&!f&&d.value.length===0&&(k.current=!1)},[f]);const R=c.at(0);if(e&&!f&&!k.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}),L(u,void 0,{rebuild:!0}),k.current=!0}return E(()=>[f,L],[f,L])}function Y(e,t){return t?e.filter(n=>n.type!==j.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 Le(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:z(o),priorPaymentType:W(o?.type||""),newPaymentMethodHandle:z(y),newPaymentType:W(y?.type||""),isPriorPaymentMethodMc:G(a,o),isNewPaymentMethodMc:G(a,y)}}}function Q(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 Ge(){const{shop:e}=M(),t=e.hasFlagEnabled(Me),n=Te();return ue(()=>!t&&n.value)}function We(){const e=$(),{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=De(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{Ge as a,We 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.