@dropins/storefront-account 4.0.0-beta.1 → 4.0.0-beta.3

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.
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{classes as U,Slot as ae}from"@dropins/tools/lib.js";import{useText as G}from"@dropins/tools/i18n.js";import{jsx as n,Fragment as D,jsxs as _}from"@dropins/tools/preact-jsx-runtime.js";import{Field as de,TextArea as Et,Checkbox as Ze,InputDate as Nt,Picker as ct,Input as Mt,Skeleton as we,SkeletonRow as K,Card as ne,Button as X,Tag as pe,Icon as ve,Modal as it,ProgressSpinner as dt,IllustratedMessage as fe,Image as Ge,Price as $t,ContentGrid as Pt,Header as me,InLineAlert as ue,InputPassword as Le,ToggleButton as Tt,Pagination as lt,Table as St}from"@dropins/tools/components.js";import*as Z from"@dropins/tools/preact-compat.js";import{memo as Be,useMemo as Ce,forwardRef as Ot,useImperativeHandle as It,useId as ut,useCallback as Te}from"@dropins/tools/preact-compat.js";import{useState as $,useEffect as J,useRef as Se,useCallback as x,useMemo as oe}from"@dropins/tools/preact-hooks.js";import{events as Oe}from"@dropins/tools/event-bus.js";import{getStoreConfig as mt,c as ht,a as pt,updateCustomerAddress as Ie,getAttributesForm as ft,getCustomerAddress as Ft,b as kt,removeCustomerAddress as Vt,getCountries as xt,createCustomerAddress as Zt,updateCustomerPassword as Bt,getCustomerPaymentTokens as Ht,deletePaymentToken as Rt,getOrderHistoryList as qt}from"../api.js";import{Fragment as Ke}from"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";const zt=()=>{const e=sessionStorage.getItem("accountStoreConfig");if(!e)return null;try{return JSON.parse(e)}catch(a){return console.error("Failed to parse cached store config:",a),sessionStorage.removeItem("accountStoreConfig"),null}},Ut=()=>{const[e,a]=$(!0),[t,r]=$(null),[s,o]=$(null),d=c=>{const{minLength:l,requiredCharacterClasses:m,shoppingAssistanceEnabled:u,shoppingAssistanceCheckboxTitle:h,shoppingAssistanceCheckboxTooltip:b}=c;r({minLength:l,requiredCharacterClasses:m}),o({shoppingAssistanceEnabled:u,shoppingAssistanceCheckboxTitle:h,shoppingAssistanceCheckboxTooltip:b})};return J(()=>{const c=zt();if(c){d(c),a(!1);return}mt().then(l=>{l&&(sessionStorage.setItem("accountStoreConfig",JSON.stringify(l)),d(l))}).catch(l=>{console.error("Failed to load store config:",l)}).finally(()=>{a(!1)})},[]),{loading:e,passwordConfigs:t,remoteShoppingAssistanceConfigs:s}},ye=({hideActionFormButtons:e,formName:a,showFormLoader:t,showSaveCheckBox:r,saveCheckBoxValue:s,forwardFormRef:o,slots:d,addressesFormTitle:c,className:l,addressFormId:m,inputsDefaultValueSet:u,billingCheckBoxValue:h,shippingCheckBoxValue:b,showBillingCheckBox:A,showShippingCheckBox:y,isOpen:w,fieldIdPrefix:v,onSubmit:f,onCloseBtnClick:E,onSuccess:P,onError:S,onChange:N})=>n("div",{className:U(["account-address-form"]),children:n($r,{hideActionFormButtons:e,formName:a,showFormLoader:t,slots:d,addressesFormTitle:c,className:l,addressFormId:m,inputsDefaultValueSet:u,shippingCheckBoxValue:b,billingCheckBoxValue:h,showShippingCheckBox:y,showBillingCheckBox:A,isOpen:w,fieldIdPrefix:v,onSubmit:f,onCloseBtnClick:E,onSuccess:P,onError:S,onChange:N,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:s})}),Wt=e=>e.reduce((a,t)=>({...a,[t.name]:t.value}),{}),jt=e=>/^\d+$/.test(e),Gt=e=>/^[a-zA-Z0-9\s]+$/.test(e),Kt=e=>/^[a-zA-Z0-9]+$/.test(e),Jt=e=>/^[a-zA-Z]+$/.test(e),Yt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),Dt=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),Xt=(e,a,t)=>{const r=new Date(e).getTime()/1e3;return!(isNaN(r)||r<0||a!==void 0&&r<a||t!==void 0&&r>t)},Je=e=>!e||isNaN(Number(e))?"":new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Qt=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),er=(e,a,t)=>{const r=e.length;return r>=a&&r<=t},$e=(e,a,t,r)=>{var p,L;const{requiredFieldError:s,lengthTextError:o,numericError:d,alphaNumWithSpacesError:c,alphaNumericError:l,alphaError:m,emailError:u,dateError:h,urlError:b,dateLengthError:A}=t,y=a==null?void 0:a.customUpperCode,w={[y]:""};if(r[y]&&delete r[y],a!=null&&a.required&&(!e||e==="false"))return{[y]:s};if(!(a!=null&&a.required)&&!e||!((p=a==null?void 0:a.validateRules)!=null&&p.length))return w;const v=Wt(a==null?void 0:a.validateRules),f=v.MIN_TEXT_LENGTH??1,E=v.MAX_TEXT_LENGTH??255,P=v.DATE_RANGE_MIN,S=v.DATE_RANGE_MAX;if(!er(e,+f,+E)&&!(P||S))return{[y]:o.replace("{min}",f).replace("{max}",E)};if(!Xt(e,+P,+S)&&(P||S))return{[y]:A.replace("{min}",Je(P)).replace("{max}",Je(S))};const i={numeric:{validate:jt,error:d},"alphanum-with-spaces":{validate:Gt,error:c},alphanumeric:{validate:Kt,error:l},alpha:{validate:Jt,error:m},email:{validate:Yt,error:u},date:{validate:Dt,error:h},url:{validate:Qt,error:b}}[v.INPUT_VALIDATION];return i&&!i.validate(e)&&!((L=r[y])!=null&&L.length)?{[y]:i.error}:w},gt=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}},tr=["true","false","yes","on","off"],rr={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:"",uid:""},nr=e=>{const a={},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 d=o[1],c=parseInt(o[2],10);t[d]||(t[d]=[]),t[d].push({index:c,value:s})}else Object.keys(e).filter(c=>c.startsWith(`${r}Multiline_`)).length>0?t[r]=[{index:1,value:s}]:a[r]=s}for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const s=t[r];s.sort((o,d)=>o.index-d.index),a[r]=s.map(o=>o.value)}return a},ar=e=>{const a={},t=[];for(const r in e){const s=tr.includes(e[r])?gt(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(rr,r)?a[r]=s:t.push({code:pt(r),value:s}))}return{...a,customAttributes:t}},le=(e,a=!1)=>{const t=ht(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=ar(nr(t));if(!a)return r;const[s,o]=r.region?r.region.split(","):[];return{...r,region:{regionCode:s,...o&&{regionId:+o}}}},be=e=>{if(!e.current)return{};const a=e.current.elements;return Array.from(a).reduce((r,s)=>(s.name&&(r[s.name]=s.type==="checkbox"?s.checked:s.value),r),{})},Ye=(e,a)=>Object.keys(e).length?Object.keys(e).every(r=>r in a&&a[r]!==""):!1,_e=e=>typeof e=="function",sr=e=>e.reduce((a,{customUpperCode:t,required:r,defaultValue:s})=>(r&&t&&(a.initialData[t]=s||"",a.errorList[t]=""),a),{initialData:{},errorList:{}}),De=e=>Object.keys(e).length>0,or=({fieldsConfig:e,onSubmit:a,onChange:t,setInputChange:r,formName:s})=>{const o=G({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"}),d=Se(null),[c,l]=$({}),[m,u]=$({}),[h,b]=$({}),[A,y]=$(!0),[w,v]=$(!1),[f,E]=$(!1),[P,S]=$(!0),[N,i]=$(!1);J(()=>{const g=()=>{if(d.current){const I=window.getComputedStyle(d.current).getPropertyValue("grid-template-rows").split(" ").length,R=d.current.querySelector(".account-address-form--saveAddressBook");R&&(R.style.gridRow=String(I-1))}};return g(),window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g)}},[e==null?void 0:e.length]);const p=x((g=!1)=>{let T=!0;const I={...m};let R=null;for(const[z,Y]of Object.entries(c)){const H=e==null?void 0:e.find(F=>F.customUpperCode.includes(z)),V=$e(Y.toString(),H,o,I);V[z]&&(Object.assign(I,V),T=!1),R||(R=Object.keys(I).find(F=>I[F])||null)}if(g||u(I),R&&d.current&&!g){const z=d.current.elements.namedItem(R);z==null||z.focus()}return T},[m,e,c,o]),L=x((g,T,I,R)=>{const z={...be(d),[T]:g,...T.includes("countryCode")?{region:""}:{}},Y={data:le(z,!0),isDataValid:Ye(I,z)};i(Y.isDataValid),p(!0),["selectedShippingAddress","selectedBillingAddress"].includes(s)&&sessionStorage.setItem(`${s}_addressData`,JSON.stringify(Y)),t==null||t(Y,{},R)},[p,s,t]);J(()=>{if(e!=null&&e.length){const{initialData:g,errorList:T}=sr(e);l(I=>({...g,...I})),u(T),b(T)}},[JSON.stringify(e)]),J(()=>{if(f)return;const g=be(d),T=sessionStorage.getItem(`${s}_addressData`);if(De(c)&&De(h)){let I={};const R=Ye(h,c);T?I=JSON.parse(T).data:I=le(g,!0)??{},t==null||t({data:I,isDataValid:R},{},null),i(R),E(!0)}},[c,h]),J(()=>{var z;if(!P)return;const g=be(d),T=!!(g!=null&&g.countryCode),I=!!((z=g==null?void 0:g.region)!=null&&z.length);g&&T&&!I&&_e(t)&&L(g==null?void 0:g.region,"region",h,null)},[P,A,e,d,t,L,h,w]);const k=x((g,T)=>{const{name:I,value:R,type:z,checked:Y}=g==null?void 0:g.target,H=z==="checkbox"?Y:R;l(q=>{const O={...q,[I]:H};return I==="countryCode"&&(O.region="",y(!0),v(!1)),O}),r==null||r({[I]:H}),E(!0);const V=e==null?void 0:e.find(q=>q.customUpperCode.includes(I));let F=T?{...T}:{...m};if(V){const q=$e(H.toString(),V,o,F);q&&Object.assign(F,q),u(F)}L(H,I,h,g)},[r,e,m,o,L,h,A]),M=x(g=>{const{name:T}=g==null?void 0:g.target,I=e==null?void 0:e.find(R=>R.customUpperCode===T);T==="region"&&(I!=null&&I.options.length)&&S(!1),S(T==="countryCode")},[]),C=x((g,T)=>{const{name:I,value:R,type:z,checked:Y}=g==null?void 0:g.target,H=z==="checkbox"?Y:R,V=e==null?void 0:e.find(F=>F.customUpperCode===I);if(V){const F=T?{...T}:{...m},q=$e(H.toString(),V,o,F);q&&Object.assign(F,q),u(F)}},[m,e,o]),B=x(g=>{g.preventDefault();const T=p();a==null||a(g,T)},[p,a]);return{isDataValid:N,formData:c,errors:m,formRef:d,handleInputChange:k,onFocus:M,handleBlur:C,handleSubmit:B,handleValidationSubmit:p}};var se=(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))(se||{});const cr=Be(({loading:e,values:a,fields:t=[],errors:r,className:s="",onChange:o,onBlur:d,onFocus:c,slots:l,fieldIdPrefix:m})=>{const u=`${s}__field`,h=Ce(()=>Object.fromEntries(t.flatMap(i=>[[`${i.code}.label`,`Account.AddressForm.fields.${i.code}.label`],[`${i.code}.placeholder`,`Account.AddressForm.fields.${i.code}.placeholder`]])),[t]),b=G(h),A=i=>b[`${i.code}.label`]||i.label,y=i=>`${A(i)} ${i.required?"*":""}`,w=i=>b[`${i.code}.placeholder`]||i.label,v=(i,p)=>{if(!(l!=null&&l[`AddressFormInput_${i.code}`]))return;const L={inputName:i.customUpperCode,handleOnChange:o,handleOnBlur:d,handleOnFocus:c,errorMessage:p,errors:r,config:i};return n(ae,{"data-testid":`addressFormInput_${i.code}`,name:`AddressFormInput_${i.code}`,slot:l[`AddressFormInput_${i.code}`],context:L},i.id)},f=(i,p,L)=>{var M;const k=i.defaultValue??((M=i.options.find(C=>C.isDefault))==null?void 0:M.value)??p??i.defaultValue;return n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:e||i.disabled,children:n(ct,{"aria-label":A(i),"aria-required":i.required?"true":"false",id:m?`${m}_${i.code}`:i.code,required:i==null?void 0:i.required,name:i.customUpperCode,floatingLabel:y(i),placeholder:w(i),options:i.options,onBlur:d,onFocus:c,handleSelect:o,defaultValue:k,value:k})},i.id)})},E=(i,p,L)=>n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:e,children:n(Mt,{"aria-label":A(i),"aria-required":i.required?"true":"false",id:m?`${m}_${i.code}`:i.code,type:"text",name:i.customUpperCode,value:p??i.defaultValue,placeholder:w(i),floatingLabel:y(i),onBlur:d,onFocus:c,onChange:o})},i.id)}),P=(i,p,L)=>n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:e||i.disabled,children:n(Nt,{"aria-label":A(i),"aria-required":i.required?"true":"false",id:m?`${m}_${i.code}`:i.code,type:"text",name:i.customUpperCode,value:p||i.defaultValue,placeholder:w(i),floatingLabel:y(i),onBlur:d,onChange:o,disabled:e||i.disabled})},i.id)}),S=(i,p,L)=>n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:(i==null?void 0:i.isHidden)??e,children:n(Ze,{"aria-label":A(i),"aria-required":i.required?"true":"false","aria-hidden":i.isHidden,tabindex:i!=null&&i.isHidden?-1:0,id:m?`${m}_${i.code}`:i.code,name:i.customUpperCode,checked:p||i.defaultValue,placeholder:w(i),label:y(i),onBlur:d,onChange:o})},i.id)}),N=(i,p,L)=>n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:e,children:n(Et,{"aria-label":A(i),"aria-required":i.required?"true":"false",id:m?`${m}_${i.code}`:i.code,type:"text",name:i.customUpperCode,value:p??i.defaultValue,label:y(i),onBlur:d,onChange:o})},i.id)});return t.length?n(D,{children:t.map(i=>{const p=r==null?void 0:r[i.customUpperCode],L=a==null?void 0:a[i.customUpperCode];switch(i.fieldType){case se.TEXT:return i.options.length?f(i,L,p):E(i,L,p);case se.MULTILINE:return E(i,L,p);case se.SELECT:return f(i,L,p);case se.DATE:return P(i,L,p);case se.BOOLEAN:return S(i,L,p);case se.TEXTAREA:return N(i,L,p);default:return null}})}):null}),Ee=({testId:e,withCard:a=!0})=>{const t=_(we,{"data-testid":e||"skeletonLoader",children:[n(K,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),n(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),n(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return a?t:n(ne,{variant:"secondary",className:U(["account-account-loaders","account-account-loaders--card-loader"]),children:t})},ir=()=>_(we,{"data-testid":"addressFormLoader",children:[n(K,{variant:"heading",size:"medium"}),n(K,{variant:"empty",size:"medium"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large",fullWidth:!0}),n(K,{size:"large",fullWidth:!0,lines:3}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large",fullWidth:!0})]}),At=Be(Ot(({setInputChange:e,showFormLoader:a,slots:t,name:r,loading:s,children:o,className:d="defaultForm",fieldsConfig:c,onSubmit:l,onChange:m,forwardFormRef:u,regionOptions:h,showSaveCheckBox:b,handleSaveCheckBoxAddress:A,saveCheckBoxAddress:y,fieldIdPrefix:w})=>{const v=G({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:f,formData:E,errors:P,formRef:S,handleInputChange:N,handleBlur:i,handleSubmit:p,handleValidationSubmit:L,onFocus:k}=or({fieldsConfig:c,onSubmit:l,onChange:m,setInputChange:e,formName:r});return It(u,()=>{const M=be(S);return{handleValidationSubmit:L,requestSubmit:()=>{var C;(C=S.current)==null||C.requestSubmit()},formData:le(M,!0),isDataValid:f}}),a||!(c!=null&&c.length)?n(ir,{}):_("form",{className:U(["account-form",d]),onSubmit:p,name:r,ref:S,children:[n(cr,{className:d,loading:s,fields:c,onChange:N,onBlur:i,errors:P,values:E,onFocus:k,slots:t,fieldIdPrefix:w}),t!=null&&t.AddressFormInputs?n(ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:t.AddressFormInputs,context:{formActions:{handleChange:N}}}):null,b?n("div",{className:"account-address-form--saveAddressBook",children:n(Ze,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:v.saveAddressBook,checked:y,onChange:M=>{N(M),A==null||A(M)}})}):null,o]})})),Xe=(e,a,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 d="default";return e&&a?d="shippingAndBilling":e?d="shipping":a&&(d="billing"),s?o[d].remove:o[d].edit},Fe=({slots:e,selectable:a,selectShipping:t,selectBilling:r,variant:s="secondary",minifiedView:o,keysSortOrder:d,addressData:c,loading:l,setAddressId:m,handleRenderModal:u,handleRenderForm:h})=>{const b=ut(),A=o?"minifiedView":"fullSizeView",y=G({actionRemove:`Account.${A}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${A}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${A}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${A}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${A}.Addresses.addressCard.defaultLabelText`,editAddressAriaLabelDefault:`Account.${A}.Addresses.addressCard.ariaLabel.editButton.default`,editAddressAriaLabelShipping:`Account.${A}.Addresses.addressCard.ariaLabel.editButton.shipping`,editAddressAriaLabelBilling:`Account.${A}.Addresses.addressCard.ariaLabel.editButton.billing`,editAddressAriaLabelShippingAndBilling:`Account.${A}.Addresses.addressCard.ariaLabel.editButton.shippingAndBilling`,removeAddressAriaLabelDefault:`Account.${A}.Addresses.addressCard.ariaLabel.removeButton.default`,removeAddressAriaLabelShipping:`Account.${A}.Addresses.addressCard.ariaLabel.removeButton.shipping`,removeAddressAriaLabelBilling:`Account.${A}.Addresses.addressCard.ariaLabel.removeButton.billing`,removeAddressAriaLabelShippingAndBilling:`Account.${A}.Addresses.addressCard.ariaLabel.removeButton.shippingAndBilling`}),w=y.cardLabelBilling.toLocaleUpperCase(),v=y.cardLabelShipping.toLocaleUpperCase(),f=y.defaultLabelText.toLocaleUpperCase(),E=Ce(()=>{const M={shippingLabel:v,billingLabel:w,hideShipping:!1,hideBilling:!1};return a?t&&!r?{shippingLabel:f,billingLabel:f,hideShipping:!1,hideBilling:!0}:r&&!t?{shippingLabel:f,billingLabel:f,hideShipping:!0,hideBilling:!1}:M:M},[w,f,v,r,t,a]),P=Te(()=>{m==null||m(c==null?void 0:c.id),u==null||u()},[u,c==null?void 0:c.id,m]),S=Te(()=>{m==null||m(c==null?void 0:c.id),h==null||h()},[h,c==null?void 0:c.id,m]),N=Ce(()=>{if(!d)return[];const{region:M,...C}=c,B={...C,...M};return d.filter(({name:g})=>B[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:B[g.name],label:g.label}))},[c,d]),{shippingLabel:i,billingLabel:p,hideShipping:L,hideBilling:k}=E;return n(ne,{variant:s,className:"account-address-card","data-testid":"addressCard",children:l?n(Ee,{}):_(D,{children:[_("div",{className:"account-address-card__action",children:[u?n(X,{type:"button",variant:"tertiary",onClick:P,"data-testid":"removeButton","aria-label":Xe(c==null?void 0:c.defaultShipping,c==null?void 0:c.defaultBilling,y,"removeButton"),"aria-describedby":b,children:y.actionRemove}):null,h?n(X,{type:"button",variant:"tertiary",onClick:S,className:"account-address-card__action--editbutton","data-testid":"editButton","aria-label":Xe(c==null?void 0:c.defaultShipping,c==null?void 0:c.defaultBilling,y,"editButton"),"aria-describedby":b,children:y.actionEdit}):null]}),n("div",{className:"account-address-card__description",id:b,children:e!=null&&e.AddressCard?n(ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:N}}):n(D,{children:N.map((M,C)=>{const B=M.label?`${M.label}: ${M==null?void 0:M.value}`:M==null?void 0:M.value;return n("p",{"data-testid":`${M.name}_${C}`,children:B},C)})})}),(c!=null&&c.defaultShipping||c!=null&&c.defaultBilling)&&!a?_("div",{className:"account-address-card__labels",children:[c!=null&&c.defaultShipping?n(pe,{label:v}):null,c!=null&&c.defaultBilling?n(pe,{label:w}):null]}):null,a?_("div",{className:"account-address-card__labels",children:[!L&&(c!=null&&c.defaultShipping)?n(pe,{label:i}):null,!k&&(c!=null&&c.defaultBilling)?n(pe,{label:p}):null]}):null]})})},dr=e=>Z.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},Z.createElement("g",{id:"Large"},Z.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Z.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},Z.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"}),Z.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"})))),lr=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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"})),ur=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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}),Z.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}),Z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),Z.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}),Z.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=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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"}),Z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),ke=e=>Z.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},Z.createElement("g",{id:"Large"},Z.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Z.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},Z.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"})))),mr=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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"})),Yr=e=>Z.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},Z.createElement("g",{clipPath:"url(#clip0_841_1324)"},Z.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"}),Z.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"})),Z.createElement("defs",null,Z.createElement("clipPath",{id:"clip0_841_1324"},Z.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)",strokeWidth:1})))),Qe=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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"}),Z.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"})),et=({selectable:e,className:a,addNewAddress:t,minifiedView:r,routeAddressesPage:s})=>{const o=r?"minifiedView":"fullSizeView",d=G({viewAllAddressesButton:`Account.${o}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${o}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${o}.Addresses.differentAddressButton`}),c=e?"span":"button",l=e?{}:{AriaRole:"button",type:"button"},m=r&&!t?d.viewAllAddressesButton:d.addNewAddressButton,u=e?d.differentAddressButton:m;return _(c,{...l,className:U(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],a]),"data-testid":"showRouteFullAddress",onClick:s,children:[n("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:u}),n(ve,{source:r&&!t?ke:dr,size:"32"})]})},hr=({minifiedView:e,keysSortOrder:a,addressData:t,open:r,submitLoading:s,onRemoveAddress:o,closeModal:d})=>{const c=e?"minifiedView":"fullSizeView",l=G({title:`Account.${c}.Addresses.removeAddressModal.title`,description:`Account.${c}.Addresses.removeAddressModal.description`,actionCancel:`Account.${c}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${c}.Addresses.removeAddressModal.actionConfirm`});return r?n(it,{className:"account-address-modal--overlay",title:n("h3",{children:l.title}),size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:d,children:_("div",{className:"account-address-modal",children:[s?n("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:n(dt,{stroke:"4",size:"large"})}):null,n("p",{children:l.description}),n(Fe,{minifiedView:e,addressData:t,keysSortOrder:a}),_("div",{className:"account-address-modal__buttons",children:[n(X,{type:"button",onClick:d,variant:"secondary",disabled:s,children:l.actionCancel}),n(X,{disabled:s,onClick:o,children:l.actionConfirm})]})]})}):null},He=({typeList:e,isEmpty:a,minifiedView:t,className:r})=>{const s=t?"minifiedView":"fullSizeView",o=G({addressesMessage:`Account.${s}.EmptyList.Addresses.message`,ordersListMessage:`Account.${s}.EmptyList.OrdersList.message`,paymentsMessage:`Account.${s}.EmptyList.Payments.message`}),d=Ce(()=>{switch(e){case"address":return{icon:lr,text:n("p",{children:o.addressesMessage})};case"orders":return{icon:mr,text:n("p",{children:o.ordersListMessage})};case"payments":return{icon:ur,text:n("p",{children:o.paymentsMessage})};default:return{icon:"",text:""}}},[e,o]);return!a||!e||!d.text?null:n(fe,{className:U(["account-empty-list",t?"account-empty-list--minified":"",r]),message:d.text,icon:n(ve,{source:d.icon}),"data-testid":"emptyList"})},tt={size:"32",stroke:"2"},rt=({minifiedView:e,orderNumber:a,orderToken:t,routeOrdersList:r,routeOrderDetails:s})=>{const o=e?"minifiedView":"fullSizeView",d=G({viewAllOrdersButton:`Account.${o}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${o}.OrdersList.ariaLabelLink`});return r?n("a",{className:U(["account-orders-list-action",["account-orders-list-action--minifiedView",e]]),"data-testid":"ordersListActionButtonMinifiedView",href:r(),children:n(ne,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:_("div",{className:"account-orders-list-action__card-wrapper",children:[n("p",{children:d.viewAllOrdersButton}),n(ve,{source:ke,...tt})]})})}):n("a",{"aria-label":`${d.ariaLabelLink} ${a??t}`,href:_e(s)?s(a,t):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:n(ve,{source:ke,...tt})})},pr=()=>{const[e,a]=$(window.innerWidth<768);return J(()=>{const t=()=>{a(window.innerWidth<768)};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),e},fr=({placeholderImage:e,minifiedView:a,item:t,withThumbnails:r,children:s,slots:o,routeTracking:d,routeOrderProduct:c,routeReturnDetails:l,...m})=>{var w,v,f,E,P,S,N,i,p,L,k,M;const u=a?"minifiedView":"fullSizeView",h=G({orderNumber:`Account.${u}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${u}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${u}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${u}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${u}.OrdersList.OrdersListCard.orderDate`,placedByAdministrator:`Account.${u}.OrdersList.OrdersListCard.placedByAdministrator`}),b=pr(),A=_e(c),y=oe(()=>((t==null?void 0:t.items)??[]).map((C,B)=>{var T,I;const g={title:(C==null?void 0:C.productName)??"",src:((I=(T=C==null?void 0:C.product)==null?void 0:T.smallImage)==null?void 0:I.url)||e,alt:(C==null?void 0:C.productName)??"",width:65,height:65,loading:"eager"};return n(ae,{name:"OrderItemImage",slot:o==null?void 0:o.OrderItemImage,context:{data:C,defaultImageProps:g},children:A?n("a",{href:(c==null?void 0:c(C))??"",target:"_blank",rel:"noreferrer",children:n(Ge,{...g})}):n(Ge,{...g})},`${B}_${C.id}`)}),[A,t.items,e,c,o==null?void 0:o.OrderItemImage]);return _(ne,{variant:"secondary",...m,className:U(["account-orders-list-card",["account-orders-list-card--full",((w=t==null?void 0:t.items)==null?void 0:w.length)>6]]),children:[n("div",{className:"account-orders-list-card__content",children:o!=null&&o.OrdersListCard?n(ae,{"data-testid":`ordersListCard${t.id}`,name:"OrdersListCard",slot:o==null?void 0:o.OrdersListCard,context:{orderHistoryListItem:t}}):_(D,{children:[n("div",{children:t==null?void 0:t.status}),(t==null?void 0:t.adminAssistedOrder)>0&&n("div",{children:h.placedByAdministrator}),o!=null&&o.OrdersListOrderTime?n(ae,{"data-testid":`ordersListOrderTime${t.id}`,name:"OrdersListOrderTime",slot:o==null?void 0:o.OrdersListOrderTime,context:{deliveryDateText:h.deliveryDateText,orderDate:t==null?void 0:t.orderDate,orderTime:t==null?void 0:t.orderTime}}):_("p",{children:[h.deliveryDateText," ",t==null?void 0:t.orderDate]}),_("p",{children:[h.orderNumber," ",t.number]}),(v=t==null?void 0:t.shipments)==null?void 0:v.map(C=>{var B;return(B=C==null?void 0:C.tracking)==null?void 0:B.map(g=>{const T=d==null?void 0:d(g);return _("p",{"data-testid":g.number,children:[n("span",{children:`${h.carrier} ${g.carrier.toLocaleUpperCase()} `}),T?n("a",{href:T,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:g.number}):n("span",{className:"account-orders-list-card__content--track_number",children:g.number})]},C.id)})}),t!=null&&t.returns&&((f=t.returns)!=null&&f.length)?_("p",{"data-testid":t.number,children:[_("span",{children:[h.returnsText," "]}),(E=t==null?void 0:t.returns)==null?void 0:E.map(C=>n("span",{"data-testid":C.number,children:_("a",{href:(l==null?void 0:l({orderNumber:t.number,orderToken:t.token,returnNumber:C.number}))??"#",className:"account-orders-list-card__content--return_number",children:[C.number," "]})},C.uid))]},t.id):null,n("p",{children:n($t,{amount:((S=(P=t==null?void 0:t.total)==null?void 0:P.grandTotal)==null?void 0:S.value)??0,currency:(i=(N=t==null?void 0:t.total)==null?void 0:N.grandTotal)==null?void 0:i.currency,weight:"normal",size:"medium"})}),_("p",{"data-testid":"itemsAmount",children:[(p=t==null?void 0:t.items)!=null&&p.length?(L=t==null?void 0:t.items)==null?void 0:L.reduce((C,B)=>{const g=(B==null?void 0:B.quantityOrdered)||0;return C+g},0):0," ",h.itemsAmount]}),(k=t==null?void 0:t.items)==null?void 0:k.map((C,B)=>{if(B>=0&&B<10)return _("p",{className:"account-orders-list-card__content--product-name",children:[_("span",{className:"account-orders-list-card__content--quantity",children:[(C==null?void 0:C.quantityOrdered)>1?C==null?void 0:C.quantityOrdered:null," "]}),C==null?void 0:C.productName.replaceAll("-"," ")]},`${B}_${C.id}`);if(B===11)return n("p",{children:"..."},"ellipsis")})]})}),r&&((M=t==null?void 0:t.items)!=null&&M.length)?n(Pt,{maxColumns:b?3:9,emptyGridContent:n(D,{}),className:U(["account-orders-list-card__images",["account-orders-list-card__images-3",b]]),"data-testid":"ordersListCardImages",children:y}):null,n("div",{className:"account-orders-list-card__actions",children:s})]})},gr=async(e,a)=>{if(a.length===1){const d=a[0],l=Object.values(d.region).every(u=>!!u)?{}:{region:{...d.region,regionId:0}};return!!await Ie({addressId:Number(d==null?void 0:d.id),defaultShipping:!1,defaultBilling:!1,...l})}const t=a.filter(d=>d.id!==e&&(d.defaultBilling||d.defaultShipping)||d.id!==e),r=a[a.length-1],s=t[0]||((r==null?void 0:r.id)!==e?r:null);return!s||!s.id?!1:!!await Ie({addressId:+s.id,defaultShipping:!0,defaultBilling:!0})},Ar=["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"],Dr=["email","firstname","lastname","middlename","gender","dob","prefix","suffix","fax"],yt=(e,a,t)=>{if(a&&t||!a&&!t)return e;const r=e.slice();return a?r.sort((s,o)=>Number(o.defaultShipping)-Number(s.defaultShipping)):t?r.sort((s,o)=>Number(o.defaultBilling)-Number(s.defaultBilling)):e},Ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(Ve),yr=({selectShipping:e,selectBilling:a,defaultSelectAddressId:t,onAddressData:r,minifiedView:s,routeAddressesPage:o,onSuccess:d})=>{const[c,l]=$(""),[m,u]=$(!1),[h,b]=$(!1),[A,y]=$(!1),[w,v]=$(!1),[f,E]=$(!1),[P,S]=$(""),[N,i]=$([]),[p,L]=$([]),k=x(async()=>{y(!0),Promise.all([ft("shortRequest"),Ft()]).then(H=>{const[V,F]=H;if(V){const q=V.map(({name:O,orderNumber:W,label:j})=>({name:kt(O),orderNumber:W,label:Ar.includes(O)?null:j}));L(q)}if(F)if(s){const q=F.filter(W=>!!W.defaultShipping||!!W.defaultBilling),O=q.length?q:F.slice(-1);i(O)}else i(F)}).finally(()=>{y(!1)})},[s]);J(()=>{k()},[k]),J(()=>{var H;if(N.length)if(t===0)E(!0),l("0");else{const V=N.find(q=>{var O;return typeof t=="string"?q.uid===t||((O=q.id)==null?void 0:O.toString())===t:+q.id===t})||yt(N,e,a)[0],F={data:le(V),isDataValid:!Ve(V)};l(((H=V==null?void 0:V.id)==null?void 0:H.toString())||(V==null?void 0:V.uid)||""),r==null||r(F)}},[N,t,r,a,e]);const M=x(H=>{S(H),E(!1)},[]),C=x((H,V)=>{const F=(H==null?void 0:H.target).value,q=(H==null?void 0:H.target).nextSibling;l(F);const O={data:le(V),isDataValid:!Ve(le(V))};r==null||r(O),E(F==="0"),q&&(q.focus(),window.scrollBy(0,100))},[r]),B=x(()=>{b(!0)},[]),g=x(()=>{S(""),b(!1),u(!1)},[]),T=x(()=>{u(!0)},[]),I=x(async()=>{v(!0),await gr(P,N),Vt(+P).then(()=>{k(),g()}).finally(()=>{v(!1)})},[N,P,g,k]),R=x(()=>{E(!1)},[]),z=x(()=>{_e(o)&&s&&!f?window.location.href=o():(E(!0),S(""))},[f,o,s]),Y=x(async()=>{await k(),await(d==null?void 0:d())},[k,d]);return{keysSortOrder:p,submitLoading:w,isModalRendered:m,isFormRendered:h,loading:A,addNewAddress:f,addressesList:N,addressId:P,handleRenderForm:B,handleRenderModal:T,removeAddress:I,onCloseBtnClick:g,setEditingAddressId:M,closeNewAddressForm:R,redirectToAddressesRoute:z,handleOnSuccess:Y,handleSelectAddressOption:C,selectedAddressOption:c}},Xr=Be(({minifiedViewKey:e,hideActionFormButtons:a=!1,inputName:t,slots:r,title:s="",addressFormTitle:o="",defaultSelectAddressId:d="",showFormLoader:c=!1,onAddressData:l,forwardFormRef:m,className:u,showSaveCheckBox:h=!1,saveCheckBoxValue:b=!1,selectShipping:A=!1,selectBilling:y=!1,selectable:w=!1,withHeader:v=!0,minifiedView:f=!1,withActionsInMinifiedView:E=!1,withActionsInFullSizeView:P=!0,inputsDefaultValueSet:S,showShippingCheckBox:N=!0,showBillingCheckBox:i=!0,shippingCheckBoxValue:p=!0,billingCheckBoxValue:L=!0,routeAddressesPage:k,onSubmit:M,onSuccess:C,onError:B,fieldIdPrefix:g})=>{const T=G({containerTitle:`Account.${e}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${e}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${e}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${e}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${e}.Addresses.newAddressFormTitle`,ariaLabelAddressPicker:`Account.${e}.Addresses.ariaLabelAddressPicker`}),{keysSortOrder:I,submitLoading:R,isModalRendered:z,isFormRendered:Y,loading:H,addNewAddress:V,addressesList:F,addressId:q,handleRenderForm:O,handleRenderModal:W,removeAddress:j,onCloseBtnClick:ee,handleOnSuccess:Q,setEditingAddressId:te,closeNewAddressForm:he,redirectToAddressesRoute:Re,handleSelectAddressOption:qe,selectedAddressOption:ze}=yr({defaultSelectAddressId:d,minifiedView:f,routeAddressesPage:k,onSuccess:C,onAddressData:l,selectShipping:A,selectBilling:y}),ge=s||T.containerTitle;let Ne=null;if(w){const re=yt(F,A,y)||[];let ce;V?ce=n("div",{className:U(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",V]]),children:n(ye,{slots:r,hideActionFormButtons:a,fieldIdPrefix:g,formName:t,showFormLoader:c,isOpen:V,forwardFormRef:m,showSaveCheckBox:h,saveCheckBoxValue:b,shippingCheckBoxValue:p,billingCheckBoxValue:L,addressesFormTitle:o||T.differentAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:N,showBillingCheckBox:i,onCloseBtnClick:he,onChange:l,onError:B,onSubmit:M,onSuccess:Q})}):re.length?ce=n(et,{selectable:w,minifiedView:f,addNewAddress:V,routeAddressesPage:Re}):ce=null;const Ue=`generalLabel_${ge.replace(/\s+/g,"")}`;Ne=_("div",{className:"account-addresses-wrapper--select-view",children:[n("span",{id:Ue,style:"display: none;",children:ge}),re.map((ie,wt)=>{var je;const Ae=((je=ie.id)==null?void 0:je.toString())||ie.uid,Me=`${t}_${Ae}`,We=`${Me}_label`;return _(Ke,{children:[n("input",{"data-testid":`radio-${wt+1}`,type:"radio",name:t,id:Me,value:Ae,checked:ze===Ae,onChange:_t=>qe(_t,ie),"aria-labelledby":`${Ue} ${We}`}),n("label",{id:We,htmlFor:Me,className:"account-addresses-wrapper__label",children:n(Fe,{slots:r,selectable:w,selectShipping:A,selectBilling:y,minifiedView:f,addressData:ie,keysSortOrder:I,loading:H})})]},Ae)}),ce&&_("div",{className:"account-addresses-wrapper__footer-section",children:[n("input",{"aria-label":`${ge} ${T.ariaLabelAddressPicker}`,"data-testid":"radio-0",type:"radio",name:t,id:`${t}_addressActions`,value:"0",checked:ze==="0",onChange:ie=>qe(ie,{}),tabindex:ce?0:-1}),n("label",{htmlFor:`${t}_addressActions`,className:"account-addresses-wrapper__label",children:ce})]})]})}else Ne=_(D,{children:[F.map(re=>n(Ke,{children:q===re.id&&Y?n(ne,{variant:"secondary",style:{marginBottom:20},children:n(ye,{slots:r,fieldIdPrefix:g,isOpen:q===re.id&&Y,addressFormId:q,inputsDefaultValueSet:re,addressesFormTitle:T.editAddressFormTitle,showShippingCheckBox:N,showBillingCheckBox:i,shippingCheckBoxValue:p,billingCheckBoxValue:L,forwardFormRef:m,onCloseBtnClick:ee,onChange:l,onError:B,onSubmit:M,onSuccess:Q})}):n(Fe,{slots:r,minifiedView:f,addressData:re,keysSortOrder:I,loading:H,setAddressId:te,handleRenderModal:f&&E||!f&&P?W:void 0,handleRenderForm:f&&E||!f&&P?O:void 0},re.id)},re.id)),n("div",{className:"account-addresses__footer",children:V?n(ne,{variant:"secondary",children:n(ye,{slots:r,fieldIdPrefix:g,isOpen:V,addressesFormTitle:T.newAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:!!(F!=null&&F.length),showBillingCheckBox:!!(F!=null&&F.length),shippingCheckBoxValue:p,billingCheckBoxValue:L,forwardFormRef:m,onChange:l,onCloseBtnClick:he,onError:B,onSubmit:M,onSuccess:Q})}):n(et,{minifiedView:f,addNewAddress:V,routeAddressesPage:Re})})]});return _("div",{children:[v?n(me,{title:ge,divider:!f,className:f?"account-addresses-header":""}):null,_("div",{className:U(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[n(hr,{minifiedView:f,addressData:F==null?void 0:F.find(re=>re.id===q),keysSortOrder:I,submitLoading:R,open:z,closeModal:ee,onRemoveAddress:j}),H?n(Ee,{testId:"addressSkeletonLoader",withCard:!1}):w?n(ye,{slots:r,hideActionFormButtons:a,fieldIdPrefix:g,formName:t,isOpen:!(F!=null&&F.length),forwardFormRef:m,showSaveCheckBox:h,saveCheckBoxValue:b,shippingCheckBoxValue:p,billingCheckBoxValue:L,inputsDefaultValueSet:S,showShippingCheckBox:N,showBillingCheckBox:i,onChange:l,onCloseBtnClick:he,onError:B,onSubmit:M,onSuccess:Q}):n(He,{isEmpty:!(F!=null&&F.length),typeList:"address",minifiedView:f}),Ne]})]})}),Lt={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Lr={...Lt,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},br={...Lt,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},vr=(e,a)=>a==null?void 0:a.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}),nt=e=>{if(!e)return null;const a=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{a.has(r.name)||a.set(r.name,"false"),r.checked&&a.set(r.name,"true")}),a&&typeof a.entries=="function"){const r=a.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},Cr=({fields:e,addressId:a,countryOptions:t,disableField:r,regionOptions:s,isRequiredRegion:o,isRequiredPostCode:d})=>e.filter(l=>!(a&&(l.customUpperCode==="defaultShipping"||l.customUpperCode==="defaultBilling")&&l.defaultValue)).map(l=>l.customUpperCode==="countryCode"?{...l,options:t,disabled:r}:l.customUpperCode==="postcode"?{...l,required:d}:l.customUpperCode==="region"?{...l,options:s,required:o,disabled:r}:l),wr=(e,a="address")=>{const t=a==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","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:pt(o),value:e[o]})}),s.length>0&&(r.custom_attributesV2=s),r},at=e=>{const a=["street","streetMultiline_1","streetMultiline_2"],t=["on","off","true","false"],r=[],s={};for(const y in e){const w=e[y];t.includes(w)&&(s[y]=gt(w)),a.includes(y)&&r.push(w)}const{street:o,streetMultiline_2:d,streetMultiline_1:c,region:l,...m}=e,[u,h]=l?l.split(","):[void 0,void 0],b=h&&u?{regionId:+h,regionCode:u}:{region:u};return wr({...m,...s,region:{...b},street:r})},_r=(e,a)=>{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=a.find(d=>(d==null?void 0:d.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,d)=>{t[`${r}Multiline_${d+2}`]=o})):t[r]=s}return t},Er=(e,a)=>e&&Object.keys(e).length>0?e:a&&Object.keys(a).length>0?a:{},Nr=({showFormLoader:e,showSaveCheckBox:a,saveCheckBoxValue:t,addressFormId:r,billingCheckBoxValue:s,shippingCheckBoxValue:o,showShippingCheckBox:d,showBillingCheckBox:c,inputsDefaultValueSet:l,onCloseBtnClick:m,onSuccess:u,onError:h,formName:b})=>{const[A,y]=$({text:"",type:"success"}),[w,v]=$(e??!1),[f,E]=$(r||""),[P,S]=$([]),[N,i]=$(null),[p,L]=$(()=>{var W,j;const O=sessionStorage.getItem(`${b}_addressData`);return O?{countryCode:(j=(W=JSON.parse(O))==null?void 0:W.data)==null?void 0:j.countryCode}:l}),[k,M]=$(!1),[C,B]=$(()=>{var j,ee;const O=sessionStorage.getItem(`${b}_addressData`);return O?(ee=(j=JSON.parse(O))==null?void 0:j.data)==null?void 0:ee.saveAddressBook:t}),g=x(O=>{B(O.target.checked)},[]);J(()=>{typeof e>"u"||v(e)},[e]),J(()=>{ft(f?"customer_address_edit":"customer_register_address").then(O=>{S(O)})},[f]),J(()=>{M(!0),xt().then(({availableCountries:O,countriesWithRequiredRegion:W,optionalZipCountries:j})=>{i({availableCountries:O,countriesWithRequiredRegion:W,optionalZipCountries:j}),M(!1)})},[]);const T=oe(()=>(N==null?void 0:N.availableCountries)||[],[N]),I=oe(()=>!(p!=null&&p.countryCode)||!N?!1:N.countriesWithRequiredRegion.includes(p.countryCode),[p==null?void 0:p.countryCode,N]),R=oe(()=>!(p!=null&&p.countryCode)||!N?!0:!N.optionalZipCountries.includes(p.countryCode),[p==null?void 0:p.countryCode,N]),z=oe(()=>{var W;if(!(p!=null&&p.countryCode)||!N)return[];const O=N.availableCountries.find(j=>j.value===p.countryCode);return((W=O==null?void 0:O.availableRegions)==null?void 0:W.map(j=>({text:j.name,value:`${j.code},${j.id}`})))||[]},[p==null?void 0:p.countryCode,N]),Y=x(()=>{y({text:"",type:"success"}),m==null||m()},[m]),H=x(async(O,W)=>{if(!W)return null;v(!0);const j=nt(O.target),ee=at(j);await Ie(ee).then(()=>{var Q;u==null||u(),m==null||m(),(Q=O==null?void 0:O.target)==null||Q.reset()}).catch(Q=>{y(te=>({...te,text:Q.message,type:"error"})),h==null||h(Q)}).finally(()=>{E(""),v(!1)})},[m,h,u]),V=x(async(O,W)=>{if(!W)return;v(!0);const{saveAddressBook:j,...ee}=nt(O.target),Q=at(ee);await Zt(Q).then(()=>{var te;u==null||u(),m==null||m(),(te=O==null?void 0:O.target)==null||te.reset()}).catch(te=>{y(he=>({...he,text:te.message,type:"error"})),h==null||h(te)}).finally(()=>{E(""),v(!1)})},[m,h,u]),F=oe(()=>{if(!P.length)return[];const O={...Lr,defaultValue:o??!1,isHidden:a&&!C?!0:!d},W={...br,defaultValue:s??!1,isHidden:a&&!C?!0:!c},j=[...P,O,W],ee=sessionStorage.getItem(`${b}_addressData`),Q=ee?_r(JSON.parse(ee).data,z):{},te=vr(Er(Q,l),j);return Cr({fields:te,addressId:f,countryOptions:T,disableField:k,regionOptions:z,isRequiredRegion:I,isRequiredPostCode:R})},[P,o,a,C,d,s,c,b,z,l,f,T,k,I,R]),q=x(O=>{L(W=>({...W,...O}))},[]);return{regionOptions:z,saveCheckBoxAddress:C,inLineAlert:A,addressId:f,submitLoading:w,normalizeFieldsConfig:F,handleSaveCheckBoxAddress:g,handleUpdateAddress:H,handleCreateAddress:V,handleOnCloseForm:Y,handleInputChange:q}},Mr=e=>{var s;if(!e||!Array.isArray(e.customAttributes))return e??{};const a={};(s=e==null?void 0:e.customAttributes)==null||s.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(a[o.code]=o.value)});const{customAttributes:t,...r}=e;return{...r,...ht(a,"camelCase",{})}},$r=({hideActionFormButtons:e,formName:a="",showFormLoader:t=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:s=!1,forwardFormRef:o,slots:d,addressesFormTitle:c,className:l,addressFormId:m,inputsDefaultValueSet:u,showShippingCheckBox:h=!0,showBillingCheckBox:b=!0,shippingCheckBoxValue:A=!0,billingCheckBoxValue:y=!0,isOpen:w,fieldIdPrefix:v,onSubmit:f,onCloseBtnClick:E,onSuccess:P,onError:S,onChange:N})=>{const i=G({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{inLineAlert:p,addressId:L,submitLoading:k,normalizeFieldsConfig:M,handleUpdateAddress:C,handleCreateAddress:B,handleOnCloseForm:g,handleSaveCheckBoxAddress:T,saveCheckBoxAddress:I,handleInputChange:R,regionOptions:z}=Nr({showFormLoader:t,addressFormId:m,inputsDefaultValueSet:Mr(u),shippingCheckBoxValue:A,billingCheckBoxValue:y,showShippingCheckBox:h,showBillingCheckBox:b,saveCheckBoxValue:s,showSaveCheckBox:r,onSuccess:P,onError:S,onCloseBtnClick:E,formName:a}),[Y,H]=$(0);return J(()=>{H(V=>V+1)},[u]),w?_("div",{className:U(["account-address-form-wrapper",l]),children:[c?n("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:c}):null,p.text?n(ue,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:p.type,variant:"secondary",heading:p.text,icon:p.icon}):null,_(At,{regionOptions:z,forwardFormRef:o,slots:d,className:"account-address-form",name:a||"addressesForm",fieldsConfig:M,onSubmit:f||(L?C:B),setInputChange:R,loading:k,showFormLoader:t,showSaveCheckBox:r,handleSaveCheckBoxAddress:T,saveCheckBoxAddress:I,onChange:N,fieldIdPrefix:v,children:[L?n("input",{type:"hidden",name:"addressId",value:L,"data-testid":"hidden_test_id"}):null,e?null:n("div",{className:U(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:d!=null&&d.AddressFormActions?n(ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:d.AddressFormActions,context:{handleUpdateAddress:C,handleCreateAddress:B,addressId:L}}):n(D,{children:r?null:_(D,{children:[n(X,{type:"button",onClick:g,variant:"secondary",disabled:k,children:i.secondaryButton}),n(X,{disabled:k,children:i.primaryButton})]})})})]},Y)]}):null},Pr=({currentPassword:e,newPassword:a,confirmPassword:t,translations:r})=>{let s={...xe};const o=!e.length&&!a.length&&!t.length,d=e.length&&a!==t;return o?(s={...s,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:s}):e.length?a.length?t.length?d?(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})},bt=(e,a)=>{if(a<=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>=a},xe={currentPassword:"",newPassword:"",confirmPassword:""},Tr=({passwordConfigs:e,handleSetInLineAlert:a,handleHideChangePassword:t})=>{const r=G({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]=$(!1),[d,c]=$(!1),[l,m]=$(""),[u,h]=$(""),[b,A]=$(""),[y,w]=$({currentPassword:"",newPassword:"",confirmPassword:""}),v=x(()=>{t(()=>{a({}),w(xe)})},[t,a]),f=x(p=>{m(p),w(L=>({...L,currentPassword:p?"":r.requiredFieldError}))},[r]),E=x(p=>{h(p),w(L=>({...L,newPassword:p?"":r.requiredFieldError}))},[r]),P=x(p=>{A(p),w(L=>({...L,confirmPassword:p?"":r.requiredFieldError}))},[r]),S=x(p=>{const{name:L,value:k}=p==null?void 0:p.target;w(M=>({...M,[L]:k?"":r.requiredFieldError}))},[r]),N=x(()=>{const{isValid:p,errors:L}=Pr({currentPassword:l,newPassword:u,confirmPassword:b,translations:r});return w(L),p},[l,u,b,r]),i=x(p=>{p.preventDefault(),c(!0);const L=(e==null?void 0:e.requiredCharacterClasses)??0,k=(e==null?void 0:e.minLength)??1;if(!N()){o(!0),c(!1);return}if(!bt(u,L)||k>(u==null?void 0:u.length)){o(!0),c(!1);return}Bt({currentPassword:l,newPassword:u}).then(M=>{if(!(M!=null&&M.length)){c(!1);return}m(""),h(""),A(""),w(xe),o(!1),a({type:"success",text:r.passwordUpdateMessage})}).catch(M=>{M.message==="Invalid login or password."&&a({type:"error",text:r.incorrectCurrentPassword}),M.message==="The account is locked."&&a({type:"error",text:M.message})}),c(!1)},[e,N,u,l,a,r]);return{hideChangePassword:v,handleOnBlurPassword:S,handleConfirmPasswordChange:P,handleNewPasswordChange:E,handleCurrentPasswordChange:f,mutationChangePassword:i,currentPassword:l,newPassword:u,confirmPassword:b,passwordErrors:y,submitLoading:d,isClickSubmit:s}},Sr=({passwordConfigs:e,isClickSubmit:a,password:t})=>{const r=G({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[s,o]=$("pending");J(()=>{if(!e)return;const c=bt(t,e.requiredCharacterClasses);a&&t.length>0?o(c?"success":"error"):a&&t.length===0?o("pending"):o(c?"success":"pending")},[a,e,t]);const d=oe(()=>{var l;if(!e)return;const c={status:"pending",icon:"pending",message:(l=r.messageLengthPassword)==null?void 0:l.replace("{minLength}",`${e.minLength}`)};return t.length&&t.length>=e.minLength?{...c,icon:"success",status:"success"}:t.length&&t.length<e.minLength?a?{...c,icon:"error",status:"error"}:{...c,icon:"pending",status:"pending"}:c},[e,r.messageLengthPassword,t==null?void 0:t.length,a]);return{isValidUniqueSymbols:s,defaultLengthMessage:d}},Or=(e,a,t,r,s)=>e==="error"||(a==null?void 0:a.status)==="error"||t&&r.trim().length===0?s.newPassword:void 0,Qr=({handleHideChangePassword:e,handleSetInLineAlert:a,inLineAlertProps:t})=>{const{passwordConfigs:r}=Ut(),{hideChangePassword:s,handleOnBlurPassword:o,handleConfirmPasswordChange:d,handleNewPasswordChange:c,handleCurrentPasswordChange:l,mutationChangePassword:m,currentPassword:u,newPassword:h,confirmPassword:b,passwordErrors:A,submitLoading:y,isClickSubmit:w}=Tr({passwordConfigs:r,handleSetInLineAlert:a,handleHideChangePassword:e}),{isValidUniqueSymbols:v,defaultLengthMessage:f}=Sr({password:h,isClickSubmit:w,passwordConfigs:r}),E=G({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 _(ne,{className:"account-change-password",variant:"secondary",children:[n(me,{title:E.containerTitle,divider:!1,className:"account-change-password__title"}),t.text?n(ue,{className:"account-change-password__notification",type:t.type,variant:"secondary",heading:t.text,icon:t.icon,"data-testid":"changePasswordInLineAlert"}):null,_("div",{className:"account-change-password__fields",children:[n(Le,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:E.currentPasswordPlaceholder,floatingLabel:E.currentPasswordFloatingLabel,errorMessage:A.currentPassword,defaultValue:u,onValue:l,onBlur:o}),n(Le,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:E.newPasswordPlaceholder,floatingLabel:E.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:f,uniqueSymbolsStatus:v,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:Or(v,f,w,h,A),defaultValue:h,onValue:c,onBlur:o}),n(Le,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:E.confirmPasswordPlaceholder,floatingLabel:E.confirmPasswordFloatingLabel,errorMessage:A.confirmPassword,defaultValue:b,onValue:d,onBlur:o})]}),_("div",{className:"account-change-password__actions",children:[n(X,{type:"button",disabled:y,onClick:s,variant:"secondary",children:E.buttonSecondary}),n(X,{variant:"primary",type:"button",disabled:y,onClick:m,children:E.buttonPrimary})]})]})},en=({inLineAlertProps:e,errorPasswordEmpty:a,passwordValue:t,showPasswordOnEmailChange:r,submitLoading:s,formFieldsList:o,handleHideEditForm:d,handleUpdateCustomerInformation:c,handleInputChange:l,handleSetPassword:m,handleOnBlurPassword:u})=>{const h=G({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 _(ne,{variant:"secondary",className:"account-edit-customer-information",children:[n(me,{title:h.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?n(ue,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,_(At,{loading:s,fieldsConfig:o||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:c,setInputChange:l,children:[r?n("div",{className:"account-edit-customer-information__password",children:n(Le,{autoComplete:"password",name:"password",placeholder:h.placeholder,floatingLabel:h.floatingLabel,errorMessage:a?h.requiredFieldError:void 0,defaultValue:t,onValue:m,onBlur:u})}):null,_("div",{className:"account-edit-customer-information__actions",children:[n(X,{disabled:s,type:"button",variant:"secondary",onClick:()=>d(),children:h.buttonSecondary}),n(X,{disabled:s,type:"submit",variant:"primary",children:h.buttonPrimary})]})]})]})},tn=({createdAt:e,slots:a,orderedCustomerData:t,showEditForm:r,showChangePassword:s,handleShowChangePassword:o,handleShowEditForm:d})=>{const c=G({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return n(ne,{variant:"secondary",className:U(["account-customer-information-card",["account-customer-information-card-short",s||r]]),children:_("div",{className:"account-customer-information-card__wrapper",children:[_("div",{className:"account-customer-information-card__actions",children:[n(X,{type:"button",variant:"tertiary",onClick:o,children:c.buttonSecondary}),n(X,{type:"button",variant:"tertiary",onClick:d,children:c.buttonPrimary})]}),n("div",{className:"account-customer-information-card__content",children:a!=null&&a.CustomerData?n(ae,{name:"CustomerData",slot:a==null?void 0:a.CustomerData,context:{customerData:t}}):_(D,{children:[t==null?void 0:t.map((l,m)=>{const u=l!=null&&l.label?`${l.label}: ${l==null?void 0:l.value}`:l==null?void 0:l.value;return n("p",{"data-testid":`${l.name}_${m}`,children:u},`${l.name}_${m}`)}),_("p",{children:[c.accountCreation,": ",e]})]})})]})})};function Ir(e){if(!e)return[];const a=`${e.firstName} ${e.lastName}`.trim(),t=e.street??"",r=e.city??"",s=e.region||void 0,o=e.postcode??"",d=e.countryCode??"";let c="";r&&s?c=`${r}, ${(s==null?void 0:s.regionCode)??""}`.trim():r?c=r:s&&(c=(s==null?void 0:s.regionCode)??"");let l=c;o&&(l=c?`${c} ${o}`:o);let m=l;return d&&(m=l?`${l}, ${d}`:d),[a,t,m]}const st=({title:e,address:a,selected:t,busy:r,onChange:s})=>{const[o,d,c]=Ir(a);return n("div",{className:"account-address-validation__option",children:n(Tt,{busy:r,className:"account-address-validation__radio",label:_("div",{children:[n("div",{className:"account-address-validation__option-title",children:n("strong",{children:e})}),o&&n("div",{children:o}),d&&n("div",{children:d}),c&&n("div",{children:c})]}),name:"address-validation-choice",selected:t,value:e,onChange:s})})},rn=({busy:e=!1,className:a,originalAddress:t,onSelectionChange:r,selection:s,suggestedAddress:o})=>{const d=!!o,c=G({title:"Account.AddressValidation.title",subtitle:"Account.AddressValidation.subtitle",suggestedAddress:"Account.AddressValidation.suggestedAddress",originalAddress:"Account.AddressValidation.originalAddress"});return _("div",{className:U(["account-address-validation",a]),children:[n(me,{className:"account-address-validation__title",divider:!1,title:c.title}),n("div",{className:"account-address-validation__subtitle",children:c.subtitle}),_("div",{className:U(["account-address-validation__options",e&&"account-address-validation__options--busy"]),children:[d&&n(st,{address:o,busy:e,selected:s==="suggested",title:c.suggestedAddress,onChange:()=>r("suggested")}),n(st,{address:t,busy:e,selected:s==="original",title:c.originalAddress,onChange:()=>r("original")})]})]})},nn=({loading:e,isRemoteShoppingAssistanceAvailable:a,isRemoteShoppingAssistanceEnabled:t,showAlert:r,checkboxLabel:s,checkboxTooltip:o,alertMessage:d,featureDisabledMessage:c,handleCheckboxChange:l,handleDismissAlert:m})=>{const[u,h]=$(!1);return e?n(we,{children:n(K,{variant:"row"})}):!e&&!a?n("div",{className:"account-seller-assisted-buying-settings-control__alert",children:n(fe,{heading:c})}):_("div",{className:"account-seller-assisted-buying-settings-control",children:[!t&&r&&n("div",{className:"account-seller-assisted-buying-settings-control__alert",children:n(ue,{variant:"secondary",type:"warning",heading:d,onDismiss:m})}),_("div",{className:"account-seller-assisted-buying-settings-control__checkbox-row",children:[n(de,{children:n(Ze,{name:"allowRemoteShoppingAssistance",value:"true",placeholder:s,label:s,checked:t,onChange:b=>l(b.currentTarget.checked)})}),o?_("div",{className:"account-seller-assisted-buying-settings-control__info-container",children:[n("button",{type:"button",className:"account-seller-assisted-buying-settings-control__info-icon",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onFocusCapture:()=>h(!0),onBlurCapture:()=>h(!1),"aria-label":o,children:"?"}),u?_("span",{className:"account-seller-assisted-buying-settings-control__tooltip",role:"tooltip",children:[o,n("span",{className:"account-seller-assisted-buying-settings-control__tooltip-arrow"})]}):null]}):null]})]})},an=({loading:e,adminAssistanceActions:a,tableHeaders:t,actionTypesMap:r,emptyStateMessage:s,featureDisabledMessage:o,isRemoteShoppingAssistanceAvailable:d=!0,errorMessage:c,currentPage:l,onPageChange:m,withWrapper:u=!0})=>{var v;if(e)return _(we,{children:[n(K,{variant:"row",fullWidth:!0}),n(K,{variant:"row",fullWidth:!0}),n(K,{variant:"row",fullWidth:!0})]});if(!d)return n("div",{className:"account-seller-assisted-buying-activity-table__alert",children:n(fe,{heading:o})});if(c)return n("div",{className:"account-seller-assisted-buying-activity-table__error",children:n(fe,{heading:c})});if(!((v=a==null?void 0:a.items)!=null&&v.length))return n("div",{className:"account-seller-assisted-buying-activity-table__empty",children:n(fe,{heading:s})});const h=[{label:t.action,key:"action",ariaLabel:t.action},{label:t.date,key:"date",ariaLabel:t.date},{label:t.details,key:"details",ariaLabel:t.details}],b=a.items.map(f=>({action:r[f.action]||f.action,date:f.date,details:f.details})),A=a.pageInfo.totalPages,y=A>1,w=n("div",{className:"account-seller-assisted-buying-activity-table",children:n("div",{className:"account-seller-assisted-buying-activity-table__table-wrapper",children:n(St,{columns:h,rowData:b,mobileLayout:"stacked",className:"account-seller-assisted-buying-activity-table__table"})})});return _(D,{children:[u?n(ne,{variant:"secondary",className:U(["account-seller-assisted-buying-activity-table-card"]),children:w}):w,y&&n("div",{className:"account-seller-assisted-buying-activity-table__pagination",children:n(lt,{currentPage:l,totalPages:A,onChange:m})})]})},vt=({cardBrand:e,lastFourDigits:a,expired:t=!1,onRemove:r,variant:s="secondary",minifiedView:o=!1})=>{const d=ut(),c=G({actionRemove:"Account.Payments.paymentCard.actionRemove",cardEndingIn:"Account.Payments.paymentCard.cardEndingIn",expiredLabel:"Account.Payments.paymentCard.expiredLabel"}),l=Te(()=>{r==null||r()},[r]),m=`•••• ${a}`,u=`${c.cardEndingIn} ${m}`;return _(ne,{variant:s,className:U(["account-payment-card",o&&"account-payment-card--minified"]),"data-testid":"paymentCard",children:[n("div",{className:"account-payment-card__action",children:r?n(X,{type:"button",variant:"tertiary",onClick:l,"data-testid":"removeButton","aria-label":`${c.actionRemove} ${e} ${u}`,"aria-describedby":d,children:c.actionRemove}):null}),_("div",{className:"account-payment-card__description",id:d,children:[n("p",{className:"account-payment-card__card-brand","data-testid":"cardBrand",children:e}),n("p",{className:"account-payment-card__card-number","data-testid":"cardNumber",children:u})]}),t?n("div",{className:"account-payment-card__labels","data-testid":"expiredTag",children:n(pe,{label:(c.expiredLabel??"Expired").toLocaleUpperCase()})}):null]})},ot="account/customerPaymentTokens",Ct="__REMOVE_FAILED__",Fr=e=>{const a=Se("api"),t=Se(void 0),[r,s]=$([]),[o,d]=$(!0),[c,l]=$(null),[m,u]=$(null),[h,b]=$(null),A=x(async()=>{d(!0),l(null),u(null);try{const f=await Ht(e);a.current="api",s(f)}catch(f){s([]),l(f instanceof Error?f.message:String(f))}finally{d(!1)}},[e]);J(()=>{let f=!1,E=!1;const P=Oe.on(ot,S=>{f||(E=!0,a.current="event",s(Array.isArray(S)?S:[]),l(null),d(!1))},{eager:!0});return(!P||!E)&&A(),()=>{f=!0,P==null||P.off()}},[A]);const y=(e==null?void 0:e.join(","))??"";J(()=>{if(a.current==="api"){if(t.current===void 0){t.current=y;return}t.current!==y&&(t.current=y,A())}},[y,A]);const w=x(async f=>{u(null),b(f);try{await Rt(f)?s(P=>P.filter(S=>S.publicHash!==f)):u(Ct)}catch(E){u(E instanceof Error?E.message:String(E))}finally{b(null)}},[]),v=x(async()=>{if(a.current==="event"){const f=Oe.lastPayload(ot);if(f===void 0)return;s(Array.isArray(f)?f:[]),l(null),u(null);return}await A()},[A]);return{items:r,loading:o,loadError:c,actionError:m,removingHash:h,removeToken:w,refetch:v}},sn=({className:e,withHeader:a=!0,minifiedView:t=!1,filterPaymentMethodCodes:r})=>{const s=G({containerTitle:"Account.Payments.containerTitle",loadError:"Account.Payments.loadError",removeError:"Account.Payments.removeError"}),{items:o,loading:d,loadError:c,actionError:l,removingHash:m,removeToken:u}=Fr(r),[h,b]=$(null),A=x(()=>{b(null)},[]),y=x(async()=>{h&&(await u(h.publicHash),b(null))},[h,u]),w=l===Ct?s.removeError:l??"",v=o.length>0?o.map(E=>{const{publicHash:P,...S}=E;return n(vt,{...S,minifiedView:t,onRemove:m!==null?void 0:()=>b(E)},P)}):null,f=o.length===0&&!c?n("div",{className:"account-payment-methods__empty","data-testid":"paymentMethodsEmpty",children:n(He,{isEmpty:!0,typeList:"payments",minifiedView:t})}):null;return _("div",{className:U(["account-payment-methods",e]),"data-testid":"paymentMethods",children:[a?n(me,{"aria-label":s.containerTitle,role:"region",title:s.containerTitle,divider:!t,className:t?"account-payment-methods-header":""}):null,c?n(ue,{className:"account-payment-methods__alert",type:"error",variant:"secondary",heading:s.loadError,description:c,icon:n(Qe,{}),"data-testid":"paymentMethodsLoadError"}):null,l&&!c?n(ue,{className:"account-payment-methods__alert",type:"error",variant:"secondary",heading:w,icon:n(Qe,{}),"data-testid":"paymentMethodsActionError"}):null,n(kr,{open:h!==null,submitLoading:h!==null&&m===h.publicHash,onRemoveToken:()=>{y()},closeModal:A,cardBrand:h==null?void 0:h.cardBrand,lastFourDigits:h==null?void 0:h.lastFourDigits,expired:h==null?void 0:h.expired,variant:h==null?void 0:h.variant,minifiedView:t}),d?n(Ee,{testId:"paymentMethodsLoader"}):n("div",{className:"account-payment-methods__list",children:v??f})]})},kr=({open:e,submitLoading:a,onRemoveToken:t,closeModal:r,cardBrand:s,lastFourDigits:o,expired:d,variant:c,minifiedView:l})=>{const m=G({title:"Account.Payments.removePaymentModal.title",description:"Account.Payments.removePaymentModal.description",actionCancel:"Account.Payments.removePaymentModal.actionCancel",actionConfirm:"Account.Payments.removePaymentModal.actionConfirm"});return e?n(it,{className:"account-payment-modal--overlay",title:n("h3",{children:m.title}),size:"full","data-testid":"paymentModal",showCloseButton:!0,onClose:r,children:_("div",{className:"account-payment-modal",children:[a?n("div",{className:"account-payment-modal__spinner","data-testid":"progressSpinner",children:n(dt,{stroke:"4",size:"large"})}):null,n("p",{children:m.description}),s&&o?n(vt,{cardBrand:s,lastFourDigits:o,expired:d,variant:c,minifiedView:l}):null,_("div",{className:"account-payment-modal__buttons",children:[n(X,{type:"button",onClick:r,variant:"secondary",disabled:a,children:m.actionCancel}),n(X,{disabled:a,onClick:t,children:m.actionConfirm})]})]})}):null},Vr=({ordersInMinifiedView:e,minifiedView:a,pageSize:t,selectedDate:r,selectedPage:s,handleSetFirstOrderDate:o})=>{const[d,c]=$([]),[l,m]=$({totalPages:1,currentPage:1,pageSize:1}),[u,h]=$(!1),[b,A]=$(""),[y,w]=$(0);return J(()=>{mt().then(v=>{A(v.baseMediaUrl)})},[]),J(()=>{const v=Oe.on("companyContext/changed",()=>{w(f=>f+1)});return()=>{v==null||v.off()}},[]),J(()=>{h(!0),qt(a?e:t,r,s).then(v=>{!v||!v.items||(m(v.pageInfo),c(v.items),o==null||o(v.dateOfFirstOrder))}).finally(()=>{h(!1)})},[o,a,e,t,r,s,y]),{loading:u,orderHistoryListItems:d,pageInfo:l,placeholderImage:b}},Pe=(e,a=1)=>{const t=new Date,r=new Date(t);switch(e){case"sixMonthsAgo":{r.setMonth(r.getMonth()-a);break}case"oneYearAgo":{r.setFullYear(r.getFullYear()-a);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`}},xr=e=>{const a=[],t=new Date().getFullYear();for(let r=e;r<=t-1;r++)a.push({value:`{"from":"${r}-01-01","to":"${r+1}-01-01 23:59:59"}`,text:r.toString()});return a},Zr=()=>{const e=G({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[a,t]=$(),[r,s]=$(JSON.stringify(Pe("sixMonthsAgo",6))),[o,d]=$(1);J(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[o]);const c=oe(()=>{const u=[{value:JSON.stringify(Pe("sixMonthsAgo",6)),text:e.pastSixMonths},{value:JSON.stringify(Pe("oneYearAgo",1)),text:e.currentYear},{value:"viewAll",text:e.viewAll}];if(a){const b=new Date(a).getFullYear();u==null||u.splice(2,0,...xr(b))}return u},[e,a]),l=x(u=>{t(u)},[]),m=x(u=>{const b=u.target.value;s(b),d(1)},[]);return{selectableDateList:c,selectedDate:r,selectedPage:o,handleSelectDate:m,setSelectedPage:d,handleSetFirstOrderDate:l}},on=({className:e,withHeader:a=!0,minifiedView:t=!1,withThumbnails:r=!0,withFilter:s=!0,ordersInMinifiedView:o=1,pageSize:d=10,routeOrdersList:c,routeOrderDetails:l,routeReturnDetails:m,routeTracking:u,routeOrderProduct:h,slots:b})=>{const A=t?"minifiedView":"fullSizeView",y=G({containerTitle:`Account.${A}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${A}.OrdersList.dateOrderPlaced`}),{selectableDateList:w,selectedDate:v,handleSelectDate:f,selectedPage:E,setSelectedPage:P,handleSetFirstOrderDate:S}=Zr(),{pageInfo:N,loading:i,orderHistoryListItems:p,placeholderImage:L}=Vr({minifiedView:t,pageSize:d,ordersInMinifiedView:o,selectedDate:v,selectedPage:E,handleSetFirstOrderDate:S});return _("div",{children:[a?n(me,{"aria-label":y.containerTitle,role:"region",title:y.containerTitle,divider:!t,className:t?"account-orders-list-header":""}):null,_("div",{className:U(["account-orders-list",e]),children:[!t&&s?_("div",{className:"account-orders-list__date-select",children:[n("span",{children:y.dateOrderPlaced}),n(ct,{value:v,name:"orderDatePicker",options:w,handleSelect:f})]}):null,i?n(D,{children:Array.from(Array(N==null?void 0:N.pageSize).keys()).map(k=>n(Ee,{testId:"orderSkeletonLoader",withCard:!1},k))}):n(D,{children:p.length?n(D,{children:p.map((k,M)=>n(fr,{placeholderImage:L,routeTracking:u,routeOrderProduct:h,routeReturnDetails:m,minifiedView:t,item:k,withThumbnails:r,slots:b,children:b!=null&&b.OrdersListAction?n(ae,{"data-testid":`ordersListActionSlot_${M}`,name:"OrdersListAction",slot:b==null?void 0:b.OrdersListAction,context:{orderHistoryListItem:k}}):n(rt,{minifiedView:t,orderNumber:k.number,orderToken:k.token,routeOrderDetails:l})},M))}):n(He,{isEmpty:!p.length,typeList:"orders",minifiedView:t})}),!t&&(N==null?void 0:N.totalPages)>1?n(lt,{totalPages:N==null?void 0:N.totalPages,currentPage:E,onChange:P}):null,t?n(rt,{minifiedView:t,routeOrdersList:c}):null]})]})};export{Xr as A,ye as AddressForm,Ee as C,en as E,on as O,sn as P,nn as S,an as a,Qe as b,Yr as c,Dr as d,ye as default,Jr as e,tn as f,nt as g,Qr as h,rn as i,wr as n,Ut as u};
3
+ import{classes as U,Slot as ae}from"@dropins/tools/lib.js";import{useText as G}from"@dropins/tools/i18n.js";import{jsx as n,Fragment as D,jsxs as _}from"@dropins/tools/preact-jsx-runtime.js";import{Field as de,TextArea as Et,Checkbox as Ze,InputDate as Nt,Picker as ct,Input as Mt,Skeleton as we,SkeletonRow as K,Card as ne,Button as X,Tag as pe,Icon as ve,Modal as it,ProgressSpinner as dt,IllustratedMessage as fe,Image as Ge,Price as $t,ContentGrid as Pt,Header as me,InLineAlert as ue,InputPassword as Le,ToggleButton as Tt,Pagination as lt,Table as St}from"@dropins/tools/components.js";import*as Z from"@dropins/tools/preact-compat.js";import{memo as Be,useMemo as Ce,forwardRef as Ot,useImperativeHandle as It,useId as ut,useCallback as Te}from"@dropins/tools/preact-compat.js";import{useState as $,useEffect as J,useRef as Se,useCallback as x,useMemo as oe}from"@dropins/tools/preact-hooks.js";import{events as Oe}from"@dropins/tools/event-bus.js";import{getStoreConfig as mt,c as ht,a as pt,updateCustomerAddress as Ie,getAttributesForm as ft,getCustomerAddress as Ft,b as kt,removeCustomerAddress as Vt,getCountries as xt,createCustomerAddress as Zt,updateCustomerPassword as Bt,getCustomerPaymentTokens as Ht,deletePaymentToken as Rt,getOrderHistoryList as qt}from"../api.js";import{Fragment as Ke}from"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";const zt=()=>{const e=sessionStorage.getItem("accountStoreConfig");if(!e)return null;try{return JSON.parse(e)}catch(a){return console.error("Failed to parse cached store config:",a),sessionStorage.removeItem("accountStoreConfig"),null}},Ut=()=>{const[e,a]=$(!0),[t,r]=$(null),[s,o]=$(null),d=c=>{const{minLength:l,requiredCharacterClasses:m,shoppingAssistanceEnabled:u,shoppingAssistanceCheckboxTitle:h,shoppingAssistanceCheckboxTooltip:b}=c;r({minLength:l,requiredCharacterClasses:m}),o({shoppingAssistanceEnabled:u,shoppingAssistanceCheckboxTitle:h,shoppingAssistanceCheckboxTooltip:b})};return J(()=>{const c=zt();if(c){d(c),a(!1);return}mt().then(l=>{l&&(sessionStorage.setItem("accountStoreConfig",JSON.stringify(l)),d(l))}).catch(l=>{console.error("Failed to load store config:",l)}).finally(()=>{a(!1)})},[]),{loading:e,passwordConfigs:t,remoteShoppingAssistanceConfigs:s}},ye=({hideActionFormButtons:e,formName:a,showFormLoader:t,showSaveCheckBox:r,saveCheckBoxValue:s,forwardFormRef:o,slots:d,addressesFormTitle:c,className:l,addressFormId:m,inputsDefaultValueSet:u,billingCheckBoxValue:h,shippingCheckBoxValue:b,showBillingCheckBox:A,showShippingCheckBox:y,isOpen:w,fieldIdPrefix:v,onSubmit:f,onCloseBtnClick:E,onSuccess:P,onError:S,onChange:N})=>n("div",{className:U(["account-address-form"]),children:n($r,{hideActionFormButtons:e,formName:a,showFormLoader:t,slots:d,addressesFormTitle:c,className:l,addressFormId:m,inputsDefaultValueSet:u,shippingCheckBoxValue:b,billingCheckBoxValue:h,showShippingCheckBox:y,showBillingCheckBox:A,isOpen:w,fieldIdPrefix:v,onSubmit:f,onCloseBtnClick:E,onSuccess:P,onError:S,onChange:N,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:s})}),Wt=e=>e.reduce((a,t)=>({...a,[t.name]:t.value}),{}),jt=e=>/^\d+$/.test(e),Gt=e=>/^[a-zA-Z0-9\s]+$/.test(e),Kt=e=>/^[a-zA-Z0-9]+$/.test(e),Jt=e=>/^[a-zA-Z]+$/.test(e),Yt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),Dt=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),Xt=(e,a,t)=>{const r=new Date(e).getTime()/1e3;return!(isNaN(r)||r<0||a!==void 0&&r<a||t!==void 0&&r>t)},Je=e=>!e||isNaN(Number(e))?"":new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Qt=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),er=(e,a,t)=>{const r=e.length;return r>=a&&r<=t},$e=(e,a,t,r)=>{var p,L;const{requiredFieldError:s,lengthTextError:o,numericError:d,alphaNumWithSpacesError:c,alphaNumericError:l,alphaError:m,emailError:u,dateError:h,urlError:b,dateLengthError:A}=t,y=a==null?void 0:a.customUpperCode,w={[y]:""};if(r[y]&&delete r[y],a!=null&&a.required&&(!e||e==="false"))return{[y]:s};if(!(a!=null&&a.required)&&!e||!((p=a==null?void 0:a.validateRules)!=null&&p.length))return w;const v=Wt(a==null?void 0:a.validateRules),f=v.MIN_TEXT_LENGTH??1,E=v.MAX_TEXT_LENGTH??255,P=v.DATE_RANGE_MIN,S=v.DATE_RANGE_MAX;if(!er(e,+f,+E)&&!(P||S))return{[y]:o.replace("{min}",f).replace("{max}",E)};if(!Xt(e,+P,+S)&&(P||S))return{[y]:A.replace("{min}",Je(P)).replace("{max}",Je(S))};const i={numeric:{validate:jt,error:d},"alphanum-with-spaces":{validate:Gt,error:c},alphanumeric:{validate:Kt,error:l},alpha:{validate:Jt,error:m},email:{validate:Yt,error:u},date:{validate:Dt,error:h},url:{validate:Qt,error:b}}[v.INPUT_VALIDATION];return i&&!i.validate(e)&&!((L=r[y])!=null&&L.length)?{[y]:i.error}:w},gt=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}},tr=["true","false","yes","on","off"],rr={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:"",uid:""},nr=e=>{const a={},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 d=o[1],c=parseInt(o[2],10);t[d]||(t[d]=[]),t[d].push({index:c,value:s})}else Object.keys(e).filter(c=>c.startsWith(`${r}Multiline_`)).length>0?t[r]=[{index:1,value:s}]:a[r]=s}for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const s=t[r];s.sort((o,d)=>o.index-d.index),a[r]=s.map(o=>o.value)}return a},ar=e=>{const a={},t=[];for(const r in e){const s=tr.includes(e[r])?gt(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(rr,r)?a[r]=s:t.push({code:pt(r),value:s}))}return{...a,customAttributes:t}},le=(e,a=!1)=>{const t=ht(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=ar(nr(t));if(!a)return r;const[s,o]=r.region?r.region.split(","):[];return{...r,region:{regionCode:s,...o&&{regionId:+o}}}},be=e=>{if(!e.current)return{};const a=e.current.elements;return Array.from(a).reduce((r,s)=>(s.name&&(r[s.name]=s.type==="checkbox"?s.checked:s.value),r),{})},Ye=(e,a)=>Object.keys(e).length?Object.keys(e).every(r=>r in a&&a[r]!==""):!1,_e=e=>typeof e=="function",sr=e=>e.reduce((a,{customUpperCode:t,required:r,defaultValue:s})=>(r&&t&&(a.initialData[t]=s||"",a.errorList[t]=""),a),{initialData:{},errorList:{}}),De=e=>Object.keys(e).length>0,or=({fieldsConfig:e,onSubmit:a,onChange:t,setInputChange:r,formName:s})=>{const o=G({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"}),d=Se(null),[c,l]=$({}),[m,u]=$({}),[h,b]=$({}),[A,y]=$(!0),[w,v]=$(!1),[f,E]=$(!1),[P,S]=$(!0),[N,i]=$(!1);J(()=>{const g=()=>{if(d.current){const I=window.getComputedStyle(d.current).getPropertyValue("grid-template-rows").split(" ").length,R=d.current.querySelector(".account-address-form--saveAddressBook");R&&(R.style.gridRow=String(I-1))}};return g(),window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g)}},[e==null?void 0:e.length]);const p=x((g=!1)=>{let T=!0;const I={...m};let R=null;for(const[z,Y]of Object.entries(c)){const H=e==null?void 0:e.find(F=>F.customUpperCode.includes(z)),V=$e(Y.toString(),H,o,I);V[z]&&(Object.assign(I,V),T=!1),R||(R=Object.keys(I).find(F=>I[F])||null)}if(g||u(I),R&&d.current&&!g){const z=d.current.elements.namedItem(R);z==null||z.focus()}return T},[m,e,c,o]),L=x((g,T,I,R)=>{const z={...be(d),[T]:g,...T.includes("countryCode")?{region:""}:{}},Y={data:le(z,!0),isDataValid:Ye(I,z)};i(Y.isDataValid),p(!0),["selectedShippingAddress","selectedBillingAddress"].includes(s)&&sessionStorage.setItem(`${s}_addressData`,JSON.stringify(Y)),t==null||t(Y,{},R)},[p,s,t]);J(()=>{if(e!=null&&e.length){const{initialData:g,errorList:T}=sr(e);l(I=>({...g,...I})),u(T),b(T)}},[JSON.stringify(e)]),J(()=>{if(f)return;const g=be(d),T=sessionStorage.getItem(`${s}_addressData`);if(De(c)&&De(h)){let I={};const R=Ye(h,c);T?I=JSON.parse(T).data:I=le(g,!0)??{},t==null||t({data:I,isDataValid:R},{},null),i(R),E(!0)}},[c,h]),J(()=>{var z;if(!P)return;const g=be(d),T=!!(g!=null&&g.countryCode),I=!!((z=g==null?void 0:g.region)!=null&&z.length);g&&T&&!I&&_e(t)&&L(g==null?void 0:g.region,"region",h,null)},[P,A,e,d,t,L,h,w]);const k=x((g,T)=>{const{name:I,value:R,type:z,checked:Y}=g==null?void 0:g.target,H=z==="checkbox"?Y:R;l(q=>{const O={...q,[I]:H};return I==="countryCode"&&(O.region="",y(!0),v(!1)),O}),r==null||r({[I]:H}),E(!0);const V=e==null?void 0:e.find(q=>q.customUpperCode.includes(I));let F=T?{...T}:{...m};if(V){const q=$e(H.toString(),V,o,F);q&&Object.assign(F,q),u(F)}L(H,I,h,g)},[r,e,m,o,L,h,A]),M=x(g=>{const{name:T}=g==null?void 0:g.target,I=e==null?void 0:e.find(R=>R.customUpperCode===T);T==="region"&&(I!=null&&I.options.length)&&S(!1),S(T==="countryCode")},[]),C=x((g,T)=>{const{name:I,value:R,type:z,checked:Y}=g==null?void 0:g.target,H=z==="checkbox"?Y:R,V=e==null?void 0:e.find(F=>F.customUpperCode===I);if(V){const F=T?{...T}:{...m},q=$e(H.toString(),V,o,F);q&&Object.assign(F,q),u(F)}},[m,e,o]),B=x(g=>{g.preventDefault();const T=p();a==null||a(g,T)},[p,a]);return{isDataValid:N,formData:c,errors:m,formRef:d,handleInputChange:k,onFocus:M,handleBlur:C,handleSubmit:B,handleValidationSubmit:p}};var se=(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))(se||{});const cr=Be(({loading:e,values:a,fields:t=[],errors:r,className:s="",onChange:o,onBlur:d,onFocus:c,slots:l,fieldIdPrefix:m})=>{const u=`${s}__field`,h=Ce(()=>Object.fromEntries(t.flatMap(i=>[[`${i.code}.label`,`Account.AddressForm.fields.${i.code}.label`],[`${i.code}.placeholder`,`Account.AddressForm.fields.${i.code}.placeholder`]])),[t]),b=G(h),A=i=>b[`${i.code}.label`]||i.label,y=i=>`${A(i)} ${i.required?"*":""}`,w=i=>b[`${i.code}.placeholder`]||i.label,v=(i,p)=>{if(!(l!=null&&l[`AddressFormInput_${i.code}`]))return;const L={inputName:i.customUpperCode,handleOnChange:o,handleOnBlur:d,handleOnFocus:c,errorMessage:p,errors:r,config:i};return n(ae,{"data-testid":`addressFormInput_${i.code}`,name:`AddressFormInput_${i.code}`,slot:l[`AddressFormInput_${i.code}`],context:L},i.id)},f=(i,p,L)=>{var M;const k=i.defaultValue??((M=i.options.find(C=>C.isDefault))==null?void 0:M.value)??p??i.defaultValue;return n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:e||i.disabled,children:n(ct,{"aria-label":A(i),"aria-required":i.required?"true":"false",id:m?`${m}_${i.code}`:i.code,required:i==null?void 0:i.required,name:i.customUpperCode,floatingLabel:y(i),placeholder:w(i),options:i.options,onBlur:d,onFocus:c,handleSelect:o,defaultValue:k,value:k})},i.id)})},E=(i,p,L)=>n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:e,children:n(Mt,{"aria-label":A(i),"aria-required":i.required?"true":"false",id:m?`${m}_${i.code}`:i.code,type:"text",name:i.customUpperCode,value:p??i.defaultValue,placeholder:w(i),floatingLabel:y(i),onBlur:d,onFocus:c,onChange:o})},i.id)}),P=(i,p,L)=>n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:e||i.disabled,children:n(Nt,{"aria-label":A(i),"aria-required":i.required?"true":"false",id:m?`${m}_${i.code}`:i.code,type:"text",name:i.customUpperCode,value:p||i.defaultValue,placeholder:w(i),floatingLabel:y(i),onBlur:d,onChange:o,disabled:e||i.disabled})},i.id)}),S=(i,p,L)=>n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:(i==null?void 0:i.isHidden)??e,children:n(Ze,{"aria-label":A(i),"aria-required":i.required?"true":"false","aria-hidden":i.isHidden,tabindex:i!=null&&i.isHidden?-1:0,id:m?`${m}_${i.code}`:i.code,name:i.customUpperCode,checked:p||i.defaultValue,placeholder:w(i),label:y(i),onBlur:d,onChange:o})},i.id)}),N=(i,p,L)=>n(D,{children:v(i,L)??n(de,{error:L,className:U([u,`${u}--${i.id}`,[`${u}--${i.id}-hidden`,i.isHidden],i.className]),"data-testid":`${s}--${i.id}`,disabled:e,children:n(Et,{"aria-label":A(i),"aria-required":i.required?"true":"false",id:m?`${m}_${i.code}`:i.code,type:"text",name:i.customUpperCode,value:p??i.defaultValue,label:y(i),onBlur:d,onChange:o})},i.id)});return t.length?n(D,{children:t.map(i=>{const p=r==null?void 0:r[i.customUpperCode],L=a==null?void 0:a[i.customUpperCode];switch(i.fieldType){case se.TEXT:return i.options.length?f(i,L,p):E(i,L,p);case se.MULTILINE:return E(i,L,p);case se.SELECT:return f(i,L,p);case se.DATE:return P(i,L,p);case se.BOOLEAN:return S(i,L,p);case se.TEXTAREA:return N(i,L,p);default:return null}})}):null}),Ee=({testId:e,withCard:a=!0})=>{const t=_(we,{"data-testid":e||"skeletonLoader",children:[n(K,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),n(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),n(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return a?t:n(ne,{variant:"secondary",className:U(["account-account-loaders","account-account-loaders--card-loader"]),children:t})},ir=()=>_(we,{"data-testid":"addressFormLoader",children:[n(K,{variant:"heading",size:"medium"}),n(K,{variant:"empty",size:"medium"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large",fullWidth:!0}),n(K,{size:"large",fullWidth:!0,lines:3}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large"}),n(K,{size:"large",fullWidth:!0})]}),At=Be(Ot(({setInputChange:e,showFormLoader:a,slots:t,name:r,loading:s,children:o,className:d="defaultForm",fieldsConfig:c,onSubmit:l,onChange:m,forwardFormRef:u,regionOptions:h,showSaveCheckBox:b,handleSaveCheckBoxAddress:A,saveCheckBoxAddress:y,fieldIdPrefix:w})=>{const v=G({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:f,formData:E,errors:P,formRef:S,handleInputChange:N,handleBlur:i,handleSubmit:p,handleValidationSubmit:L,onFocus:k}=or({fieldsConfig:c,onSubmit:l,onChange:m,setInputChange:e,formName:r});return It(u,()=>{const M=be(S);return{handleValidationSubmit:L,requestSubmit:()=>{var C;(C=S.current)==null||C.requestSubmit()},formData:le(M,!0),isDataValid:f}}),a||!(c!=null&&c.length)?n(ir,{}):_("form",{className:U(["account-form",d]),onSubmit:p,name:r,ref:S,children:[n(cr,{className:d,loading:s,fields:c,onChange:N,onBlur:i,errors:P,values:E,onFocus:k,slots:t,fieldIdPrefix:w}),t!=null&&t.AddressFormInputs?n(ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:t.AddressFormInputs,context:{formActions:{handleChange:N}}}):null,b?n("div",{className:"account-address-form--saveAddressBook",children:n(Ze,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:v.saveAddressBook,checked:y,onChange:M=>{N(M),A==null||A(M)}})}):null,o]})})),Xe=(e,a,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 d="default";return e&&a?d="shippingAndBilling":e?d="shipping":a&&(d="billing"),s?o[d].remove:o[d].edit},Fe=({slots:e,selectable:a,selectShipping:t,selectBilling:r,variant:s="secondary",minifiedView:o,keysSortOrder:d,addressData:c,loading:l,setAddressId:m,handleRenderModal:u,handleRenderForm:h})=>{const b=ut(),A=o?"minifiedView":"fullSizeView",y=G({actionRemove:`Account.${A}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${A}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${A}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${A}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${A}.Addresses.addressCard.defaultLabelText`,editAddressAriaLabelDefault:`Account.${A}.Addresses.addressCard.ariaLabel.editButton.default`,editAddressAriaLabelShipping:`Account.${A}.Addresses.addressCard.ariaLabel.editButton.shipping`,editAddressAriaLabelBilling:`Account.${A}.Addresses.addressCard.ariaLabel.editButton.billing`,editAddressAriaLabelShippingAndBilling:`Account.${A}.Addresses.addressCard.ariaLabel.editButton.shippingAndBilling`,removeAddressAriaLabelDefault:`Account.${A}.Addresses.addressCard.ariaLabel.removeButton.default`,removeAddressAriaLabelShipping:`Account.${A}.Addresses.addressCard.ariaLabel.removeButton.shipping`,removeAddressAriaLabelBilling:`Account.${A}.Addresses.addressCard.ariaLabel.removeButton.billing`,removeAddressAriaLabelShippingAndBilling:`Account.${A}.Addresses.addressCard.ariaLabel.removeButton.shippingAndBilling`}),w=y.cardLabelBilling.toLocaleUpperCase(),v=y.cardLabelShipping.toLocaleUpperCase(),f=y.defaultLabelText.toLocaleUpperCase(),E=Ce(()=>{const M={shippingLabel:v,billingLabel:w,hideShipping:!1,hideBilling:!1};return a?t&&!r?{shippingLabel:f,billingLabel:f,hideShipping:!1,hideBilling:!0}:r&&!t?{shippingLabel:f,billingLabel:f,hideShipping:!0,hideBilling:!1}:M:M},[w,f,v,r,t,a]),P=Te(()=>{m==null||m(c==null?void 0:c.id),u==null||u()},[u,c==null?void 0:c.id,m]),S=Te(()=>{m==null||m(c==null?void 0:c.id),h==null||h()},[h,c==null?void 0:c.id,m]),N=Ce(()=>{if(!d)return[];const{region:M,...C}=c,B={...C,...M};return d.filter(({name:g})=>B[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:B[g.name],label:g.label}))},[c,d]),{shippingLabel:i,billingLabel:p,hideShipping:L,hideBilling:k}=E;return n(ne,{variant:s,className:"account-address-card","data-testid":"addressCard",children:l?n(Ee,{}):_(D,{children:[_("div",{className:"account-address-card__action",children:[u?n(X,{type:"button",variant:"tertiary",onClick:P,"data-testid":"removeButton","aria-label":Xe(c==null?void 0:c.defaultShipping,c==null?void 0:c.defaultBilling,y,"removeButton"),"aria-describedby":b,children:y.actionRemove}):null,h?n(X,{type:"button",variant:"tertiary",onClick:S,className:"account-address-card__action--editbutton","data-testid":"editButton","aria-label":Xe(c==null?void 0:c.defaultShipping,c==null?void 0:c.defaultBilling,y,"editButton"),"aria-describedby":b,children:y.actionEdit}):null]}),n("div",{className:"account-address-card__description",id:b,children:e!=null&&e.AddressCard?n(ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:N}}):n(D,{children:N.map((M,C)=>{const B=M.label?`${M.label}: ${M==null?void 0:M.value}`:M==null?void 0:M.value;return n("p",{"data-testid":`${M.name}_${C}`,children:B},C)})})}),(c!=null&&c.defaultShipping||c!=null&&c.defaultBilling)&&!a?_("div",{className:"account-address-card__labels",children:[c!=null&&c.defaultShipping?n(pe,{label:v}):null,c!=null&&c.defaultBilling?n(pe,{label:w}):null]}):null,a?_("div",{className:"account-address-card__labels",children:[!L&&(c!=null&&c.defaultShipping)?n(pe,{label:i}):null,!k&&(c!=null&&c.defaultBilling)?n(pe,{label:p}):null]}):null]})})},dr=e=>Z.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},Z.createElement("g",{id:"Large"},Z.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Z.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},Z.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"}),Z.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"})))),lr=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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"})),ur=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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}),Z.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}),Z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),Z.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}),Z.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})),Yr=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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"}),Z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),ke=e=>Z.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},Z.createElement("g",{id:"Large"},Z.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Z.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},Z.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"})))),mr=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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"})),Dr=e=>Z.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},Z.createElement("g",{clipPath:"url(#clip0_841_1324)"},Z.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"}),Z.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"})),Z.createElement("defs",null,Z.createElement("clipPath",{id:"clip0_841_1324"},Z.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)",strokeWidth:1})))),Qe=e=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Z.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"}),Z.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"})),et=({selectable:e,className:a,addNewAddress:t,minifiedView:r,routeAddressesPage:s})=>{const o=r?"minifiedView":"fullSizeView",d=G({viewAllAddressesButton:`Account.${o}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${o}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${o}.Addresses.differentAddressButton`}),c=e?"span":"button",l=e?{}:{AriaRole:"button",type:"button"},m=r&&!t?d.viewAllAddressesButton:d.addNewAddressButton,u=e?d.differentAddressButton:m;return _(c,{...l,className:U(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],a]),"data-testid":"showRouteFullAddress",onClick:s,children:[n("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:u}),n(ve,{source:r&&!t?ke:dr,size:"32"})]})},hr=({minifiedView:e,keysSortOrder:a,addressData:t,open:r,submitLoading:s,onRemoveAddress:o,closeModal:d})=>{const c=e?"minifiedView":"fullSizeView",l=G({title:`Account.${c}.Addresses.removeAddressModal.title`,description:`Account.${c}.Addresses.removeAddressModal.description`,actionCancel:`Account.${c}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${c}.Addresses.removeAddressModal.actionConfirm`});return r?n(it,{className:"account-address-modal--overlay",title:n("h3",{children:l.title}),size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:d,children:_("div",{className:"account-address-modal",children:[s?n("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:n(dt,{stroke:"4",size:"large"})}):null,n("p",{children:l.description}),n(Fe,{minifiedView:e,addressData:t,keysSortOrder:a}),_("div",{className:"account-address-modal__buttons",children:[n(X,{type:"button",onClick:d,variant:"secondary",disabled:s,children:l.actionCancel}),n(X,{disabled:s,onClick:o,children:l.actionConfirm})]})]})}):null},He=({typeList:e,isEmpty:a,minifiedView:t,className:r})=>{const s=t?"minifiedView":"fullSizeView",o=G({addressesMessage:`Account.${s}.EmptyList.Addresses.message`,ordersListMessage:`Account.${s}.EmptyList.OrdersList.message`,paymentsMessage:`Account.${s}.EmptyList.Payments.message`}),d=Ce(()=>{switch(e){case"address":return{icon:lr,text:n("p",{children:o.addressesMessage})};case"orders":return{icon:mr,text:n("p",{children:o.ordersListMessage})};case"payments":return{icon:ur,text:n("p",{children:o.paymentsMessage})};default:return{icon:"",text:""}}},[e,o]);return!a||!e||!d.text?null:n(fe,{className:U(["account-empty-list",t?"account-empty-list--minified":"",r]),message:d.text,icon:n(ve,{source:d.icon}),"data-testid":"emptyList"})},tt={size:"32",stroke:"2"},rt=({minifiedView:e,orderNumber:a,orderToken:t,routeOrdersList:r,routeOrderDetails:s})=>{const o=e?"minifiedView":"fullSizeView",d=G({viewAllOrdersButton:`Account.${o}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${o}.OrdersList.ariaLabelLink`});return r?n("a",{className:U(["account-orders-list-action",["account-orders-list-action--minifiedView",e]]),"data-testid":"ordersListActionButtonMinifiedView",href:r(),children:n(ne,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:_("div",{className:"account-orders-list-action__card-wrapper",children:[n("p",{children:d.viewAllOrdersButton}),n(ve,{source:ke,...tt})]})})}):n("a",{"aria-label":`${d.ariaLabelLink} ${a??t}`,href:_e(s)?s(a,t):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:n(ve,{source:ke,...tt})})},pr=()=>{const[e,a]=$(window.innerWidth<768);return J(()=>{const t=()=>{a(window.innerWidth<768)};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),e},fr=({placeholderImage:e,minifiedView:a,item:t,withThumbnails:r,children:s,slots:o,routeTracking:d,routeOrderProduct:c,routeReturnDetails:l,...m})=>{var w,v,f,E,P,S,N,i,p,L,k,M;const u=a?"minifiedView":"fullSizeView",h=G({orderNumber:`Account.${u}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${u}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${u}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${u}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${u}.OrdersList.OrdersListCard.orderDate`,placedByAdministrator:`Account.${u}.OrdersList.OrdersListCard.placedByAdministrator`}),b=pr(),A=_e(c),y=oe(()=>((t==null?void 0:t.items)??[]).map((C,B)=>{var T,I;const g={title:(C==null?void 0:C.productName)??"",src:((I=(T=C==null?void 0:C.product)==null?void 0:T.smallImage)==null?void 0:I.url)||e,alt:(C==null?void 0:C.productName)??"",width:65,height:65,loading:"eager"};return n(ae,{name:"OrderItemImage",slot:o==null?void 0:o.OrderItemImage,context:{data:C,defaultImageProps:g},children:A?n("a",{href:(c==null?void 0:c(C))??"",target:"_blank",rel:"noreferrer",children:n(Ge,{...g})}):n(Ge,{...g})},`${B}_${C.id}`)}),[A,t.items,e,c,o==null?void 0:o.OrderItemImage]);return _(ne,{variant:"secondary",...m,className:U(["account-orders-list-card",["account-orders-list-card--full",((w=t==null?void 0:t.items)==null?void 0:w.length)>6]]),children:[n("div",{className:"account-orders-list-card__content",children:o!=null&&o.OrdersListCard?n(ae,{"data-testid":`ordersListCard${t.id}`,name:"OrdersListCard",slot:o==null?void 0:o.OrdersListCard,context:{orderHistoryListItem:t}}):_(D,{children:[n("div",{children:t==null?void 0:t.status}),(t==null?void 0:t.adminAssistedOrder)>0&&n("div",{children:h.placedByAdministrator}),o!=null&&o.OrdersListOrderTime?n(ae,{"data-testid":`ordersListOrderTime${t.id}`,name:"OrdersListOrderTime",slot:o==null?void 0:o.OrdersListOrderTime,context:{deliveryDateText:h.deliveryDateText,orderDate:t==null?void 0:t.orderDate,orderTime:t==null?void 0:t.orderTime}}):_("p",{children:[h.deliveryDateText," ",t==null?void 0:t.orderDate]}),_("p",{children:[h.orderNumber," ",t.number]}),(v=t==null?void 0:t.shipments)==null?void 0:v.map(C=>{var B;return(B=C==null?void 0:C.tracking)==null?void 0:B.map(g=>{const T=d==null?void 0:d(g);return _("p",{"data-testid":g.number,children:[n("span",{children:`${h.carrier} ${g.carrier.toLocaleUpperCase()} `}),T?n("a",{href:T,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:g.number}):n("span",{className:"account-orders-list-card__content--track_number",children:g.number})]},C.id)})}),t!=null&&t.returns&&((f=t.returns)!=null&&f.length)?_("p",{"data-testid":t.number,children:[_("span",{children:[h.returnsText," "]}),(E=t==null?void 0:t.returns)==null?void 0:E.map(C=>n("span",{"data-testid":C.number,children:_("a",{href:(l==null?void 0:l({orderNumber:t.number,orderToken:t.token,returnNumber:C.number}))??"#",className:"account-orders-list-card__content--return_number",children:[C.number," "]})},C.uid))]},t.id):null,n("p",{children:n($t,{amount:((S=(P=t==null?void 0:t.total)==null?void 0:P.grandTotal)==null?void 0:S.value)??0,currency:(i=(N=t==null?void 0:t.total)==null?void 0:N.grandTotal)==null?void 0:i.currency,weight:"normal",size:"medium"})}),_("p",{"data-testid":"itemsAmount",children:[(p=t==null?void 0:t.items)!=null&&p.length?(L=t==null?void 0:t.items)==null?void 0:L.reduce((C,B)=>{const g=(B==null?void 0:B.quantityOrdered)||0;return C+g},0):0," ",h.itemsAmount]}),(k=t==null?void 0:t.items)==null?void 0:k.map((C,B)=>{if(B>=0&&B<10)return _("p",{className:"account-orders-list-card__content--product-name",children:[_("span",{className:"account-orders-list-card__content--quantity",children:[(C==null?void 0:C.quantityOrdered)>1?C==null?void 0:C.quantityOrdered:null," "]}),C==null?void 0:C.productName.replaceAll("-"," ")]},`${B}_${C.id}`);if(B===11)return n("p",{children:"..."},"ellipsis")})]})}),r&&((M=t==null?void 0:t.items)!=null&&M.length)?n(Pt,{maxColumns:b?3:9,emptyGridContent:n(D,{}),className:U(["account-orders-list-card__images",["account-orders-list-card__images-3",b]]),"data-testid":"ordersListCardImages",children:y}):null,n("div",{className:"account-orders-list-card__actions",children:s})]})},gr=async(e,a)=>{if(a.length===1){const d=a[0],l=Object.values(d.region).every(u=>!!u)?{}:{region:{...d.region,regionId:0}};return!!await Ie({addressId:Number(d==null?void 0:d.id),defaultShipping:!1,defaultBilling:!1,...l})}const t=a.filter(d=>d.id!==e&&(d.defaultBilling||d.defaultShipping)||d.id!==e),r=a[a.length-1],s=t[0]||((r==null?void 0:r.id)!==e?r:null);return!s||!s.id?!1:!!await Ie({addressId:+s.id,defaultShipping:!0,defaultBilling:!0})},Ar=["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"],Xr=["email","firstname","lastname","middlename","gender","dob","prefix","suffix","fax"],yt=(e,a,t)=>{if(a&&t||!a&&!t)return e;const r=e.slice();return a?r.sort((s,o)=>Number(o.defaultShipping)-Number(s.defaultShipping)):t?r.sort((s,o)=>Number(o.defaultBilling)-Number(s.defaultBilling)):e},Ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(Ve),yr=({selectShipping:e,selectBilling:a,defaultSelectAddressId:t,onAddressData:r,minifiedView:s,routeAddressesPage:o,onSuccess:d})=>{const[c,l]=$(""),[m,u]=$(!1),[h,b]=$(!1),[A,y]=$(!1),[w,v]=$(!1),[f,E]=$(!1),[P,S]=$(""),[N,i]=$([]),[p,L]=$([]),k=x(async()=>{y(!0),Promise.all([ft("shortRequest"),Ft()]).then(H=>{const[V,F]=H;if(V){const q=V.map(({name:O,orderNumber:W,label:j})=>({name:kt(O),orderNumber:W,label:Ar.includes(O)?null:j}));L(q)}if(F)if(s){const q=F.filter(W=>!!W.defaultShipping||!!W.defaultBilling),O=q.length?q:F.slice(-1);i(O)}else i(F)}).finally(()=>{y(!1)})},[s]);J(()=>{k()},[k]),J(()=>{var H;if(N.length)if(t===0)E(!0),l("0");else{const V=N.find(q=>{var O;return typeof t=="string"?q.uid===t||((O=q.id)==null?void 0:O.toString())===t:+q.id===t})||yt(N,e,a)[0],F={data:le(V),isDataValid:!Ve(V)};l(((H=V==null?void 0:V.id)==null?void 0:H.toString())||(V==null?void 0:V.uid)||""),r==null||r(F)}},[N,t,r,a,e]);const M=x(H=>{S(H),E(!1)},[]),C=x((H,V)=>{const F=(H==null?void 0:H.target).value,q=(H==null?void 0:H.target).nextSibling;l(F);const O={data:le(V),isDataValid:!Ve(le(V))};r==null||r(O),E(F==="0"),q&&(q.focus(),window.scrollBy(0,100))},[r]),B=x(()=>{b(!0)},[]),g=x(()=>{S(""),b(!1),u(!1)},[]),T=x(()=>{u(!0)},[]),I=x(async()=>{v(!0),await gr(P,N),Vt(+P).then(()=>{k(),g()}).finally(()=>{v(!1)})},[N,P,g,k]),R=x(()=>{E(!1)},[]),z=x(()=>{_e(o)&&s&&!f?window.location.href=o():(E(!0),S(""))},[f,o,s]),Y=x(async()=>{await k(),await(d==null?void 0:d())},[k,d]);return{keysSortOrder:p,submitLoading:w,isModalRendered:m,isFormRendered:h,loading:A,addNewAddress:f,addressesList:N,addressId:P,handleRenderForm:B,handleRenderModal:T,removeAddress:I,onCloseBtnClick:g,setEditingAddressId:M,closeNewAddressForm:R,redirectToAddressesRoute:z,handleOnSuccess:Y,handleSelectAddressOption:C,selectedAddressOption:c}},Qr=Be(({minifiedViewKey:e,hideActionFormButtons:a=!1,inputName:t,slots:r,title:s="",addressFormTitle:o="",defaultSelectAddressId:d="",showFormLoader:c=!1,onAddressData:l,forwardFormRef:m,className:u,showSaveCheckBox:h=!1,saveCheckBoxValue:b=!1,selectShipping:A=!1,selectBilling:y=!1,selectable:w=!1,withHeader:v=!0,minifiedView:f=!1,withActionsInMinifiedView:E=!1,withActionsInFullSizeView:P=!0,inputsDefaultValueSet:S,showShippingCheckBox:N=!0,showBillingCheckBox:i=!0,shippingCheckBoxValue:p=!0,billingCheckBoxValue:L=!0,routeAddressesPage:k,onSubmit:M,onSuccess:C,onError:B,fieldIdPrefix:g})=>{const T=G({containerTitle:`Account.${e}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${e}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${e}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${e}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${e}.Addresses.newAddressFormTitle`,ariaLabelAddressPicker:`Account.${e}.Addresses.ariaLabelAddressPicker`}),{keysSortOrder:I,submitLoading:R,isModalRendered:z,isFormRendered:Y,loading:H,addNewAddress:V,addressesList:F,addressId:q,handleRenderForm:O,handleRenderModal:W,removeAddress:j,onCloseBtnClick:ee,handleOnSuccess:Q,setEditingAddressId:te,closeNewAddressForm:he,redirectToAddressesRoute:Re,handleSelectAddressOption:qe,selectedAddressOption:ze}=yr({defaultSelectAddressId:d,minifiedView:f,routeAddressesPage:k,onSuccess:C,onAddressData:l,selectShipping:A,selectBilling:y}),ge=s||T.containerTitle;let Ne=null;if(w){const re=yt(F,A,y)||[];let ce;V?ce=n("div",{className:U(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",V]]),children:n(ye,{slots:r,hideActionFormButtons:a,fieldIdPrefix:g,formName:t,showFormLoader:c,isOpen:V,forwardFormRef:m,showSaveCheckBox:h,saveCheckBoxValue:b,shippingCheckBoxValue:p,billingCheckBoxValue:L,addressesFormTitle:o||T.differentAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:N,showBillingCheckBox:i,onCloseBtnClick:he,onChange:l,onError:B,onSubmit:M,onSuccess:Q})}):re.length?ce=n(et,{selectable:w,minifiedView:f,addNewAddress:V,routeAddressesPage:Re}):ce=null;const Ue=`generalLabel_${ge.replace(/\s+/g,"")}`;Ne=_("div",{className:"account-addresses-wrapper--select-view",children:[n("span",{id:Ue,style:"display: none;",children:ge}),re.map((ie,wt)=>{var je;const Ae=((je=ie.id)==null?void 0:je.toString())||ie.uid,Me=`${t}_${Ae}`,We=`${Me}_label`;return _(Ke,{children:[n("input",{"data-testid":`radio-${wt+1}`,type:"radio",name:t,id:Me,value:Ae,checked:ze===Ae,onChange:_t=>qe(_t,ie),"aria-labelledby":`${Ue} ${We}`}),n("label",{id:We,htmlFor:Me,className:"account-addresses-wrapper__label",children:n(Fe,{slots:r,selectable:w,selectShipping:A,selectBilling:y,minifiedView:f,addressData:ie,keysSortOrder:I,loading:H})})]},Ae)}),ce&&_("div",{className:"account-addresses-wrapper__footer-section",children:[n("input",{"aria-label":`${ge} ${T.ariaLabelAddressPicker}`,"data-testid":"radio-0",type:"radio",name:t,id:`${t}_addressActions`,value:"0",checked:ze==="0",onChange:ie=>qe(ie,{}),tabindex:ce?0:-1}),n("label",{htmlFor:`${t}_addressActions`,className:"account-addresses-wrapper__label",children:ce})]})]})}else Ne=_(D,{children:[F.map(re=>n(Ke,{children:q===re.id&&Y?n(ne,{variant:"secondary",style:{marginBottom:20},children:n(ye,{slots:r,fieldIdPrefix:g,isOpen:q===re.id&&Y,addressFormId:q,inputsDefaultValueSet:re,addressesFormTitle:T.editAddressFormTitle,showShippingCheckBox:N,showBillingCheckBox:i,shippingCheckBoxValue:p,billingCheckBoxValue:L,forwardFormRef:m,onCloseBtnClick:ee,onChange:l,onError:B,onSubmit:M,onSuccess:Q})}):n(Fe,{slots:r,minifiedView:f,addressData:re,keysSortOrder:I,loading:H,setAddressId:te,handleRenderModal:f&&E||!f&&P?W:void 0,handleRenderForm:f&&E||!f&&P?O:void 0},re.id)},re.id)),n("div",{className:"account-addresses__footer",children:V?n(ne,{variant:"secondary",children:n(ye,{slots:r,fieldIdPrefix:g,isOpen:V,addressesFormTitle:T.newAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:!!(F!=null&&F.length),showBillingCheckBox:!!(F!=null&&F.length),shippingCheckBoxValue:p,billingCheckBoxValue:L,forwardFormRef:m,onChange:l,onCloseBtnClick:he,onError:B,onSubmit:M,onSuccess:Q})}):n(et,{minifiedView:f,addNewAddress:V,routeAddressesPage:Re})})]});return _("div",{children:[v?n(me,{title:ge,divider:!f,className:f?"account-addresses-header":""}):null,_("div",{className:U(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[n(hr,{minifiedView:f,addressData:F==null?void 0:F.find(re=>re.id===q),keysSortOrder:I,submitLoading:R,open:z,closeModal:ee,onRemoveAddress:j}),H?n(Ee,{testId:"addressSkeletonLoader",withCard:!1}):w?n(ye,{slots:r,hideActionFormButtons:a,fieldIdPrefix:g,formName:t,isOpen:!(F!=null&&F.length),forwardFormRef:m,showSaveCheckBox:h,saveCheckBoxValue:b,shippingCheckBoxValue:p,billingCheckBoxValue:L,inputsDefaultValueSet:S,showShippingCheckBox:N,showBillingCheckBox:i,onChange:l,onCloseBtnClick:he,onError:B,onSubmit:M,onSuccess:Q}):n(He,{isEmpty:!(F!=null&&F.length),typeList:"address",minifiedView:f}),Ne]})]})}),Lt={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Lr={...Lt,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},br={...Lt,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},vr=(e,a)=>a==null?void 0:a.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}),nt=e=>{if(!e)return null;const a=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{a.has(r.name)||a.set(r.name,"false"),r.checked&&a.set(r.name,"true")}),a&&typeof a.entries=="function"){const r=a.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},Cr=({fields:e,addressId:a,countryOptions:t,disableField:r,regionOptions:s,isRequiredRegion:o,isRequiredPostCode:d})=>e.filter(l=>!(a&&(l.customUpperCode==="defaultShipping"||l.customUpperCode==="defaultBilling")&&l.defaultValue)).map(l=>l.customUpperCode==="countryCode"?{...l,options:t,disabled:r}:l.customUpperCode==="postcode"?{...l,required:d}:l.customUpperCode==="region"?{...l,options:s,required:o,disabled:r}:l),wr=(e,a="address")=>{const t=a==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","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:pt(o),value:e[o]})}),s.length>0&&(r.custom_attributesV2=s),r},at=e=>{const a=["street","streetMultiline_1","streetMultiline_2"],t=["on","off","true","false"],r=[],s={};for(const y in e){const w=e[y];t.includes(w)&&(s[y]=gt(w)),a.includes(y)&&r.push(w)}const{street:o,streetMultiline_2:d,streetMultiline_1:c,region:l,...m}=e,[u,h]=l?l.split(","):[void 0,void 0],b=h&&u?{regionId:+h,regionCode:u}:{region:u};return wr({...m,...s,region:{...b},street:r})},_r=(e,a)=>{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=a.find(d=>(d==null?void 0:d.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,d)=>{t[`${r}Multiline_${d+2}`]=o})):t[r]=s}return t},Er=(e,a)=>e&&Object.keys(e).length>0?e:a&&Object.keys(a).length>0?a:{},Nr=({showFormLoader:e,showSaveCheckBox:a,saveCheckBoxValue:t,addressFormId:r,billingCheckBoxValue:s,shippingCheckBoxValue:o,showShippingCheckBox:d,showBillingCheckBox:c,inputsDefaultValueSet:l,onCloseBtnClick:m,onSuccess:u,onError:h,formName:b})=>{const[A,y]=$({text:"",type:"success"}),[w,v]=$(e??!1),[f,E]=$(r||""),[P,S]=$([]),[N,i]=$(null),[p,L]=$(()=>{var W,j;const O=sessionStorage.getItem(`${b}_addressData`);return O?{countryCode:(j=(W=JSON.parse(O))==null?void 0:W.data)==null?void 0:j.countryCode}:l}),[k,M]=$(!1),[C,B]=$(()=>{var j,ee;const O=sessionStorage.getItem(`${b}_addressData`);return O?(ee=(j=JSON.parse(O))==null?void 0:j.data)==null?void 0:ee.saveAddressBook:t}),g=x(O=>{B(O.target.checked)},[]);J(()=>{typeof e>"u"||v(e)},[e]),J(()=>{ft(f?"customer_address_edit":"customer_register_address").then(O=>{S(O)})},[f]),J(()=>{M(!0),xt().then(({availableCountries:O,countriesWithRequiredRegion:W,optionalZipCountries:j})=>{i({availableCountries:O,countriesWithRequiredRegion:W,optionalZipCountries:j}),M(!1)})},[]);const T=oe(()=>(N==null?void 0:N.availableCountries)||[],[N]),I=oe(()=>!(p!=null&&p.countryCode)||!N?!1:N.countriesWithRequiredRegion.includes(p.countryCode),[p==null?void 0:p.countryCode,N]),R=oe(()=>!(p!=null&&p.countryCode)||!N?!0:!N.optionalZipCountries.includes(p.countryCode),[p==null?void 0:p.countryCode,N]),z=oe(()=>{var W;if(!(p!=null&&p.countryCode)||!N)return[];const O=N.availableCountries.find(j=>j.value===p.countryCode);return((W=O==null?void 0:O.availableRegions)==null?void 0:W.map(j=>({text:j.name,value:`${j.code},${j.id}`})))||[]},[p==null?void 0:p.countryCode,N]),Y=x(()=>{y({text:"",type:"success"}),m==null||m()},[m]),H=x(async(O,W)=>{if(!W)return null;v(!0);const j=nt(O.target),ee=at(j);await Ie(ee).then(()=>{var Q;u==null||u(),m==null||m(),(Q=O==null?void 0:O.target)==null||Q.reset()}).catch(Q=>{y(te=>({...te,text:Q.message,type:"error"})),h==null||h(Q)}).finally(()=>{E(""),v(!1)})},[m,h,u]),V=x(async(O,W)=>{if(!W)return;v(!0);const{saveAddressBook:j,...ee}=nt(O.target),Q=at(ee);await Zt(Q).then(()=>{var te;u==null||u(),m==null||m(),(te=O==null?void 0:O.target)==null||te.reset()}).catch(te=>{y(he=>({...he,text:te.message,type:"error"})),h==null||h(te)}).finally(()=>{E(""),v(!1)})},[m,h,u]),F=oe(()=>{if(!P.length)return[];const O={...Lr,defaultValue:o??!1,isHidden:a&&!C?!0:!d},W={...br,defaultValue:s??!1,isHidden:a&&!C?!0:!c},j=[...P,O,W],ee=sessionStorage.getItem(`${b}_addressData`),Q=ee?_r(JSON.parse(ee).data,z):{},te=vr(Er(Q,l),j);return Cr({fields:te,addressId:f,countryOptions:T,disableField:k,regionOptions:z,isRequiredRegion:I,isRequiredPostCode:R})},[P,o,a,C,d,s,c,b,z,l,f,T,k,I,R]),q=x(O=>{L(W=>({...W,...O}))},[]);return{regionOptions:z,saveCheckBoxAddress:C,inLineAlert:A,addressId:f,submitLoading:w,normalizeFieldsConfig:F,handleSaveCheckBoxAddress:g,handleUpdateAddress:H,handleCreateAddress:V,handleOnCloseForm:Y,handleInputChange:q}},Mr=e=>{var s;if(!e||!Array.isArray(e.customAttributes))return e??{};const a={};(s=e==null?void 0:e.customAttributes)==null||s.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(a[o.code]=o.value)});const{customAttributes:t,...r}=e;return{...r,...ht(a,"camelCase",{})}},$r=({hideActionFormButtons:e,formName:a="",showFormLoader:t=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:s=!1,forwardFormRef:o,slots:d,addressesFormTitle:c,className:l,addressFormId:m,inputsDefaultValueSet:u,showShippingCheckBox:h=!0,showBillingCheckBox:b=!0,shippingCheckBoxValue:A=!0,billingCheckBoxValue:y=!0,isOpen:w,fieldIdPrefix:v,onSubmit:f,onCloseBtnClick:E,onSuccess:P,onError:S,onChange:N})=>{const i=G({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{inLineAlert:p,addressId:L,submitLoading:k,normalizeFieldsConfig:M,handleUpdateAddress:C,handleCreateAddress:B,handleOnCloseForm:g,handleSaveCheckBoxAddress:T,saveCheckBoxAddress:I,handleInputChange:R,regionOptions:z}=Nr({showFormLoader:t,addressFormId:m,inputsDefaultValueSet:Mr(u),shippingCheckBoxValue:A,billingCheckBoxValue:y,showShippingCheckBox:h,showBillingCheckBox:b,saveCheckBoxValue:s,showSaveCheckBox:r,onSuccess:P,onError:S,onCloseBtnClick:E,formName:a}),[Y,H]=$(0);return J(()=>{H(V=>V+1)},[u]),w?_("div",{className:U(["account-address-form-wrapper",l]),children:[c?n("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:c}):null,p.text?n(ue,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:p.type,variant:"secondary",heading:p.text,icon:p.icon}):null,_(At,{regionOptions:z,forwardFormRef:o,slots:d,className:"account-address-form",name:a||"addressesForm",fieldsConfig:M,onSubmit:f||(L?C:B),setInputChange:R,loading:k,showFormLoader:t,showSaveCheckBox:r,handleSaveCheckBoxAddress:T,saveCheckBoxAddress:I,onChange:N,fieldIdPrefix:v,children:[L?n("input",{type:"hidden",name:"addressId",value:L,"data-testid":"hidden_test_id"}):null,e?null:n("div",{className:U(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:d!=null&&d.AddressFormActions?n(ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:d.AddressFormActions,context:{handleUpdateAddress:C,handleCreateAddress:B,addressId:L}}):n(D,{children:r?null:_(D,{children:[n(X,{type:"button",onClick:g,variant:"secondary",disabled:k,children:i.secondaryButton}),n(X,{disabled:k,children:i.primaryButton})]})})})]},Y)]}):null},Pr=({currentPassword:e,newPassword:a,confirmPassword:t,translations:r})=>{let s={...xe};const o=!e.length&&!a.length&&!t.length,d=e.length&&a!==t;return o?(s={...s,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:s}):e.length?a.length?t.length?d?(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})},bt=(e,a)=>{if(a<=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>=a},xe={currentPassword:"",newPassword:"",confirmPassword:""},Tr=({passwordConfigs:e,handleSetInLineAlert:a,handleHideChangePassword:t})=>{const r=G({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]=$(!1),[d,c]=$(!1),[l,m]=$(""),[u,h]=$(""),[b,A]=$(""),[y,w]=$({currentPassword:"",newPassword:"",confirmPassword:""}),v=x(()=>{t(()=>{a({}),w(xe)})},[t,a]),f=x(p=>{m(p),w(L=>({...L,currentPassword:p?"":r.requiredFieldError}))},[r]),E=x(p=>{h(p),w(L=>({...L,newPassword:p?"":r.requiredFieldError}))},[r]),P=x(p=>{A(p),w(L=>({...L,confirmPassword:p?"":r.requiredFieldError}))},[r]),S=x(p=>{const{name:L,value:k}=p==null?void 0:p.target;w(M=>({...M,[L]:k?"":r.requiredFieldError}))},[r]),N=x(()=>{const{isValid:p,errors:L}=Pr({currentPassword:l,newPassword:u,confirmPassword:b,translations:r});return w(L),p},[l,u,b,r]),i=x(p=>{p.preventDefault(),c(!0);const L=(e==null?void 0:e.requiredCharacterClasses)??0,k=(e==null?void 0:e.minLength)??1;if(!N()){o(!0),c(!1);return}if(!bt(u,L)||k>(u==null?void 0:u.length)){o(!0),c(!1);return}Bt({currentPassword:l,newPassword:u}).then(M=>{if(!(M!=null&&M.length)){c(!1);return}m(""),h(""),A(""),w(xe),o(!1),a({type:"success",text:r.passwordUpdateMessage})}).catch(M=>{M.message==="Invalid login or password."&&a({type:"error",text:r.incorrectCurrentPassword}),M.message==="The account is locked."&&a({type:"error",text:M.message})}),c(!1)},[e,N,u,l,a,r]);return{hideChangePassword:v,handleOnBlurPassword:S,handleConfirmPasswordChange:P,handleNewPasswordChange:E,handleCurrentPasswordChange:f,mutationChangePassword:i,currentPassword:l,newPassword:u,confirmPassword:b,passwordErrors:y,submitLoading:d,isClickSubmit:s}},Sr=({passwordConfigs:e,isClickSubmit:a,password:t})=>{const r=G({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[s,o]=$("pending");J(()=>{if(!e)return;const c=bt(t,e.requiredCharacterClasses);a&&t.length>0?o(c?"success":"error"):a&&t.length===0?o("pending"):o(c?"success":"pending")},[a,e,t]);const d=oe(()=>{var l;if(!e)return;const c={status:"pending",icon:"pending",message:(l=r.messageLengthPassword)==null?void 0:l.replace("{minLength}",`${e.minLength}`)};return t.length&&t.length>=e.minLength?{...c,icon:"success",status:"success"}:t.length&&t.length<e.minLength?a?{...c,icon:"error",status:"error"}:{...c,icon:"pending",status:"pending"}:c},[e,r.messageLengthPassword,t==null?void 0:t.length,a]);return{isValidUniqueSymbols:s,defaultLengthMessage:d}},Or=(e,a,t,r,s)=>e==="error"||(a==null?void 0:a.status)==="error"||t&&r.trim().length===0?s.newPassword:void 0,en=({handleHideChangePassword:e,handleSetInLineAlert:a,inLineAlertProps:t})=>{const{passwordConfigs:r}=Ut(),{hideChangePassword:s,handleOnBlurPassword:o,handleConfirmPasswordChange:d,handleNewPasswordChange:c,handleCurrentPasswordChange:l,mutationChangePassword:m,currentPassword:u,newPassword:h,confirmPassword:b,passwordErrors:A,submitLoading:y,isClickSubmit:w}=Tr({passwordConfigs:r,handleSetInLineAlert:a,handleHideChangePassword:e}),{isValidUniqueSymbols:v,defaultLengthMessage:f}=Sr({password:h,isClickSubmit:w,passwordConfigs:r}),E=G({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 _(ne,{className:"account-change-password",variant:"secondary",children:[n(me,{title:E.containerTitle,divider:!1,className:"account-change-password__title"}),t.text?n(ue,{className:"account-change-password__notification",type:t.type,variant:"secondary",heading:t.text,icon:t.icon,"data-testid":"changePasswordInLineAlert"}):null,_("div",{className:"account-change-password__fields",children:[n(Le,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:E.currentPasswordPlaceholder,floatingLabel:E.currentPasswordFloatingLabel,errorMessage:A.currentPassword,defaultValue:u,onValue:l,onBlur:o}),n(Le,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:E.newPasswordPlaceholder,floatingLabel:E.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:f,uniqueSymbolsStatus:v,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:Or(v,f,w,h,A),defaultValue:h,onValue:c,onBlur:o}),n(Le,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:E.confirmPasswordPlaceholder,floatingLabel:E.confirmPasswordFloatingLabel,errorMessage:A.confirmPassword,defaultValue:b,onValue:d,onBlur:o})]}),_("div",{className:"account-change-password__actions",children:[n(X,{type:"button",disabled:y,onClick:s,variant:"secondary",children:E.buttonSecondary}),n(X,{variant:"primary",type:"button",disabled:y,onClick:m,children:E.buttonPrimary})]})]})},tn=({inLineAlertProps:e,errorPasswordEmpty:a,passwordValue:t,showPasswordOnEmailChange:r,submitLoading:s,formFieldsList:o,handleHideEditForm:d,handleUpdateCustomerInformation:c,handleInputChange:l,handleSetPassword:m,handleOnBlurPassword:u})=>{const h=G({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 _(ne,{variant:"secondary",className:"account-edit-customer-information",children:[n(me,{title:h.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?n(ue,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,_(At,{loading:s,fieldsConfig:o||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:c,setInputChange:l,children:[r?n("div",{className:"account-edit-customer-information__password",children:n(Le,{autoComplete:"password",name:"password",placeholder:h.placeholder,floatingLabel:h.floatingLabel,errorMessage:a?h.requiredFieldError:void 0,defaultValue:t,onValue:m,onBlur:u})}):null,_("div",{className:"account-edit-customer-information__actions",children:[n(X,{disabled:s,type:"button",variant:"secondary",onClick:()=>d(),children:h.buttonSecondary}),n(X,{disabled:s,type:"submit",variant:"primary",children:h.buttonPrimary})]})]})]})},rn=({createdAt:e,slots:a,orderedCustomerData:t,showEditForm:r,showChangePassword:s,handleShowChangePassword:o,handleShowEditForm:d})=>{const c=G({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return n(ne,{variant:"secondary",className:U(["account-customer-information-card",["account-customer-information-card-short",s||r]]),children:_("div",{className:"account-customer-information-card__wrapper",children:[_("div",{className:"account-customer-information-card__actions",children:[n(X,{type:"button",variant:"tertiary",onClick:o,children:c.buttonSecondary}),n(X,{type:"button",variant:"tertiary",onClick:d,children:c.buttonPrimary})]}),n("div",{className:"account-customer-information-card__content",children:a!=null&&a.CustomerData?n(ae,{name:"CustomerData",slot:a==null?void 0:a.CustomerData,context:{customerData:t}}):_(D,{children:[t==null?void 0:t.map((l,m)=>{const u=l!=null&&l.label?`${l.label}: ${l==null?void 0:l.value}`:l==null?void 0:l.value;return n("p",{"data-testid":`${l.name}_${m}`,children:u},`${l.name}_${m}`)}),_("p",{children:[c.accountCreation,": ",e]})]})})]})})};function Ir(e){if(!e)return[];const a=`${e.firstName} ${e.lastName}`.trim(),t=e.street??"",r=e.city??"",s=e.region||void 0,o=e.postcode??"",d=e.countryCode??"";let c="";r&&s?c=`${r}, ${(s==null?void 0:s.regionCode)??""}`.trim():r?c=r:s&&(c=(s==null?void 0:s.regionCode)??"");let l=c;o&&(l=c?`${c} ${o}`:o);let m=l;return d&&(m=l?`${l}, ${d}`:d),[a,t,m]}const st=({title:e,address:a,selected:t,busy:r,onChange:s})=>{const[o,d,c]=Ir(a);return n("div",{className:"account-address-validation__option",children:n(Tt,{busy:r,className:"account-address-validation__radio",label:_("div",{children:[n("div",{className:"account-address-validation__option-title",children:n("strong",{children:e})}),o&&n("div",{children:o}),d&&n("div",{children:d}),c&&n("div",{children:c})]}),name:"address-validation-choice",selected:t,value:e,onChange:s})})},nn=({busy:e=!1,className:a,originalAddress:t,onSelectionChange:r,selection:s,suggestedAddress:o})=>{const d=!!o,c=G({title:"Account.AddressValidation.title",subtitle:"Account.AddressValidation.subtitle",suggestedAddress:"Account.AddressValidation.suggestedAddress",originalAddress:"Account.AddressValidation.originalAddress"});return _("div",{className:U(["account-address-validation",a]),children:[n(me,{className:"account-address-validation__title",divider:!1,title:c.title}),n("div",{className:"account-address-validation__subtitle",children:c.subtitle}),_("div",{className:U(["account-address-validation__options",e&&"account-address-validation__options--busy"]),children:[d&&n(st,{address:o,busy:e,selected:s==="suggested",title:c.suggestedAddress,onChange:()=>r("suggested")}),n(st,{address:t,busy:e,selected:s==="original",title:c.originalAddress,onChange:()=>r("original")})]})]})},an=({loading:e,isRemoteShoppingAssistanceAvailable:a,isRemoteShoppingAssistanceEnabled:t,showAlert:r,checkboxLabel:s,checkboxTooltip:o,alertMessage:d,featureDisabledMessage:c,handleCheckboxChange:l,handleDismissAlert:m})=>{const[u,h]=$(!1);return e?n(we,{children:n(K,{variant:"row"})}):!e&&!a?n("div",{className:"account-seller-assisted-buying-settings-control__alert",children:n(fe,{heading:c})}):_("div",{className:"account-seller-assisted-buying-settings-control",children:[!t&&r&&n("div",{className:"account-seller-assisted-buying-settings-control__alert",children:n(ue,{variant:"secondary",type:"warning",heading:d,onDismiss:m})}),_("div",{className:"account-seller-assisted-buying-settings-control__checkbox-row",children:[n(de,{children:n(Ze,{name:"allowRemoteShoppingAssistance",value:"true",placeholder:s,label:s,checked:t,onChange:b=>l(b.currentTarget.checked)})}),o?_("div",{className:"account-seller-assisted-buying-settings-control__info-container",children:[n("button",{type:"button",className:"account-seller-assisted-buying-settings-control__info-icon",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onFocusCapture:()=>h(!0),onBlurCapture:()=>h(!1),"aria-label":o,children:"?"}),u?_("span",{className:"account-seller-assisted-buying-settings-control__tooltip",role:"tooltip",children:[o,n("span",{className:"account-seller-assisted-buying-settings-control__tooltip-arrow"})]}):null]}):null]})]})},sn=({loading:e,adminAssistanceActions:a,tableHeaders:t,actionTypesMap:r,emptyStateMessage:s,featureDisabledMessage:o,isRemoteShoppingAssistanceAvailable:d=!0,errorMessage:c,currentPage:l,onPageChange:m,withWrapper:u=!0})=>{var v;if(e)return _(we,{children:[n(K,{variant:"row",fullWidth:!0}),n(K,{variant:"row",fullWidth:!0}),n(K,{variant:"row",fullWidth:!0})]});if(!d)return n("div",{className:"account-seller-assisted-buying-activity-table__alert",children:n(fe,{heading:o})});if(c)return n("div",{className:"account-seller-assisted-buying-activity-table__error",children:n(fe,{heading:c})});if(!((v=a==null?void 0:a.items)!=null&&v.length))return n("div",{className:"account-seller-assisted-buying-activity-table__empty",children:n(fe,{heading:s})});const h=[{label:t.action,key:"action",ariaLabel:t.action},{label:t.date,key:"date",ariaLabel:t.date},{label:t.details,key:"details",ariaLabel:t.details}],b=a.items.map(f=>({action:r[f.action]||f.action,date:f.date,details:f.details})),A=a.pageInfo.totalPages,y=A>1,w=n("div",{className:"account-seller-assisted-buying-activity-table",children:n("div",{className:"account-seller-assisted-buying-activity-table__table-wrapper",children:n(St,{columns:h,rowData:b,mobileLayout:"stacked",className:"account-seller-assisted-buying-activity-table__table"})})});return _(D,{children:[u?n(ne,{variant:"secondary",className:U(["account-seller-assisted-buying-activity-table-card"]),children:w}):w,y&&n("div",{className:"account-seller-assisted-buying-activity-table__pagination",children:n(lt,{currentPage:l,totalPages:A,onChange:m})})]})},vt=({cardBrand:e,lastFourDigits:a,expired:t=!1,onRemove:r,variant:s="secondary",minifiedView:o=!1})=>{const d=ut(),c=G({actionRemove:"Account.Payments.paymentCard.actionRemove",cardEndingIn:"Account.Payments.paymentCard.cardEndingIn",expiredLabel:"Account.Payments.paymentCard.expiredLabel"}),l=Te(()=>{r==null||r()},[r]),m=`•••• ${a}`,u=`${c.cardEndingIn} ${m}`;return _(ne,{variant:s,className:U(["account-payment-card",o&&"account-payment-card--minified"]),"data-testid":"paymentCard",children:[n("div",{className:"account-payment-card__action",children:r?n(X,{type:"button",variant:"tertiary",onClick:l,"data-testid":"removeButton","aria-label":`${c.actionRemove} ${e} ${u}`,"aria-describedby":d,children:c.actionRemove}):null}),_("div",{className:"account-payment-card__description",id:d,children:[n("p",{className:"account-payment-card__card-brand","data-testid":"cardBrand",children:e}),n("p",{className:"account-payment-card__card-number","data-testid":"cardNumber",children:u})]}),t?n("div",{className:"account-payment-card__labels","data-testid":"expiredTag",children:n(pe,{label:(c.expiredLabel??"Expired").toLocaleUpperCase()})}):null]})},ot="account/customerPaymentTokens",Ct="__REMOVE_FAILED__",Fr=e=>{const a=Se("api"),t=Se(void 0),[r,s]=$([]),[o,d]=$(!0),[c,l]=$(null),[m,u]=$(null),[h,b]=$(null),A=x(async()=>{d(!0),l(null),u(null);try{const f=await Ht(e);a.current="api",s(f)}catch(f){s([]),l(f instanceof Error?f.message:String(f))}finally{d(!1)}},[e]);J(()=>{let f=!1,E=!1;const P=Oe.on(ot,S=>{f||(E=!0,a.current="event",s(Array.isArray(S)?S:[]),l(null),d(!1))},{eager:!0});return(!P||!E)&&A(),()=>{f=!0,P==null||P.off()}},[A]);const y=(e==null?void 0:e.join(","))??"";J(()=>{if(a.current==="api"){if(t.current===void 0){t.current=y;return}t.current!==y&&(t.current=y,A())}},[y,A]);const w=x(async f=>{u(null),b(f);try{await Rt(f)?s(P=>P.filter(S=>S.publicHash!==f)):u(Ct)}catch(E){u(E instanceof Error?E.message:String(E))}finally{b(null)}},[]),v=x(async()=>{if(a.current==="event"){const f=Oe.lastPayload(ot);if(f===void 0)return;s(Array.isArray(f)?f:[]),l(null),u(null);return}await A()},[A]);return{items:r,loading:o,loadError:c,actionError:m,removingHash:h,removeToken:w,refetch:v}},on=({className:e,withHeader:a=!0,minifiedView:t=!1,filterPaymentMethodCodes:r})=>{const s=G({containerTitle:"Account.Payments.containerTitle",loadError:"Account.Payments.loadError",removeError:"Account.Payments.removeError"}),{items:o,loading:d,loadError:c,actionError:l,removingHash:m,removeToken:u}=Fr(r),[h,b]=$(null),A=x(()=>{b(null)},[]),y=x(async()=>{h&&(await u(h.publicHash),b(null))},[h,u]),w=l===Ct?s.removeError:l??"",v=o.length>0?o.map(E=>{const{publicHash:P,...S}=E;return n(vt,{...S,minifiedView:t,onRemove:m!==null?void 0:()=>b(E)},P)}):null,f=o.length===0&&!c?n("div",{className:"account-payment-methods__empty","data-testid":"paymentMethodsEmpty",children:n(He,{isEmpty:!0,typeList:"payments",minifiedView:t})}):null;return _("div",{className:U(["account-payment-methods",e]),"data-testid":"paymentMethods",children:[a?n(me,{"aria-label":s.containerTitle,role:"region",title:s.containerTitle,divider:!t,className:t?"account-payment-methods-header":""}):null,c?n(ue,{className:"account-payment-methods__alert",type:"error",variant:"secondary",heading:s.loadError,description:c,icon:n(Qe,{}),"data-testid":"paymentMethodsLoadError"}):null,l&&!c?n(ue,{className:"account-payment-methods__alert",type:"error",variant:"secondary",heading:w,icon:n(Qe,{}),"data-testid":"paymentMethodsActionError"}):null,n(kr,{open:h!==null,submitLoading:h!==null&&m===h.publicHash,onRemoveToken:()=>{y()},closeModal:A,cardBrand:h==null?void 0:h.cardBrand,lastFourDigits:h==null?void 0:h.lastFourDigits,expired:h==null?void 0:h.expired,variant:h==null?void 0:h.variant,minifiedView:t}),d?n(Ee,{testId:"paymentMethodsLoader"}):n("div",{className:"account-payment-methods__list",children:v??f})]})},kr=({open:e,submitLoading:a,onRemoveToken:t,closeModal:r,cardBrand:s,lastFourDigits:o,expired:d,variant:c,minifiedView:l})=>{const m=G({title:"Account.Payments.removePaymentModal.title",description:"Account.Payments.removePaymentModal.description",actionCancel:"Account.Payments.removePaymentModal.actionCancel",actionConfirm:"Account.Payments.removePaymentModal.actionConfirm"});return e?n(it,{className:"account-payment-modal--overlay",title:n("h3",{children:m.title}),size:"full","data-testid":"paymentModal",showCloseButton:!0,onClose:r,children:_("div",{className:"account-payment-modal",children:[a?n("div",{className:"account-payment-modal__spinner","data-testid":"progressSpinner",children:n(dt,{stroke:"4",size:"large"})}):null,n("p",{children:m.description}),s&&o?n(vt,{cardBrand:s,lastFourDigits:o,expired:d,variant:c,minifiedView:l}):null,_("div",{className:"account-payment-modal__buttons",children:[n(X,{type:"button",onClick:r,variant:"secondary",disabled:a,children:m.actionCancel}),n(X,{disabled:a,onClick:t,children:m.actionConfirm})]})]})}):null},Vr=({ordersInMinifiedView:e,minifiedView:a,pageSize:t,selectedDate:r,selectedPage:s,handleSetFirstOrderDate:o})=>{const[d,c]=$([]),[l,m]=$({totalPages:1,currentPage:1,pageSize:1}),[u,h]=$(!1),[b,A]=$(""),[y,w]=$(0);return J(()=>{mt().then(v=>{A(v.baseMediaUrl)})},[]),J(()=>{const v=Oe.on("companyContext/changed",()=>{w(f=>f+1)});return()=>{v==null||v.off()}},[]),J(()=>{h(!0),qt(a?e:t,r,s).then(v=>{!v||!v.items||(m(v.pageInfo),c(v.items),o==null||o(v.dateOfFirstOrder))}).finally(()=>{h(!1)})},[o,a,e,t,r,s,y]),{loading:u,orderHistoryListItems:d,pageInfo:l,placeholderImage:b}},Pe=(e,a=1)=>{const t=new Date,r=new Date(t);switch(e){case"sixMonthsAgo":{r.setMonth(r.getMonth()-a);break}case"oneYearAgo":{r.setFullYear(r.getFullYear()-a);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`}},xr=e=>{const a=[],t=new Date().getFullYear();for(let r=e;r<=t-1;r++)a.push({value:`{"from":"${r}-01-01","to":"${r+1}-01-01 23:59:59"}`,text:r.toString()});return a},Zr=()=>{const e=G({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[a,t]=$(),[r,s]=$(JSON.stringify(Pe("sixMonthsAgo",6))),[o,d]=$(1);J(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[o]);const c=oe(()=>{const u=[{value:JSON.stringify(Pe("sixMonthsAgo",6)),text:e.pastSixMonths},{value:JSON.stringify(Pe("oneYearAgo",1)),text:e.currentYear},{value:"viewAll",text:e.viewAll}];if(a){const b=new Date(a).getFullYear();u==null||u.splice(2,0,...xr(b))}return u},[e,a]),l=x(u=>{t(u)},[]),m=x(u=>{const b=u.target.value;s(b),d(1)},[]);return{selectableDateList:c,selectedDate:r,selectedPage:o,handleSelectDate:m,setSelectedPage:d,handleSetFirstOrderDate:l}},cn=({className:e,withHeader:a=!0,minifiedView:t=!1,withThumbnails:r=!0,withFilter:s=!0,ordersInMinifiedView:o=1,pageSize:d=10,routeOrdersList:c,routeOrderDetails:l,routeReturnDetails:m,routeTracking:u,routeOrderProduct:h,slots:b})=>{const A=t?"minifiedView":"fullSizeView",y=G({containerTitle:`Account.${A}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${A}.OrdersList.dateOrderPlaced`}),{selectableDateList:w,selectedDate:v,handleSelectDate:f,selectedPage:E,setSelectedPage:P,handleSetFirstOrderDate:S}=Zr(),{pageInfo:N,loading:i,orderHistoryListItems:p,placeholderImage:L}=Vr({minifiedView:t,pageSize:d,ordersInMinifiedView:o,selectedDate:v,selectedPage:E,handleSetFirstOrderDate:S});return _("div",{children:[a?n(me,{"aria-label":y.containerTitle,role:"region",title:y.containerTitle,divider:!t,className:t?"account-orders-list-header":""}):null,_("div",{className:U(["account-orders-list",e]),children:[!t&&s?_("div",{className:"account-orders-list__date-select",children:[n("span",{children:y.dateOrderPlaced}),n(ct,{value:v,name:"orderDatePicker",options:w,handleSelect:f})]}):null,i?n(D,{children:Array.from(Array(N==null?void 0:N.pageSize).keys()).map(k=>n(Ee,{testId:"orderSkeletonLoader",withCard:!1},k))}):n(D,{children:p.length?n(D,{children:p.map((k,M)=>n(fr,{placeholderImage:L,routeTracking:u,routeOrderProduct:h,routeReturnDetails:m,minifiedView:t,item:k,withThumbnails:r,slots:b,children:b!=null&&b.OrdersListAction?n(ae,{"data-testid":`ordersListActionSlot_${M}`,name:"OrdersListAction",slot:b==null?void 0:b.OrdersListAction,context:{orderHistoryListItem:k}}):n(rt,{minifiedView:t,orderNumber:k.number,orderToken:k.token,routeOrderDetails:l})},M))}):n(He,{isEmpty:!p.length,typeList:"orders",minifiedView:t})}),!t&&(N==null?void 0:N.totalPages)>1?n(lt,{totalPages:N==null?void 0:N.totalPages,currentPage:E,onChange:P}):null,t?n(rt,{minifiedView:t,routeOrdersList:c}):null]})]})};export{Qr as A,ye as AddressForm,Ee as C,tn as E,cn as O,on as P,an as S,sn as a,Qe as b,Dr as c,Xr as d,ye as default,Yr as e,rn as f,nt as g,en as h,nn as i,wr as n,Ut as u};
4
4
  //# sourceMappingURL=AddressForm.js.map