@dropins/storefront-account 4.2.0-beta.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/containers/AddressForm.js +1 -1
- package/containers/AddressForm.js.map +1 -1
- package/package.json +1 -1
- package/render.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{classes as G,Slot as Te}from"@dropins/tools/lib.js";import{useText as Q}from"@dropins/tools/i18n.js";import{jsx as a,Fragment as le,jsxs as P}from"@dropins/tools/preact-jsx-runtime.js";import{Field as Ie,TextArea as tr,Checkbox as ft,InputDate as rr,Picker as $t,Input as xt,Skeleton as He,SkeletonRow as se,Card as _e,Button as ie,Tag as $e,Icon as Ge,Modal as Ft,ProgressSpinner as Zt,IllustratedMessage as Fe,Image as yt,Price as nr,ContentGrid as ar,Header as ke,LiveRegion as Ht,InLineAlert as Pe,InputPassword as Ue,ToggleButton as sr,Pagination as Vt,Table as or}from"@dropins/tools/components.js";import*as $ from"@dropins/tools/preact-compat.js";import{memo as ht,useMemo as qe,forwardRef as dr,useImperativeHandle as cr,useId as gt,useCallback as nt}from"@dropins/tools/preact-compat.js";import{useRef as Ze,useState as S,useEffect as oe,useCallback as F,useMemo as Ne}from"@dropins/tools/preact-hooks.js";import{events as at}from"@dropins/tools/event-bus.js";import{c as Rt,a as zt,updateCustomerAddress as st,getCustomerCompanyContext as lr,g as Xe,getCustomerRolePermissions as ir,b as ur,getCompanyAddressBook as fr,getAttributesForm as ot,getCustomerAddress as hr,deleteCompanyAddress as gr,removeCustomerAddress as pr,getCountries as mr,setDefaultCompanyAddress as Qe,updateCompanyAddress as Ar,createCompanyAddress as yr,createCustomerAddress as br,getStoreConfig as Ut,updateCustomerPassword as Lr,getCustomerPaymentTokens as Cr,deletePaymentToken as vr,getOrderHistoryList as _r,O as wr,d as Br}from"../api.js";import{Fragment as bt}from"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";const Er=e=>e.reduce((r,t)=>({...r,[t.name]:t.value}),{}),Nr=e=>/^\d+$/.test(e),Tr=e=>/^[a-zA-Z0-9\s]+$/.test(e),Sr=e=>/^[a-zA-Z0-9]+$/.test(e),Ir=e=>/^[a-zA-Z]+$/.test(e),Pr=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),Mr=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),Or=(e,r,t)=>{const n=new Date(e).getTime()/1e3;return!(isNaN(n)||n<0||r!==void 0&&n<r||t!==void 0&&n>t)},Lt=e=>!e||isNaN(Number(e))?"":new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],kr=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),$r=(e,r,t)=>{const n=e.length;return n>=r&&n<=t},et=(e,r,t,n)=>{var E,C;const{requiredFieldError:s,lengthTextError:o,numericError:l,alphaNumWithSpacesError:d,alphaNumericError:u,alphaError:h,emailError:i,dateError:f,urlError:y,dateLengthError:L}=t,m=r==null?void 0:r.customUpperCode,p={[m]:""};if(n[m]&&delete n[m],r!=null&&r.required&&(!e||e==="false"))return{[m]:s};if(!(r!=null&&r.required)&&!e||!((E=r==null?void 0:r.validateRules)!=null&&E.length))return p;const _=Er(r==null?void 0:r.validateRules),g=_.MIN_TEXT_LENGTH??1,B=_.MAX_TEXT_LENGTH??255,v=_.DATE_RANGE_MIN,I=_.DATE_RANGE_MAX;if(!$r(e,+g,+B)&&!(v||I))return{[m]:o.replace("{min}",g).replace("{max}",B)};if(!Or(e,+v,+I)&&(v||I))return{[m]:L.replace("{min}",Lt(v)).replace("{max}",Lt(I))};const c={numeric:{validate:Nr,error:l},"alphanum-with-spaces":{validate:Tr,error:d},alphanumeric:{validate:Sr,error:u},alpha:{validate:Ir,error:h},email:{validate:Pr,error:i},date:{validate:Mr,error:f},url:{validate:kr,error:y}}[_.INPUT_VALIDATION];return c&&!c.validate(e)&&!((C=n[m])!=null&&C.length)?{[m]:c.error}:p},Dt=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},xr=["true","false","yes","on","off"],Fr={firstName:"",lastName:"",nickname:"",city:"",company:"",countryCode:"",addressType:"",addressTypeShipping:"",addressTypeBilling:"",isDefault:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:"",uid:""},Zr=e=>{const r={},t={};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=e[n],o=n.match(/^(.*)Multiline_(\d+)$/);if(o){const l=o[1],d=parseInt(o[2],10);t[l]||(t[l]=[]),t[l].push({index:d,value:s})}else Object.keys(e).filter(d=>d.startsWith(`${n}Multiline_`)).length>0?t[n]=[{index:1,value:s}]:r[n]=s}for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=t[n];s.sort((o,l)=>o.index-l.index),r[n]=s.map(o=>o.value)}return r},Hr=e=>{const r={},t=[];for(const n in e){const s=xr.includes(e[n])?Dt(e[n]):e[n];Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(Fr,n)?r[n]=s:t.push({code:zt(n),value:s}))}return{...r,customAttributes:t}},We=(e,r=!1)=>{const t=Rt(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),n=Hr(Zr(t));if(!r)return n;const[s,o]=n.region?n.region.split(","):[];return{...n,region:{regionCode:s,...o&&{regionId:+o}}}},De=e=>{if(!e.current)return{};const r=e.current.elements;return Array.from(r).reduce((n,s)=>(s.name&&(n[s.name]=s.type==="checkbox"?s.checked:s.value),n),{})},Ct=(e,r)=>Object.keys(e).length?Object.keys(e).every(n=>n in r&&r[n]!==""):!1,Ke=e=>typeof e=="function",Vr=e=>e.reduce((r,{customUpperCode:t,required:n,defaultValue:s})=>(n&&t&&(r.initialData[t]=s||"",r.errorList[t]=""),r),{initialData:{},errorList:{}}),vt=e=>Object.keys(e).length>0,Rr=({fieldsConfig:e,onSubmit:r,onChange:t,setInputChange:n,formName:s})=>{const o=Q({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),l=Ze(null),[d,u]=S({}),[h,i]=S({}),[f,y]=S({}),[L,m]=S(!0),[p,_]=S(!1),[g,B]=S(!1),[v,I]=S(!0),[V,c]=S(!1);oe(()=>{const b=()=>{if(l.current){const A=window.getComputedStyle(l.current).getPropertyValue("grid-template-rows").split(" ").length,k=l.current.querySelector(".account-address-form--saveAddressBook");k&&(k.style.gridRow=String(A-1))}};return b(),window.addEventListener("resize",b),()=>{window.removeEventListener("resize",b)}},[e==null?void 0:e.length]);const E=F((b=!1)=>{let N=!0;const A={...h};let k=null;for(const[x,z]of Object.entries(d)){const J=e==null?void 0:e.find(re=>re.customUpperCode.includes(x)),de=et(z.toString(),J,o,A);de[x]&&(Object.assign(A,de),N=!1),k||(k=Object.keys(A).find(re=>A[re])||null)}if(b||i(A),k&&l.current&&!b){const x=l.current.elements.namedItem(k);x==null||x.focus()}return N},[h,e,d,o]),C=F((b,N,A,k,x)=>{const z={...De(l),...x||{},[N]:b,...N.includes("countryCode")?{region:""}:{}},J={data:We(z,!0),isDataValid:Ct(A,z)};c(J.isDataValid),E(!0),["selectedShippingAddress","selectedBillingAddress"].includes(s)&&sessionStorage.setItem(`${s}_addressData`,JSON.stringify(J)),t==null||t(J,{},k)},[E,s,t]);oe(()=>{if(e!=null&&e.length){const{initialData:b,errorList:N}=Vr(e);u(A=>({...b,...A})),i(N),y(N)}},[JSON.stringify(e)]),oe(()=>{if(g)return;const b=De(l),N=sessionStorage.getItem(`${s}_addressData`);if(vt(d)&&vt(f)){let A={};const k=Ct(f,d);N?A=JSON.parse(N).data:A=We(b,!0)??{},t==null||t({data:A,isDataValid:k},{},null),c(k),B(!0)}},[d,f]),oe(()=>{var x;if(!v)return;const b=De(l),N=!!(b!=null&&b.countryCode),A=!!((x=b==null?void 0:b.region)!=null&&x.length);b&&N&&!A&&Ke(t)&&C(b==null?void 0:b.region,"region",f,null)},[v,L,e,l,t,C,f,p]);const O=F((b,N)=>{const{name:A,value:k,type:x,checked:z}=b==null?void 0:b.target,J=x==="checkbox"?z:k,de=x==="checkbox"&&A==="defaultShipping"&&z?{defaultBilling:!1}:x==="checkbox"&&A==="defaultBilling"&&z?{defaultShipping:!1}:x==="checkbox"&&A==="addressTypeShipping"&&z?{addressTypeBilling:!1}:x==="checkbox"&&A==="addressTypeBilling"&&z?{addressTypeShipping:!1}:{};u(Y=>{const R={...Y,...de,[A]:J};return A==="countryCode"&&(R.region="",m(!0),_(!1)),R}),n==null||n({...de,[A]:J}),B(!0);const re=e==null?void 0:e.find(Y=>Y.customUpperCode.includes(A)),ne=N?{...N}:{...h};if(re){const Y=et(J.toString(),re,o,ne);Y&&Object.assign(ne,Y),i(ne)}C(J,A,f,b,de)},[n,e,h,o,C,f,L]),M=F(b=>{const{name:N}=b==null?void 0:b.target,A=e==null?void 0:e.find(k=>k.customUpperCode===N);N==="region"&&(A!=null&&A.options.length)&&I(!1),I(N==="countryCode")},[]),w=F((b,N)=>{const{name:A,value:k,type:x,checked:z}=b==null?void 0:b.target,J=x==="checkbox"?z:k,de=e==null?void 0:e.find(re=>re.customUpperCode===A);if(de){const re=N?{...N}:{...h},ne=et(J.toString(),de,o,re);ne&&Object.assign(re,ne),i(re)}},[h,e,o]),H=F(b=>{b.preventDefault();const N=E();r==null||r(b,N)},[E,r]);return{isDataValid:V,formData:d,errors:h,formRef:l,handleInputChange:O,onFocus:M,handleBlur:w,handleSubmit:H,handleValidationSubmit:E}};var Be=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(Be||{});const zr={firstname:"given-name",middlename:"additional-name",lastname:"family-name",email:"email"},Ur=e=>zr[e],Dr=ht(({loading:e,values:r,fields:t=[],errors:n,className:s="",onChange:o,onBlur:l,onFocus:d,slots:u,fieldIdPrefix:h})=>{const i=`${s}__field`,f=qe(()=>Object.fromEntries(t.flatMap(c=>[[`${c.code}.label`,`Account.AddressForm.fields.${c.code}.label`],[`${c.code}.placeholder`,`Account.AddressForm.fields.${c.code}.placeholder`]])),[t]),y=Q(f),L=c=>c.forceLabel?c.label:y[`${c.code}.label`]||c.label,m=c=>`${L(c)} ${c.required?"*":""}`,p=c=>y[`${c.code}.placeholder`]||c.label,_=(c,E)=>{if(!(u!=null&&u[`AddressFormInput_${c.code}`]))return;const C={inputName:c.customUpperCode,handleOnChange:o,handleOnBlur:l,handleOnFocus:d,errorMessage:E,errors:n,config:c};return a(Te,{"data-testid":`addressFormInput_${c.code}`,name:`AddressFormInput_${c.code}`,slot:u[`AddressFormInput_${c.code}`],context:C},c.id)},g=(c,E,C)=>{var M;const O=c.defaultValue??((M=c.options.find(w=>w.isDefault))==null?void 0:M.value)??E??c.defaultValue;return a(le,{children:_(c,C)??a(Ie,{error:C,className:G([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled,children:a($t,{"aria-label":L(c),"aria-required":c.required?"true":"false",id:h?`${h}_${c.code}`:c.code,required:c==null?void 0:c.required,name:c.customUpperCode,floatingLabel:m(c),placeholder:p(c),options:c.options,onBlur:l,onFocus:d,handleSelect:o,defaultValue:O,value:O,disabled:e||c.disabled})},c.id)})},B=(c,E,C)=>a(le,{children:_(c,C)??a(Ie,{error:C,className:G([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled,children:a(xt,{"aria-label":L(c),"aria-required":c.required?"true":"false",id:h?`${h}_${c.code}`:c.code,type:"text",name:c.customUpperCode,autoComplete:Ur(c.code),value:E??c.defaultValue,placeholder:p(c),floatingLabel:m(c),onBlur:l,onFocus:d,onChange:o,disabled:e||c.disabled})},c.id)}),v=(c,E,C)=>a(le,{children:_(c,C)??a(Ie,{error:C,className:G([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled,children:a(rr,{"aria-label":L(c),"aria-required":c.required?"true":"false",id:h?`${h}_${c.code}`:c.code,type:"text",name:c.customUpperCode,value:E||c.defaultValue,placeholder:p(c),floatingLabel:m(c),onBlur:l,onChange:o,disabled:e||c.disabled})},c.id)}),I=(c,E,C)=>a(le,{children:_(c,C)??a(Ie,{error:C,className:G([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled||(c==null?void 0:c.isHidden),children:a(ft,{"aria-label":L(c),"aria-required":c.required?"true":"false","aria-hidden":c.isHidden,tabindex:c!=null&&c.isHidden?-1:0,id:h?`${h}_${c.code}`:c.code,name:c.customUpperCode,checked:typeof E=="boolean"?E:!!c.defaultValue,placeholder:p(c),label:m(c),onBlur:l,onChange:o,disabled:e||c.disabled||(c==null?void 0:c.isHidden)})},c.id)}),V=(c,E,C)=>a(le,{children:_(c,C)??a(Ie,{error:C,className:G([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled,children:a(tr,{"aria-label":L(c),"aria-required":c.required?"true":"false",id:h?`${h}_${c.code}`:c.code,type:"text",name:c.customUpperCode,value:E??c.defaultValue,label:m(c),onBlur:l,onChange:o,disabled:e||c.disabled})},c.id)});return t.length?a(le,{children:t.map(c=>{const E=n==null?void 0:n[c.customUpperCode],C=r==null?void 0:r[c.customUpperCode];switch(c.fieldType){case Be.TEXT:return c.options.length?g(c,C,E):B(c,C,E);case Be.MULTILINE:return B(c,C,E);case Be.SELECT:return g(c,C,E);case Be.DATE:return v(c,C,E);case Be.BOOLEAN:return I(c,C,E);case Be.TEXTAREA:return V(c,C,E);default:return null}})}):null}),Je=({testId:e,withCard:r=!0})=>{const t=P(He,{"data-testid":e||"skeletonLoader",children:[a(se,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(se,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(se,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return r?t:a(_e,{variant:"secondary",className:G(["account-account-loaders","account-account-loaders--card-loader"]),children:t})},Gr=()=>P(He,{"data-testid":"addressFormLoader",children:[a(se,{variant:"heading",size:"medium"}),a(se,{variant:"empty",size:"medium"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large",fullWidth:!0}),a(se,{size:"large",fullWidth:!0,lines:3}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large",fullWidth:!0})]}),qr=()=>a(He,{"data-testid":"addressActionsLoader",className:"account-account-loaders--address-actions-loader",children:a(se,{size:"medium"})}),Gt=ht(dr(({setInputChange:e,showFormLoader:r,slots:t,name:n,loading:s,children:o,className:l="defaultForm",fieldsConfig:d,onSubmit:u,onChange:h,forwardFormRef:i,regionOptions:f,showSaveCheckBox:y,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:m,fieldIdPrefix:p})=>{const _=Q({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:g,formData:B,errors:v,formRef:I,handleInputChange:V,handleBlur:c,handleSubmit:E,handleValidationSubmit:C,onFocus:O}=Rr({fieldsConfig:d,onSubmit:u,onChange:h,setInputChange:e,formName:n});return cr(i,()=>{const M=De(I);return{handleValidationSubmit:C,requestSubmit:()=>{var w;(w=I.current)==null||w.requestSubmit()},formData:We(M,!0),isDataValid:g}}),r||!(d!=null&&d.length)?a(Gr,{}):P("form",{className:G(["account-form",l]),onSubmit:E,name:n,ref:I,children:[a(Dr,{className:l,loading:s,fields:d,onChange:V,onBlur:c,errors:v,values:B,onFocus:O,slots:t,fieldIdPrefix:p}),t!=null&&t.AddressFormInputs?a(Te,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:t.AddressFormInputs,context:{formActions:{handleChange:V}}}):null,y?a("div",{className:"account-address-form--saveAddressBook",children:a(ft,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:_.saveAddressBook,checked:m,onChange:M=>{V(M),L==null||L(M)}})}):null,o]})})),_t=(e,r,t={},n="editButton")=>{const s=n==="removeButton",o={shippingAndBilling:{edit:t.editAddressAriaLabelShippingAndBilling,remove:t.removeAddressAriaLabelShippingAndBilling},shipping:{edit:t.editAddressAriaLabelShipping,remove:t.removeAddressAriaLabelShipping},billing:{edit:t.editAddressAriaLabelBilling,remove:t.removeAddressAriaLabelBilling},default:{edit:t.editAddressAriaLabelDefault,remove:t.removeAddressAriaLabelDefault}};let l="default";return e&&r?l="shippingAndBilling":e?l="shipping":r&&(l="billing"),s?o[l].remove:o[l].edit},dt=({slots:e,selectable:r,selectShipping:t,selectBilling:n,variant:s="secondary",minifiedView:o,keysSortOrder:l,addressData:d,loading:u,setAddressId:h,handleRenderModal:i,handleRenderForm:f,isB2BFlow:y,permissions:L})=>{const m=gt(),p=o?"minifiedView":"fullSizeView",_=Q({actionRemove:`Account.${p}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${p}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${p}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${p}.Addresses.addressCard.cardLabelBilling`,cardLabelDefaultShipping:`Account.${p}.Addresses.addressCard.cardLabelDefaultShipping`,cardLabelDefaultBilling:`Account.${p}.Addresses.addressCard.cardLabelDefaultBilling`,defaultLabelText:`Account.${p}.Addresses.addressCard.defaultLabelText`,editAddressAriaLabelDefault:`Account.${p}.Addresses.addressCard.ariaLabel.editButton.default`,editAddressAriaLabelShipping:`Account.${p}.Addresses.addressCard.ariaLabel.editButton.shipping`,editAddressAriaLabelBilling:`Account.${p}.Addresses.addressCard.ariaLabel.editButton.billing`,editAddressAriaLabelShippingAndBilling:`Account.${p}.Addresses.addressCard.ariaLabel.editButton.shippingAndBilling`,removeAddressAriaLabelDefault:`Account.${p}.Addresses.addressCard.ariaLabel.removeButton.default`,removeAddressAriaLabelShipping:`Account.${p}.Addresses.addressCard.ariaLabel.removeButton.shipping`,removeAddressAriaLabelBilling:`Account.${p}.Addresses.addressCard.ariaLabel.removeButton.billing`,removeAddressAriaLabelShippingAndBilling:`Account.${p}.Addresses.addressCard.ariaLabel.removeButton.shippingAndBilling`}),g=_.cardLabelBilling.toLocaleUpperCase(),B=_.cardLabelShipping.toLocaleUpperCase(),v=_.defaultLabelText.toLocaleUpperCase(),I=y?_.cardLabelDefaultShipping.toLocaleUpperCase():B,V=y?_.cardLabelDefaultBilling.toLocaleUpperCase():g,c=qe(()=>{const N={shippingLabel:B,billingLabel:g,hideShipping:!1,hideBilling:!1};return r?t&&!n?{shippingLabel:v,billingLabel:v,hideShipping:!1,hideBilling:!0}:n&&!t?{shippingLabel:v,billingLabel:v,hideShipping:!0,hideBilling:!1}:N:N},[g,v,B,n,t,r]),E=nt(()=>{h==null||h(d==null?void 0:d.id),i==null||i()},[i,d==null?void 0:d.id,h]),C=nt(()=>{h==null||h(d==null?void 0:d.id),f==null||f()},[f,d==null?void 0:d.id,h]),O=qe(()=>{if(!l||!d)return[];const{region:N,...A}=d,k={...A,...N||{}},x=l.filter(({name:z})=>k[z]).map(z=>({name:z.name,orderNumber:z.orderNumber,value:k[z.name],label:z.label}));return k.nickname&&!x.some(({name:z})=>z==="nickname")&&x.push({name:"nickname",orderNumber:Number.MAX_SAFE_INTEGER,value:k.nickname,label:null}),x},[d,l]),{shippingLabel:M,billingLabel:w,hideShipping:H,hideBilling:b}=c;return a(_e,{variant:s,className:"account-address-card","data-testid":"addressCard",children:u?a(Je,{}):P(le,{children:[P("div",{className:"account-address-card__action",children:[i&&(!y||L!=null&&L.canDeleteAddress)?a(ie,{type:"button",variant:"tertiary",onClick:E,"data-testid":"removeButton","aria-label":_t(d==null?void 0:d.defaultShipping,d==null?void 0:d.defaultBilling,_,"removeButton"),"aria-describedby":m,children:_.actionRemove}):null,f&&(!y||L!=null&&L.canEditAddress||L!=null&&L.canSetDefaultAddress)?a(ie,{type:"button",variant:"tertiary",onClick:C,className:"account-address-card__action--editbutton","data-testid":"editButton","aria-label":_t(d==null?void 0:d.defaultShipping,d==null?void 0:d.defaultBilling,_,"editButton"),"aria-describedby":m,children:_.actionEdit}):null]}),a("div",{className:"account-address-card__description",id:m,children:e!=null&&e.AddressCard?a(Te,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:O}}):a(le,{children:O.map((N,A)=>{const k=N.label?`${N.label}: ${N==null?void 0:N.value}`:N==null?void 0:N.value;return a("p",{"data-testid":`${N.name}_${A}`,children:k},A)})})}),(d!=null&&d.defaultShipping||d!=null&&d.defaultBilling)&&!r?P("div",{className:"account-address-card__labels",children:[d!=null&&d.defaultShipping?a($e,{label:I}):null,d!=null&&d.defaultBilling?a($e,{label:V}):null]}):null,r?P("div",{className:"account-address-card__labels",children:[!H&&(d!=null&&d.defaultShipping)?a($e,{label:M}):null,!b&&(d!=null&&d.defaultBilling)?a($e,{label:w}):null]}):null]})})},Wr=e=>$.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},$.createElement("g",{id:"Large"},$.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),$.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},$.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),$.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),jr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"currentColor"})),Kr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.00718 5H22.1507C22.7047 5 23.1579 5.45323 23.1579 6.00718V7.51794C23.1579 7.51794 1.01007 7.58844 1 7.55823V6.00718C1 5.45323 1.45323 5 2.00718 5Z",stroke:"currentColor",strokeWidth:1}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M23.1579 9.78409V18.3451C23.1579 18.899 22.7047 19.3523 22.1507 19.3523H2.00718C1.45323 19.3523 1 18.899 1 18.3451V9.78409H23.1579Z",stroke:"currentColor",strokeWidth:1}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.6192 17.5897C18.4535 17.5897 19.1299 16.9133 19.1299 16.0789C19.1299 15.2446 18.4535 14.5682 17.6192 14.5682C16.7848 14.5682 16.1084 15.2446 16.1084 16.0789C16.1084 16.9133 16.7848 17.5897 17.6192 17.5897Z",stroke:"currentColor",strokeWidth:1}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8848 17.5897C20.7192 17.5897 21.3956 16.9133 21.3956 16.0789C21.3956 15.2446 20.7192 14.5682 19.8848 14.5682C19.0504 14.5682 18.374 15.2446 18.374 16.0789C18.374 16.9133 19.0504 17.5897 19.8848 17.5897Z",stroke:"currentColor",strokeWidth:1})),Jr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),ct=e=>$.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},$.createElement("g",{id:"Large"},$.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),$.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},$.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),Yr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),Xr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"currentColor"})),Qr=e=>$.createElement("svg",{id:"Icon_Search_Base","data-name":"Icon \\u2013 Search \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24",...e},$.createElement("g",{id:"Large"},$.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),$.createElement("g",{id:"Search_icon","data-name":"Search icon",transform:"translate(3.75 3.75)"},$.createElement("circle",{vectorEffect:"non-scaling-stroke",id:"Ellipse_186","data-name":"Ellipse 186",cx:6,cy:6,r:6,fill:"none",stroke:"currentColor"}),$.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_556","data-name":"Line 556",x2:6,y2:6,transform:"translate(10.5 10.5)",fill:"none",stroke:"currentColor"})))),en=e=>$.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("g",{clipPath:"url(#clip0_841_1324)"},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),$.createElement("defs",null,$.createElement("clipPath",{id:"clip0_841_1324"},$.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)",strokeWidth:1})))),lt=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),wt=({selectable:e,className:r,addNewAddress:t,minifiedView:n,routeAddressesPage:s,isB2BFlow:o,permissions:l,loading:d})=>{const u=n?"minifiedView":"fullSizeView",h=Q({viewAllAddressesButton:`Account.${u}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${u}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${u}.Addresses.differentAddressButton`,noPermissionCreateAddresses:"Account.AddressForm.notifications.noPermissionCreateAddresses"}),i=e?"span":"button",f=e?{}:{AriaRole:"button",type:"button"},y=n&&!t?h.viewAllAddressesButton:h.addNewAddressButton,L=e?h.differentAddressButton:y;return d?a("div",{className:G(["account-actions-address","account-actions-address--loading",r]),"data-testid":"addressActionsLoaderWrapper",children:a(qr,{})}):o&&!(l!=null&&l.canCreateAddress)?a("div",{className:G(["account-actions-address","account-actions-address--no-permission",r]),"data-testid":"noPermissionMessage",children:a("span",{className:"account-actions-address__title",children:h.noPermissionCreateAddresses})}):P(i,{...f,className:G(["account-actions-address",["account-actions-address--viewall",n],["account-actions-address--address",!n],["account-actions-address--selectable",e],r]),"data-testid":"showRouteFullAddress",onClick:s,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:L}),a(Ge,{source:n&&!t?ct:Wr,size:"32"})]})},tn=({minifiedView:e,keysSortOrder:r,addressData:t,open:n,submitLoading:s,onRemoveAddress:o,closeModal:l,isB2BFlow:d,permissions:u})=>{const h=e?"minifiedView":"fullSizeView",i=Q({title:`Account.${h}.Addresses.removeAddressModal.title`,description:`Account.${h}.Addresses.removeAddressModal.description`,actionCancel:`Account.${h}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${h}.Addresses.removeAddressModal.actionConfirm`});if(!n)return null;const f=s||d&&!(u!=null&&u.canDeleteAddress);return a(Ft,{className:"account-address-modal--overlay",title:a("h3",{children:i.title}),size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:l,children:P("div",{className:"account-address-modal",children:[s?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Zt,{stroke:"4",size:"large"})}):null,a("p",{children:i.description}),t?a(dt,{minifiedView:e,addressData:t,keysSortOrder:r}):null,P("div",{className:"account-address-modal__buttons",children:[a(ie,{type:"button",onClick:l,variant:"secondary",disabled:s,children:i.actionCancel}),a(ie,{disabled:f,onClick:o,children:i.actionConfirm})]})]})})},je=({typeList:e,isEmpty:r,minifiedView:t,className:n})=>{const s=t?"minifiedView":"fullSizeView",o=Q({addressesMessage:`Account.${s}.EmptyList.Addresses.message`,ordersListMessage:`Account.${s}.EmptyList.OrdersList.message`,paymentsMessage:`Account.${s}.EmptyList.Payments.message`}),l=qe(()=>{switch(e){case"address":return{icon:jr,text:a("p",{children:o.addressesMessage})};case"orders":return{icon:Xr,text:a("p",{children:o.ordersListMessage})};case"payments":return{icon:Kr,text:a("p",{children:o.paymentsMessage})};default:return{icon:"",text:""}}},[e,o]);return!r||!e||!l.text?null:a(Fe,{className:G(["account-empty-list",t?"account-empty-list--minified":"",n]),message:l.text,icon:a(Ge,{source:l.icon}),"data-testid":"emptyList"})},Bt={size:"32",stroke:"2"},Et=({minifiedView:e,orderNumber:r,orderToken:t,routeOrdersList:n,routeOrderDetails:s})=>{const o=e?"minifiedView":"fullSizeView",l=Q({viewAllOrdersButton:`Account.${o}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${o}.OrdersList.ariaLabelLink`});return n?a("a",{className:G(["account-orders-list-action",["account-orders-list-action--minifiedView",e]]),"data-testid":"ordersListActionButtonMinifiedView",href:n(),children:a(_e,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:P("div",{className:"account-orders-list-action__card-wrapper",children:[a("p",{children:l.viewAllOrdersButton}),a(Ge,{source:ct,...Bt})]})})}):a("a",{"aria-label":`${l.ariaLabelLink} ${r??t}`,href:Ke(s)?s(r,t):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:a(Ge,{source:ct,...Bt})})},rn=()=>{const[e,r]=S(window.innerWidth<768);return oe(()=>{const t=()=>{r(window.innerWidth<768)};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),e},nn=({placeholderImage:e,minifiedView:r,item:t,withThumbnails:n,children:s,slots:o,routeTracking:l,routeOrderProduct:d,routeReturnDetails:u,...h})=>{var p,_,g,B,v,I,V,c,E,C,O,M;const i=r?"minifiedView":"fullSizeView",f=Q({orderNumber:`Account.${i}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${i}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${i}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${i}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${i}.OrdersList.OrdersListCard.orderDate`,placedByAdministrator:`Account.${i}.OrdersList.OrdersListCard.placedByAdministrator`}),y=rn(),L=Ke(d),m=Ne(()=>((t==null?void 0:t.items)??[]).map((w,H)=>{var N,A;const b={title:(w==null?void 0:w.productName)??"",src:((A=(N=w==null?void 0:w.product)==null?void 0:N.smallImage)==null?void 0:A.url)||e,alt:(w==null?void 0:w.productName)??"",width:65,height:65,loading:"eager"};return a(Te,{name:"OrderItemImage",slot:o==null?void 0:o.OrderItemImage,context:{data:w,defaultImageProps:b},children:L?a("a",{href:(d==null?void 0:d(w))??"",target:"_blank",rel:"noreferrer",children:a(yt,{...b})}):a(yt,{...b})},`${H}_${w.id}`)}),[L,t.items,e,d,o==null?void 0:o.OrderItemImage]);return P(_e,{variant:"secondary",...h,className:G(["account-orders-list-card",["account-orders-list-card--full",((p=t==null?void 0:t.items)==null?void 0:p.length)>6]]),children:[a("div",{className:"account-orders-list-card__content",children:o!=null&&o.OrdersListCard?a(Te,{"data-testid":`ordersListCard${t.id}`,name:"OrdersListCard",slot:o==null?void 0:o.OrdersListCard,context:{orderHistoryListItem:t}}):P(le,{children:[a("div",{children:t==null?void 0:t.status}),(t==null?void 0:t.adminAssistedOrder)>0&&a("div",{children:f.placedByAdministrator}),o!=null&&o.OrdersListOrderTime?a(Te,{"data-testid":`ordersListOrderTime${t.id}`,name:"OrdersListOrderTime",slot:o==null?void 0:o.OrdersListOrderTime,context:{deliveryDateText:f.deliveryDateText,orderDate:t==null?void 0:t.orderDate,orderTime:t==null?void 0:t.orderTime}}):P("p",{children:[f.deliveryDateText," ",t==null?void 0:t.orderDate]}),P("p",{children:[f.orderNumber," ",t.number]}),(_=t==null?void 0:t.shipments)==null?void 0:_.map(w=>{var H;return(H=w==null?void 0:w.tracking)==null?void 0:H.map(b=>{const N=l==null?void 0:l(b);return P("p",{"data-testid":b.number,children:[a("span",{children:`${f.carrier} ${b.carrier.toLocaleUpperCase()} `}),N?a("a",{href:N,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:b.number}):a("span",{className:"account-orders-list-card__content--track_number",children:b.number})]},w.id)})}),t!=null&&t.returns&&((g=t.returns)!=null&&g.length)?P("p",{"data-testid":t.number,children:[P("span",{children:[f.returnsText," "]}),(B=t==null?void 0:t.returns)==null?void 0:B.map(w=>a("span",{"data-testid":w.number,children:P("a",{href:(u==null?void 0:u({orderNumber:t.number,orderToken:t.token,returnNumber:w.number}))??"#",className:"account-orders-list-card__content--return_number",children:[w.number," "]})},w.uid))]},t.id):null,a("p",{children:a(nr,{amount:((I=(v=t==null?void 0:t.total)==null?void 0:v.grandTotal)==null?void 0:I.value)??0,currency:(c=(V=t==null?void 0:t.total)==null?void 0:V.grandTotal)==null?void 0:c.currency,weight:"normal",size:"medium"})}),P("p",{"data-testid":"itemsAmount",children:[(E=t==null?void 0:t.items)!=null&&E.length?(C=t==null?void 0:t.items)==null?void 0:C.reduce((w,H)=>{const b=(H==null?void 0:H.quantityOrdered)||0;return w+b},0):0," ",f.itemsAmount]}),(O=t==null?void 0:t.items)!=null&&O.length?a("ul",{className:"account-orders-list-card__product-list",children:t.items.map((w,H)=>{if(H>=0&&H<10)return P("li",{className:"account-orders-list-card__content--product-name",children:[P("span",{className:"account-orders-list-card__content--quantity",children:[(w==null?void 0:w.quantityOrdered)>1?w==null?void 0:w.quantityOrdered:null," "]}),w==null?void 0:w.productName.replaceAll("-"," ")]},`${H}_${w.id}`);if(H===11)return a("li",{children:"..."},"ellipsis")})}):null]})}),n&&((M=t==null?void 0:t.items)!=null&&M.length)?a(ar,{maxColumns:y?3:9,emptyGridContent:a(le,{}),className:G(["account-orders-list-card__images",["account-orders-list-card__images-3",y]]),"data-testid":"ordersListCardImages",children:m}):null,a("div",{className:"account-orders-list-card__actions",children:s})]})},an=(e,r)=>e||(r?"checkout":"addressBook"),sn=e=>e==="addressBook",on=e=>e==="checkout",dn=(e,r)=>!!e&&!!r,cn=e=>!!(e!=null&&e.canAccessAddressBook)&&!!(e!=null&&e.canViewAddress),ln=({isB2BCandidate:e,isCompanyAddressBookEnabled:r,enforceB2BPermissions:t,permissions:n,hasB2BContainerAccess:s})=>!!e&&!!r&&t&&!(n!=null&&n.loading)&&!s,un=({isB2BCandidate:e,isCompanyAddressBookEnabled:r,isB2BWithoutViewAccess:t})=>!!e&&(r||t),fn=({isCheckoutContext:e,isB2BFlow:r,selectable:t,isCustomShippingAddressAllowed:n,selectShipping:s,selectBilling:o})=>e&&!!r&&!!t&&(!!o&&!s||!n),hn=({b2bEnabled:e,customerTypeLoading:r})=>!!e&&r,gn=({isB2BCandidate:e,enforceB2BPermissions:r,permissionsLoading:t})=>e&&r&&!!t,pn=e=>e,mn=({enforceB2BPermissions:e,hasB2BContainerAccess:r})=>e&&!r,An=async(e,r)=>{if(r.length===1){const l=r[0],u=Object.values(l.region).every(i=>!!i)?{}:{region:{...l.region,regionId:0}};return!!await st({addressId:Number(l==null?void 0:l.id),defaultShipping:!1,defaultBilling:!1,...u})}const t=r.filter(l=>l.id!==e&&(l.defaultBilling||l.defaultShipping)||l.id!==e),n=r[r.length-1],s=t[0]||((n==null?void 0:n.id)!==e?n:null);return!s||!s.id?!1:!!await st({addressId:+s.id,defaultShipping:!0,defaultBilling:!0})},yn=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing","fax","prefix","suffix","middlename"],Ba=["email","firstname","lastname","middlename","gender","dob","prefix","suffix","fax"],qt=(e,r,t)=>{if(r&&t||!r&&!t)return e;const n=e.slice();return r?n.sort((s,o)=>Number(o.defaultShipping)-Number(s.defaultShipping)):n.sort((s,o)=>Number(o.defaultBilling)-Number(s.defaultBilling))};var Oe=(e=>(e.SHIPPING="SHIPPING",e.BILLING="BILLING",e))(Oe||{});const bn=e=>{if((e==null?void 0:e.addressType)===Oe.SHIPPING||(e==null?void 0:e.addressType)===Oe.BILLING)return e.addressType;const r=!!(e!=null&&e.defaultShipping),t=!!(e!=null&&e.defaultBilling);if(r!==t)return r?Oe.SHIPPING:Oe.BILLING},Ln=({addresses:e,isCheckoutContext:r,selectable:t,selectShipping:n,selectBilling:s})=>{if(!r||!t)return e;const o=!!(n&&!s);if(!o&&!!!(s&&!n))return e;const d=o?Oe.SHIPPING:Oe.BILLING;return e.filter(u=>bn(u)===d)},Cn=(e=!0)=>{const[r,t]=S(e),[n,s]=S(!1);return oe(()=>{if(!e){s(!1),t(!1);return}let o=!0;return t(!0),lr().then(l=>{o&&s(l)}).catch(l=>{console.error("[Account][useCustomerType] Failed to resolve company context",l),o&&s(!1)}).finally(()=>{o&&t(!1)}),()=>{o=!1}},[e]),{isB2BCustomer:n,loading:r}},vn=(e=!0)=>{const[r,t]=S(e),[n,s]=S(Xe());return oe(()=>{if(!e){s(Xe()),t(!1);return}let o=!0;return t(!0),ir().then(l=>{o&&s(l)}).catch(l=>{console.error("[Account][useCompanyAddressPermissions] Failed to resolve role permissions",l),o&&s(Xe())}).finally(()=>{o&&t(!1)}),()=>{o=!1}},[e]),{...n,loading:r}},it=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(it),_n=e=>{const r=e==null?void 0:e.region;if(!r||typeof r!="object")return e;const t={...r},n=t.regionId;if(n===""||n===null||n===void 0)delete t.regionId;else if(typeof n=="string"){const s=n.trim();!s||!/^\d+$/.test(s)?delete t.regionId:t.regionId=Number(s)}else typeof n=="number"&&!Number.isFinite(n)&&delete t.regionId;return{...e,region:t}},Nt=({item:e,isCheckoutContext:r,selectable:t,isB2BFlow:n})=>{const s=We(e);if(r&&t&&n){const o={...s};o.id&&(o.companyAddressId=o.id),delete o.id;const l=_n(o);return{selectedItem:e,data:l}}return{selectedItem:e,data:s}},wn=({b2bEnabled:e,selectShipping:r,selectBilling:t,selectable:n,contextMode:s,defaultSelectAddressId:o,onAddressData:l,minifiedView:d,routeAddressesPage:u,onSuccess:h})=>{const{isB2BCustomer:i,loading:f}=Cn(!!e),y=vn(!!e),L=dn(e,i),m=an(s,n),p=sn(m),_=on(m),[g,B]=S(""),[v,I]=S(!1),[V,c]=S(!1),[E,C]=S(!1),[O,M]=S(!1),[w,H]=S(!1),[b,N]=S(""),[A,k]=S([]),[x,z]=S([]),[J,de]=S(!1),[re,ne]=S(!0),Y=cn(y),R=ln({isB2BCandidate:L,isCompanyAddressBookEnabled:J,enforceB2BPermissions:p,permissions:y,hasB2BContainerAccess:Y}),ce=un({isB2BCandidate:L,isCompanyAddressBookEnabled:J,isB2BWithoutViewAccess:R}),me=fn({isCheckoutContext:_,isB2BFlow:ce,selectable:n,isCustomShippingAddressAllowed:re,selectShipping:r,selectBilling:t}),we=F(q=>{if(!q)return;const T=q.map(({name:U,orderNumber:D,label:X})=>({name:ur(U),orderNumber:D,label:yn.includes(U)?null:X}));z(T)},[]),Ae=F(async()=>{var U;const q=hn({b2bEnabled:e,customerTypeLoading:f}),T=gn({isB2BCandidate:L,enforceB2BPermissions:p,permissionsLoading:y==null?void 0:y.loading});if(q||T){C(!0);return}C(!0);try{if(pn(L))try{const Z=await fr(),j=!!(Z!=null&&Z.addressBookEnabled),te=!!(Z!=null&&Z.addressBookCustomShippingAddressEnabled);if(de(j),ne(te),j){if(mn({enforceB2BPermissions:p,hasB2BContainerAccess:Y})){k([]);return}const K=await ot("shortRequest");we(K);const ue=((U=Z==null?void 0:Z.addresses)==null?void 0:U.items)??[],fe=Ln({addresses:ue,isCheckoutContext:_,selectable:n,selectShipping:r,selectBilling:t});if(d){const W=fe.filter(ae=>!!ae.defaultShipping||!!ae.defaultBilling),ee=W.length?W:fe.slice(-1);k(ee)}else k(fe);return}}catch{de(!1),ne(!0)}de(!1),ne(!0);const[D,X]=await Promise.all([ot("shortRequest"),hr()]);if(we(D),X)if(d){const Z=X.filter(te=>!!te.defaultShipping||!!te.defaultBilling),j=Z.length?Z:X.slice(-1);k(j)}else k(X)}catch{}finally{C(!1)}},[e,f,d,L,_,n,r,t,p,Y,y==null?void 0:y.loading,we]);oe(()=>{Ae()},[Ae]),oe(()=>{var Z;if(!A.length){me&&(B(""),H(!1),l==null||l({data:{},isDataValid:!1}));return}const q=A.find(j=>{var te;return typeof o=="string"?j.uid===o||((te=j.id)==null?void 0:te.toString())===o:+j.id===o})||qt(A,r,t)[0],{selectedItem:T,data:U}=Nt({item:q,isCheckoutContext:_,selectable:n,isB2BFlow:ce}),D={data:U,isDataValid:!it(T)},X=((Z=q==null?void 0:q.id)==null?void 0:Z.toString())||(q==null?void 0:q.uid)||"";B(X),l==null||l(D)},[A,o,l,t,r,me,_,n,ce]);const ve=F(q=>{N(q),H(!1)},[]),ye=F((q,T)=>{const U=(q==null?void 0:q.target).value;if(me&&U==="0")return;const D=(q==null?void 0:q.target).nextSibling;B(U);const{data:X}=Nt({item:T,isCheckoutContext:_,selectable:n,isB2BFlow:ce}),Z={data:X,isDataValid:!it(X)};l==null||l(Z),H(U==="0"),D&&(D.focus(),window.scrollBy(0,100))},[l,me,_,n,ce]),Me=F(()=>{c(!0)},[]),ge=F(()=>{N(""),c(!1),I(!1)},[]),pe=F(()=>{I(!0)},[]),Ee=F(async()=>{M(!0);try{if(ce){if(!(y!=null&&y.canDeleteAddress))return;await gr(b)}else await An(b,A),await pr(+b);ge(),await Ae()}catch{}finally{M(!1)}},[A,b,ge,Ae,ce,y==null?void 0:y.canDeleteAddress]),Se=F(()=>{H(!1)},[]),be=F(()=>{if(me)return;Ke(u)&&d&&!w?window.location.href=u():(H(!0),N(""))},[w,u,d,me]),Le=F(async()=>{await Ae(),await(h==null?void 0:h())},[Ae,h]);return{keysSortOrder:x,submitLoading:O,isModalRendered:v,isFormRendered:V,loading:E,addNewAddress:w,addressesList:A,addressId:b,handleRenderForm:Me,handleRenderModal:pe,removeAddress:Ee,onCloseBtnClick:ge,setEditingAddressId:ve,closeNewAddressForm:Se,redirectToAddressesRoute:be,handleOnSuccess:Le,handleSelectAddressOption:ye,selectedAddressOption:g,permissions:y,isB2BFlow:ce,enforceB2BPermissions:p,isAddressSelectionLocked:me}},Ea=ht(({minifiedViewKey:e,hideActionFormButtons:r=!1,inputName:t,b2bEnabled:n,slots:s,title:o="",headerLevel:l,addressFormTitle:d="",defaultSelectAddressId:u="",showFormLoader:h=!1,onAddressData:i,forwardFormRef:f,className:y,showSaveCheckBox:L=!1,saveCheckBoxValue:m=!1,selectShipping:p=!1,selectBilling:_=!1,selectable:g=!1,withHeader:B=!0,minifiedView:v=!1,withActionsInMinifiedView:I=!1,withActionsInFullSizeView:V=!0,inputsDefaultValueSet:c,showShippingCheckBox:E=!0,showBillingCheckBox:C=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:M=!0,routeAddressesPage:w,onSubmit:H,onSuccess:b,onError:N,fieldIdPrefix:A,contextMode:k})=>{const x=Q({containerTitle:`Account.${e}.Addresses.containerTitle`,differentAddressButton:`Account.${e}.Addresses.differentAddressButton`,differentAddressFormTitle:`Account.${e}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${e}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${e}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${e}.Addresses.newAddressFormTitle`,loading:"Account.Addresses.loading",loaded:"Account.Addresses.loaded"}),{keysSortOrder:z,submitLoading:J,isModalRendered:de,isFormRendered:re,loading:ne,addNewAddress:Y,addressesList:R,addressId:ce,handleRenderForm:me,handleRenderModal:we,removeAddress:Ae,onCloseBtnClick:ve,handleOnSuccess:ye,setEditingAddressId:Me,closeNewAddressForm:ge,redirectToAddressesRoute:pe,handleSelectAddressOption:Ee,selectedAddressOption:Se,isAddressSelectionLocked:be,permissions:Le,isB2BFlow:q,enforceB2BPermissions:T}=wn({b2bEnabled:n,defaultSelectAddressId:u,minifiedView:v,routeAddressesPage:w,onSuccess:b,onAddressData:i,selectShipping:p,selectBilling:_,selectable:g,contextMode:k}),U=T!==!1,D=!!q&&U,X=o||x.containerTitle,Z=R.some(K=>!!K.defaultShipping),j=R.some(K=>!!K.defaultBilling);let te=null;if(g){const K=qt(R,p,_)||[];let ue;Y&&!be?ue=a("div",{className:G(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",Y]]),children:a(xe,{slots:s,hideActionFormButtons:r,fieldIdPrefix:A,formName:t,showFormLoader:h,isOpen:Y,forwardFormRef:f,showSaveCheckBox:L,saveCheckBoxValue:m,shippingCheckBoxValue:O,billingCheckBoxValue:M,addressesFormTitle:d||x.differentAddressFormTitle,inputsDefaultValueSet:c,showShippingCheckBox:E,showBillingCheckBox:C,hasDefaultShippingAddress:Z,hasDefaultBillingAddress:j,onCloseBtnClick:ge,onChange:i,onError:N,onSubmit:H,onSuccess:ye,isB2BFlow:q,enforceB2BPermissions:U,permissions:Le})}):K.length&&!be?ue=a(wt,{selectable:g,minifiedView:v,addNewAddress:Y,routeAddressesPage:pe,isB2BFlow:D,permissions:Le,loading:ne}):ue=null;const fe=`generalLabel_${X.replace(/\s+/g,"")}`;te=P("div",{className:"account-addresses-wrapper--select-view",children:[a("span",{id:fe,style:"display: none;",children:X}),K.map((W,ee)=>{var ze;const ae=((ze=W.id)==null?void 0:ze.toString())||W.uid,he=`${t}_${ae}`,Re=`${he}_label`;return P(bt,{children:[a("input",{"data-testid":`radio-${ee+1}`,type:"radio",name:t,id:he,value:ae,checked:Se===ae,onChange:Ye=>Ee(Ye,W),"aria-labelledby":`${fe} ${Re}`}),a("label",{id:Re,htmlFor:he,className:"account-addresses-wrapper__label",children:a(dt,{slots:s,selectable:g,selectShipping:p,selectBilling:_,minifiedView:v,addressData:W,keysSortOrder:z,loading:ne})})]},ae)}),ue&&P("div",{className:"account-addresses-wrapper__footer-section",children:[a("input",{"aria-label":x.differentAddressButton,"data-testid":"radio-0",type:"radio",name:t,id:`${t}_addressActions`,value:"0",checked:Se==="0",onChange:W=>Ee(W,{}),tabindex:ue?0:-1}),a("label",{htmlFor:`${t}_addressActions`,className:"account-addresses-wrapper__label",children:ue})]})]})}else te=P(le,{children:[R.map(K=>a(bt,{children:ce===K.id&&re?a(_e,{variant:"secondary",style:{marginBottom:20},children:a(xe,{slots:s,fieldIdPrefix:A,isOpen:ce===K.id&&re,addressFormId:ce,inputsDefaultValueSet:K,addressesFormTitle:x.editAddressFormTitle,showShippingCheckBox:E,showBillingCheckBox:C,hasDefaultShippingAddress:Z,hasDefaultBillingAddress:j,shippingCheckBoxValue:O,billingCheckBoxValue:M,forwardFormRef:f,onCloseBtnClick:ve,onChange:i,onError:N,onSubmit:H,onSuccess:ye,isB2BFlow:q,enforceB2BPermissions:U,permissions:Le})}):a(dt,{slots:s,minifiedView:v,addressData:K,keysSortOrder:z,loading:ne,setAddressId:Me,handleRenderModal:v&&I||!v&&V?we:void 0,handleRenderForm:v&&I||!v&&V?me:void 0,isB2BFlow:D,permissions:Le},K.id)},K.id)),a("div",{className:"account-addresses__footer",children:Y?a(_e,{variant:"secondary",children:a(xe,{slots:s,fieldIdPrefix:A,isOpen:Y,addressesFormTitle:x.newAddressFormTitle,inputsDefaultValueSet:c,showShippingCheckBox:!!(R!=null&&R.length),showBillingCheckBox:!!(R!=null&&R.length),hasDefaultShippingAddress:Z,hasDefaultBillingAddress:j,shippingCheckBoxValue:O,billingCheckBoxValue:M,forwardFormRef:f,onChange:i,onCloseBtnClick:ge,onError:N,onSubmit:H,onSuccess:ye,isB2BFlow:q,enforceB2BPermissions:U,permissions:Le})}):a(wt,{minifiedView:v,addNewAddress:Y,routeAddressesPage:pe,isB2BFlow:D,permissions:Le,loading:ne})})]});return P("div",{children:[B?a(ke,{title:X,divider:!v,className:G(["account-addresses-header-title",["account-addresses-header",v]]),level:l??(v?2:1)}):null,P("div",{className:G(["account-addresses-wrapper",y]),"data-testid":"addressesIdWrapper",children:[a(tn,{minifiedView:v,addressData:R==null?void 0:R.find(K=>K.id===ce),keysSortOrder:z,submitLoading:J,open:de,closeModal:ve,onRemoveAddress:Ae,isB2BFlow:D,permissions:Le}),a(Ht,{message:ne?x.loading:x.loaded}),ne?a(Je,{testId:"addressSkeletonLoader",withCard:!1}):g?be?a(je,{isEmpty:!(R!=null&&R.length),typeList:"address",minifiedView:v}):a(xe,{slots:s,hideActionFormButtons:r,fieldIdPrefix:A,formName:t,isOpen:!(R!=null&&R.length),forwardFormRef:f,showSaveCheckBox:L,saveCheckBoxValue:m,shippingCheckBoxValue:O,billingCheckBoxValue:M,inputsDefaultValueSet:c,showShippingCheckBox:E,showBillingCheckBox:C,hasDefaultShippingAddress:Z,hasDefaultBillingAddress:j,onChange:i,onCloseBtnClick:ge,onError:N,onSubmit:H,onSuccess:ye,isB2BFlow:q,enforceB2BPermissions:U,permissions:Le}):a(je,{isEmpty:!(R!=null&&R.length),typeList:"address",minifiedView:v}),te]})]})}),Ve={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:Be.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Bn={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:"",fieldType:Be.TEXT,className:"",required:!1,orderNumber:50,isHidden:!1},En={...Ve,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Nn={...Ve,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Tn={...Ve,label:"Shipping Address",name:"address_type_shipping",id:"address_type_shipping",code:"address_type_shipping",customUpperCode:"addressTypeShipping",orderNumber:90},Sn={...Ve,label:"Billing Address",name:"address_type_billing",id:"address_type_billing",code:"address_type_billing",customUpperCode:"addressTypeBilling",orderNumber:91},In={...Ve,label:"Set as default address",name:"is_default",id:"is_default",code:"is_default",customUpperCode:"isDefault",orderNumber:92},Pn={...Bn,label:"Nickname",name:"nickname",id:"nickname",code:"nickname",customUpperCode:"nickname"},Mn=(e,r)=>r==null?void 0:r.map(t=>{const n={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},s=JSON.parse(JSON.stringify(t));if(Object.hasOwn(n,t.customUpperCode)){const o=n[t.customUpperCode];t.customUpperCode==="region"&&typeof o=="object"?s.defaultValue=o.regionCode&&o.regionId?`${o.regionCode},${o.regionId}`:o.region??o.regionCode:s.defaultValue=o}return s}),Tt=e=>{if(!e)return null;const r=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(n=>{r.has(n.name)||r.set(n.name,"false"),n.checked&&r.set(n.name,"true")}),r&&typeof r.entries=="function"){const n=r.entries();if(n&&typeof n[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(n)))||{}}return{}},On=({fields:e,addressId:r,countryOptions:t,disableField:n,regionOptions:s,isRequiredRegion:o,isRequiredPostCode:l,keepDefaultCheckBoxesOnEdit:d})=>e.filter(h=>!(r&&!d&&(h.customUpperCode==="defaultShipping"||h.customUpperCode==="defaultBilling")&&h.defaultValue)).map(h=>h.customUpperCode==="countryCode"?{...h,options:t,disabled:n}:h.customUpperCode==="postcode"?{...h,required:l}:h.customUpperCode==="region"?{...h,options:s,required:o,disabled:n}:h),kn=(e,r="address")=>{const t=r==="address"?["region","city","company","countryCode","countryId","addressType","addressTypeShipping","addressTypeBilling","isDefault","defaultBilling","defaultShipping","fax","firstName","lastName","nickname","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dob","prefix","suffix","fax"],n={},s=[];return Object.keys(e).forEach(o=>{t.includes(o)?n[o]=e[o]:s.push({attribute_code:zt(o),value:e[o]})}),s.length>0&&(n.custom_attributesV2=s),n},St=e=>{const r=["street","streetMultiline_1","streetMultiline_2"],t=["on","off","true","false"],n=[],s={};for(const m in e){const p=e[m];t.includes(p)&&(s[m]=Dt(p)),r.includes(m)&&n.push(p)}const{street:o,streetMultiline_2:l,streetMultiline_1:d,region:u,...h}=e,[i,f]=u?u.split(","):[void 0,void 0],y=f&&i?{regionId:+f,regionCode:i}:{region:i};return kn({...h,...s,region:{...y},street:n})},$n=(e,r)=>{const t={};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=e[n];if(n==="region"&&s.regionId){const o=r.find(l=>(l==null?void 0:l.id)===s.regionId);o?t[n]={...s,text:o.text}:t[n]=s}else Array.isArray(s)?(t[n]=s[0]||"",s.slice(1).forEach((o,l)=>{t[`${n}Multiline_${l+2}`]=o})):t[n]=s}return t},xn=(e,r)=>!!e&&r!==!1,Fn=({isB2BFlow:e,shouldEnforceB2BPermissions:r,permissions:t})=>!!e&&!r&&(t==null?void 0:t.loading)===!1&&(t==null?void 0:t.canCreateAddress)===!1,Wt=(e,r)=>{const t=!!r.addressTypeShipping&&!!r.addressTypeBilling;return!!e&&(t||!!r.defaultShipping&&!!r.defaultBilling)},Zn=(e,r)=>e&&!r,It=({requestPayload:e,shouldEnforceB2BPermissions:r,canSetDefaultAddress:t})=>(typeof e.isDefault=="boolean"?e.isDefault:!!e.defaultShipping||!!e.defaultBilling)&&(!r||!!t),Hn=({isTemporaryCheckoutAddressMode:e,shouldEnforceB2BPermissions:r,canSetDefaultAddress:t})=>!e&&(!r||!!t),Pt=({requestPayload:e,shouldEnforceB2BPermissions:r,canSetDefaultAddress:t})=>{if(!Zn(r,t))return e;const n={...e};return delete n.defaultShipping,delete n.defaultBilling,delete n.isDefault,n},Vn=({shouldEnforceB2BPermissions:e,canEditAddress:r,isB2BFlow:t,requestPayload:n})=>{if(e&&!r)return"noPermissionEditAddresses";if(Wt(t,n))return"companyAddressSingleDefaultType"},Rn=({shouldEnforceB2BPermissions:e,canCreateAddress:r,isB2BFlow:t,requestPayload:n})=>{if(e&&!r)return"noPermissionCreateAddresses";if(Wt(t,n))return"companyAddressSingleDefaultType"},tt=e=>e instanceof Error&&e.message?e.message:typeof e=="string"&&e.trim()?e:"Unknown error",zn=({showShippingCheckBox:e,showBillingCheckBox:r,shippingCheckBoxValue:t,billingCheckBoxValue:n})=>({showShipping:!!e,showBilling:!!r,shippingDefaultValue:t??!1,billingDefaultValue:n??!1}),Un=e=>{const r={...e};return r.showShipping&&r.showBilling?(r.shippingDefaultValue===r.billingDefaultValue&&(r.shippingDefaultValue=!0,r.billingDefaultValue=!1),r):r.showShipping&&!r.showBilling&&!r.shippingDefaultValue?(r.shippingDefaultValue=!0,r):(!r.showShipping&&r.showBilling&&!r.billingDefaultValue&&(r.billingDefaultValue=!0),r)},Dn={none:{showShipping:!0,showBilling:!0,shippingDefaultValue:!1,billingDefaultValue:!1},shippingOnly:{showShipping:!1,showBilling:!0,shippingDefaultValue:!1,billingDefaultValue:!0},billingOnly:{showShipping:!0,showBilling:!1,shippingDefaultValue:!0,billingDefaultValue:!1},both:{showShipping:!1,showBilling:!1,shippingDefaultValue:!1,billingDefaultValue:!1}},Gn=({hasDefaultShippingAddress:e,hasDefaultBillingAddress:r})=>{const t=!!e,n=!!r;let s="none";return t&&n?s="both":t?s="shippingOnly":n&&(s="billingOnly"),Dn[s]},qn=({isB2BFlow:e,showShippingCheckBox:r,showBillingCheckBox:t,shippingCheckBoxValue:n,billingCheckBoxValue:s,addressId:o,hasDefaultShippingAddress:l,hasDefaultBillingAddress:d})=>{const u=zn({showShippingCheckBox:r,showBillingCheckBox:t,shippingCheckBoxValue:n,billingCheckBoxValue:s}),h=!o;return e?h?Gn({hasDefaultShippingAddress:l,hasDefaultBillingAddress:d}):u:h?Un(u):u},Wn=(e,r)=>e&&Object.keys(e).length>0?e:r&&Object.keys(r).length>0?r:{},Mt=e=>(e==null?void 0:e.name)==="nickname"||(e==null?void 0:e.code)==="nickname"||(e==null?void 0:e.customUpperCode)==="nickname",jn=({showFormLoader:e,showSaveCheckBox:r,saveCheckBoxValue:t,addressFormId:n,billingCheckBoxValue:s,shippingCheckBoxValue:o,showShippingCheckBox:l,showBillingCheckBox:d,hasDefaultShippingAddress:u,hasDefaultBillingAddress:h,inputsDefaultValueSet:i,onCloseBtnClick:f,onSuccess:y,onError:L,formName:m,isB2BFlow:p,enforceB2BPermissions:_,permissions:g})=>{const B=Q({noPermissionEditAddresses:"Account.AddressForm.notifications.noPermissionEditAddresses",noPermissionCreateAddresses:"Account.AddressForm.notifications.noPermissionCreateAddresses",companyAddressSingleDefaultType:"Account.AddressForm.notifications.companyAddressSingleDefaultType",b2bShippingTypeLabel:"Account.AddressForm.formText.b2bShippingTypeLabel",b2bBillingTypeLabel:"Account.AddressForm.formText.b2bBillingTypeLabel",b2bIsDefaultLabel:"Account.AddressForm.formText.b2bIsDefaultLabel",b2bIsDefaultShippingLabel:"Account.AddressForm.formText.b2bIsDefaultShippingLabel",b2bIsDefaultBillingLabel:"Account.AddressForm.formText.b2bIsDefaultBillingLabel"}),v=xn(p,_),I=Fn({isB2BFlow:p,shouldEnforceB2BPermissions:v,permissions:g}),[V,c]=S({text:"",type:"success"}),[E,C]=S(e??!1),[O,M]=S(n||""),[w,H]=S([]),[b,N]=S(null),[A,k]=S(()=>{var U,D;const T=sessionStorage.getItem(`${m}_addressData`);return T?{countryCode:(D=(U=JSON.parse(T))==null?void 0:U.data)==null?void 0:D.countryCode}:i}),[x,z]=S(!1),[J,de]=S(()=>{var D,X;const T=sessionStorage.getItem(`${m}_addressData`);return T?(X=(D=JSON.parse(T))==null?void 0:D.data)==null?void 0:X.saveAddressBook:t}),re=!v||!!(g!=null&&g.canEditAddress),ne=!v||!!(g!=null&&g.canSetDefaultAddress),Y=!!(p&&O),R=Y&&v&&!re&&ne,ce=Y&&v&&re&&!ne,me=F(T=>{de(T.target.checked)},[]);oe(()=>{typeof e>"u"||C(e)},[e]),oe(()=>{ot(O?"customer_address_edit":"customer_register_address").then(T=>{H(T)})},[O]),oe(()=>{z(!0),mr().then(({availableCountries:T,countriesWithRequiredRegion:U,optionalZipCountries:D})=>{N({availableCountries:T,countriesWithRequiredRegion:U,optionalZipCountries:D}),z(!1)})},[]);const we=Ne(()=>(b==null?void 0:b.availableCountries)||[],[b]),Ae=Ne(()=>!(A!=null&&A.countryCode)||!b?!1:b.countriesWithRequiredRegion.includes(A.countryCode),[A==null?void 0:A.countryCode,b]),ve=Ne(()=>!(A!=null&&A.countryCode)||!b?!0:!b.optionalZipCountries.includes(A.countryCode),[A==null?void 0:A.countryCode,b]),ye=Ne(()=>{var U;if(!(A!=null&&A.countryCode)||!b)return[];const T=b.availableCountries.find(D=>D.value===A.countryCode);return((U=T==null?void 0:T.availableRegions)==null?void 0:U.map(D=>({text:D.name,value:`${D.code},${D.id}`})))||[]},[A==null?void 0:A.countryCode,b]),Me=F(()=>{c({text:"",type:"success"}),f==null||f()},[f]),ge=F(T=>T.addressType==="BILLING"?"BILLING":T.addressType==="SHIPPING"?"SHIPPING":T.addressTypeBilling&&!T.addressTypeShipping?"BILLING":T.addressTypeShipping&&!T.addressTypeBilling?"SHIPPING":T.defaultBilling&&!T.defaultShipping?"BILLING":T.defaultShipping&&!T.defaultBilling?"SHIPPING":(i==null?void 0:i.addressType)??"SHIPPING",[i==null?void 0:i.addressType]),pe=F(T=>typeof T.isDefault=="boolean"?T.isDefault:typeof T.defaultShipping=="boolean"||typeof T.defaultBilling=="boolean"?!!(T.defaultShipping||T.defaultBilling):!!(i!=null&&i.defaultShipping||i!=null&&i.defaultBilling),[i==null?void 0:i.defaultBilling,i==null?void 0:i.defaultShipping]),Ee=F(async(T,U)=>{var fe,W;if(!U)return null;const D=Tt(T.target),Z={...St(D)},j=i==null?void 0:i.addressType;if(p){const ee=ge(Z),ae=pe(Z),he=Y&&j?j:ee;Z.addressType=he,Z.addressTypeShipping=he==="SHIPPING",Z.addressTypeBilling=he==="BILLING",Z.isDefault=ae,Z.defaultShipping=he==="SHIPPING"?ae:!1,Z.defaultBilling=he==="BILLING"?ae:!1}if(p&&R){C(!0);try{Z.isDefault&&await Qe(O),y==null||y(),f==null||f(),(fe=T==null?void 0:T.target)==null||fe.reset()}catch(ee){const ae=tt(ee);c(he=>({...he,text:ae,type:"error"})),L==null||L(ae)}finally{C(!1)}return null}const te=Vn({shouldEnforceB2BPermissions:v,canEditAddress:g==null?void 0:g.canEditAddress,isB2BFlow:p,requestPayload:Z});if(te)return c(ee=>({...ee,text:B[te],type:"warning"})),null;C(!0);const K=Pt({requestPayload:Z,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress}),ue=p?{...K,isDefault:pe(Z)}:K;try{if(p){const ee=It({requestPayload:Z,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress});await Ar(O,ue),ee&&await Qe(O)}else{const ee={...K,addressId:Number(O)};await st(ee)}y==null||y(),f==null||f(),(W=T==null?void 0:T.target)==null||W.reset()}catch(ee){const ae=tt(ee);c(he=>({...he,text:ae,type:"error"})),L==null||L(ae)}finally{C(!1)}},[f,L,y,p,v,B,O,i,g==null?void 0:g.canEditAddress,g==null?void 0:g.canSetDefaultAddress,ge,pe,Y,R]),Se=F(async(T,U)=>{var ue,fe;if(!U)return;const{saveAddressBook:D,...X}=Tt(T.target),j={...St(X)};if(p){const W=ge(j),ee=pe(j);j.addressType=W,j.addressTypeShipping=W==="SHIPPING",j.addressTypeBilling=W==="BILLING",j.isDefault=ee,j.defaultShipping=W==="SHIPPING"?ee:!1,j.defaultBilling=W==="BILLING"?ee:!1}if(C(!0),I)return y==null||y(),f==null||f(),(ue=T==null?void 0:T.target)==null||ue.reset(),M(""),C(!1),null;const te=Rn({shouldEnforceB2BPermissions:v,canCreateAddress:g==null?void 0:g.canCreateAddress,isB2BFlow:p,requestPayload:j});if(te)return c(W=>({...W,text:B[te],type:"warning"})),C(!1),null;const K=Pt({requestPayload:j,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress});try{if(p){const W=await yr(K);It({requestPayload:K,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress})&&await Qe(String((W==null?void 0:W.id)??""))}else await br(K);y==null||y(),f==null||f(),(fe=T==null?void 0:T.target)==null||fe.reset()}catch(W){const ee=tt(W);c(ae=>({...ae,text:ee,type:"error"})),L==null||L(ee)}finally{M(""),C(!1)}},[f,L,y,p,v,I,B,g==null?void 0:g.canCreateAddress,g==null?void 0:g.canSetDefaultAddress,ge,pe]),be=Ne(()=>qn({isB2BFlow:p,showShippingCheckBox:l,showBillingCheckBox:d,shippingCheckBoxValue:o,billingCheckBoxValue:s,addressId:O,hasDefaultShippingAddress:u,hasDefaultBillingAddress:h}),[p,l,d,o,s,O,u,h]),Le=Ne(()=>{if(!w.length)return[];const T=w.some(Ce=>Mt(Ce)&&Ce.fieldType===Be.TEXT&&!Ce.isHidden),D=p&&!T?[...w.filter(Ce=>!Mt(Ce)),Pn]:w,X=Hn({isTemporaryCheckoutAddressMode:I,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress}),Z=A==null?void 0:A.addressTypeBilling,j=A==null?void 0:A.addressTypeShipping,te=typeof Z=="boolean"||typeof j=="boolean"?Z?"BILLING":"SHIPPING":(i==null?void 0:i.addressType)??"SHIPPING",K=!!(i!=null&&i.defaultShipping||i!=null&&i.defaultBilling),ue=!!(p&&O),fe=!X||ce||R&&K,W=!!(!v||I||r&&!J),ee={...En,defaultValue:be.shippingDefaultValue,isHidden:!!(r&&!J||!be.showShipping||!X)},ae={...Nn,defaultValue:be.billingDefaultValue,isHidden:!!(r&&!J||!be.showBilling||!X)},he={...Tn,label:B.b2bShippingTypeLabel,forceLabel:!0,defaultValue:te==="SHIPPING",isHidden:W,disabled:ue},Re={...Sn,label:B.b2bBillingTypeLabel,forceLabel:!0,defaultValue:te==="BILLING",isHidden:W,disabled:ue},ze=te==="BILLING"?B.b2bIsDefaultBillingLabel:B.b2bIsDefaultShippingLabel,Ye={...In,label:ze,forceLabel:!0,defaultValue:K,isHidden:W,disabled:fe},Yt=p?[...D,he,Re,Ye]:[...D,ee,ae],pt=sessionStorage.getItem(`${m}_addressData`),Xt=pt?$n(JSON.parse(pt).data,ye):{},mt=Wn(Xt,i),Qt=p?{...mt,addressTypeShipping:te==="SHIPPING",addressTypeBilling:te==="BILLING",isDefault:K}:mt,er=Mn(Qt,Yt),At=On({fields:er,addressId:O,countryOptions:we,disableField:x,regionOptions:ye,isRequiredRegion:Ae,isRequiredPostCode:ve,keepDefaultCheckBoxesOnEdit:!!(p&&O)});return R?At.map(Ce=>Ce.customUpperCode==="addressTypeShipping"||Ce.customUpperCode==="addressTypeBilling"||Ce.customUpperCode==="isDefault"?{...Ce,disabled:Ce.customUpperCode==="isDefault"?fe:!0}:{...Ce,disabled:!0}):At},[w,p,r,J,be,I,v,g==null?void 0:g.canSetDefaultAddress,m,ye,i,O,we,x,Ae,ve,R,ce,A==null?void 0:A.addressTypeShipping,A==null?void 0:A.addressTypeBilling,B.b2bShippingTypeLabel,B.b2bBillingTypeLabel,B.b2bIsDefaultShippingLabel,B.b2bIsDefaultBillingLabel]),q=F(T=>{k(U=>({...U,...T}))},[]);return{regionOptions:ye,saveCheckBoxAddress:J,inLineAlert:V,addressId:O,submitLoading:E,normalizeFieldsConfig:Le,handleSaveCheckBoxAddress:me,handleUpdateAddress:Ee,handleCreateAddress:Se,handleOnCloseForm:Me,handleInputChange:q}},Kn=e=>{var s;if(!e||!Array.isArray(e.customAttributes))return e??{};const r={};(s=e==null?void 0:e.customAttributes)==null||s.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(r[o.code]=o.value)});const{customAttributes:t,...n}=e;return{...n,...Rt(r,"camelCase",{})}},Jn=({hideActionFormButtons:e,formName:r="",showFormLoader:t=!1,showSaveCheckBox:n=!1,saveCheckBoxValue:s=!1,forwardFormRef:o,slots:l,addressesFormTitle:d,className:u,addressFormId:h,inputsDefaultValueSet:i,showShippingCheckBox:f=!0,showBillingCheckBox:y=!0,hasDefaultShippingAddress:L=!1,hasDefaultBillingAddress:m=!1,shippingCheckBoxValue:p=!0,billingCheckBoxValue:_=!0,isOpen:g,fieldIdPrefix:B,onSubmit:v,onCloseBtnClick:I,onSuccess:V,onError:c,onChange:E,isB2BFlow:C,enforceB2BPermissions:O,permissions:M})=>{const w=Q({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook",noPermissionEditAddresses:"Account.AddressForm.notifications.noPermissionEditAddresses",noPermissionCreateAddresses:"Account.AddressForm.notifications.noPermissionCreateAddresses"}),H=!!C&&O!==!1,b=!!n&&!(C&&!H),{inLineAlert:N,addressId:A,submitLoading:k,normalizeFieldsConfig:x,handleUpdateAddress:z,handleCreateAddress:J,handleOnCloseForm:de,handleSaveCheckBoxAddress:re,saveCheckBoxAddress:ne,handleInputChange:Y,regionOptions:R}=jn({showFormLoader:t,addressFormId:h,inputsDefaultValueSet:Kn(i),shippingCheckBoxValue:p,billingCheckBoxValue:_,showShippingCheckBox:f,showBillingCheckBox:y,hasDefaultShippingAddress:L,hasDefaultBillingAddress:m,saveCheckBoxValue:s,showSaveCheckBox:b,onSuccess:V,onError:c,onCloseBtnClick:I,formName:r,isB2BFlow:C,enforceB2BPermissions:O,permissions:M}),ce=!!h,me=!H||!!(M!=null&&M.canEditAddress),we=!H||!!(M!=null&&M.canSetDefaultAddress),Ae=!H||!!(M!=null&&M.canCreateAddress),ve=ce?!me&&!we:!Ae,ye=ce?w.noPermissionEditAddresses:w.noPermissionCreateAddresses,[Me,ge]=S(0),pe=Ze(null);return oe(()=>{const Ee=JSON.stringify(i??null);if(pe.current===Ee)return;const Se=pe.current===null;pe.current=Ee,!Se&&ge(be=>be+1)},[i]),g?ve?P("div",{className:G(["account-address-form-wrapper",u]),children:[d?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:d}):null,a(Pe,{"data-testid":"noPermissionAlert",className:"account-address-form-wrapper__notification",type:"warning",variant:"secondary",heading:ye})]}):P("div",{className:G(["account-address-form-wrapper",u]),children:[d?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:d}):null,N.text?a(Pe,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:N.type,variant:"secondary",heading:N.text,icon:N.icon}):null,P(Gt,{regionOptions:R,forwardFormRef:o,slots:l,className:"account-address-form",name:r||"addressesForm",fieldsConfig:x,onSubmit:v||(A?z:J),setInputChange:Y,loading:k,showFormLoader:t,showSaveCheckBox:b,handleSaveCheckBoxAddress:re,saveCheckBoxAddress:ne,onChange:E,fieldIdPrefix:B,children:[A?a("input",{type:"hidden",name:"addressId",value:A,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:G(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",b]]),children:l!=null&&l.AddressFormActions?a(Te,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:l.AddressFormActions,context:{handleUpdateAddress:z,handleCreateAddress:J,addressId:A}}):a(le,{children:b?null:P(le,{children:[a(ie,{type:"button",onClick:de,variant:"secondary",disabled:k||ve,children:w.secondaryButton}),a(ie,{disabled:k||ve,children:w.primaryButton})]})})})]},Me)]}):null},Yn=()=>{const e=sessionStorage.getItem("accountStoreConfig");if(!e)return null;try{return JSON.parse(e)}catch(r){return console.error("Failed to parse cached store config:",r),sessionStorage.removeItem("accountStoreConfig"),null}},Xn=()=>{const[e,r]=S(!0),[t,n]=S(null),[s,o]=S(null),l=d=>{const{minLength:u,requiredCharacterClasses:h,shoppingAssistanceEnabled:i,shoppingAssistanceCheckboxTitle:f,shoppingAssistanceCheckboxTooltip:y}=d;n({minLength:u,requiredCharacterClasses:h}),o({shoppingAssistanceEnabled:i,shoppingAssistanceCheckboxTitle:f,shoppingAssistanceCheckboxTooltip:y})};return oe(()=>{const d=Yn();if(d){l(d),r(!1);return}Ut().then(u=>{u&&(sessionStorage.setItem("accountStoreConfig",JSON.stringify(u)),l(u))}).catch(u=>{console.error("Failed to load store config:",u)}).finally(()=>{r(!1)})},[]),{loading:e,passwordConfigs:t,remoteShoppingAssistanceConfigs:s}},Qn=({currentPassword:e,newPassword:r,confirmPassword:t,translations:n})=>{let s={...ut};const o=!e.length&&!r.length&&!t.length,l=e.length&&r!==t;return o?(s={...s,currentPassword:n.requiredFieldError,newPassword:n.requiredFieldError,confirmPassword:n.requiredFieldError},{isValid:!1,errors:s}):e.length?r.length?t.length?l?(s={...s,currentPassword:"",newPassword:"",confirmPassword:n.passwordMismatch},{isValid:!1,errors:s}):{isValid:!0,errors:s}:(s={...s,confirmPassword:n.requiredFieldError},{isValid:!1,errors:s}):(s={...s,newPassword:n.requiredFieldError},{isValid:!1,errors:s}):(s={...s,currentPassword:n.requiredFieldError},{isValid:!1,errors:s})},jt=(e,r)=>{if(r<=1)return!0;const t=/[0-9]/.test(e)?1:0,n=/[a-z]/.test(e)?1:0,s=/[A-Z]/.test(e)?1:0,o=/[^a-zA-Z0-9\s]/.test(e)?1:0;return t+n+s+o>=r},ut={currentPassword:"",newPassword:"",confirmPassword:""},ea=({passwordConfigs:e,handleSetInLineAlert:r,handleHideChangePassword:t})=>{const n=Q({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[s,o]=S(!1),[l,d]=S(!1),[u,h]=S(""),[i,f]=S(""),[y,L]=S(""),[m,p]=S({currentPassword:"",newPassword:"",confirmPassword:""}),_=F(()=>{t(()=>{r({}),p(ut)})},[t,r]),g=F(E=>{h(E),p(C=>({...C,currentPassword:E?"":n.requiredFieldError}))},[n]),B=F(E=>{f(E),p(C=>({...C,newPassword:E?"":n.requiredFieldError}))},[n]),v=F(E=>{L(E),p(C=>({...C,confirmPassword:E?"":n.requiredFieldError}))},[n]),I=F(E=>{const{name:C,value:O}=E==null?void 0:E.target;p(M=>({...M,[C]:O?"":n.requiredFieldError}))},[n]),V=F(()=>{const{isValid:E,errors:C}=Qn({currentPassword:u,newPassword:i,confirmPassword:y,translations:n});return p(C),E},[u,i,y,n]),c=F(E=>{E.preventDefault(),d(!0);const C=(e==null?void 0:e.requiredCharacterClasses)??0,O=(e==null?void 0:e.minLength)??1;if(!V()){o(!0),d(!1);return}if(!jt(i,C)||O>(i==null?void 0:i.length)){o(!0),d(!1);return}Lr({currentPassword:u,newPassword:i}).then(M=>{if(!(M!=null&&M.length)){d(!1);return}h(""),f(""),L(""),p(ut),o(!1),r({type:"success",text:n.passwordUpdateMessage})}).catch(M=>{M.message==="Invalid login or password."&&r({type:"error",text:n.incorrectCurrentPassword}),M.message==="The account is locked."&&r({type:"error",text:M.message})}),d(!1)},[e,V,i,u,r,n]);return{hideChangePassword:_,handleOnBlurPassword:I,handleConfirmPasswordChange:v,handleNewPasswordChange:B,handleCurrentPasswordChange:g,mutationChangePassword:c,currentPassword:u,newPassword:i,confirmPassword:y,passwordErrors:m,submitLoading:l,isClickSubmit:s}},ta=({passwordConfigs:e,isClickSubmit:r,password:t})=>{const n=Q({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[s,o]=S("pending");oe(()=>{if(!e)return;const d=jt(t,e.requiredCharacterClasses);r&&t.length>0?o(d?"success":"error"):r&&t.length===0?o("pending"):o(d?"success":"pending")},[r,e,t]);const l=Ne(()=>{var u;if(!e)return;const d={status:"pending",icon:"pending",message:(u=n.messageLengthPassword)==null?void 0:u.replace("{minLength}",`${e.minLength}`)};return t.length&&t.length>=e.minLength?{...d,icon:"success",status:"success"}:t.length&&t.length<e.minLength?r?{...d,icon:"error",status:"error"}:{...d,icon:"pending",status:"pending"}:d},[e,n.messageLengthPassword,t==null?void 0:t.length,r]);return{isValidUniqueSymbols:s,defaultLengthMessage:l}},ra=(e,r,t,n,s)=>e==="error"||(r==null?void 0:r.status)==="error"||t&&n.trim().length===0?s.newPassword:void 0,Na=({handleHideChangePassword:e,handleSetInLineAlert:r,inLineAlertProps:t})=>{const{passwordConfigs:n}=Xn(),{hideChangePassword:s,handleOnBlurPassword:o,handleConfirmPasswordChange:l,handleNewPasswordChange:d,handleCurrentPasswordChange:u,mutationChangePassword:h,currentPassword:i,newPassword:f,confirmPassword:y,passwordErrors:L,submitLoading:m,isClickSubmit:p}=ea({passwordConfigs:n,handleSetInLineAlert:r,handleHideChangePassword:e}),{isValidUniqueSymbols:_,defaultLengthMessage:g}=ta({password:f,isClickSubmit:p,passwordConfigs:n}),B=Q({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return P(_e,{className:"account-change-password",variant:"secondary",children:[a(ke,{title:B.containerTitle,divider:!1,className:"account-change-password__title",level:3}),t.text?a(Pe,{className:"account-change-password__notification",type:t.type,variant:"secondary",heading:t.text,icon:t.icon,"data-testid":"changePasswordInLineAlert"}):null,P("div",{className:"account-change-password__fields",children:[a(Ue,{className:"account-change-password__fields-item",autoComplete:"current-password",name:"currentPassword",placeholder:B.currentPasswordPlaceholder,floatingLabel:B.currentPasswordFloatingLabel,errorMessage:L.currentPassword,defaultValue:i,onValue:u,onBlur:o}),a(Ue,{className:"account-change-password__fields-item",autoComplete:"new-password",name:"newPassword",placeholder:B.newPasswordPlaceholder,floatingLabel:B.newPasswordFloatingLabel,minLength:n==null?void 0:n.minLength,validateLengthConfig:g,uniqueSymbolsStatus:_,requiredCharacterClasses:n==null?void 0:n.requiredCharacterClasses,errorMessage:ra(_,g,p,f,L),defaultValue:f,onValue:d,onBlur:o}),a(Ue,{className:"account-change-password__fields-item",autoComplete:"new-password",name:"confirmPassword",placeholder:B.confirmPasswordPlaceholder,floatingLabel:B.confirmPasswordFloatingLabel,errorMessage:L.confirmPassword,defaultValue:y,onValue:l,onBlur:o})]}),P("div",{className:"account-change-password__actions",children:[a(ie,{type:"button",disabled:m,onClick:s,variant:"secondary",children:B.buttonSecondary}),a(ie,{variant:"primary",type:"button",disabled:m,onClick:h,children:B.buttonPrimary})]})]})},Ta=({inLineAlertProps:e,errorPasswordEmpty:r,passwordValue:t,showPasswordOnEmailChange:n,submitLoading:s,formFieldsList:o,handleHideEditForm:l,handleUpdateCustomerInformation:d,handleInputChange:u,handleSetPassword:h,handleOnBlurPassword:i})=>{const f=Q({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return P(_e,{variant:"secondary",className:"account-edit-customer-information",children:[a(ke,{title:f.containerTitle,divider:!1,className:"account-edit-customer-information__title",level:3}),e.text?a(Pe,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,P(Gt,{loading:s,fieldsConfig:o||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:d,setInputChange:u,children:[n?a("div",{className:"account-edit-customer-information__password",children:a(Ue,{autoComplete:"current-password",name:"password",placeholder:f.placeholder,floatingLabel:f.floatingLabel,errorMessage:r?f.requiredFieldError:void 0,defaultValue:t,onValue:h,onBlur:i})}):null,P("div",{className:"account-edit-customer-information__actions",children:[a(ie,{disabled:s,type:"button",variant:"secondary",onClick:()=>l(),children:f.buttonSecondary}),a(ie,{disabled:s,type:"submit",variant:"primary",children:f.buttonPrimary})]})]})]})},Sa=({createdAt:e,slots:r,orderedCustomerData:t,showEditForm:n,showChangePassword:s,handleShowChangePassword:o,handleShowEditForm:l})=>{const d=Q({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonSecondaryAriaLabel:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondaryAriaLabel",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",buttonPrimaryAriaLabel:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimaryAriaLabel",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return a(_e,{variant:"secondary",className:G(["account-customer-information-card",["account-customer-information-card-short",s||n]]),children:P("div",{className:"account-customer-information-card__wrapper",children:[P("div",{className:"account-customer-information-card__actions",children:[a(ie,{type:"button",variant:"tertiary","aria-label":d.buttonSecondaryAriaLabel,onClick:o,children:d.buttonSecondary}),a(ie,{type:"button",variant:"tertiary","aria-label":d.buttonPrimaryAriaLabel,onClick:l,children:d.buttonPrimary})]}),a("div",{className:"account-customer-information-card__content",children:r!=null&&r.CustomerData?a(Te,{name:"CustomerData",slot:r==null?void 0:r.CustomerData,context:{customerData:t}}):P(le,{children:[t==null?void 0:t.map((u,h)=>{const i=u!=null&&u.label?`${u.label}: ${u==null?void 0:u.value}`:u==null?void 0:u.value;return a("p",{"data-testid":`${u.name}_${h}`,children:i},`${u.name}_${h}`)}),P("p",{children:[d.accountCreation,": ",e]})]})})]})})};function na(e){if(!e)return[];const r=`${e.firstName} ${e.lastName}`.trim(),t=e.street??"",n=e.city??"",s=e.region||void 0,o=e.postcode??"",l=e.countryCode??"";let d="";n&&s?d=`${n}, ${(s==null?void 0:s.regionCode)??""}`.trim():n?d=n:s&&(d=(s==null?void 0:s.regionCode)??"");let u=d;o&&(u=d?`${d} ${o}`:o);let h=u;return l&&(h=u?`${u}, ${l}`:l),[r,t,h]}const Ot=({title:e,address:r,selected:t,busy:n,onChange:s})=>{const[o,l,d]=na(r);return a("div",{className:"account-address-validation__option",children:a(sr,{busy:n,className:"account-address-validation__radio",label:P("div",{children:[a("div",{className:"account-address-validation__option-title",children:a("strong",{children:e})}),o&&a("div",{children:o}),l&&a("div",{children:l}),d&&a("div",{children:d})]}),name:"address-validation-choice",selected:t,value:e,onChange:s})})},Ia=({busy:e=!1,className:r,originalAddress:t,onSelectionChange:n,selection:s,suggestedAddress:o})=>{const l=!!o,d=Q({title:"Account.AddressValidation.title",subtitle:"Account.AddressValidation.subtitle",suggestedAddress:"Account.AddressValidation.suggestedAddress",originalAddress:"Account.AddressValidation.originalAddress"});return P("div",{className:G(["account-address-validation",r]),children:[a(ke,{className:"account-address-validation__title",divider:!1,title:d.title,level:1}),a("div",{className:"account-address-validation__subtitle",children:d.subtitle}),P("div",{className:G(["account-address-validation__options",e&&"account-address-validation__options--busy"]),children:[l&&a(Ot,{address:o,busy:e,selected:s==="suggested",title:d.suggestedAddress,onChange:()=>n("suggested")}),a(Ot,{address:t,busy:e,selected:s==="original",title:d.originalAddress,onChange:()=>n("original")})]})]})},Pa=({loading:e,isRemoteShoppingAssistanceAvailable:r,isRemoteShoppingAssistanceEnabled:t,showAlert:n,checkboxLabel:s,checkboxTooltip:o,alertMessage:l,featureDisabledMessage:d,handleCheckboxChange:u,handleDismissAlert:h})=>{const[i,f]=S(!1);return e?a(He,{children:a(se,{variant:"row"})}):!e&&!r?a("div",{className:"account-seller-assisted-buying-settings-control__alert",children:a(Fe,{heading:d})}):P("div",{className:"account-seller-assisted-buying-settings-control",children:[!t&&n&&a("div",{className:"account-seller-assisted-buying-settings-control__alert",children:a(Pe,{variant:"secondary",type:"warning",heading:l,onDismiss:h})}),P("div",{className:"account-seller-assisted-buying-settings-control__checkbox-row",children:[a(Ie,{children:a(ft,{name:"allowRemoteShoppingAssistance",value:"true",placeholder:s,label:s,checked:t,onChange:y=>u(y.currentTarget.checked)})}),o?P("div",{className:"account-seller-assisted-buying-settings-control__info-container",children:[a("button",{type:"button",className:"account-seller-assisted-buying-settings-control__info-icon",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onFocusCapture:()=>f(!0),onBlurCapture:()=>f(!1),"aria-label":o,children:"?"}),i?P("span",{className:"account-seller-assisted-buying-settings-control__tooltip",role:"tooltip",children:[o,a("span",{className:"account-seller-assisted-buying-settings-control__tooltip-arrow"})]}):null]}):null]})]})},Ma=({loading:e,adminAssistanceActions:r,tableHeaders:t,actionTypesMap:n,emptyStateMessage:s,featureDisabledMessage:o,isRemoteShoppingAssistanceAvailable:l=!0,errorMessage:d,currentPage:u,onPageChange:h,withWrapper:i=!0})=>{var _;if(e)return P(He,{children:[a(se,{variant:"row",fullWidth:!0}),a(se,{variant:"row",fullWidth:!0}),a(se,{variant:"row",fullWidth:!0})]});if(!l)return a("div",{className:"account-seller-assisted-buying-activity-table__alert",children:a(Fe,{heading:o})});if(d)return a("div",{className:"account-seller-assisted-buying-activity-table__error",children:a(Fe,{heading:d})});if(!((_=r==null?void 0:r.items)!=null&&_.length))return a("div",{className:"account-seller-assisted-buying-activity-table__empty",children:a(Fe,{heading:s})});const f=[{label:t.action,key:"action",ariaLabel:t.action},{label:t.date,key:"date",ariaLabel:t.date},{label:t.details,key:"details",ariaLabel:t.details}],y=r.items.map(g=>({action:n[g.action]||g.action,date:g.date,details:g.details})),L=r.pageInfo.totalPages,m=L>1,p=a("div",{className:"account-seller-assisted-buying-activity-table",children:a("div",{className:"account-seller-assisted-buying-activity-table__table-wrapper",children:a(or,{columns:f,rowData:y,mobileLayout:"stacked",className:"account-seller-assisted-buying-activity-table__table"})})});return P(le,{children:[i?a(_e,{variant:"secondary",className:G(["account-seller-assisted-buying-activity-table-card"]),children:p}):p,m&&a("div",{className:"account-seller-assisted-buying-activity-table__pagination",children:a(Vt,{currentPage:u,totalPages:L,onChange:h})})]})},Kt=({cardBrand:e,lastFourDigits:r,expired:t=!1,onRemove:n,variant:s="secondary",minifiedView:o=!1})=>{const l=gt(),d=Q({actionRemove:"Account.Payments.paymentCard.actionRemove",cardEndingIn:"Account.Payments.paymentCard.cardEndingIn",expiredLabel:"Account.Payments.paymentCard.expiredLabel"}),u=nt(()=>{n==null||n()},[n]),h=`•••• ${r}`,i=`${d.cardEndingIn} ${h}`;return P(_e,{variant:s,className:G(["account-payment-card",o&&"account-payment-card--minified"]),"data-testid":"paymentCard",children:[a("div",{className:"account-payment-card__action",children:n?a(ie,{type:"button",variant:"tertiary",onClick:u,"data-testid":"removeButton","aria-label":`${d.actionRemove} ${e} ${i}`,"aria-describedby":l,children:d.actionRemove}):null}),P("div",{className:"account-payment-card__description",id:l,children:[a("p",{className:"account-payment-card__card-brand","data-testid":"cardBrand",children:e}),a("p",{className:"account-payment-card__card-number","data-testid":"cardNumber",children:i})]}),t?a("div",{className:"account-payment-card__labels","data-testid":"expiredTag",children:a($e,{label:(d.expiredLabel??"Expired").toLocaleUpperCase()})}):null]})},kt="account/customerPaymentTokens",Jt="__REMOVE_FAILED__",aa=e=>{const r=Ze("api"),t=Ze(void 0),[n,s]=S([]),[o,l]=S(!0),[d,u]=S(null),[h,i]=S(null),[f,y]=S(null),L=F(async()=>{l(!0),u(null),i(null);try{const g=await Cr(e);r.current="api",s(g)}catch(g){s([]),u(g instanceof Error?g.message:String(g))}finally{l(!1)}},[e]);oe(()=>{let g=!1,B=!1;const v=at.on(kt,I=>{g||(B=!0,r.current="event",s(Array.isArray(I)?I:[]),u(null),l(!1))},{eager:!0});return(!v||!B)&&L(),()=>{g=!0,v==null||v.off()}},[L]);const m=(e==null?void 0:e.join(","))??"";oe(()=>{if(r.current==="api"){if(t.current===void 0){t.current=m;return}t.current!==m&&(t.current=m,L())}},[m,L]);const p=F(async g=>{i(null),y(g);try{await vr(g)?s(v=>v.filter(I=>I.publicHash!==g)):i(Jt)}catch(B){i(B instanceof Error?B.message:String(B))}finally{y(null)}},[]),_=F(async()=>{if(r.current==="event"){const g=at.lastPayload(kt);if(g===void 0)return;s(Array.isArray(g)?g:[]),u(null),i(null);return}await L()},[L]);return{items:n,loading:o,loadError:d,actionError:h,removingHash:f,removeToken:p,refetch:_}},Oa=({className:e,withHeader:r=!0,minifiedView:t=!1,filterPaymentMethodCodes:n})=>{const s=Q({containerTitle:"Account.Payments.containerTitle",loadError:"Account.Payments.loadError",removeError:"Account.Payments.removeError"}),{items:o,loading:l,loadError:d,actionError:u,removingHash:h,removeToken:i}=aa(n),[f,y]=S(null),L=F(()=>{y(null)},[]),m=F(async()=>{f&&(await i(f.publicHash),y(null))},[f,i]),p=u===Jt?s.removeError:u??"",_=o.length>0?o.map(B=>{const{publicHash:v,...I}=B;return a(Kt,{...I,minifiedView:t,onRemove:h!==null?void 0:()=>y(B)},v)}):null,g=o.length===0&&!d?a("div",{className:"account-payment-methods__empty","data-testid":"paymentMethodsEmpty",children:a(je,{isEmpty:!0,typeList:"payments",minifiedView:t})}):null;return P("div",{className:G(["account-payment-methods",e]),"data-testid":"paymentMethods",children:[r?a(ke,{"aria-label":s.containerTitle,role:"region",title:s.containerTitle,divider:!t,className:G(["account-payment-methods-header-title",["account-payment-methods-header",t]]),level:t?2:1}):null,d?a(Pe,{className:"account-payment-methods__alert",type:"error",variant:"secondary",heading:s.loadError,description:d,icon:a(lt,{}),"data-testid":"paymentMethodsLoadError"}):null,u&&!d?a(Pe,{className:"account-payment-methods__alert",type:"error",variant:"secondary",heading:p,icon:a(lt,{}),"data-testid":"paymentMethodsActionError"}):null,a(sa,{open:f!==null,submitLoading:f!==null&&h===f.publicHash,onRemoveToken:()=>{m()},closeModal:L,cardBrand:f==null?void 0:f.cardBrand,lastFourDigits:f==null?void 0:f.lastFourDigits,expired:f==null?void 0:f.expired,variant:f==null?void 0:f.variant,minifiedView:t}),l?a(Je,{testId:"paymentMethodsLoader"}):a("div",{className:"account-payment-methods__list",children:_??g})]})},sa=({open:e,submitLoading:r,onRemoveToken:t,closeModal:n,cardBrand:s,lastFourDigits:o,expired:l,variant:d,minifiedView:u})=>{const h=Q({title:"Account.Payments.removePaymentModal.title",description:"Account.Payments.removePaymentModal.description",actionCancel:"Account.Payments.removePaymentModal.actionCancel",actionConfirm:"Account.Payments.removePaymentModal.actionConfirm"});return e?a(Ft,{className:"account-payment-modal--overlay",title:a("h3",{children:h.title}),size:"full","data-testid":"paymentModal",showCloseButton:!0,onClose:n,children:P("div",{className:"account-payment-modal",children:[r?a("div",{className:"account-payment-modal__spinner","data-testid":"progressSpinner",children:a(Zt,{stroke:"4",size:"large"})}):null,a("p",{children:h.description}),s&&o?a(Kt,{cardBrand:s,lastFourDigits:o,expired:l,variant:d,minifiedView:u}):null,P("div",{className:"account-payment-modal__buttons",children:[a(ie,{type:"button",onClick:n,variant:"secondary",disabled:r,children:h.actionCancel}),a(ie,{disabled:r,onClick:t,children:h.actionConfirm})]})]})}):null},xe=({hideActionFormButtons:e,formName:r,showFormLoader:t,showSaveCheckBox:n,saveCheckBoxValue:s,forwardFormRef:o,slots:l,addressesFormTitle:d,className:u,addressFormId:h,inputsDefaultValueSet:i,billingCheckBoxValue:f,shippingCheckBoxValue:y,showBillingCheckBox:L,showShippingCheckBox:m,hasDefaultShippingAddress:p,hasDefaultBillingAddress:_,isOpen:g,fieldIdPrefix:B,onSubmit:v,onCloseBtnClick:I,onSuccess:V,onError:c,onChange:E,isB2BFlow:C,enforceB2BPermissions:O,permissions:M})=>a("div",{className:G(["account-address-form"]),children:a(Jn,{hideActionFormButtons:e,formName:r,showFormLoader:t,slots:l,addressesFormTitle:d,className:u,addressFormId:h,inputsDefaultValueSet:i,shippingCheckBoxValue:y,billingCheckBoxValue:f,showShippingCheckBox:m,showBillingCheckBox:L,hasDefaultShippingAddress:p,hasDefaultBillingAddress:_,isOpen:g,fieldIdPrefix:B,onSubmit:v,onCloseBtnClick:I,onSuccess:V,onError:c,onChange:E,forwardFormRef:o,showSaveCheckBox:n,saveCheckBoxValue:s,isB2BFlow:C,enforceB2BPermissions:O,permissions:M})});xe.displayName="AddressForm";const oa={success:a(Jr,{}),warning:a(en,{}),error:a(lt,{})},da=()=>{const[e,r]=S({}),t=F(n=>{if(!(n!=null&&n.type)){r({});return}const s=oa[n.type];r({...n,icon:s})},[]);return{inLineAlertProps:e,handleSetInLineAlert:t}},ca=({ordersInMinifiedView:e,minifiedView:r,pageSize:t,selectedDate:n,selectedPage:s,searchText:o,handleSetFirstOrderDate:l,handleSetInLineAlert:d})=>{const u=Q({searchError:"Account.fullSizeView.OrdersList.OrdersListSearch.error"}),[h,i]=S([]),[f,y]=S({totalPages:1,currentPage:1,pageSize:1}),[L,m]=S(!1),[p,_]=S(""),[g,B]=S(0),v=F(()=>{B(I=>I+1)},[]);return oe(()=>{Ut().then(I=>{_(I.baseMediaUrl)})},[]),oe(()=>{const I=at.on("companyContext/changed",v);return()=>{I==null||I.off()}},[v]),oe(()=>{const I=new AbortController;return m(!0),d==null||d(),_r(r?e:t,n,s,o,I.signal).then(V=>{if(!I.signal.aborted){if(!(V!=null&&V.items)){i([]),d==null||d({type:"error",text:u.searchError});return}y(V.pageInfo),i(V.items),l==null||l(V.dateOfFirstOrder)}}).catch(()=>{I.signal.aborted||(i([]),d==null||d({type:"error",text:u.searchError}))}).finally(()=>{I.signal.aborted||m(!1)}),()=>{I.abort()}},[l,d,r,e,t,n,s,o,g,u.searchError]),{loading:L,orderHistoryListItems:h,pageInfo:f,placeholderImage:p,refetchOrders:v}},rt=(e,r=1)=>{const t=new Date,n=new Date(t);switch(e){case"sixMonthsAgo":{n.setMonth(n.getMonth()-r);break}case"oneYearAgo":{n.setFullYear(n.getFullYear()-r);break}default:return""}return{from:n==null?void 0:n.toISOString().split("T")[0],to:`${t==null?void 0:t.toISOString().split("T")[0]} 23:59:59`}},la=e=>{const r=[],t=new Date().getFullYear();for(let n=e;n<=t-1;n++)r.push({value:`{"from":"${n}-01-01","to":"${n+1}-01-01 23:59:59"}`,text:n.toString()});return r},ia=(e="selectedDate")=>{const r=Q({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[t,n]=S(),[s,o]=S(JSON.stringify(rt("sixMonthsAgo",6))),[l,d]=S(1),[u,h]=S("");oe(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[l]);const i=Ne(()=>{const m=[{value:JSON.stringify(rt("sixMonthsAgo",6)),text:r.pastSixMonths},{value:JSON.stringify(rt("oneYearAgo",1)),text:r.currentYear},{value:"viewAll",text:r.viewAll}];if(t){const _=new Date(t).getFullYear();m==null||m.splice(2,0,...la(_))}return m},[r,t]),f=F(m=>{n(m)},[]),y=F(m=>{const _=m.target.value;o(_),d(1)},[]),L=F(m=>{h(m),m&&e==="allOrders"&&o("viewAll"),d(1)},[e]);return{selectableDateList:i,selectedDate:s,selectedPage:l,searchText:u,handleSelectDate:y,handleSearch:L,setSelectedPage:d,handleSetFirstOrderDate:f}},ua=({actionLabel:e,actionDisabled:r,clearLabel:t,onClear:n,error:s,...o})=>P("div",{className:G(["account-orders-list__search-input",["account-orders-list__search-input--has-clear",!r],["account-orders-list__search-input--error",!!s]]),children:[a(xt,{...o,error:s,"aria-invalid":!!s}),P("div",{className:"account-orders-list__search-actions",children:[r?null:a(ie,{className:"account-orders-list__search-clear",type:"button",variant:"tertiary",icon:a(Yr,{}),"aria-label":t,onClick:n}),a(ie,{className:"account-orders-list__search-submit",type:"submit",variant:"tertiary",icon:a(Qr,{}),"aria-label":e,disabled:r})]})]}),fa=({handleSearch:e,refetchOrders:r,searchText:t})=>{const n=Q({action:"Account.fullSizeView.OrdersList.OrdersListSearch.action",clear:"Account.fullSizeView.OrdersList.OrdersListSearch.clear",label:"Account.fullSizeView.OrdersList.OrdersListSearch.label",minimumLength:"Account.fullSizeView.OrdersList.OrdersListSearch.minimumLength",placeholder:"Account.fullSizeView.OrdersList.OrdersListSearch.placeholder"}),[s,o]=S(t),[l,d]=S(""),u=Ze(null),h=`${gt()}-order-search`,i=!!(s.trim()||t),f=m=>{d(""),o(m),m!==t?e(m):m&&r()},y=()=>{const m=s.trim();if(m.length>0&&m.length<Br){d(n.minimumLength);return}f(m)},L=()=>{var p;f("");const m=(p=u.current)==null?void 0:p.elements.namedItem("orderSearch");m instanceof HTMLInputElement&&m.focus()};return a("form",{ref:u,className:"account-orders-list__search",role:"search","aria-label":n.action,onSubmit:m=>{m.preventDefault(),y()},children:a(Ie,{label:n.label,error:l||void 0,children:a(ua,{id:h,name:"orderSearch",value:s,maxLength:wr,placeholder:n.placeholder,actionLabel:n.action,actionDisabled:!i,clearLabel:n.clear,onClear:L,onInput:m=>{o(m.currentTarget.value),d("")}})})})},ka=({className:e,withHeader:r=!0,minifiedView:t=!1,withThumbnails:n=!0,withFilter:s=!0,withSearch:o=!1,searchScope:l="selectedDate",ordersInMinifiedView:d=1,pageSize:u=10,routeOrdersList:h,routeOrderDetails:i,routeReturnDetails:f,routeTracking:y,routeOrderProduct:L,slots:m})=>{const p=t?"minifiedView":"fullSizeView",_=Q({containerTitle:`Account.${p}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${p}.OrdersList.dateOrderPlaced`,loading:"Account.OrdersList.loading",loaded:"Account.OrdersList.loaded"}),{selectableDateList:g,selectedDate:B,handleSelectDate:v,selectedPage:I,searchText:V,handleSearch:c,setSelectedPage:E,handleSetFirstOrderDate:C}=ia(l),{inLineAlertProps:O,handleSetInLineAlert:M}=da(),{pageInfo:w,loading:H,orderHistoryListItems:b,placeholderImage:N,refetchOrders:A}=ca({minifiedView:t,pageSize:u,ordersInMinifiedView:d,selectedDate:B,selectedPage:I,searchText:V,handleSetFirstOrderDate:C,handleSetInLineAlert:M});return P("div",{children:[r?a(ke,{"aria-label":_.containerTitle,role:"region",title:_.containerTitle,divider:!t,className:G(["account-orders-list-header-title",["account-orders-list-header",t]]),level:t?2:1}):null,P("div",{className:G(["account-orders-list",e]),children:[a(Ht,{message:H?_.loading:_.loaded}),!t&&(o||s)?P("div",{className:"account-orders-list__controls",children:[s?a(Ie,{className:"account-orders-list__date-select",label:_.dateOrderPlaced,children:a($t,{id:"orderDatePicker",value:B,name:"orderDatePicker","aria-label":_.dateOrderPlaced,options:g,handleSelect:v})}):null,o?a(fa,{handleSearch:c,refetchOrders:A,searchText:V}):null]}):null,O.text?a(Pe,{"data-testid":"ordersListInLineAlert",className:"account-orders-list__notification",type:O.type,variant:"secondary",heading:O.text,icon:O.icon}):null,H?a(le,{children:Array.from(Array(w==null?void 0:w.pageSize).keys()).map(k=>a(Je,{testId:"orderSkeletonLoader",withCard:!1},k))}):a(le,{children:b.length?a(le,{children:b.map((k,x)=>a(nn,{placeholderImage:N,routeTracking:y,routeOrderProduct:L,routeReturnDetails:f,minifiedView:t,item:k,withThumbnails:n,slots:m,children:m!=null&&m.OrdersListAction?a(Te,{"data-testid":`ordersListActionSlot_${x}`,name:"OrdersListAction",slot:m==null?void 0:m.OrdersListAction,context:{orderHistoryListItem:k}}):a(Et,{minifiedView:t,orderNumber:k.number,orderToken:k.token,routeOrderDetails:i})},x))}):a(je,{isEmpty:!b.length,typeList:"orders",minifiedView:t})}),!t&&(w==null?void 0:w.totalPages)>1?a(Vt,{totalPages:w==null?void 0:w.totalPages,currentPage:I,onChange:E}):null,t?a(Et,{minifiedView:t,routeOrdersList:h}):null]})]})};export{Ia as A,xe as AddressForm,Je as C,Ta as E,ka as O,Oa as P,Ma as S,Ea as a,Sa as b,Na as c,Ba as d,xe as default,Xn as e,Pa as f,Tt as g,kn as n,da as u};
|
|
3
|
+
import{classes as q,Slot as Te}from"@dropins/tools/lib.js";import{useText as Q}from"@dropins/tools/i18n.js";import{jsx as a,Fragment as le,jsxs as P}from"@dropins/tools/preact-jsx-runtime.js";import{Field as Ie,TextArea as tr,Checkbox as ft,InputDate as rr,Picker as $t,Input as xt,Skeleton as He,SkeletonRow as se,Card as _e,Button as ie,Tag as $e,Icon as Ge,Modal as Ft,ProgressSpinner as Zt,IllustratedMessage as Fe,Image as yt,Price as nr,ContentGrid as ar,Header as ke,LiveRegion as Ht,InLineAlert as Pe,InputPassword as Ue,ToggleButton as sr,Pagination as Vt,Table as or}from"@dropins/tools/components.js";import*as $ from"@dropins/tools/preact-compat.js";import{memo as ht,useMemo as qe,forwardRef as dr,useImperativeHandle as cr,useId as gt,useCallback as nt}from"@dropins/tools/preact-compat.js";import{useRef as Ze,useState as S,useCallback as x,useEffect as oe,useMemo as Ne}from"@dropins/tools/preact-hooks.js";import{events as at}from"@dropins/tools/event-bus.js";import{c as Rt,a as zt,updateCustomerAddress as st,getCustomerCompanyContext as lr,g as Xe,getCustomerRolePermissions as ir,b as ur,getCompanyAddressBook as fr,getAttributesForm as ot,getCustomerAddress as hr,deleteCompanyAddress as gr,removeCustomerAddress as mr,getCountries as pr,setDefaultCompanyAddress as Qe,updateCompanyAddress as Ar,createCompanyAddress as yr,createCustomerAddress as br,getStoreConfig as Ut,updateCustomerPassword as Lr,getCustomerPaymentTokens as Cr,deletePaymentToken as vr,getOrderHistoryList as _r,O as Br,d as wr}from"../api.js";import{Fragment as bt}from"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";const Er=e=>e.reduce((n,t)=>({...n,[t.name]:t.value}),{}),Nr=e=>/^\d+$/.test(e),Tr=e=>/^[a-zA-Z0-9\s]+$/.test(e),Sr=e=>/^[a-zA-Z0-9]+$/.test(e),Ir=e=>/^[a-zA-Z]+$/.test(e),Pr=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),Mr=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),Or=(e,n,t)=>{const r=new Date(e).getTime()/1e3;return!(isNaN(r)||r<0||n!==void 0&&r<n||t!==void 0&&r>t)},Lt=e=>!e||isNaN(Number(e))?"":new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],kr=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),$r=(e,n,t)=>{const r=e.length;return r>=n&&r<=t},et=(e,n,t,r)=>{var N,C;const{requiredFieldError:s,lengthTextError:o,numericError:l,alphaNumWithSpacesError:d,alphaNumericError:u,alphaError:h,emailError:i,dateError:f,urlError:y,dateLengthError:b}=t,p=n==null?void 0:n.customUpperCode,m={[p]:""};if(r[p]&&delete r[p],n!=null&&n.required&&(!e||e==="false"))return{[p]:s};if(!(n!=null&&n.required)&&!e||!((N=n==null?void 0:n.validateRules)!=null&&N.length))return m;const _=Er(n==null?void 0:n.validateRules),g=_.MIN_TEXT_LENGTH??1,w=_.MAX_TEXT_LENGTH??255,v=_.DATE_RANGE_MIN,I=_.DATE_RANGE_MAX;if(!$r(e,+g,+w)&&!(v||I))return{[p]:o.replace("{min}",g).replace("{max}",w)};if(!Or(e,+v,+I)&&(v||I))return{[p]:b.replace("{min}",Lt(v)).replace("{max}",Lt(I))};const c={numeric:{validate:Nr,error:l},"alphanum-with-spaces":{validate:Tr,error:d},alphanumeric:{validate:Sr,error:u},alpha:{validate:Ir,error:h},email:{validate:Pr,error:i},date:{validate:Mr,error:f},url:{validate:kr,error:y}}[_.INPUT_VALIDATION];return c&&!c.validate(e)&&!((C=r[p])!=null&&C.length)?{[p]:c.error}:m},Dt=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},xr=["true","false","yes","on","off"],Fr={firstName:"",lastName:"",nickname:"",city:"",company:"",countryCode:"",addressType:"",addressTypeShipping:"",addressTypeBilling:"",isDefault:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:"",uid:""},Zr=e=>{const n={},t={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const s=e[r],o=r.match(/^(.*)Multiline_(\d+)$/);if(o){const l=o[1],d=parseInt(o[2],10);t[l]||(t[l]=[]),t[l].push({index:d,value:s})}else Object.keys(e).filter(d=>d.startsWith(`${r}Multiline_`)).length>0?t[r]=[{index:1,value:s}]:n[r]=s}for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const s=t[r];s.sort((o,l)=>o.index-l.index),n[r]=s.map(o=>o.value)}return n},Hr=e=>{const n={},t=[];for(const r in e){const s=xr.includes(e[r])?Dt(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Fr,r)?n[r]=s:t.push({code:zt(r),value:s}))}return{...n,customAttributes:t}},We=(e,n=!1)=>{const t=Rt(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=Hr(Zr(t));if(!n)return r;const[s,o]=r.region?r.region.split(","):[];return{...r,region:{regionCode:s,...o&&{regionId:+o}}}},De=e=>{if(!e.current)return{};const n=e.current.elements;return Array.from(n).reduce((r,s)=>(s.name&&(r[s.name]=s.type==="checkbox"?s.checked:s.value),r),{})},Ct=(e,n)=>Object.keys(e).length?Object.keys(e).every(r=>r in n&&n[r]!==""):!1,Ke=e=>typeof e=="function",Vr=e=>e.reduce((n,{customUpperCode:t,required:r,defaultValue:s})=>(r&&t&&(n.initialData[t]=s||"",n.errorList[t]=""),n),{initialData:{},errorList:{}}),vt=e=>Object.keys(e).length>0,Rr=({fieldsConfig:e,onSubmit:n,onChange:t,setInputChange:r,formName:s})=>{const o=Q({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),l=Ze(null),[d,u]=S({}),[h,i]=S({}),[f,y]=S({}),[b,p]=S(!0),[m,_]=S(!1),[g,w]=S(!1),[v,I]=S(!0),[V,c]=S(!1),N=x((L=!1)=>{let T=!0;const A={...h};let k=null;for(const[Z,G]of Object.entries(d)){const K=e==null?void 0:e.find(re=>re.customUpperCode.includes(Z)),de=et(G.toString(),K,o,A);de[Z]&&(Object.assign(A,de),T=!1),k||(k=Object.keys(A).find(re=>A[re])||null)}if(L||i(A),k&&l.current&&!L){const Z=l.current.elements.namedItem(k);Z==null||Z.focus()}return T},[h,e,d,o]),C=x((L,T,A,k,Z)=>{const G={...De(l),...Z||{},[T]:L,...T.includes("countryCode")?{region:""}:{}},K={data:We(G,!0),isDataValid:Ct(A,G)};c(K.isDataValid),N(!0),["selectedShippingAddress","selectedBillingAddress"].includes(s)&&sessionStorage.setItem(`${s}_addressData`,JSON.stringify(K)),t==null||t(K,{},k)},[N,s,t]);oe(()=>{if(e!=null&&e.length){const{initialData:L,errorList:T}=Vr(e);u(A=>({...L,...A})),i(T),y(T)}},[JSON.stringify(e)]),oe(()=>{if(g)return;const L=De(l),T=sessionStorage.getItem(`${s}_addressData`);if(vt(d)&&vt(f)){let A={};const k=Ct(f,d);T?A=JSON.parse(T).data:A=We(L,!0)??{},t==null||t({data:A,isDataValid:k},{},null),c(k),w(!0)}},[d,f]),oe(()=>{var Z;if(!v)return;const L=De(l),T=!!(L!=null&&L.countryCode),A=!!((Z=L==null?void 0:L.region)!=null&&Z.length);L&&T&&!A&&Ke(t)&&C(L==null?void 0:L.region,"region",f,null)},[v,b,e,l,t,C,f,m]);const O=x((L,T)=>{const{name:A,value:k,type:Z,checked:G}=L==null?void 0:L.target,K=Z==="checkbox"?G:k,de=Z==="checkbox"&&A==="addressTypeShipping"&&G?{addressTypeBilling:!1}:Z==="checkbox"&&A==="addressTypeBilling"&&G?{addressTypeShipping:!1}:{};u(J=>{const R={...J,...de,[A]:K};return A==="countryCode"&&(R.region="",p(!0),_(!1)),R}),r==null||r({...de,[A]:K}),w(!0);const re=e==null?void 0:e.find(J=>J.customUpperCode.includes(A)),ne=T?{...T}:{...h};if(re){const J=et(K.toString(),re,o,ne);J&&Object.assign(ne,J),i(ne)}C(K,A,f,L,de)},[r,e,h,o,C,f,b]),M=x(L=>{const{name:T}=L==null?void 0:L.target,A=e==null?void 0:e.find(k=>k.customUpperCode===T);T==="region"&&(A!=null&&A.options.length)&&I(!1),I(T==="countryCode")},[]),B=x((L,T)=>{const{name:A,value:k,type:Z,checked:G}=L==null?void 0:L.target,K=Z==="checkbox"?G:k,de=e==null?void 0:e.find(re=>re.customUpperCode===A);if(de){const re=T?{...T}:{...h},ne=et(K.toString(),de,o,re);ne&&Object.assign(re,ne),i(re)}},[h,e,o]),F=x(L=>{L.preventDefault();const T=N();n==null||n(L,T)},[N,n]);return{isDataValid:V,formData:d,errors:h,formRef:l,handleInputChange:O,onFocus:M,handleBlur:B,handleSubmit:F,handleValidationSubmit:N}};var we=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(we||{});const zr={firstname:"given-name",middlename:"additional-name",lastname:"family-name",email:"email"},Ur=e=>zr[e],Dr=ht(({loading:e,values:n,fields:t=[],errors:r,className:s="",onChange:o,onBlur:l,onFocus:d,slots:u,fieldIdPrefix:h})=>{const i=`${s}__field`,f=qe(()=>Object.fromEntries(t.flatMap(c=>[[`${c.code}.label`,`Account.AddressForm.fields.${c.code}.label`],[`${c.code}.placeholder`,`Account.AddressForm.fields.${c.code}.placeholder`]])),[t]),y=Q(f),b=c=>c.forceLabel?c.label:y[`${c.code}.label`]||c.label,p=c=>`${b(c)} ${c.required?"*":""}`,m=c=>y[`${c.code}.placeholder`]||c.label,_=(c,N)=>{if(!(u!=null&&u[`AddressFormInput_${c.code}`]))return;const C={inputName:c.customUpperCode,handleOnChange:o,handleOnBlur:l,handleOnFocus:d,errorMessage:N,errors:r,config:c};return a(Te,{"data-testid":`addressFormInput_${c.code}`,name:`AddressFormInput_${c.code}`,slot:u[`AddressFormInput_${c.code}`],context:C},c.id)},g=(c,N,C)=>{var M;const O=c.defaultValue??((M=c.options.find(B=>B.isDefault))==null?void 0:M.value)??N??c.defaultValue;return a(le,{children:_(c,C)??a(Ie,{error:C,className:q([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled,children:a($t,{"aria-label":b(c),"aria-required":c.required?"true":"false",id:h?`${h}_${c.code}`:c.code,required:c==null?void 0:c.required,name:c.customUpperCode,floatingLabel:p(c),placeholder:m(c),options:c.options,onBlur:l,onFocus:d,handleSelect:o,defaultValue:O,value:O,disabled:e||c.disabled})},c.id)})},w=(c,N,C)=>a(le,{children:_(c,C)??a(Ie,{error:C,className:q([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled,children:a(xt,{"aria-label":b(c),"aria-required":c.required?"true":"false",id:h?`${h}_${c.code}`:c.code,type:"text",name:c.customUpperCode,autoComplete:Ur(c.code),value:N??c.defaultValue,placeholder:m(c),floatingLabel:p(c),onBlur:l,onFocus:d,onChange:o,disabled:e||c.disabled})},c.id)}),v=(c,N,C)=>a(le,{children:_(c,C)??a(Ie,{error:C,className:q([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled,children:a(rr,{"aria-label":b(c),"aria-required":c.required?"true":"false",id:h?`${h}_${c.code}`:c.code,type:"text",name:c.customUpperCode,value:N||c.defaultValue,placeholder:m(c),floatingLabel:p(c),onBlur:l,onChange:o,disabled:e||c.disabled})},c.id)}),I=(c,N,C)=>a(le,{children:_(c,C)??a(Ie,{error:C,className:q([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled||(c==null?void 0:c.isHidden),children:a(ft,{"aria-label":b(c),"aria-required":c.required?"true":"false","aria-hidden":c.isHidden,tabindex:c!=null&&c.isHidden?-1:0,id:h?`${h}_${c.code}`:c.code,name:c.customUpperCode,checked:typeof N=="boolean"?N:!!c.defaultValue,placeholder:m(c),label:p(c),onBlur:l,onChange:o,disabled:e||c.disabled||(c==null?void 0:c.isHidden)})},c.id)}),V=(c,N,C)=>a(le,{children:_(c,C)??a(Ie,{error:C,className:q([i,`${i}--${c.id}`,[`${i}--${c.id}-hidden`,c.isHidden],c.className]),"data-testid":`${s}--${c.id}`,disabled:e||c.disabled,children:a(tr,{"aria-label":b(c),"aria-required":c.required?"true":"false",id:h?`${h}_${c.code}`:c.code,type:"text",name:c.customUpperCode,value:N??c.defaultValue,label:p(c),onBlur:l,onChange:o,disabled:e||c.disabled})},c.id)});return t.length?a(le,{children:t.map(c=>{const N=r==null?void 0:r[c.customUpperCode],C=n==null?void 0:n[c.customUpperCode];switch(c.fieldType){case we.TEXT:return c.options.length?g(c,C,N):w(c,C,N);case we.MULTILINE:return w(c,C,N);case we.SELECT:return g(c,C,N);case we.DATE:return v(c,C,N);case we.BOOLEAN:return I(c,C,N);case we.TEXTAREA:return V(c,C,N);default:return null}})}):null}),Je=({testId:e,withCard:n=!0})=>{const t=P(He,{"data-testid":e||"skeletonLoader",children:[a(se,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(se,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(se,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return n?t:a(_e,{variant:"secondary",className:q(["account-account-loaders","account-account-loaders--card-loader"]),children:t})},Gr=()=>P(He,{"data-testid":"addressFormLoader",children:[a(se,{variant:"heading",size:"medium"}),a(se,{variant:"empty",size:"medium"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large",fullWidth:!0}),a(se,{size:"large",fullWidth:!0,lines:3}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large"}),a(se,{size:"large",fullWidth:!0})]}),qr=()=>a(He,{"data-testid":"addressActionsLoader",className:"account-account-loaders--address-actions-loader",children:a(se,{size:"medium"})}),Gt=ht(dr(({setInputChange:e,showFormLoader:n,slots:t,name:r,loading:s,children:o,className:l="defaultForm",fieldsConfig:d,onSubmit:u,onChange:h,forwardFormRef:i,regionOptions:f,showSaveCheckBox:y,handleSaveCheckBoxAddress:b,saveCheckBoxAddress:p,fieldIdPrefix:m})=>{const _=Q({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:g,formData:w,errors:v,formRef:I,handleInputChange:V,handleBlur:c,handleSubmit:N,handleValidationSubmit:C,onFocus:O}=Rr({fieldsConfig:d,onSubmit:u,onChange:h,setInputChange:e,formName:r});return cr(i,()=>{const M=De(I);return{handleValidationSubmit:C,requestSubmit:()=>{var B;(B=I.current)==null||B.requestSubmit()},formData:We(M,!0),isDataValid:g}}),n||!(d!=null&&d.length)?a(Gr,{}):P("form",{className:q(["account-form",l]),onSubmit:N,name:r,ref:I,children:[a(Dr,{className:l,loading:s,fields:d,onChange:V,onBlur:c,errors:v,values:w,onFocus:O,slots:t,fieldIdPrefix:m}),t!=null&&t.AddressFormInputs?a(Te,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:t.AddressFormInputs,context:{formActions:{handleChange:V}}}):null,y?a("div",{className:"account-address-form--saveAddressBook",children:a(ft,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:_.saveAddressBook,checked:p,onChange:M=>{V(M),b==null||b(M)}})}):null,o]})})),_t=(e,n,t={},r="editButton")=>{const s=r==="removeButton",o={shippingAndBilling:{edit:t.editAddressAriaLabelShippingAndBilling,remove:t.removeAddressAriaLabelShippingAndBilling},shipping:{edit:t.editAddressAriaLabelShipping,remove:t.removeAddressAriaLabelShipping},billing:{edit:t.editAddressAriaLabelBilling,remove:t.removeAddressAriaLabelBilling},default:{edit:t.editAddressAriaLabelDefault,remove:t.removeAddressAriaLabelDefault}};let l="default";return e&&n?l="shippingAndBilling":e?l="shipping":n&&(l="billing"),s?o[l].remove:o[l].edit},dt=({slots:e,selectable:n,selectShipping:t,selectBilling:r,variant:s="secondary",minifiedView:o,keysSortOrder:l,addressData:d,loading:u,setAddressId:h,handleRenderModal:i,handleRenderForm:f,isB2BFlow:y,permissions:b})=>{const p=gt(),m=o?"minifiedView":"fullSizeView",_=Q({actionRemove:`Account.${m}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${m}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${m}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${m}.Addresses.addressCard.cardLabelBilling`,cardLabelDefaultShipping:`Account.${m}.Addresses.addressCard.cardLabelDefaultShipping`,cardLabelDefaultBilling:`Account.${m}.Addresses.addressCard.cardLabelDefaultBilling`,defaultLabelText:`Account.${m}.Addresses.addressCard.defaultLabelText`,editAddressAriaLabelDefault:`Account.${m}.Addresses.addressCard.ariaLabel.editButton.default`,editAddressAriaLabelShipping:`Account.${m}.Addresses.addressCard.ariaLabel.editButton.shipping`,editAddressAriaLabelBilling:`Account.${m}.Addresses.addressCard.ariaLabel.editButton.billing`,editAddressAriaLabelShippingAndBilling:`Account.${m}.Addresses.addressCard.ariaLabel.editButton.shippingAndBilling`,removeAddressAriaLabelDefault:`Account.${m}.Addresses.addressCard.ariaLabel.removeButton.default`,removeAddressAriaLabelShipping:`Account.${m}.Addresses.addressCard.ariaLabel.removeButton.shipping`,removeAddressAriaLabelBilling:`Account.${m}.Addresses.addressCard.ariaLabel.removeButton.billing`,removeAddressAriaLabelShippingAndBilling:`Account.${m}.Addresses.addressCard.ariaLabel.removeButton.shippingAndBilling`}),g=_.cardLabelBilling.toLocaleUpperCase(),w=_.cardLabelShipping.toLocaleUpperCase(),v=_.defaultLabelText.toLocaleUpperCase(),I=y?_.cardLabelDefaultShipping.toLocaleUpperCase():w,V=y?_.cardLabelDefaultBilling.toLocaleUpperCase():g,c=qe(()=>{const T={shippingLabel:w,billingLabel:g,hideShipping:!1,hideBilling:!1};return n?t&&!r?{shippingLabel:v,billingLabel:v,hideShipping:!1,hideBilling:!0}:r&&!t?{shippingLabel:v,billingLabel:v,hideShipping:!0,hideBilling:!1}:T:T},[g,v,w,r,t,n]),N=nt(()=>{h==null||h(d==null?void 0:d.id),i==null||i()},[i,d==null?void 0:d.id,h]),C=nt(()=>{h==null||h(d==null?void 0:d.id),f==null||f()},[f,d==null?void 0:d.id,h]),O=qe(()=>{if(!l||!d)return[];const{region:T,...A}=d,k={...A,...T||{}},Z=l.filter(({name:G})=>k[G]).map(G=>({name:G.name,orderNumber:G.orderNumber,value:k[G.name],label:G.label}));return k.nickname&&!Z.some(({name:G})=>G==="nickname")&&Z.push({name:"nickname",orderNumber:Number.MAX_SAFE_INTEGER,value:k.nickname,label:null}),Z},[d,l]),{shippingLabel:M,billingLabel:B,hideShipping:F,hideBilling:L}=c;return a(_e,{variant:s,className:"account-address-card","data-testid":"addressCard",children:u?a(Je,{}):P(le,{children:[P("div",{className:"account-address-card__action",children:[i&&(!y||b!=null&&b.canDeleteAddress)?a(ie,{type:"button",variant:"tertiary",onClick:N,"data-testid":"removeButton","aria-label":_t(d==null?void 0:d.defaultShipping,d==null?void 0:d.defaultBilling,_,"removeButton"),"aria-describedby":p,children:_.actionRemove}):null,f&&(!y||b!=null&&b.canEditAddress||b!=null&&b.canSetDefaultAddress)?a(ie,{type:"button",variant:"tertiary",onClick:C,className:"account-address-card__action--editbutton","data-testid":"editButton","aria-label":_t(d==null?void 0:d.defaultShipping,d==null?void 0:d.defaultBilling,_,"editButton"),"aria-describedby":p,children:_.actionEdit}):null]}),a("div",{className:"account-address-card__description",id:p,children:e!=null&&e.AddressCard?a(Te,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:O}}):a(le,{children:O.map((T,A)=>{const k=T.label?`${T.label}: ${T==null?void 0:T.value}`:T==null?void 0:T.value;return a("p",{"data-testid":`${T.name}_${A}`,children:k},A)})})}),(d!=null&&d.defaultShipping||d!=null&&d.defaultBilling)&&!n?P("div",{className:"account-address-card__labels",children:[d!=null&&d.defaultShipping?a($e,{label:I}):null,d!=null&&d.defaultBilling?a($e,{label:V}):null]}):null,n?P("div",{className:"account-address-card__labels",children:[!F&&(d!=null&&d.defaultShipping)?a($e,{label:M}):null,!L&&(d!=null&&d.defaultBilling)?a($e,{label:B}):null]}):null]})})},Wr=e=>$.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},$.createElement("g",{id:"Large"},$.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),$.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},$.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),$.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),jr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"currentColor"})),Kr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.00718 5H22.1507C22.7047 5 23.1579 5.45323 23.1579 6.00718V7.51794C23.1579 7.51794 1.01007 7.58844 1 7.55823V6.00718C1 5.45323 1.45323 5 2.00718 5Z",stroke:"currentColor",strokeWidth:1}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M23.1579 9.78409V18.3451C23.1579 18.899 22.7047 19.3523 22.1507 19.3523H2.00718C1.45323 19.3523 1 18.899 1 18.3451V9.78409H23.1579Z",stroke:"currentColor",strokeWidth:1}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.6192 17.5897C18.4535 17.5897 19.1299 16.9133 19.1299 16.0789C19.1299 15.2446 18.4535 14.5682 17.6192 14.5682C16.7848 14.5682 16.1084 15.2446 16.1084 16.0789C16.1084 16.9133 16.7848 17.5897 17.6192 17.5897Z",stroke:"currentColor",strokeWidth:1}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8848 17.5897C20.7192 17.5897 21.3956 16.9133 21.3956 16.0789C21.3956 15.2446 20.7192 14.5682 19.8848 14.5682C19.0504 14.5682 18.374 15.2446 18.374 16.0789C18.374 16.9133 19.0504 17.5897 19.8848 17.5897Z",stroke:"currentColor",strokeWidth:1})),Jr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),ct=e=>$.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},$.createElement("g",{id:"Large"},$.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),$.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},$.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),Yr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),Xr=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"currentColor"})),Qr=e=>$.createElement("svg",{id:"Icon_Search_Base","data-name":"Icon \\u2013 Search \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24",...e},$.createElement("g",{id:"Large"},$.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),$.createElement("g",{id:"Search_icon","data-name":"Search icon",transform:"translate(3.75 3.75)"},$.createElement("circle",{vectorEffect:"non-scaling-stroke",id:"Ellipse_186","data-name":"Ellipse 186",cx:6,cy:6,r:6,fill:"none",stroke:"currentColor"}),$.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_556","data-name":"Line 556",x2:6,y2:6,transform:"translate(10.5 10.5)",fill:"none",stroke:"currentColor"})))),en=e=>$.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("g",{clipPath:"url(#clip0_841_1324)"},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),$.createElement("defs",null,$.createElement("clipPath",{id:"clip0_841_1324"},$.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)",strokeWidth:1})))),lt=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Bt=({selectable:e,className:n,addNewAddress:t,minifiedView:r,routeAddressesPage:s,isB2BFlow:o,permissions:l,loading:d})=>{const u=r?"minifiedView":"fullSizeView",h=Q({viewAllAddressesButton:`Account.${u}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${u}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${u}.Addresses.differentAddressButton`,noPermissionCreateAddresses:"Account.AddressForm.notifications.noPermissionCreateAddresses"}),i=e?"span":"button",f=e?{}:{AriaRole:"button",type:"button"},y=r&&!t?h.viewAllAddressesButton:h.addNewAddressButton,b=e?h.differentAddressButton:y;return d?a("div",{className:q(["account-actions-address","account-actions-address--loading",n]),"data-testid":"addressActionsLoaderWrapper",children:a(qr,{})}):o&&!(l!=null&&l.canCreateAddress)?a("div",{className:q(["account-actions-address","account-actions-address--no-permission",n]),"data-testid":"noPermissionMessage",children:a("span",{className:"account-actions-address__title",children:h.noPermissionCreateAddresses})}):P(i,{...f,className:q(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],n]),"data-testid":"showRouteFullAddress",onClick:s,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:b}),a(Ge,{source:r&&!t?ct:Wr,size:"32"})]})},tn=({minifiedView:e,keysSortOrder:n,addressData:t,open:r,submitLoading:s,onRemoveAddress:o,closeModal:l,isB2BFlow:d,permissions:u})=>{const h=e?"minifiedView":"fullSizeView",i=Q({title:`Account.${h}.Addresses.removeAddressModal.title`,description:`Account.${h}.Addresses.removeAddressModal.description`,actionCancel:`Account.${h}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${h}.Addresses.removeAddressModal.actionConfirm`});if(!r)return null;const f=s||d&&!(u!=null&&u.canDeleteAddress);return a(Ft,{className:"account-address-modal--overlay",title:a("h3",{children:i.title}),size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:l,children:P("div",{className:"account-address-modal",children:[s?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Zt,{stroke:"4",size:"large"})}):null,a("p",{children:i.description}),t?a(dt,{minifiedView:e,addressData:t,keysSortOrder:n}):null,P("div",{className:"account-address-modal__buttons",children:[a(ie,{type:"button",onClick:l,variant:"secondary",disabled:s,children:i.actionCancel}),a(ie,{disabled:f,onClick:o,children:i.actionConfirm})]})]})})},je=({typeList:e,isEmpty:n,minifiedView:t,className:r})=>{const s=t?"minifiedView":"fullSizeView",o=Q({addressesMessage:`Account.${s}.EmptyList.Addresses.message`,ordersListMessage:`Account.${s}.EmptyList.OrdersList.message`,paymentsMessage:`Account.${s}.EmptyList.Payments.message`}),l=qe(()=>{switch(e){case"address":return{icon:jr,text:a("p",{children:o.addressesMessage})};case"orders":return{icon:Xr,text:a("p",{children:o.ordersListMessage})};case"payments":return{icon:Kr,text:a("p",{children:o.paymentsMessage})};default:return{icon:"",text:""}}},[e,o]);return!n||!e||!l.text?null:a(Fe,{className:q(["account-empty-list",t?"account-empty-list--minified":"",r]),message:l.text,icon:a(Ge,{source:l.icon}),"data-testid":"emptyList"})},wt={size:"32",stroke:"2"},Et=({minifiedView:e,orderNumber:n,orderToken:t,routeOrdersList:r,routeOrderDetails:s})=>{const o=e?"minifiedView":"fullSizeView",l=Q({viewAllOrdersButton:`Account.${o}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${o}.OrdersList.ariaLabelLink`});return r?a("a",{className:q(["account-orders-list-action",["account-orders-list-action--minifiedView",e]]),"data-testid":"ordersListActionButtonMinifiedView",href:r(),children:a(_e,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:P("div",{className:"account-orders-list-action__card-wrapper",children:[a("p",{children:l.viewAllOrdersButton}),a(Ge,{source:ct,...wt})]})})}):a("a",{"aria-label":`${l.ariaLabelLink} ${n??t}`,href:Ke(s)?s(n,t):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:a(Ge,{source:ct,...wt})})},rn=()=>{const[e,n]=S(window.innerWidth<768);return oe(()=>{const t=()=>{n(window.innerWidth<768)};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),e},nn=({placeholderImage:e,minifiedView:n,item:t,withThumbnails:r,children:s,slots:o,routeTracking:l,routeOrderProduct:d,routeReturnDetails:u,...h})=>{var m,_,g,w,v,I,V,c,N,C,O,M;const i=n?"minifiedView":"fullSizeView",f=Q({orderNumber:`Account.${i}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${i}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${i}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${i}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${i}.OrdersList.OrdersListCard.orderDate`,placedByAdministrator:`Account.${i}.OrdersList.OrdersListCard.placedByAdministrator`}),y=rn(),b=Ke(d),p=Ne(()=>((t==null?void 0:t.items)??[]).map((B,F)=>{var T,A;const L={title:(B==null?void 0:B.productName)??"",src:((A=(T=B==null?void 0:B.product)==null?void 0:T.smallImage)==null?void 0:A.url)||e,alt:(B==null?void 0:B.productName)??"",width:65,height:65,loading:"eager"};return a(Te,{name:"OrderItemImage",slot:o==null?void 0:o.OrderItemImage,context:{data:B,defaultImageProps:L},children:b?a("a",{href:(d==null?void 0:d(B))??"",target:"_blank",rel:"noreferrer",children:a(yt,{...L})}):a(yt,{...L})},`${F}_${B.id}`)}),[b,t.items,e,d,o==null?void 0:o.OrderItemImage]);return P(_e,{variant:"secondary",...h,className:q(["account-orders-list-card",["account-orders-list-card--full",((m=t==null?void 0:t.items)==null?void 0:m.length)>6]]),children:[a("div",{className:"account-orders-list-card__content",children:o!=null&&o.OrdersListCard?a(Te,{"data-testid":`ordersListCard${t.id}`,name:"OrdersListCard",slot:o==null?void 0:o.OrdersListCard,context:{orderHistoryListItem:t}}):P(le,{children:[a("div",{children:t==null?void 0:t.status}),(t==null?void 0:t.adminAssistedOrder)>0&&a("div",{children:f.placedByAdministrator}),o!=null&&o.OrdersListOrderTime?a(Te,{"data-testid":`ordersListOrderTime${t.id}`,name:"OrdersListOrderTime",slot:o==null?void 0:o.OrdersListOrderTime,context:{deliveryDateText:f.deliveryDateText,orderDate:t==null?void 0:t.orderDate,orderTime:t==null?void 0:t.orderTime}}):P("p",{children:[f.deliveryDateText," ",t==null?void 0:t.orderDate]}),P("p",{children:[f.orderNumber," ",t.number]}),(_=t==null?void 0:t.shipments)==null?void 0:_.map(B=>{var F;return(F=B==null?void 0:B.tracking)==null?void 0:F.map(L=>{const T=l==null?void 0:l(L);return P("p",{"data-testid":L.number,children:[a("span",{children:`${f.carrier} ${L.carrier.toLocaleUpperCase()} `}),T?a("a",{href:T,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:L.number}):a("span",{className:"account-orders-list-card__content--track_number",children:L.number})]},B.id)})}),t!=null&&t.returns&&((g=t.returns)!=null&&g.length)?P("p",{"data-testid":t.number,children:[P("span",{children:[f.returnsText," "]}),(w=t==null?void 0:t.returns)==null?void 0:w.map(B=>a("span",{"data-testid":B.number,children:P("a",{href:(u==null?void 0:u({orderNumber:t.number,orderToken:t.token,returnNumber:B.number}))??"#",className:"account-orders-list-card__content--return_number",children:[B.number," "]})},B.uid))]},t.id):null,a("p",{children:a(nr,{amount:((I=(v=t==null?void 0:t.total)==null?void 0:v.grandTotal)==null?void 0:I.value)??0,currency:(c=(V=t==null?void 0:t.total)==null?void 0:V.grandTotal)==null?void 0:c.currency,weight:"normal",size:"medium"})}),P("p",{"data-testid":"itemsAmount",children:[(N=t==null?void 0:t.items)!=null&&N.length?(C=t==null?void 0:t.items)==null?void 0:C.reduce((B,F)=>{const L=(F==null?void 0:F.quantityOrdered)||0;return B+L},0):0," ",f.itemsAmount]}),(O=t==null?void 0:t.items)!=null&&O.length?a("ul",{className:"account-orders-list-card__product-list",children:t.items.map((B,F)=>{if(F>=0&&F<10)return P("li",{className:"account-orders-list-card__content--product-name",children:[P("span",{className:"account-orders-list-card__content--quantity",children:[(B==null?void 0:B.quantityOrdered)>1?B==null?void 0:B.quantityOrdered:null," "]}),B==null?void 0:B.productName.replaceAll("-"," ")]},`${F}_${B.id}`);if(F===11)return a("li",{children:"..."},"ellipsis")})}):null]})}),r&&((M=t==null?void 0:t.items)!=null&&M.length)?a(ar,{maxColumns:y?3:9,emptyGridContent:a(le,{}),className:q(["account-orders-list-card__images",["account-orders-list-card__images-3",y]]),"data-testid":"ordersListCardImages",children:p}):null,a("div",{className:"account-orders-list-card__actions",children:s})]})},an=(e,n)=>e||(n?"checkout":"addressBook"),sn=e=>e==="addressBook",on=e=>e==="checkout",dn=(e,n)=>!!e&&!!n,cn=e=>!!(e!=null&&e.canAccessAddressBook)&&!!(e!=null&&e.canViewAddress),ln=({isB2BCandidate:e,isCompanyAddressBookEnabled:n,enforceB2BPermissions:t,permissions:r,hasB2BContainerAccess:s})=>!!e&&!!n&&t&&!(r!=null&&r.loading)&&!s,un=({isB2BCandidate:e,isCompanyAddressBookEnabled:n,isB2BWithoutViewAccess:t})=>!!e&&(n||t),fn=({isCheckoutContext:e,isB2BFlow:n,selectable:t,isCustomShippingAddressAllowed:r,selectShipping:s,selectBilling:o})=>e&&!!n&&!!t&&(!!o&&!s||!r),hn=({b2bEnabled:e,customerTypeLoading:n})=>!!e&&n,gn=({isB2BCandidate:e,enforceB2BPermissions:n,permissionsLoading:t})=>e&&n&&!!t,mn=e=>e,pn=({enforceB2BPermissions:e,hasB2BContainerAccess:n})=>e&&!n,An=async(e,n)=>{if(n.length===1){const l=n[0],u=Object.values(l.region).every(i=>!!i)?{}:{region:{...l.region,regionId:0}};return!!await st({addressId:Number(l==null?void 0:l.id),defaultShipping:!1,defaultBilling:!1,...u})}const t=n.filter(l=>l.id!==e&&(l.defaultBilling||l.defaultShipping)||l.id!==e),r=n[n.length-1],s=t[0]||((r==null?void 0:r.id)!==e?r:null);return!s||!s.id?!1:!!await st({addressId:+s.id,defaultShipping:!0,defaultBilling:!0})},yn=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing","fax","prefix","suffix","middlename"],Ba=["email","firstname","lastname","middlename","gender","dob","prefix","suffix","fax"],qt=(e,n,t)=>{if(n&&t||!n&&!t)return e;const r=e.slice();return n?r.sort((s,o)=>Number(o.defaultShipping)-Number(s.defaultShipping)):r.sort((s,o)=>Number(o.defaultBilling)-Number(s.defaultBilling))};var Oe=(e=>(e.SHIPPING="SHIPPING",e.BILLING="BILLING",e))(Oe||{});const bn=e=>{if((e==null?void 0:e.addressType)===Oe.SHIPPING||(e==null?void 0:e.addressType)===Oe.BILLING)return e.addressType;const n=!!(e!=null&&e.defaultShipping),t=!!(e!=null&&e.defaultBilling);if(n!==t)return n?Oe.SHIPPING:Oe.BILLING},Ln=({addresses:e,isCheckoutContext:n,selectable:t,selectShipping:r,selectBilling:s})=>{if(!n||!t)return e;const o=!!(r&&!s);if(!o&&!!!(s&&!r))return e;const d=o?Oe.SHIPPING:Oe.BILLING;return e.filter(u=>bn(u)===d)},Cn=(e=!0)=>{const[n,t]=S(e),[r,s]=S(!1);return oe(()=>{if(!e){s(!1),t(!1);return}let o=!0;return t(!0),lr().then(l=>{o&&s(l)}).catch(l=>{console.error("[Account][useCustomerType] Failed to resolve company context",l),o&&s(!1)}).finally(()=>{o&&t(!1)}),()=>{o=!1}},[e]),{isB2BCustomer:r,loading:n}},vn=(e=!0)=>{const[n,t]=S(e),[r,s]=S(Xe());return oe(()=>{if(!e){s(Xe()),t(!1);return}let o=!0;return t(!0),ir().then(l=>{o&&s(l)}).catch(l=>{console.error("[Account][useCompanyAddressPermissions] Failed to resolve role permissions",l),o&&s(Xe())}).finally(()=>{o&&t(!1)}),()=>{o=!1}},[e]),{...r,loading:n}},it=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(it),_n=e=>{const n=e==null?void 0:e.region;if(!n||typeof n!="object")return e;const t={...n},r=t.regionId;if(r===""||r===null||r===void 0)delete t.regionId;else if(typeof r=="string"){const s=r.trim();!s||!/^\d+$/.test(s)?delete t.regionId:t.regionId=Number(s)}else typeof r=="number"&&!Number.isFinite(r)&&delete t.regionId;return{...e,region:t}},Nt=({item:e,isCheckoutContext:n,selectable:t,isB2BFlow:r})=>{const s=We(e);if(n&&t&&r){const o={...s};o.id&&(o.companyAddressId=o.id),delete o.id;const l=_n(o);return{selectedItem:e,data:l}}return{selectedItem:e,data:s}},Bn=({b2bEnabled:e,selectShipping:n,selectBilling:t,selectable:r,contextMode:s,defaultSelectAddressId:o,onAddressData:l,minifiedView:d,routeAddressesPage:u,onSuccess:h})=>{const{isB2BCustomer:i,loading:f}=Cn(!!e),y=vn(!!e),b=dn(e,i),p=an(s,r),m=sn(p),_=on(p),[g,w]=S(""),[v,I]=S(!1),[V,c]=S(!1),[N,C]=S(!1),[O,M]=S(!1),[B,F]=S(!1),[L,T]=S(""),[A,k]=S([]),[Z,G]=S([]),[K,de]=S(!1),[re,ne]=S(!0),J=cn(y),R=ln({isB2BCandidate:b,isCompanyAddressBookEnabled:K,enforceB2BPermissions:m,permissions:y,hasB2BContainerAccess:J}),ce=un({isB2BCandidate:b,isCompanyAddressBookEnabled:K,isB2BWithoutViewAccess:R}),ge=fn({isCheckoutContext:_,isB2BFlow:ce,selectable:r,isCustomShippingAddressAllowed:re,selectShipping:n,selectBilling:t}),Be=x(Y=>{if(!Y)return;const E=Y.map(({name:z,orderNumber:U,label:X})=>({name:ur(z),orderNumber:U,label:yn.includes(z)?null:X}));G(E)},[]),Ae=x(async()=>{var z;const Y=hn({b2bEnabled:e,customerTypeLoading:f}),E=gn({isB2BCandidate:b,enforceB2BPermissions:m,permissionsLoading:y==null?void 0:y.loading});if(Y||E){C(!0);return}C(!0);try{if(mn(b))try{const H=await fr(),j=!!(H!=null&&H.addressBookEnabled),ee=!!(H!=null&&H.addressBookCustomShippingAddressEnabled);if(de(j),ne(ee),j){if(pn({enforceB2BPermissions:m,hasB2BContainerAccess:J})){k([]);return}const D=await ot("shortRequest");Be(D);const ue=((z=H==null?void 0:H.addresses)==null?void 0:z.items)??[],fe=Ln({addresses:ue,isCheckoutContext:_,selectable:r,selectShipping:n,selectBilling:t});if(d){const W=fe.filter(ae=>!!ae.defaultShipping||!!ae.defaultBilling),te=W.length?W:fe.slice(-1);k(te)}else k(fe);return}}catch{de(!1),ne(!0)}de(!1),ne(!0);const[U,X]=await Promise.all([ot("shortRequest"),hr()]);if(Be(U),X)if(d){const H=X.filter(ee=>!!ee.defaultShipping||!!ee.defaultBilling),j=H.length?H:X.slice(-1);k(j)}else k(X)}catch{}finally{C(!1)}},[e,f,d,b,_,r,n,t,m,J,y==null?void 0:y.loading,Be]);oe(()=>{Ae()},[Ae]),oe(()=>{var j;const Y=()=>{w(""),F(!1),l==null||l({data:{},isDataValid:!1})};if(!A.length){ge&&Y();return}if(o===0){if(ge){Y();return}F(!0),w("0");return}const E=A.find(ee=>{var D;return typeof o=="string"?ee.uid===o||((D=ee.id)==null?void 0:D.toString())===o:+ee.id===o})||qt(A,n,t)[0],{selectedItem:z,data:U}=Nt({item:E,isCheckoutContext:_,selectable:r,isB2BFlow:ce}),X={data:U,isDataValid:!it(z)},H=((j=E==null?void 0:E.id)==null?void 0:j.toString())||(E==null?void 0:E.uid)||"";w(H),l==null||l(X)},[A,o,l,t,n,ge,_,r,ce]);const ve=x(Y=>{T(Y),F(!1)},[]),ye=x((Y,E)=>{const z=(Y==null?void 0:Y.target).value;if(ge&&z==="0")return;const U=(Y==null?void 0:Y.target).nextSibling;w(z);const{data:X}=Nt({item:E,isCheckoutContext:_,selectable:r,isB2BFlow:ce}),H={data:X,isDataValid:!it(X)};l==null||l(H),F(z==="0"),U&&(U.focus(),window.scrollBy(0,100))},[l,ge,_,r,ce]),Me=x(()=>{c(!0)},[]),me=x(()=>{T(""),c(!1),I(!1)},[]),pe=x(()=>{I(!0)},[]),Ee=x(async()=>{M(!0);try{if(ce){if(!(y!=null&&y.canDeleteAddress))return;await gr(L)}else await An(L,A),await mr(+L);me(),await Ae()}catch{}finally{M(!1)}},[A,L,me,Ae,ce,y==null?void 0:y.canDeleteAddress]),Se=x(()=>{F(!1)},[]),be=x(()=>{if(ge)return;Ke(u)&&d&&!B?window.location.href=u():(F(!0),T(""))},[B,u,d,ge]),Le=x(async()=>{await Ae(),await(h==null?void 0:h())},[Ae,h]);return{keysSortOrder:Z,submitLoading:O,isModalRendered:v,isFormRendered:V,loading:N,addNewAddress:B,addressesList:A,addressId:L,handleRenderForm:Me,handleRenderModal:pe,removeAddress:Ee,onCloseBtnClick:me,setEditingAddressId:ve,closeNewAddressForm:Se,redirectToAddressesRoute:be,handleOnSuccess:Le,handleSelectAddressOption:ye,selectedAddressOption:g,permissions:y,isB2BFlow:ce,enforceB2BPermissions:m,isAddressSelectionLocked:ge}},wa=ht(({minifiedViewKey:e,hideActionFormButtons:n=!1,inputName:t,b2bEnabled:r,slots:s,title:o="",headerLevel:l,addressFormTitle:d="",defaultSelectAddressId:u="",showFormLoader:h=!1,onAddressData:i,forwardFormRef:f,className:y,showSaveCheckBox:b=!1,saveCheckBoxValue:p=!1,selectShipping:m=!1,selectBilling:_=!1,selectable:g=!1,withHeader:w=!0,minifiedView:v=!1,withActionsInMinifiedView:I=!1,withActionsInFullSizeView:V=!0,inputsDefaultValueSet:c,showShippingCheckBox:N=!0,showBillingCheckBox:C=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:M=!0,routeAddressesPage:B,onSubmit:F,onSuccess:L,onError:T,fieldIdPrefix:A,contextMode:k})=>{const Z=Q({containerTitle:`Account.${e}.Addresses.containerTitle`,differentAddressButton:`Account.${e}.Addresses.differentAddressButton`,differentAddressFormTitle:`Account.${e}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${e}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${e}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${e}.Addresses.newAddressFormTitle`,loading:"Account.Addresses.loading",loaded:"Account.Addresses.loaded"}),{keysSortOrder:G,submitLoading:K,isModalRendered:de,isFormRendered:re,loading:ne,addNewAddress:J,addressesList:R,addressId:ce,handleRenderForm:ge,handleRenderModal:Be,removeAddress:Ae,onCloseBtnClick:ve,handleOnSuccess:ye,setEditingAddressId:Me,closeNewAddressForm:me,redirectToAddressesRoute:pe,handleSelectAddressOption:Ee,selectedAddressOption:Se,isAddressSelectionLocked:be,permissions:Le,isB2BFlow:Y,enforceB2BPermissions:E}=Bn({b2bEnabled:r,defaultSelectAddressId:u,minifiedView:v,routeAddressesPage:B,onSuccess:L,onAddressData:i,selectShipping:m,selectBilling:_,selectable:g,contextMode:k}),z=E!==!1,U=!!Y&&z,X=o||Z.containerTitle,H=R.some(D=>!!D.defaultShipping),j=R.some(D=>!!D.defaultBilling);let ee=null;if(g){const D=qt(R,m,_)||[];let ue;J&&!be?ue=a("div",{className:q(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",J]]),children:a(xe,{slots:s,hideActionFormButtons:n,fieldIdPrefix:A,formName:t,showFormLoader:h,isOpen:J,forwardFormRef:f,showSaveCheckBox:b,saveCheckBoxValue:p,shippingCheckBoxValue:O,billingCheckBoxValue:M,addressesFormTitle:d||Z.differentAddressFormTitle,inputsDefaultValueSet:c,showShippingCheckBox:N,showBillingCheckBox:C,hasDefaultShippingAddress:H,hasDefaultBillingAddress:j,onCloseBtnClick:me,onChange:i,onError:T,onSubmit:F,onSuccess:ye,isB2BFlow:Y,enforceB2BPermissions:z,permissions:Le})}):D.length&&!be?ue=a(Bt,{selectable:g,minifiedView:v,addNewAddress:J,routeAddressesPage:pe,isB2BFlow:U,permissions:Le,loading:ne}):ue=null;const fe=`generalLabel_${X.replace(/\s+/g,"")}`;ee=P("div",{className:"account-addresses-wrapper--select-view",children:[a("span",{id:fe,style:"display: none;",children:X}),D.map((W,te)=>{var ze;const ae=((ze=W.id)==null?void 0:ze.toString())||W.uid,he=`${t}_${ae}`,Re=`${he}_label`;return P(bt,{children:[a("input",{"data-testid":`radio-${te+1}`,type:"radio",name:t,id:he,value:ae,checked:Se===ae,onChange:Ye=>Ee(Ye,W),"aria-labelledby":`${fe} ${Re}`}),a("label",{id:Re,htmlFor:he,className:"account-addresses-wrapper__label",children:a(dt,{slots:s,selectable:g,selectShipping:m,selectBilling:_,minifiedView:v,addressData:W,keysSortOrder:G,loading:ne})})]},ae)}),ue&&P("div",{className:"account-addresses-wrapper__footer-section",children:[a("input",{"aria-label":Z.differentAddressButton,"data-testid":"radio-0",type:"radio",name:t,id:`${t}_addressActions`,value:"0",checked:Se==="0",onChange:W=>Ee(W,{}),tabindex:ue?0:-1}),a("label",{htmlFor:`${t}_addressActions`,className:"account-addresses-wrapper__label",children:ue})]})]})}else ee=P(le,{children:[R.map(D=>a(bt,{children:ce===D.id&&re?a(_e,{variant:"secondary",style:{marginBottom:20},children:a(xe,{slots:s,fieldIdPrefix:A,isOpen:ce===D.id&&re,addressFormId:ce,inputsDefaultValueSet:D,addressesFormTitle:Z.editAddressFormTitle,showShippingCheckBox:N,showBillingCheckBox:C,hasDefaultShippingAddress:H,hasDefaultBillingAddress:j,shippingCheckBoxValue:O,billingCheckBoxValue:M,forwardFormRef:f,onCloseBtnClick:ve,onChange:i,onError:T,onSubmit:F,onSuccess:ye,isB2BFlow:Y,enforceB2BPermissions:z,permissions:Le})}):a(dt,{slots:s,minifiedView:v,addressData:D,keysSortOrder:G,loading:ne,setAddressId:Me,handleRenderModal:v&&I||!v&&V?Be:void 0,handleRenderForm:v&&I||!v&&V?ge:void 0,isB2BFlow:U,permissions:Le},D.id)},D.id)),a("div",{className:"account-addresses__footer",children:J?a(_e,{variant:"secondary",children:a(xe,{slots:s,fieldIdPrefix:A,isOpen:J,addressesFormTitle:Z.newAddressFormTitle,inputsDefaultValueSet:c,showShippingCheckBox:!!(R!=null&&R.length),showBillingCheckBox:!!(R!=null&&R.length),hasDefaultShippingAddress:H,hasDefaultBillingAddress:j,shippingCheckBoxValue:O,billingCheckBoxValue:M,forwardFormRef:f,onChange:i,onCloseBtnClick:me,onError:T,onSubmit:F,onSuccess:ye,isB2BFlow:Y,enforceB2BPermissions:z,permissions:Le})}):a(Bt,{minifiedView:v,addNewAddress:J,routeAddressesPage:pe,isB2BFlow:U,permissions:Le,loading:ne})})]});return P("div",{children:[w?a(ke,{title:X,divider:!v,className:q(["account-addresses-header-title",["account-addresses-header",v]]),level:l??(v?2:1)}):null,P("div",{className:q(["account-addresses-wrapper",y]),"data-testid":"addressesIdWrapper",children:[a(tn,{minifiedView:v,addressData:R==null?void 0:R.find(D=>D.id===ce),keysSortOrder:G,submitLoading:K,open:de,closeModal:ve,onRemoveAddress:Ae,isB2BFlow:U,permissions:Le}),a(Ht,{message:ne?Z.loading:Z.loaded}),ne?a(Je,{testId:"addressSkeletonLoader",withCard:!1}):g?be?a(je,{isEmpty:!(R!=null&&R.length),typeList:"address",minifiedView:v}):a(xe,{slots:s,hideActionFormButtons:n,fieldIdPrefix:A,formName:t,isOpen:!(R!=null&&R.length),forwardFormRef:f,showSaveCheckBox:b,saveCheckBoxValue:p,shippingCheckBoxValue:O,billingCheckBoxValue:M,inputsDefaultValueSet:c,showShippingCheckBox:N,showBillingCheckBox:C,hasDefaultShippingAddress:H,hasDefaultBillingAddress:j,onChange:i,onCloseBtnClick:me,onError:T,onSubmit:F,onSuccess:ye,isB2BFlow:Y,enforceB2BPermissions:z,permissions:Le}):a(je,{isEmpty:!(R!=null&&R.length),typeList:"address",minifiedView:v}),ee]})]})}),Ve={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:we.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},wn={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:"",fieldType:we.TEXT,className:"",required:!1,orderNumber:50,isHidden:!1},En={...Ve,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Nn={...Ve,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Tn={...Ve,label:"Shipping Address",name:"address_type_shipping",id:"address_type_shipping",code:"address_type_shipping",customUpperCode:"addressTypeShipping",orderNumber:90},Sn={...Ve,label:"Billing Address",name:"address_type_billing",id:"address_type_billing",code:"address_type_billing",customUpperCode:"addressTypeBilling",orderNumber:91},In={...Ve,label:"Set as default address",name:"is_default",id:"is_default",code:"is_default",customUpperCode:"isDefault",orderNumber:92},Pn={...wn,label:"Nickname",name:"nickname",id:"nickname",code:"nickname",customUpperCode:"nickname"},Mn=(e,n)=>n==null?void 0:n.map(t=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},s=JSON.parse(JSON.stringify(t));if(Object.hasOwn(r,t.customUpperCode)){const o=r[t.customUpperCode];t.customUpperCode==="region"&&typeof o=="object"?s.defaultValue=o.regionCode&&o.regionId?`${o.regionCode},${o.regionId}`:o.region??o.regionCode:s.defaultValue=o}return s}),Tt=e=>{if(!e)return null;const n=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{n.has(r.name)||n.set(r.name,"false"),r.checked&&n.set(r.name,"true")}),n&&typeof n.entries=="function"){const r=n.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},On=({fields:e,addressId:n,countryOptions:t,disableField:r,regionOptions:s,isRequiredRegion:o,isRequiredPostCode:l,keepDefaultCheckBoxesOnEdit:d})=>e.filter(h=>!(n&&!d&&(h.customUpperCode==="defaultShipping"||h.customUpperCode==="defaultBilling")&&h.defaultValue)).map(h=>h.customUpperCode==="countryCode"?{...h,options:t,disabled:r}:h.customUpperCode==="postcode"?{...h,required:l}:h.customUpperCode==="region"?{...h,options:s,required:o,disabled:r}:h),kn=(e,n="address")=>{const t=n==="address"?["region","city","company","countryCode","countryId","addressType","addressTypeShipping","addressTypeBilling","isDefault","defaultBilling","defaultShipping","fax","firstName","lastName","nickname","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dob","prefix","suffix","fax"],r={},s=[];return Object.keys(e).forEach(o=>{t.includes(o)?r[o]=e[o]:s.push({attribute_code:zt(o),value:e[o]})}),s.length>0&&(r.custom_attributesV2=s),r},St=e=>{const n=["street","streetMultiline_1","streetMultiline_2"],t=["on","off","true","false"],r=[],s={};for(const p in e){const m=e[p];t.includes(m)&&(s[p]=Dt(m)),n.includes(p)&&r.push(m)}const{street:o,streetMultiline_2:l,streetMultiline_1:d,region:u,...h}=e,[i,f]=u?u.split(","):[void 0,void 0],y=f&&i?{regionId:+f,regionCode:i}:{region:i};return kn({...h,...s,region:{...y},street:r})},$n=(e,n)=>{const t={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const s=e[r];if(r==="region"&&s.regionId){const o=n.find(l=>(l==null?void 0:l.id)===s.regionId);o?t[r]={...s,text:o.text}:t[r]=s}else Array.isArray(s)?(t[r]=s[0]||"",s.slice(1).forEach((o,l)=>{t[`${r}Multiline_${l+2}`]=o})):t[r]=s}return t},xn=(e,n)=>!!e&&n!==!1,Fn=({isB2BFlow:e,shouldEnforceB2BPermissions:n,permissions:t})=>!!e&&!n&&(t==null?void 0:t.loading)===!1&&(t==null?void 0:t.canCreateAddress)===!1,Wt=(e,n)=>{const t=!!n.addressTypeShipping&&!!n.addressTypeBilling;return!!e&&(t||!!n.defaultShipping&&!!n.defaultBilling)},Zn=(e,n)=>e&&!n,It=({requestPayload:e,shouldEnforceB2BPermissions:n,canSetDefaultAddress:t})=>(typeof e.isDefault=="boolean"?e.isDefault:!!e.defaultShipping||!!e.defaultBilling)&&(!n||!!t),Hn=({isTemporaryCheckoutAddressMode:e,shouldEnforceB2BPermissions:n,canSetDefaultAddress:t})=>!e&&(!n||!!t),Pt=({requestPayload:e,shouldEnforceB2BPermissions:n,canSetDefaultAddress:t})=>{if(!Zn(n,t))return e;const r={...e};return delete r.defaultShipping,delete r.defaultBilling,delete r.isDefault,r},Vn=({shouldEnforceB2BPermissions:e,canEditAddress:n,isB2BFlow:t,requestPayload:r})=>{if(e&&!n)return"noPermissionEditAddresses";if(Wt(t,r))return"companyAddressSingleDefaultType"},Rn=({shouldEnforceB2BPermissions:e,canCreateAddress:n,isB2BFlow:t,requestPayload:r})=>{if(e&&!n)return"noPermissionCreateAddresses";if(Wt(t,r))return"companyAddressSingleDefaultType"},tt=e=>e instanceof Error&&e.message?e.message:typeof e=="string"&&e.trim()?e:"Unknown error",zn=({showShippingCheckBox:e,showBillingCheckBox:n,shippingCheckBoxValue:t,billingCheckBoxValue:r})=>({showShipping:!!e,showBilling:!!n,shippingDefaultValue:t??!1,billingDefaultValue:r??!1}),Un={none:{showShipping:!0,showBilling:!0,shippingDefaultValue:!1,billingDefaultValue:!1},shippingOnly:{showShipping:!1,showBilling:!0,shippingDefaultValue:!1,billingDefaultValue:!0},billingOnly:{showShipping:!0,showBilling:!1,shippingDefaultValue:!0,billingDefaultValue:!1},both:{showShipping:!1,showBilling:!1,shippingDefaultValue:!1,billingDefaultValue:!1}},Dn=({hasDefaultShippingAddress:e,hasDefaultBillingAddress:n})=>{const t=!!e,r=!!n;let s="none";return t&&r?s="both":t?s="shippingOnly":r&&(s="billingOnly"),Un[s]},Gn=({isB2BFlow:e,showShippingCheckBox:n,showBillingCheckBox:t,shippingCheckBoxValue:r,billingCheckBoxValue:s,addressId:o,hasDefaultShippingAddress:l,hasDefaultBillingAddress:d})=>{const u=zn({showShippingCheckBox:n,showBillingCheckBox:t,shippingCheckBoxValue:r,billingCheckBoxValue:s}),h=!o;return!e||!h?u:Dn({hasDefaultShippingAddress:l,hasDefaultBillingAddress:d})},qn=(e,n)=>e&&Object.keys(e).length>0?e:n&&Object.keys(n).length>0?n:{},Mt=e=>(e==null?void 0:e.name)==="nickname"||(e==null?void 0:e.code)==="nickname"||(e==null?void 0:e.customUpperCode)==="nickname",Wn=({showFormLoader:e,showSaveCheckBox:n,saveCheckBoxValue:t,addressFormId:r,billingCheckBoxValue:s,shippingCheckBoxValue:o,showShippingCheckBox:l,showBillingCheckBox:d,hasDefaultShippingAddress:u,hasDefaultBillingAddress:h,inputsDefaultValueSet:i,onCloseBtnClick:f,onSuccess:y,onError:b,formName:p,isB2BFlow:m,enforceB2BPermissions:_,permissions:g})=>{const w=Q({noPermissionEditAddresses:"Account.AddressForm.notifications.noPermissionEditAddresses",noPermissionCreateAddresses:"Account.AddressForm.notifications.noPermissionCreateAddresses",companyAddressSingleDefaultType:"Account.AddressForm.notifications.companyAddressSingleDefaultType",b2bShippingTypeLabel:"Account.AddressForm.formText.b2bShippingTypeLabel",b2bBillingTypeLabel:"Account.AddressForm.formText.b2bBillingTypeLabel",b2bIsDefaultLabel:"Account.AddressForm.formText.b2bIsDefaultLabel",b2bIsDefaultShippingLabel:"Account.AddressForm.formText.b2bIsDefaultShippingLabel",b2bIsDefaultBillingLabel:"Account.AddressForm.formText.b2bIsDefaultBillingLabel"}),v=xn(m,_),I=Fn({isB2BFlow:m,shouldEnforceB2BPermissions:v,permissions:g}),[V,c]=S({text:"",type:"success"}),[N,C]=S(e??!1),[O,M]=S(r||""),[B,F]=S([]),[L,T]=S(null),[A,k]=S(()=>{var z,U;const E=sessionStorage.getItem(`${p}_addressData`);return E?{countryCode:(U=(z=JSON.parse(E))==null?void 0:z.data)==null?void 0:U.countryCode}:i}),[Z,G]=S(!1),[K,de]=S(()=>{var U,X;const E=sessionStorage.getItem(`${p}_addressData`);return E?(X=(U=JSON.parse(E))==null?void 0:U.data)==null?void 0:X.saveAddressBook:t}),re=!v||!!(g!=null&&g.canEditAddress),ne=!v||!!(g!=null&&g.canSetDefaultAddress),J=!!(m&&O),R=J&&v&&!re&&ne,ce=J&&v&&re&&!ne,ge=x(E=>{de(E.target.checked)},[]);oe(()=>{typeof e>"u"||C(e)},[e]),oe(()=>{ot(O?"customer_address_edit":"customer_register_address").then(E=>{F(E)})},[O]),oe(()=>{G(!0),pr().then(({availableCountries:E,countriesWithRequiredRegion:z,optionalZipCountries:U})=>{T({availableCountries:E,countriesWithRequiredRegion:z,optionalZipCountries:U}),G(!1)})},[]);const Be=Ne(()=>(L==null?void 0:L.availableCountries)||[],[L]),Ae=Ne(()=>!(A!=null&&A.countryCode)||!L?!1:L.countriesWithRequiredRegion.includes(A.countryCode),[A==null?void 0:A.countryCode,L]),ve=Ne(()=>!(A!=null&&A.countryCode)||!L?!0:!L.optionalZipCountries.includes(A.countryCode),[A==null?void 0:A.countryCode,L]),ye=Ne(()=>{var z;if(!(A!=null&&A.countryCode)||!L)return[];const E=L.availableCountries.find(U=>U.value===A.countryCode);return((z=E==null?void 0:E.availableRegions)==null?void 0:z.map(U=>({text:U.name,value:`${U.code},${U.id}`})))||[]},[A==null?void 0:A.countryCode,L]),Me=x(()=>{c({text:"",type:"success"}),f==null||f()},[f]),me=x(E=>E.addressType==="BILLING"?"BILLING":E.addressType==="SHIPPING"?"SHIPPING":E.addressTypeBilling&&!E.addressTypeShipping?"BILLING":E.addressTypeShipping&&!E.addressTypeBilling?"SHIPPING":E.defaultBilling&&!E.defaultShipping?"BILLING":E.defaultShipping&&!E.defaultBilling?"SHIPPING":(i==null?void 0:i.addressType)??"SHIPPING",[i==null?void 0:i.addressType]),pe=x(E=>typeof E.isDefault=="boolean"?E.isDefault:typeof E.defaultShipping=="boolean"||typeof E.defaultBilling=="boolean"?!!(E.defaultShipping||E.defaultBilling):!!(i!=null&&i.defaultShipping||i!=null&&i.defaultBilling),[i==null?void 0:i.defaultBilling,i==null?void 0:i.defaultShipping]),Ee=x(async(E,z)=>{var fe,W;if(!z)return null;const U=Tt(E.target),H={...St(U)},j=i==null?void 0:i.addressType;if(m){const te=me(H),ae=pe(H),he=J&&j?j:te;H.addressType=he,H.addressTypeShipping=he==="SHIPPING",H.addressTypeBilling=he==="BILLING",H.isDefault=ae,H.defaultShipping=he==="SHIPPING"?ae:!1,H.defaultBilling=he==="BILLING"?ae:!1}if(m&&R){C(!0);try{H.isDefault&&await Qe(O),y==null||y(),f==null||f(),(fe=E==null?void 0:E.target)==null||fe.reset()}catch(te){const ae=tt(te);c(he=>({...he,text:ae,type:"error"})),b==null||b(ae)}finally{C(!1)}return null}const ee=Vn({shouldEnforceB2BPermissions:v,canEditAddress:g==null?void 0:g.canEditAddress,isB2BFlow:m,requestPayload:H});if(ee)return c(te=>({...te,text:w[ee],type:"warning"})),null;C(!0);const D=Pt({requestPayload:H,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress}),ue=m?{...D,isDefault:pe(H)}:D;try{if(m){const te=It({requestPayload:H,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress});await Ar(O,ue),te&&await Qe(O)}else{const te={...D,addressId:Number(O)};await st(te)}y==null||y(),f==null||f(),(W=E==null?void 0:E.target)==null||W.reset()}catch(te){const ae=tt(te);c(he=>({...he,text:ae,type:"error"})),b==null||b(ae)}finally{C(!1)}},[f,b,y,m,v,w,O,i,g==null?void 0:g.canEditAddress,g==null?void 0:g.canSetDefaultAddress,me,pe,J,R]),Se=x(async(E,z)=>{var ue,fe;if(!z)return;const{saveAddressBook:U,...X}=Tt(E.target),j={...St(X)};if(m){const W=me(j),te=pe(j);j.addressType=W,j.addressTypeShipping=W==="SHIPPING",j.addressTypeBilling=W==="BILLING",j.isDefault=te,j.defaultShipping=W==="SHIPPING"?te:!1,j.defaultBilling=W==="BILLING"?te:!1}if(C(!0),I)return y==null||y(),f==null||f(),(ue=E==null?void 0:E.target)==null||ue.reset(),M(""),C(!1),null;const ee=Rn({shouldEnforceB2BPermissions:v,canCreateAddress:g==null?void 0:g.canCreateAddress,isB2BFlow:m,requestPayload:j});if(ee)return c(W=>({...W,text:w[ee],type:"warning"})),C(!1),null;const D=Pt({requestPayload:j,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress});try{if(m){const W=await yr(D);It({requestPayload:D,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress})&&await Qe(String((W==null?void 0:W.id)??""))}else await br(D);y==null||y(),f==null||f(),(fe=E==null?void 0:E.target)==null||fe.reset()}catch(W){const te=tt(W);c(ae=>({...ae,text:te,type:"error"})),b==null||b(te)}finally{M(""),C(!1)}},[f,b,y,m,v,I,w,g==null?void 0:g.canCreateAddress,g==null?void 0:g.canSetDefaultAddress,me,pe]),be=Ne(()=>Gn({isB2BFlow:m,showShippingCheckBox:l,showBillingCheckBox:d,shippingCheckBoxValue:o,billingCheckBoxValue:s,addressId:O,hasDefaultShippingAddress:u,hasDefaultBillingAddress:h}),[m,l,d,o,s,O,u,h]),Le=Ne(()=>{if(!B.length)return[];const E=B.some(Ce=>Mt(Ce)&&Ce.fieldType===we.TEXT&&!Ce.isHidden),U=m&&!E?[...B.filter(Ce=>!Mt(Ce)),Pn]:B,X=Hn({isTemporaryCheckoutAddressMode:I,shouldEnforceB2BPermissions:v,canSetDefaultAddress:g==null?void 0:g.canSetDefaultAddress}),H=A==null?void 0:A.addressTypeBilling,j=A==null?void 0:A.addressTypeShipping,ee=typeof H=="boolean"||typeof j=="boolean"?H?"BILLING":"SHIPPING":(i==null?void 0:i.addressType)??"SHIPPING",D=!!(i!=null&&i.defaultShipping||i!=null&&i.defaultBilling),ue=!!(m&&O),fe=!X||ce||R&&D,W=!!(!v||I||n&&!K),te={...En,defaultValue:be.shippingDefaultValue,isHidden:!!(n&&!K||!be.showShipping||!X)},ae={...Nn,defaultValue:be.billingDefaultValue,isHidden:!!(n&&!K||!be.showBilling||!X)},he={...Tn,label:w.b2bShippingTypeLabel,forceLabel:!0,defaultValue:ee==="SHIPPING",isHidden:W,disabled:ue},Re={...Sn,label:w.b2bBillingTypeLabel,forceLabel:!0,defaultValue:ee==="BILLING",isHidden:W,disabled:ue},ze=ee==="BILLING"?w.b2bIsDefaultBillingLabel:w.b2bIsDefaultShippingLabel,Ye={...In,label:ze,forceLabel:!0,defaultValue:D,isHidden:W,disabled:fe},Yt=m?[...U,he,Re,Ye]:[...U,te,ae],mt=sessionStorage.getItem(`${p}_addressData`),Xt=mt?$n(JSON.parse(mt).data,ye):{},pt=qn(Xt,i),Qt=m?{...pt,addressTypeShipping:ee==="SHIPPING",addressTypeBilling:ee==="BILLING",isDefault:D}:pt,er=Mn(Qt,Yt),At=On({fields:er,addressId:O,countryOptions:Be,disableField:Z,regionOptions:ye,isRequiredRegion:Ae,isRequiredPostCode:ve,keepDefaultCheckBoxesOnEdit:!!(m&&O)});return R?At.map(Ce=>Ce.customUpperCode==="addressTypeShipping"||Ce.customUpperCode==="addressTypeBilling"||Ce.customUpperCode==="isDefault"?{...Ce,disabled:Ce.customUpperCode==="isDefault"?fe:!0}:{...Ce,disabled:!0}):At},[B,m,n,K,be,I,v,g==null?void 0:g.canSetDefaultAddress,p,ye,i,O,Be,Z,Ae,ve,R,ce,A==null?void 0:A.addressTypeShipping,A==null?void 0:A.addressTypeBilling,w.b2bShippingTypeLabel,w.b2bBillingTypeLabel,w.b2bIsDefaultShippingLabel,w.b2bIsDefaultBillingLabel]),Y=x(E=>{k(z=>({...z,...E}))},[]);return{regionOptions:ye,saveCheckBoxAddress:K,inLineAlert:V,addressId:O,submitLoading:N,normalizeFieldsConfig:Le,handleSaveCheckBoxAddress:ge,handleUpdateAddress:Ee,handleCreateAddress:Se,handleOnCloseForm:Me,handleInputChange:Y}},jn=e=>{var s;if(!e||!Array.isArray(e.customAttributes))return e??{};const n={};(s=e==null?void 0:e.customAttributes)==null||s.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(n[o.code]=o.value)});const{customAttributes:t,...r}=e;return{...r,...Rt(n,"camelCase",{})}},Kn=({hideActionFormButtons:e,formName:n="",showFormLoader:t=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:s=!1,forwardFormRef:o,slots:l,addressesFormTitle:d,className:u,addressFormId:h,inputsDefaultValueSet:i,showShippingCheckBox:f=!0,showBillingCheckBox:y=!0,hasDefaultShippingAddress:b=!1,hasDefaultBillingAddress:p=!1,shippingCheckBoxValue:m=!0,billingCheckBoxValue:_=!0,isOpen:g,fieldIdPrefix:w,onSubmit:v,onCloseBtnClick:I,onSuccess:V,onError:c,onChange:N,isB2BFlow:C,enforceB2BPermissions:O,permissions:M})=>{const B=Q({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook",noPermissionEditAddresses:"Account.AddressForm.notifications.noPermissionEditAddresses",noPermissionCreateAddresses:"Account.AddressForm.notifications.noPermissionCreateAddresses"}),F=!!C&&O!==!1,L=!!r&&!(C&&!F),{inLineAlert:T,addressId:A,submitLoading:k,normalizeFieldsConfig:Z,handleUpdateAddress:G,handleCreateAddress:K,handleOnCloseForm:de,handleSaveCheckBoxAddress:re,saveCheckBoxAddress:ne,handleInputChange:J,regionOptions:R}=Wn({showFormLoader:t,addressFormId:h,inputsDefaultValueSet:jn(i),shippingCheckBoxValue:m,billingCheckBoxValue:_,showShippingCheckBox:f,showBillingCheckBox:y,hasDefaultShippingAddress:b,hasDefaultBillingAddress:p,saveCheckBoxValue:s,showSaveCheckBox:L,onSuccess:V,onError:c,onCloseBtnClick:I,formName:n,isB2BFlow:C,enforceB2BPermissions:O,permissions:M}),ce=!!h,ge=!F||!!(M!=null&&M.canEditAddress),Be=!F||!!(M!=null&&M.canSetDefaultAddress),Ae=!F||!!(M!=null&&M.canCreateAddress),ve=ce?!ge&&!Be:!Ae,ye=ce?B.noPermissionEditAddresses:B.noPermissionCreateAddresses,[Me,me]=S(0),pe=Ze(null);return oe(()=>{const Ee=JSON.stringify(i??null);if(pe.current===Ee)return;const Se=pe.current===null;pe.current=Ee,!Se&&me(be=>be+1)},[i]),g?ve?P("div",{className:q(["account-address-form-wrapper",u]),children:[d?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:d}):null,a(Pe,{"data-testid":"noPermissionAlert",className:"account-address-form-wrapper__notification",type:"warning",variant:"secondary",heading:ye})]}):P("div",{className:q(["account-address-form-wrapper",u]),children:[d?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:d}):null,T.text?a(Pe,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:T.type,variant:"secondary",heading:T.text,icon:T.icon}):null,P(Gt,{regionOptions:R,forwardFormRef:o,slots:l,className:"account-address-form",name:n||"addressesForm",fieldsConfig:Z,onSubmit:v||(A?G:K),setInputChange:J,loading:k,showFormLoader:t,showSaveCheckBox:L,handleSaveCheckBoxAddress:re,saveCheckBoxAddress:ne,onChange:N,fieldIdPrefix:w,children:[A?a("input",{type:"hidden",name:"addressId",value:A,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:q(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",L]]),children:l!=null&&l.AddressFormActions?a(Te,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:l.AddressFormActions,context:{handleUpdateAddress:G,handleCreateAddress:K,addressId:A}}):a(le,{children:L?null:P(le,{children:[a(ie,{type:"button",onClick:de,variant:"secondary",disabled:k||ve,children:B.secondaryButton}),a(ie,{disabled:k||ve,children:B.primaryButton})]})})})]},Me)]}):null},Jn=()=>{const e=sessionStorage.getItem("accountStoreConfig");if(!e)return null;try{return JSON.parse(e)}catch(n){return console.error("Failed to parse cached store config:",n),sessionStorage.removeItem("accountStoreConfig"),null}},Yn=()=>{const[e,n]=S(!0),[t,r]=S(null),[s,o]=S(null),l=d=>{const{minLength:u,requiredCharacterClasses:h,shoppingAssistanceEnabled:i,shoppingAssistanceCheckboxTitle:f,shoppingAssistanceCheckboxTooltip:y}=d;r({minLength:u,requiredCharacterClasses:h}),o({shoppingAssistanceEnabled:i,shoppingAssistanceCheckboxTitle:f,shoppingAssistanceCheckboxTooltip:y})};return oe(()=>{const d=Jn();if(d){l(d),n(!1);return}Ut().then(u=>{u&&(sessionStorage.setItem("accountStoreConfig",JSON.stringify(u)),l(u))}).catch(u=>{console.error("Failed to load store config:",u)}).finally(()=>{n(!1)})},[]),{loading:e,passwordConfigs:t,remoteShoppingAssistanceConfigs:s}},Xn=({currentPassword:e,newPassword:n,confirmPassword:t,translations:r})=>{let s={...ut};const o=!e.length&&!n.length&&!t.length,l=e.length&&n!==t;return o?(s={...s,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:s}):e.length?n.length?t.length?l?(s={...s,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:s}):{isValid:!0,errors:s}:(s={...s,confirmPassword:r.requiredFieldError},{isValid:!1,errors:s}):(s={...s,newPassword:r.requiredFieldError},{isValid:!1,errors:s}):(s={...s,currentPassword:r.requiredFieldError},{isValid:!1,errors:s})},jt=(e,n)=>{if(n<=1)return!0;const t=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,s=/[A-Z]/.test(e)?1:0,o=/[^a-zA-Z0-9\s]/.test(e)?1:0;return t+r+s+o>=n},ut={currentPassword:"",newPassword:"",confirmPassword:""},Qn=({passwordConfigs:e,handleSetInLineAlert:n,handleHideChangePassword:t})=>{const r=Q({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[s,o]=S(!1),[l,d]=S(!1),[u,h]=S(""),[i,f]=S(""),[y,b]=S(""),[p,m]=S({currentPassword:"",newPassword:"",confirmPassword:""}),_=x(()=>{t(()=>{n({}),m(ut)})},[t,n]),g=x(N=>{h(N),m(C=>({...C,currentPassword:N?"":r.requiredFieldError}))},[r]),w=x(N=>{f(N),m(C=>({...C,newPassword:N?"":r.requiredFieldError}))},[r]),v=x(N=>{b(N),m(C=>({...C,confirmPassword:N?"":r.requiredFieldError}))},[r]),I=x(N=>{const{name:C,value:O}=N==null?void 0:N.target;m(M=>({...M,[C]:O?"":r.requiredFieldError}))},[r]),V=x(()=>{const{isValid:N,errors:C}=Xn({currentPassword:u,newPassword:i,confirmPassword:y,translations:r});return m(C),N},[u,i,y,r]),c=x(N=>{N.preventDefault(),d(!0);const C=(e==null?void 0:e.requiredCharacterClasses)??0,O=(e==null?void 0:e.minLength)??1;if(!V()){o(!0),d(!1);return}if(!jt(i,C)||O>(i==null?void 0:i.length)){o(!0),d(!1);return}Lr({currentPassword:u,newPassword:i}).then(M=>{if(!(M!=null&&M.length)){d(!1);return}h(""),f(""),b(""),m(ut),o(!1),n({type:"success",text:r.passwordUpdateMessage})}).catch(M=>{M.message==="Invalid login or password."&&n({type:"error",text:r.incorrectCurrentPassword}),M.message==="The account is locked."&&n({type:"error",text:M.message})}),d(!1)},[e,V,i,u,n,r]);return{hideChangePassword:_,handleOnBlurPassword:I,handleConfirmPasswordChange:v,handleNewPasswordChange:w,handleCurrentPasswordChange:g,mutationChangePassword:c,currentPassword:u,newPassword:i,confirmPassword:y,passwordErrors:p,submitLoading:l,isClickSubmit:s}},ea=({passwordConfigs:e,isClickSubmit:n,password:t})=>{const r=Q({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[s,o]=S("pending");oe(()=>{if(!e)return;const d=jt(t,e.requiredCharacterClasses);n&&t.length>0?o(d?"success":"error"):n&&t.length===0?o("pending"):o(d?"success":"pending")},[n,e,t]);const l=Ne(()=>{var u;if(!e)return;const d={status:"pending",icon:"pending",message:(u=r.messageLengthPassword)==null?void 0:u.replace("{minLength}",`${e.minLength}`)};return t.length&&t.length>=e.minLength?{...d,icon:"success",status:"success"}:t.length&&t.length<e.minLength?n?{...d,icon:"error",status:"error"}:{...d,icon:"pending",status:"pending"}:d},[e,r.messageLengthPassword,t==null?void 0:t.length,n]);return{isValidUniqueSymbols:s,defaultLengthMessage:l}},ta=(e,n,t,r,s)=>e==="error"||(n==null?void 0:n.status)==="error"||t&&r.trim().length===0?s.newPassword:void 0,Ea=({handleHideChangePassword:e,handleSetInLineAlert:n,inLineAlertProps:t})=>{const{passwordConfigs:r}=Yn(),{hideChangePassword:s,handleOnBlurPassword:o,handleConfirmPasswordChange:l,handleNewPasswordChange:d,handleCurrentPasswordChange:u,mutationChangePassword:h,currentPassword:i,newPassword:f,confirmPassword:y,passwordErrors:b,submitLoading:p,isClickSubmit:m}=Qn({passwordConfigs:r,handleSetInLineAlert:n,handleHideChangePassword:e}),{isValidUniqueSymbols:_,defaultLengthMessage:g}=ea({password:f,isClickSubmit:m,passwordConfigs:r}),w=Q({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return P(_e,{className:"account-change-password",variant:"secondary",children:[a(ke,{title:w.containerTitle,divider:!1,className:"account-change-password__title",level:3}),t.text?a(Pe,{className:"account-change-password__notification",type:t.type,variant:"secondary",heading:t.text,icon:t.icon,"data-testid":"changePasswordInLineAlert"}):null,P("div",{className:"account-change-password__fields",children:[a(Ue,{className:"account-change-password__fields-item",autoComplete:"current-password",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:b.currentPassword,defaultValue:i,onValue:u,onBlur:o}),a(Ue,{className:"account-change-password__fields-item",autoComplete:"new-password",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:g,uniqueSymbolsStatus:_,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:ta(_,g,m,f,b),defaultValue:f,onValue:d,onBlur:o}),a(Ue,{className:"account-change-password__fields-item",autoComplete:"new-password",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:b.confirmPassword,defaultValue:y,onValue:l,onBlur:o})]}),P("div",{className:"account-change-password__actions",children:[a(ie,{type:"button",disabled:p,onClick:s,variant:"secondary",children:w.buttonSecondary}),a(ie,{variant:"primary",type:"button",disabled:p,onClick:h,children:w.buttonPrimary})]})]})},Na=({inLineAlertProps:e,errorPasswordEmpty:n,passwordValue:t,showPasswordOnEmailChange:r,submitLoading:s,formFieldsList:o,handleHideEditForm:l,handleUpdateCustomerInformation:d,handleInputChange:u,handleSetPassword:h,handleOnBlurPassword:i})=>{const f=Q({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return P(_e,{variant:"secondary",className:"account-edit-customer-information",children:[a(ke,{title:f.containerTitle,divider:!1,className:"account-edit-customer-information__title",level:3}),e.text?a(Pe,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,P(Gt,{loading:s,fieldsConfig:o||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:d,setInputChange:u,children:[r?a("div",{className:"account-edit-customer-information__password",children:a(Ue,{autoComplete:"current-password",name:"password",placeholder:f.placeholder,floatingLabel:f.floatingLabel,errorMessage:n?f.requiredFieldError:void 0,defaultValue:t,onValue:h,onBlur:i})}):null,P("div",{className:"account-edit-customer-information__actions",children:[a(ie,{disabled:s,type:"button",variant:"secondary",onClick:()=>l(),children:f.buttonSecondary}),a(ie,{disabled:s,type:"submit",variant:"primary",children:f.buttonPrimary})]})]})]})},Ta=({createdAt:e,slots:n,orderedCustomerData:t,showEditForm:r,showChangePassword:s,handleShowChangePassword:o,handleShowEditForm:l})=>{const d=Q({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonSecondaryAriaLabel:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondaryAriaLabel",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",buttonPrimaryAriaLabel:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimaryAriaLabel",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return a(_e,{variant:"secondary",className:q(["account-customer-information-card",["account-customer-information-card-short",s||r]]),children:P("div",{className:"account-customer-information-card__wrapper",children:[P("div",{className:"account-customer-information-card__actions",children:[a(ie,{type:"button",variant:"tertiary","aria-label":d.buttonSecondaryAriaLabel,onClick:o,children:d.buttonSecondary}),a(ie,{type:"button",variant:"tertiary","aria-label":d.buttonPrimaryAriaLabel,onClick:l,children:d.buttonPrimary})]}),a("div",{className:"account-customer-information-card__content",children:n!=null&&n.CustomerData?a(Te,{name:"CustomerData",slot:n==null?void 0:n.CustomerData,context:{customerData:t}}):P(le,{children:[t==null?void 0:t.map((u,h)=>{const i=u!=null&&u.label?`${u.label}: ${u==null?void 0:u.value}`:u==null?void 0:u.value;return a("p",{"data-testid":`${u.name}_${h}`,children:i},`${u.name}_${h}`)}),P("p",{children:[d.accountCreation,": ",e]})]})})]})})};function ra(e){if(!e)return[];const n=`${e.firstName} ${e.lastName}`.trim(),t=e.street??"",r=e.city??"",s=e.region||void 0,o=e.postcode??"",l=e.countryCode??"";let d="";r&&s?d=`${r}, ${(s==null?void 0:s.regionCode)??""}`.trim():r?d=r:s&&(d=(s==null?void 0:s.regionCode)??"");let u=d;o&&(u=d?`${d} ${o}`:o);let h=u;return l&&(h=u?`${u}, ${l}`:l),[n,t,h]}const Ot=({title:e,address:n,selected:t,busy:r,onChange:s})=>{const[o,l,d]=ra(n);return a("div",{className:"account-address-validation__option",children:a(sr,{busy:r,className:"account-address-validation__radio",label:P("div",{children:[a("div",{className:"account-address-validation__option-title",children:a("strong",{children:e})}),o&&a("div",{children:o}),l&&a("div",{children:l}),d&&a("div",{children:d})]}),name:"address-validation-choice",selected:t,value:e,onChange:s})})},Sa=({busy:e=!1,className:n,originalAddress:t,onSelectionChange:r,selection:s,suggestedAddress:o})=>{const l=!!o,d=Q({title:"Account.AddressValidation.title",subtitle:"Account.AddressValidation.subtitle",suggestedAddress:"Account.AddressValidation.suggestedAddress",originalAddress:"Account.AddressValidation.originalAddress"});return P("div",{className:q(["account-address-validation",n]),children:[a(ke,{className:"account-address-validation__title",divider:!1,title:d.title,level:1}),a("div",{className:"account-address-validation__subtitle",children:d.subtitle}),P("div",{className:q(["account-address-validation__options",e&&"account-address-validation__options--busy"]),children:[l&&a(Ot,{address:o,busy:e,selected:s==="suggested",title:d.suggestedAddress,onChange:()=>r("suggested")}),a(Ot,{address:t,busy:e,selected:s==="original",title:d.originalAddress,onChange:()=>r("original")})]})]})},Ia=({loading:e,isRemoteShoppingAssistanceAvailable:n,isRemoteShoppingAssistanceEnabled:t,showAlert:r,checkboxLabel:s,checkboxTooltip:o,alertMessage:l,featureDisabledMessage:d,handleCheckboxChange:u,handleDismissAlert:h})=>{const[i,f]=S(!1);return e?a(He,{children:a(se,{variant:"row"})}):!e&&!n?a("div",{className:"account-seller-assisted-buying-settings-control__alert",children:a(Fe,{heading:d})}):P("div",{className:"account-seller-assisted-buying-settings-control",children:[!t&&r&&a("div",{className:"account-seller-assisted-buying-settings-control__alert",children:a(Pe,{variant:"secondary",type:"warning",heading:l,onDismiss:h})}),P("div",{className:"account-seller-assisted-buying-settings-control__checkbox-row",children:[a(Ie,{children:a(ft,{name:"allowRemoteShoppingAssistance",value:"true",placeholder:s,label:s,checked:t,onChange:y=>u(y.currentTarget.checked)})}),o?P("div",{className:"account-seller-assisted-buying-settings-control__info-container",children:[a("button",{type:"button",className:"account-seller-assisted-buying-settings-control__info-icon",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onFocusCapture:()=>f(!0),onBlurCapture:()=>f(!1),"aria-label":o,children:"?"}),i?P("span",{className:"account-seller-assisted-buying-settings-control__tooltip",role:"tooltip",children:[o,a("span",{className:"account-seller-assisted-buying-settings-control__tooltip-arrow"})]}):null]}):null]})]})},Pa=({loading:e,adminAssistanceActions:n,tableHeaders:t,actionTypesMap:r,emptyStateMessage:s,featureDisabledMessage:o,isRemoteShoppingAssistanceAvailable:l=!0,errorMessage:d,currentPage:u,onPageChange:h,withWrapper:i=!0})=>{var _;if(e)return P(He,{children:[a(se,{variant:"row",fullWidth:!0}),a(se,{variant:"row",fullWidth:!0}),a(se,{variant:"row",fullWidth:!0})]});if(!l)return a("div",{className:"account-seller-assisted-buying-activity-table__alert",children:a(Fe,{heading:o})});if(d)return a("div",{className:"account-seller-assisted-buying-activity-table__error",children:a(Fe,{heading:d})});if(!((_=n==null?void 0:n.items)!=null&&_.length))return a("div",{className:"account-seller-assisted-buying-activity-table__empty",children:a(Fe,{heading:s})});const f=[{label:t.action,key:"action",ariaLabel:t.action},{label:t.date,key:"date",ariaLabel:t.date},{label:t.details,key:"details",ariaLabel:t.details}],y=n.items.map(g=>({action:r[g.action]||g.action,date:g.date,details:g.details})),b=n.pageInfo.totalPages,p=b>1,m=a("div",{className:"account-seller-assisted-buying-activity-table",children:a("div",{className:"account-seller-assisted-buying-activity-table__table-wrapper",children:a(or,{columns:f,rowData:y,mobileLayout:"stacked",className:"account-seller-assisted-buying-activity-table__table"})})});return P(le,{children:[i?a(_e,{variant:"secondary",className:q(["account-seller-assisted-buying-activity-table-card"]),children:m}):m,p&&a("div",{className:"account-seller-assisted-buying-activity-table__pagination",children:a(Vt,{currentPage:u,totalPages:b,onChange:h})})]})},Kt=({cardBrand:e,lastFourDigits:n,expired:t=!1,onRemove:r,variant:s="secondary",minifiedView:o=!1})=>{const l=gt(),d=Q({actionRemove:"Account.Payments.paymentCard.actionRemove",cardEndingIn:"Account.Payments.paymentCard.cardEndingIn",expiredLabel:"Account.Payments.paymentCard.expiredLabel"}),u=nt(()=>{r==null||r()},[r]),h=`•••• ${n}`,i=`${d.cardEndingIn} ${h}`;return P(_e,{variant:s,className:q(["account-payment-card",o&&"account-payment-card--minified"]),"data-testid":"paymentCard",children:[a("div",{className:"account-payment-card__action",children:r?a(ie,{type:"button",variant:"tertiary",onClick:u,"data-testid":"removeButton","aria-label":`${d.actionRemove} ${e} ${i}`,"aria-describedby":l,children:d.actionRemove}):null}),P("div",{className:"account-payment-card__description",id:l,children:[a("p",{className:"account-payment-card__card-brand","data-testid":"cardBrand",children:e}),a("p",{className:"account-payment-card__card-number","data-testid":"cardNumber",children:i})]}),t?a("div",{className:"account-payment-card__labels","data-testid":"expiredTag",children:a($e,{label:(d.expiredLabel??"Expired").toLocaleUpperCase()})}):null]})},kt="account/customerPaymentTokens",Jt="__REMOVE_FAILED__",na=e=>{const n=Ze("api"),t=Ze(void 0),[r,s]=S([]),[o,l]=S(!0),[d,u]=S(null),[h,i]=S(null),[f,y]=S(null),b=x(async()=>{l(!0),u(null),i(null);try{const g=await Cr(e);n.current="api",s(g)}catch(g){s([]),u(g instanceof Error?g.message:String(g))}finally{l(!1)}},[e]);oe(()=>{let g=!1,w=!1;const v=at.on(kt,I=>{g||(w=!0,n.current="event",s(Array.isArray(I)?I:[]),u(null),l(!1))},{eager:!0});return(!v||!w)&&b(),()=>{g=!0,v==null||v.off()}},[b]);const p=(e==null?void 0:e.join(","))??"";oe(()=>{if(n.current==="api"){if(t.current===void 0){t.current=p;return}t.current!==p&&(t.current=p,b())}},[p,b]);const m=x(async g=>{i(null),y(g);try{await vr(g)?s(v=>v.filter(I=>I.publicHash!==g)):i(Jt)}catch(w){i(w instanceof Error?w.message:String(w))}finally{y(null)}},[]),_=x(async()=>{if(n.current==="event"){const g=at.lastPayload(kt);if(g===void 0)return;s(Array.isArray(g)?g:[]),u(null),i(null);return}await b()},[b]);return{items:r,loading:o,loadError:d,actionError:h,removingHash:f,removeToken:m,refetch:_}},Ma=({className:e,withHeader:n=!0,minifiedView:t=!1,filterPaymentMethodCodes:r})=>{const s=Q({containerTitle:"Account.Payments.containerTitle",loadError:"Account.Payments.loadError",removeError:"Account.Payments.removeError"}),{items:o,loading:l,loadError:d,actionError:u,removingHash:h,removeToken:i}=na(r),[f,y]=S(null),b=x(()=>{y(null)},[]),p=x(async()=>{f&&(await i(f.publicHash),y(null))},[f,i]),m=u===Jt?s.removeError:u??"",_=o.length>0?o.map(w=>{const{publicHash:v,...I}=w;return a(Kt,{...I,minifiedView:t,onRemove:h!==null?void 0:()=>y(w)},v)}):null,g=o.length===0&&!d?a("div",{className:"account-payment-methods__empty","data-testid":"paymentMethodsEmpty",children:a(je,{isEmpty:!0,typeList:"payments",minifiedView:t})}):null;return P("div",{className:q(["account-payment-methods",e]),"data-testid":"paymentMethods",children:[n?a(ke,{"aria-label":s.containerTitle,role:"region",title:s.containerTitle,divider:!t,className:q(["account-payment-methods-header-title",["account-payment-methods-header",t]]),level:t?2:1}):null,d?a(Pe,{className:"account-payment-methods__alert",type:"error",variant:"secondary",heading:s.loadError,description:d,icon:a(lt,{}),"data-testid":"paymentMethodsLoadError"}):null,u&&!d?a(Pe,{className:"account-payment-methods__alert",type:"error",variant:"secondary",heading:m,icon:a(lt,{}),"data-testid":"paymentMethodsActionError"}):null,a(aa,{open:f!==null,submitLoading:f!==null&&h===f.publicHash,onRemoveToken:()=>{p()},closeModal:b,cardBrand:f==null?void 0:f.cardBrand,lastFourDigits:f==null?void 0:f.lastFourDigits,expired:f==null?void 0:f.expired,variant:f==null?void 0:f.variant,minifiedView:t}),l?a(Je,{testId:"paymentMethodsLoader"}):a("div",{className:"account-payment-methods__list",children:_??g})]})},aa=({open:e,submitLoading:n,onRemoveToken:t,closeModal:r,cardBrand:s,lastFourDigits:o,expired:l,variant:d,minifiedView:u})=>{const h=Q({title:"Account.Payments.removePaymentModal.title",description:"Account.Payments.removePaymentModal.description",actionCancel:"Account.Payments.removePaymentModal.actionCancel",actionConfirm:"Account.Payments.removePaymentModal.actionConfirm"});return e?a(Ft,{className:"account-payment-modal--overlay",title:a("h3",{children:h.title}),size:"full","data-testid":"paymentModal",showCloseButton:!0,onClose:r,children:P("div",{className:"account-payment-modal",children:[n?a("div",{className:"account-payment-modal__spinner","data-testid":"progressSpinner",children:a(Zt,{stroke:"4",size:"large"})}):null,a("p",{children:h.description}),s&&o?a(Kt,{cardBrand:s,lastFourDigits:o,expired:l,variant:d,minifiedView:u}):null,P("div",{className:"account-payment-modal__buttons",children:[a(ie,{type:"button",onClick:r,variant:"secondary",disabled:n,children:h.actionCancel}),a(ie,{disabled:n,onClick:t,children:h.actionConfirm})]})]})}):null},xe=({hideActionFormButtons:e,formName:n,showFormLoader:t,showSaveCheckBox:r,saveCheckBoxValue:s,forwardFormRef:o,slots:l,addressesFormTitle:d,className:u,addressFormId:h,inputsDefaultValueSet:i,billingCheckBoxValue:f,shippingCheckBoxValue:y,showBillingCheckBox:b,showShippingCheckBox:p,hasDefaultShippingAddress:m,hasDefaultBillingAddress:_,isOpen:g,fieldIdPrefix:w,onSubmit:v,onCloseBtnClick:I,onSuccess:V,onError:c,onChange:N,isB2BFlow:C,enforceB2BPermissions:O,permissions:M})=>a("div",{className:q(["account-address-form"]),children:a(Kn,{hideActionFormButtons:e,formName:n,showFormLoader:t,slots:l,addressesFormTitle:d,className:u,addressFormId:h,inputsDefaultValueSet:i,shippingCheckBoxValue:y,billingCheckBoxValue:f,showShippingCheckBox:p,showBillingCheckBox:b,hasDefaultShippingAddress:m,hasDefaultBillingAddress:_,isOpen:g,fieldIdPrefix:w,onSubmit:v,onCloseBtnClick:I,onSuccess:V,onError:c,onChange:N,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:s,isB2BFlow:C,enforceB2BPermissions:O,permissions:M})});xe.displayName="AddressForm";const sa={success:a(Jr,{}),warning:a(en,{}),error:a(lt,{})},oa=()=>{const[e,n]=S({}),t=x(r=>{if(!(r!=null&&r.type)){n({});return}const s=sa[r.type];n({...r,icon:s})},[]);return{inLineAlertProps:e,handleSetInLineAlert:t}},da=({ordersInMinifiedView:e,minifiedView:n,pageSize:t,selectedDate:r,selectedPage:s,searchText:o,handleSetFirstOrderDate:l,handleSetInLineAlert:d})=>{const u=Q({searchError:"Account.fullSizeView.OrdersList.OrdersListSearch.error"}),[h,i]=S([]),[f,y]=S({totalPages:1,currentPage:1,pageSize:1}),[b,p]=S(!1),[m,_]=S(""),[g,w]=S(0),v=x(()=>{w(I=>I+1)},[]);return oe(()=>{Ut().then(I=>{_(I.baseMediaUrl)})},[]),oe(()=>{const I=at.on("companyContext/changed",v);return()=>{I==null||I.off()}},[v]),oe(()=>{const I=new AbortController;return p(!0),d==null||d(),_r(n?e:t,r,s,o,I.signal).then(V=>{if(!I.signal.aborted){if(!(V!=null&&V.items)){i([]),d==null||d({type:"error",text:u.searchError});return}y(V.pageInfo),i(V.items),l==null||l(V.dateOfFirstOrder)}}).catch(()=>{I.signal.aborted||(i([]),d==null||d({type:"error",text:u.searchError}))}).finally(()=>{I.signal.aborted||p(!1)}),()=>{I.abort()}},[l,d,n,e,t,r,s,o,g,u.searchError]),{loading:b,orderHistoryListItems:h,pageInfo:f,placeholderImage:m,refetchOrders:v}},rt=(e,n=1)=>{const t=new Date,r=new Date(t);switch(e){case"sixMonthsAgo":{r.setMonth(r.getMonth()-n);break}case"oneYearAgo":{r.setFullYear(r.getFullYear()-n);break}default:return""}return{from:r==null?void 0:r.toISOString().split("T")[0],to:`${t==null?void 0:t.toISOString().split("T")[0]} 23:59:59`}},ca=e=>{const n=[],t=new Date().getFullYear();for(let r=e;r<=t-1;r++)n.push({value:`{"from":"${r}-01-01","to":"${r+1}-01-01 23:59:59"}`,text:r.toString()});return n},la=(e="selectedDate")=>{const n=Q({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[t,r]=S(),[s,o]=S(JSON.stringify(rt("sixMonthsAgo",6))),[l,d]=S(1),[u,h]=S("");oe(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[l]);const i=Ne(()=>{const p=[{value:JSON.stringify(rt("sixMonthsAgo",6)),text:n.pastSixMonths},{value:JSON.stringify(rt("oneYearAgo",1)),text:n.currentYear},{value:"viewAll",text:n.viewAll}];if(t){const _=new Date(t).getFullYear();p==null||p.splice(2,0,...ca(_))}return p},[n,t]),f=x(p=>{r(p)},[]),y=x(p=>{const _=p.target.value;o(_),d(1)},[]),b=x(p=>{h(p),p&&e==="allOrders"&&o("viewAll"),d(1)},[e]);return{selectableDateList:i,selectedDate:s,selectedPage:l,searchText:u,handleSelectDate:y,handleSearch:b,setSelectedPage:d,handleSetFirstOrderDate:f}},ia=({actionLabel:e,actionDisabled:n,clearLabel:t,onClear:r,error:s,...o})=>P("div",{className:q(["account-orders-list__search-input",["account-orders-list__search-input--has-clear",!n],["account-orders-list__search-input--error",!!s]]),children:[a(xt,{...o,error:s,"aria-invalid":!!s}),P("div",{className:"account-orders-list__search-actions",children:[n?null:a(ie,{className:"account-orders-list__search-clear",type:"button",variant:"tertiary",icon:a(Yr,{}),"aria-label":t,onClick:r}),a(ie,{className:"account-orders-list__search-submit",type:"submit",variant:"tertiary",icon:a(Qr,{}),"aria-label":e,disabled:n})]})]}),ua=({handleSearch:e,refetchOrders:n,searchText:t})=>{const r=Q({action:"Account.fullSizeView.OrdersList.OrdersListSearch.action",clear:"Account.fullSizeView.OrdersList.OrdersListSearch.clear",label:"Account.fullSizeView.OrdersList.OrdersListSearch.label",minimumLength:"Account.fullSizeView.OrdersList.OrdersListSearch.minimumLength",placeholder:"Account.fullSizeView.OrdersList.OrdersListSearch.placeholder"}),[s,o]=S(t),[l,d]=S(""),u=Ze(null),h=`${gt()}-order-search`,i=!!(s.trim()||t),f=p=>{d(""),o(p),p!==t?e(p):p&&n()},y=()=>{const p=s.trim();if(p.length>0&&p.length<wr){d(r.minimumLength);return}f(p)},b=()=>{var m;f("");const p=(m=u.current)==null?void 0:m.elements.namedItem("orderSearch");p instanceof HTMLInputElement&&p.focus()};return a("form",{ref:u,className:"account-orders-list__search",role:"search","aria-label":r.action,onSubmit:p=>{p.preventDefault(),y()},children:a(Ie,{label:r.label,error:l||void 0,children:a(ia,{id:h,name:"orderSearch",value:s,maxLength:Br,placeholder:r.placeholder,actionLabel:r.action,actionDisabled:!i,clearLabel:r.clear,onClear:b,onInput:p=>{o(p.currentTarget.value),d("")}})})})},Oa=({className:e,withHeader:n=!0,minifiedView:t=!1,withThumbnails:r=!0,withFilter:s=!0,withSearch:o=!1,searchScope:l="selectedDate",ordersInMinifiedView:d=1,pageSize:u=10,routeOrdersList:h,routeOrderDetails:i,routeReturnDetails:f,routeTracking:y,routeOrderProduct:b,slots:p})=>{const m=t?"minifiedView":"fullSizeView",_=Q({containerTitle:`Account.${m}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${m}.OrdersList.dateOrderPlaced`,loading:"Account.OrdersList.loading",loaded:"Account.OrdersList.loaded"}),{selectableDateList:g,selectedDate:w,handleSelectDate:v,selectedPage:I,searchText:V,handleSearch:c,setSelectedPage:N,handleSetFirstOrderDate:C}=la(l),{inLineAlertProps:O,handleSetInLineAlert:M}=oa(),{pageInfo:B,loading:F,orderHistoryListItems:L,placeholderImage:T,refetchOrders:A}=da({minifiedView:t,pageSize:u,ordersInMinifiedView:d,selectedDate:w,selectedPage:I,searchText:V,handleSetFirstOrderDate:C,handleSetInLineAlert:M});return P("div",{children:[n?a(ke,{"aria-label":_.containerTitle,role:"region",title:_.containerTitle,divider:!t,className:q(["account-orders-list-header-title",["account-orders-list-header",t]]),level:t?2:1}):null,P("div",{className:q(["account-orders-list",e]),children:[a(Ht,{message:F?_.loading:_.loaded}),!t&&(o||s)?P("div",{className:"account-orders-list__controls",children:[s?a(Ie,{className:"account-orders-list__date-select",label:_.dateOrderPlaced,children:a($t,{id:"orderDatePicker",value:w,name:"orderDatePicker","aria-label":_.dateOrderPlaced,options:g,handleSelect:v})}):null,o?a(ua,{handleSearch:c,refetchOrders:A,searchText:V}):null]}):null,O.text?a(Pe,{"data-testid":"ordersListInLineAlert",className:"account-orders-list__notification",type:O.type,variant:"secondary",heading:O.text,icon:O.icon}):null,F?a(le,{children:Array.from(Array(B==null?void 0:B.pageSize).keys()).map(k=>a(Je,{testId:"orderSkeletonLoader",withCard:!1},k))}):a(le,{children:L.length?a(le,{children:L.map((k,Z)=>a(nn,{placeholderImage:T,routeTracking:y,routeOrderProduct:b,routeReturnDetails:f,minifiedView:t,item:k,withThumbnails:r,slots:p,children:p!=null&&p.OrdersListAction?a(Te,{"data-testid":`ordersListActionSlot_${Z}`,name:"OrdersListAction",slot:p==null?void 0:p.OrdersListAction,context:{orderHistoryListItem:k}}):a(Et,{minifiedView:t,orderNumber:k.number,orderToken:k.token,routeOrderDetails:i})},Z))}):a(je,{isEmpty:!L.length,typeList:"orders",minifiedView:t})}),!t&&(B==null?void 0:B.totalPages)>1?a(Vt,{totalPages:B==null?void 0:B.totalPages,currentPage:I,onChange:N}):null,t?a(Et,{minifiedView:t,routeOrdersList:h}):null]})]})};export{Sa as A,xe as AddressForm,Je as C,Na as E,Oa as O,Ma as P,Pa as S,wa as a,Ta as b,Ea as c,Ba as d,xe as default,Yn as e,Ia as f,Tt as g,kn as n,oa as u};
|
|
4
4
|
//# sourceMappingURL=AddressForm.js.map
|