import{u as e,v as a,t as s,h as l,D as i}from"./2c1ab0fe.Dbn2KvkT.js";import{b as n,a as d}from"./efa0389a.BBF5Yj3v.js";import{S as t,k as r,b6 as o,b7 as c,b8 as u,b9 as p,H as b,f as g,j as v}from"./164ad2e3.FTBuhkTQ.js";import{B as m}from"./74835653.BLveyRHP.js";import{d as y,aU as f,aV as h,F as _,aW as C}from"./4b4bc88f.z1yoAwwH.js";import{A}from"./4b1c22b7.Tf9Z0cR8.js";function j(){const{i18n:a,checkout:s}=y(),l=s.addressManager.billing.value.suggestedAddress.value,i=l.address,d=l.type,o="billing-fact"===d?a.translate("payment.use_order_billing_address_label"):"billing"===d?a.translate("payment.use_location_billing_address_label"):"shipping"===d?a.translate("payment.use_location_shipping_address_label"):void 0;return i&&d&&o?e(n,{value:d,children:e(t,{children:[e(r,{type:"strong",children:o}),e(r,{color:"subdued",children:e(A,{hiddenFields:["phone","company","firstName","lastName"],multiline:!1,address:i})})]})}):null}function k({renderFormOnly:A=!1}={}){const{i18n:k,source:N,checkout:L}=y(),B=L.negotiator.current.fields.deliveryNext.value,F=f(B),O=o(),{billingAddress:x,shippingAddress:I,billingAddressOption:P}=L.negotiator.parts,U=I.value,w=L.proposal.facts.billingAddress,z=L.configuration.layout.isOnePage.value,D=c(),H=u(),M=L.negotiator.current.fields.buyerIdentity.value?.purchasingCompany,R=L.negotiator.current.fields.buyerIdentity.value?.customerProfile,S=R&&!h(R)&&0===R.billingAddresses.length&&0===R.shippingAddresses.length,T=(!R||S)&&U.oneTimeUse,V=a(()=>({firstName:void 0,lastName:void 0,address1:void 0,address2:void 0,company:void 0,city:void 0,postalCode:void 0,phone:void 0,zoneCode:void 0,name:void 0,countryCode:x.fields.countryCode.peek()}),[x.fields.countryCode]),W=a(()=>I.fields.countryCode.peek(),[I.fields.countryCode]),q=s(([e])=>{e&&(P.value=e,_(N)?"custom"===e?x.value=V:"shipping"===e?x.value=D.value:"billing-fact"===e&&w&&(x.value=w):"custom"===e&&M?x.value=C({countryCode:W}):"custom"===e?x.fields.countryCode.value=W:"shipping"===e&&(x.value=D.value,H()))},[P,N,M,w,x,V,D,W,H]),E=k.translate("payment.billing_address_title");p(),l(()=>{_(N)&&"form"===O.value?x.value=V:"shipping"===P.value?x.value=D.value:"billing-fact"===P.value&&w&&(x.value=w)},[]);const G=P.value,J=a(()=>[G],[G]);return e(v,{accessibilityRole:"group",accessibilityLabelledBy:z?void 0:"billingAddress",accessibilityLabel:z?E:void 0,children:e(t,{gap:"base",children:[z?null:e(t,{gap:"small-400",children:[e(b,{id:"billingAddress",children:E}),T?null:e(g,{color:"subdued",children:F?k.translate("payment.billing_address_description_no_shipping_address"):k.translate("payment.billing_address_description")})]}),e(i,{when:()=>!A&&"form"!==O.value,fallback:e(m,{}),children:e(d,{name:"billing_address_selector",values:J,onChange:q,variant:"block",children:[M?e(j,{}):e(n,{value:"shipping",accessibilityLabel:k.translate("payment.same_billing_address_label"),children:e(r,{type:"strong",children:k.translate("payment.same_billing_address_label")})}),e(n,{value:"custom",selectedContent:e(m,{}),accessibilityLabel:k.translate("payment.different_billing_address_label"),children:e(r,{type:"strong",children:k.translate("payment.different_billing_address_label")})})]})})]})})}export{k as B};