@dropins/storefront-account 1.0.4 → 1.0.5

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,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as a,Fragment as D,jsxs as G}from"@dropins/tools/preact-jsx-runtime.js";import{classes as Q,Slot as me}from"@dropins/tools/lib.js";import{Field as le,Picker as Je,Input as Xe,InputDate as Ke,Checkbox as Re,TextArea as Ye,Card as he,Skeleton as we,SkeletonRow as K,Button as de,Tag as pe,Icon as He,Modal as Qe,ProgressSpinner as De,IllustratedMessage as et,Header as tt,InLineAlert as rt}from"@dropins/tools/components.js";import{useRef as st,useState as $,useEffect as ee,useCallback as k,useMemo as nt}from"@dropins/tools/preact-hooks.js";import{n as Ve,o as ze,u as ye,c as ke,e as at,m as dt,j as ot,h as lt,i as it,d as ct}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as Y from"@dropins/tools/preact-compat.js";import{memo as _e,forwardRef as ut,useImperativeHandle as pt,useId as ft,useMemo as ve,useCallback as Ne}from"@dropins/tools/preact-compat.js";import{Fragment as Te}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:t,saveCheckBoxValue:d,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,billingCheckBoxValue:g,shippingCheckBoxValue:y,showBillingCheckBox:M,showShippingCheckBox:L,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S})=>a("div",{className:Q(["account-address-form"]),children:a(Yt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,shippingCheckBoxValue:y,billingCheckBoxValue:g,showShippingCheckBox:L,showBillingCheckBox:M,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S,forwardFormRef:l,showSaveCheckBox:t,saveCheckBoxValue:d})}),At=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ht=e=>/^\d+$/.test(e),mt=e=>/^[a-zA-Z0-9\s]+$/.test(e),Lt=e=>/^[a-zA-Z0-9]+$/.test(e),gt=e=>/^[a-zA-Z]+$/.test(e),bt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),Ct=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),yt=(e,s,n)=>{const t=new Date(e).getTime()/1e3;return!(isNaN(t)||t<0||s!==void 0&&t<s||n!==void 0&&t>n)},Ze=e=>!e||isNaN(Number(e))?"":new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],vt=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),Mt=(e,s,n)=>{const t=e.length;return t>=s&&t<=n},Ce=(e,s,n,t)=>{var O,B;const{requiredFieldError:d,lengthTextError:l,numericError:i,alphaNumWithSpacesError:o,alphaNumericError:c,alphaError:p,emailError:f,dateError:g,urlError:y,dateLengthError:M}=n,L=s==null?void 0:s.customUpperCode,N={[L]:""};if(t[L]&&delete t[L],s!=null&&s.required&&(!e||e==="false"))return{[L]:d};if(!(s!=null&&s.required)&&!e||!((O=s==null?void 0:s.validateRules)!=null&&O.length))return N;const r=At(s==null?void 0:s.validateRules),u=r.MIN_TEXT_LENGTH??1,A=r.MAX_TEXT_LENGTH??255,T=r.DATE_RANGE_MIN,S=r.DATE_RANGE_MAX;if(!Mt(e,+u,+A)&&!(T||S))return{[L]:l.replace("{min}",u).replace("{max}",A)};if(!yt(e,+T,+S)&&(T||S))return{[L]:M.replace("{min}",Ze(T)).replace("{max}",Ze(S))};const q={numeric:{validate:ht,error:i},"alphanum-with-spaces":{validate:mt,error:o},alphanumeric:{validate:Lt,error:c},alpha:{validate:gt,error:p},email:{validate:bt,error:f},date:{validate:Ct,error:g},url:{validate:vt,error:y}}[r.INPUT_VALIDATION];return q&&!q.validate(e)&&!((B=t[L])!=null&&B.length)?{[L]:q.error}:N},qe=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}},Et=["true","false","yes","on","off"],_t={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},$t=e=>{const s={},n={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const d=e[t],l=t.match(/^(.*)Multiline_(\d+)$/);if(l){const i=l[1],o=parseInt(l[2],10);n[i]||(n[i]=[]),n[i].push({index:o,value:d})}else Object.keys(e).filter(o=>o.startsWith(`${t}Multiline_`)).length>0?n[t]=[{index:1,value:d}]:s[t]=d}for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const d=n[t];d.sort((l,i)=>l.index-i.index),s[t]=d.map(l=>l.value)}return s},Nt=e=>{const s={},n=[];for(const t in e){const d=Et.includes(e[t])?qe(e[t]):e[t];Object.prototype.hasOwnProperty.call(e,t)&&(Object.prototype.hasOwnProperty.call(_t,t)?s[t]=d:n.push({code:ze(t),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Ve(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),t=Nt($t(n));if(!s)return t;const[d,l]=t.region?t.region.split(","):[];return{...t,region:{regionCode:d,...l&&{regionId:+l}}}},Ae=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((t,d)=>(d.name&&(t[d.name]=d.type==="checkbox"?d.checked:d.value),t),{})},Ie=(e,s)=>Object.keys(e).length?Object.keys(e).every(t=>t in s&&s[t]!==""):!1,Ue=e=>typeof e=="function",Tt=e=>e.reduce((s,{customUpperCode:n,required:t,defaultValue:d})=>(t&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),Se=e=>Object.keys(e).length>0,Zt=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:t,formName:d,isWaitingForResponse:l})=>{const i=ne({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"}),o=st(null),[c,p]=$({}),[f,g]=$({}),[y,M]=$({}),[L,N]=$(!0),[r,u]=$(!1),[A,T]=$(!1),[S,_]=$(!0),[q,O]=$(!1);ee(()=>{const h=()=>{if(o.current){const b=window.getComputedStyle(o.current).getPropertyValue("grid-template-rows").split(" ").length,C=o.current.querySelector(".account-address-form--saveAddressBook");C&&(C.style.gridRow=String(b-1))}};return h(),window.addEventListener("resize",h),()=>{window.removeEventListener("resize",h)}},[e==null?void 0:e.length]);const B=k((h=!1)=>{let v=!0;const b={...f};let C=null;for(const[x,m]of Object.entries(c)){const I=e==null?void 0:e.find(F=>F.customUpperCode.includes(x)),z=Ce(m.toString(),I,i,b);z[x]&&(Object.assign(b,z),v=!1),C||(C=Object.keys(b).find(F=>b[F])||null)}if(h||g(b),C&&o.current&&!h){const x=o.current.elements.namedItem(C);x==null||x.focus()}return v},[f,e,c,i]),w=k((h,v,b,C)=>{const x={...Ae(o),[v]:h,...v.includes("countryCode")?{region:""}:{}},m={data:ae(x,!0),isDataValid:Ie(b,x)};O(m.isDataValid),B(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(m)),n==null||n(m,{},C)},[B,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:h,errorList:v}=Tt(e);p(b=>({...h,...b})),g(v),M(v)}},[JSON.stringify(e)]),ee(()=>{if(A)return;const h=Ae(o),v=sessionStorage.getItem(`${d}_addressData`);if(Se(c)&&Se(y)){let b={};const C=Ie(y,c);v?b=JSON.parse(v).data:b=ae(h,!0)??{},n==null||n({data:b,isDataValid:C},{},null),O(C),T(!0)}},[c,y]),ee(()=>{var x;if(!S)return;const h=Ae(o),v=!!(h!=null&&h.countryCode),b=!!((x=h==null?void 0:h.region)!=null&&x.length);h&&v&&!b&&Ue(n)&&!l&&w(h==null?void 0:h.region,"region",y,null)},[S,L,e,o,n,w,y,r,l]);const Z=k((h,v)=>{const{name:b,value:C,type:x,checked:m}=h==null?void 0:h.target,I=x==="checkbox"?m:C;p(H=>{const te={...H,[b]:I};return b==="countryCode"&&(te.region="",N(!0),u(!1)),te}),t==null||t({[b]:I}),T(!0);const z=e==null?void 0:e.find(H=>H.customUpperCode.includes(b));let F=v?{...v}:{...f};if(z){const H=Ce(I.toString(),z,i,F);H&&Object.assign(F,H),g(F)}w(I,b,y,h)},[t,e,f,i,w,y,L]),P=k(h=>{const{name:v}=h==null?void 0:h.target,b=e==null?void 0:e.find(C=>C.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&_(!1),_(v==="countryCode")},[]),j=k((h,v)=>{const{name:b,value:C,type:x,checked:m}=h==null?void 0:h.target,I=x==="checkbox"?m:C,z=e==null?void 0:e.find(F=>F.customUpperCode===b);if(z){const F=v?{...v}:{...f},H=Ce(I.toString(),z,i,F);H&&Object.assign(F,H),g(F)}},[f,e,i]),V=k(h=>{h.preventDefault();const v=B();s==null||s(h,v)},[B,s]);return{isDataValid:q,formData:c,errors:f,formRef:o,handleInputChange:Z,onFocus:P,handleBlur:j,handleSubmit:V,handleValidationSubmit:B}};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 It=_e(({loading:e,values:s,fields:n=[],errors:t,className:d="",onChange:l,onBlur:i,onFocus:o,slots:c})=>{const p=`${d}__field`,f=(r,u)=>{if(!(c!=null&&c[`AddressFormInput_${r.code}`]))return;const A={inputName:r.customUpperCode,handleOnChange:l,handleOnBlur:i,handleOnFocus:o,errorMessage:u,errors:t,config:r};return a(me,{"data-testid":`addressFormInput_${r.code}`,name:`AddressFormInput_${r.code}`,slot:c[`AddressFormInput_${r.code}`],context:A},r.id)},g=(r,u,A)=>{var S;const T=((S=r.options.find(_=>_.isDefault))==null?void 0:S.value)??u??r.defaultValue;return a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e||r.disabled,children:a(Je,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,required:r==null?void 0:r.required,name:r.customUpperCode,floatingLabel:`${r.label} ${r.required?"*":""}`,placeholder:r.label,options:r.options,onBlur:i,onFocus:o,handleSelect:l,defaultValue:T,value:T})},r.id)})},y=(r,u,A)=>a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e,children:a(Xe,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u??r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:i,onFocus:o,onChange:l})},r.id)}),M=(r,u,A)=>a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e||r.disabled,children:a(Ke,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u||r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l,disabled:e||r.disabled})},r.id)}),L=(r,u,A)=>a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:(r==null?void 0:r.isHidden)??e,children:a(Re,{"aria-label":r.label,"aria-required":r.required?"true":"false","aria-hidden":r.isHidden,tabindex:r!=null&&r.isHidden?-1:0,id:r.code,name:r.customUpperCode,checked:u||r.defaultValue,placeholder:r.label,label:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l})},r.id)}),N=(r,u,A)=>a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e,children:a(Ye,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u??r.defaultValue,label:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l})},r.id)});return n.length?a(D,{children:n.map(r=>{const u=t==null?void 0:t[r.customUpperCode],A=s==null?void 0:s[r.customUpperCode];switch(r.fieldType){case se.TEXT:return r.options.length?g(r,A,u):y(r,A,u);case se.MULTILINE:return y(r,A,u);case se.SELECT:return g(r,A,u);case se.DATE:return M(r,A,u);case se.BOOLEAN:return L(r,A,u);case se.TEXTAREA:return N(r,A,u);default:return null}})}):null}),Pe=({testId:e,withCard:s=!0})=>{const n=G(we,{"data-testid":e||"skeletonLoader",children:[a(K,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:Q(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},St=()=>G(we,{"data-testid":"addressFormLoader",children:[a(K,{variant:"heading",size:"medium"}),a(K,{variant:"empty",size:"medium"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large",fullWidth:!0}),a(K,{size:"large",fullWidth:!0,lines:3}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large",fullWidth:!0})]}),xt=_e(ut(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:t,name:d,loading:l,children:i,className:o="defaultForm",fieldsConfig:c,onSubmit:p,onChange:f,forwardFormRef:g,regionOptions:y,showSaveCheckBox:M,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:N})=>{const r=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:u,formData:A,errors:T,formRef:S,handleInputChange:_,handleBlur:q,handleSubmit:O,handleValidationSubmit:B,onFocus:w}=Zt({fieldsConfig:c,onSubmit:p,onChange:f,setInputChange:s,regionOptions:y,formName:d,isWaitingForResponse:e});return pt(g,()=>{const Z=Ae(S);return{handleValidationSubmit:B,formData:ae(Z,!0),isDataValid:u}}),n||!(c!=null&&c.length)?a(St,{}):G("form",{className:Q(["account-form",o]),onSubmit:O,name:d,ref:S,children:[a(It,{className:o,loading:l,fields:c,onChange:_,onBlur:q,errors:T,values:A,onFocus:w,slots:t}),t!=null&&t.AddressFormInputs?a(me,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:t.AddressFormInputs,context:{formActions:{handleChange:_}}}):null,M?a("div",{className:"account-address-form--saveAddressBook",children:a(Re,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:r.saveAddressBook,checked:N,onChange:Z=>{_(Z),L==null||L(Z)}})}):null,i]})})),xe=(e,s,n={},t="editButton")=>{const d=t==="removeButton",l={shippingAndBilling:{edit:n.editAddressAriaLabelShippingAndBilling,remove:n.removeAddressAriaLabelShippingAndBilling},shipping:{edit:n.editAddressAriaLabelShipping,remove:n.removeAddressAriaLabelShipping},billing:{edit:n.editAddressAriaLabelBilling,remove:n.removeAddressAriaLabelBilling},default:{edit:n.editAddressAriaLabelDefault,remove:n.removeAddressAriaLabelDefault}};let i="default";return e&&s?i="shippingAndBilling":e?i="shipping":s&&(i="billing"),d?l[i].remove:l[i].edit},Me=({slots:e,selectable:s,selectShipping:n,selectBilling:t,variant:d="secondary",minifiedView:l,keysSortOrder:i,addressData:o,loading:c,setAddressId:p,handleRenderModal:f,handleRenderForm:g})=>{const y=ft(),M=l?"minifiedView":"fullSizeView",L=ne({actionRemove:`Account.${M}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${M}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${M}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${M}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${M}.Addresses.addressCard.defaultLabelText`,editAddressAriaLabelDefault:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.default`,editAddressAriaLabelShipping:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.shipping`,editAddressAriaLabelBilling:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.billing`,editAddressAriaLabelShippingAndBilling:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.shippingAndBilling`,removeAddressAriaLabelDefault:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.default`,removeAddressAriaLabelShipping:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.shipping`,removeAddressAriaLabelBilling:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.billing`,removeAddressAriaLabelShippingAndBilling:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.shippingAndBilling`}),N=L.cardLabelBilling.toLocaleUpperCase(),r=L.cardLabelShipping.toLocaleUpperCase(),u=L.defaultLabelText.toLocaleUpperCase(),A=ve(()=>{const Z={shippingLabel:r,billingLabel:N,hideShipping:!1,hideBilling:!1};return s?n&&!t?{shippingLabel:u,billingLabel:u,hideShipping:!1,hideBilling:!0}:t&&!n?{shippingLabel:u,billingLabel:u,hideShipping:!0,hideBilling:!1}:Z:Z},[N,u,r,t,n,s]),T=Ne(()=>{p==null||p(o==null?void 0:o.id),f==null||f()},[f,o==null?void 0:o.id,p]),S=Ne(()=>{p==null||p(o==null?void 0:o.id),g==null||g()},[g,o==null?void 0:o.id,p]),_=ve(()=>{if(!i)return[];const{region:Z,...P}=o,j={...P,...Z};return i.filter(({name:V})=>j[V]).map(V=>({name:V.name,orderNumber:V.orderNumber,value:j[V.name],label:V.label}))},[o,i]),{shippingLabel:q,billingLabel:O,hideShipping:B,hideBilling:w}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(Pe,{}):G(D,{children:[G("div",{className:"account-address-card__action",children:[f?a(de,{type:"button",variant:"tertiary",onClick:T,"data-testid":"removeButton","aria-label":xe(o==null?void 0:o.defaultShipping,o==null?void 0:o.defaultBilling,L,"removeButton"),"aria-describedby":y,children:L.actionRemove}):null,g?a(de,{type:"button",variant:"tertiary",onClick:S,className:"account-address-card__action--editbutton","data-testid":"editButton","aria-label":xe(o==null?void 0:o.defaultShipping,o==null?void 0:o.defaultBilling,L,"editButton"),"aria-describedby":y,children:L.actionEdit}):null]}),a("div",{className:"account-address-card__description",id:y,children:e!=null&&e.AddressCard?a(me,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:_}}):a(D,{children:_.map((Z,P)=>{const j=Z.label?`${Z.label}: ${Z==null?void 0:Z.value}`:Z==null?void 0:Z.value;return a("p",{"data-testid":`${Z.name}_${P}`,children:j},P)})})}),(o!=null&&o.defaultShipping||o!=null&&o.defaultBilling)&&!s?G("div",{className:"account-address-card__labels",children:[o!=null&&o.defaultShipping?a(pe,{label:r}):null,o!=null&&o.defaultBilling?a(pe,{label:N}):null]}):null,s?G("div",{className:"account-address-card__labels",children:[!B&&(o!=null&&o.defaultShipping)?a(pe,{label:q}):null,!w&&(o!=null&&o.defaultBilling)?a(pe,{label:O}):null]}):null]})})},Ft=e=>Y.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},Y.createElement("g",{id:"Large"},Y.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Y.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},Y.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"}),Y.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"})))),Ot=e=>Y.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},Y.createElement("g",{id:"Large"},Y.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Y.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},Y.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"})))),Bt=e=>Y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Y.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"})),Rt=e=>Y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Y.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"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:t,routeAddressesPage:d})=>{const l=t?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${l}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${l}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${l}.Addresses.differentAddressButton`}),o=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},p=t&&!n?i.viewAllAddressesButton:i.addNewAddressButton,f=e?i.differentAddressButton:p;return G(o,{...c,className:Q(["account-actions-address",["account-actions-address--viewall",t],["account-actions-address--address",!t],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:f}),a(He,{source:t&&!n?Ot:Ft,size:"32"})]})},wt=({minifiedView:e,keysSortOrder:s,addressData:n,open:t,submitLoading:d,onRemoveAddress:l,closeModal:i})=>{const o=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${o}.Addresses.removeAddressModal.title`,description:`Account.${o}.Addresses.removeAddressModal.description`,actionCancel:`Account.${o}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${o}.Addresses.removeAddressModal.actionConfirm`});return t?a("div",{className:"account-address-modal",children:G(Qe,{className:"account-address-modal--overlay",title:a("h3",{children:c.title}),size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(De,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),G("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:l,children:c.actionConfirm})]})]})}):null},Ht=({typeList:e,isEmpty:s,minifiedView:n,className:t})=>{const d=n?"minifiedView":"fullSizeView",l=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=ve(()=>{switch(e){case"address":return{icon:Bt,text:a("p",{children:l.addressesMessage})};case"orders":return{icon:Rt,text:a("p",{children:l.ordersListMessage})};default:return{icon:"",text:""}}},[e,l]);return!s||!e||!i.text?null:a(et,{className:Q(["account-empty-list",n?"account-empty-list--minified":"",t]),message:i.text,icon:a(He,{source:i.icon}),"data-testid":"emptyList"})},Vt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(f=>!!f)?{}:{region:{...i.region,regionId:0}};return!!await ye({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),t=s[s.length-1],d=n[0]||((t==null?void 0:t.id)!==e?t:null);return!d||!d.id?!1:!!await ye({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},zt=["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"],or=["email","firstname","lastname","middlename","gender","dob","prefix","suffix","fax"],je=(e,s,n)=>{if(s&&n||!s&&!n)return e;const t=e.slice();return s?t.sort((d,l)=>Number(l.defaultShipping)-Number(d.defaultShipping)):n?t.sort((d,l)=>Number(l.defaultBilling)-Number(d.defaultBilling)):e},Ee=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(Ee),kt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:t,minifiedView:d,routeAddressesPage:l,onSuccess:i})=>{const[o,c]=$(""),[p,f]=$(!1),[g,y]=$(!1),[M,L]=$(!1),[N,r]=$(!1),[u,A]=$(!1),[T,S]=$(""),[_,q]=$([]),[O,B]=$([]),w=k(async()=>{L(!0),Promise.all([ke("shortRequest"),at()]).then(m=>{const[I,z]=m;if(I){const F=I.map(({name:H,orderNumber:te,label:re})=>({name:dt(H),orderNumber:te,label:zt.includes(H)?null:re}));B(F)}if(z)if(d){const F=z.filter(H=>!!H.defaultShipping||!!H.defaultBilling);q(F)}else q(z)}).finally(()=>{L(!1)})},[d]);ee(()=>{w()},[w]),ee(()=>{var m;if(_.length)if(n===0)A(!0),c("0");else{const I=_.find(F=>+F.id===n)||je(_,e,s)[0],z={data:ae(I),isDataValid:!Ee(I)};c(n.toString()||((m=I==null?void 0:I.id)==null?void 0:m.toString())),t==null||t(z)}},[_,n,t,s,e]);const Z=k(m=>{S(m),A(!1)},[]),P=k((m,I)=>{const z=(m==null?void 0:m.target).value,F=(m==null?void 0:m.target).nextSibling;c(z);const H={data:ae(I),isDataValid:!Ee(ae(I))};t==null||t(H),A(z==="0"),F&&(F.focus(),window.scrollBy(0,100))},[t]),j=k(()=>{y(!0)},[]),V=k(()=>{S(""),y(!1),f(!1)},[]),h=k(()=>{f(!0)},[]),v=k(async()=>{r(!0),await Vt(T,_),ot(+T).then(()=>{w(),V()}).finally(()=>{r(!1)})},[_,T,V,w]),b=k(()=>{A(!1)},[]),C=k(()=>{Ue(l)&&d&&!u?window.location.href=l():(A(!0),S(""))},[u,l,d]),x=k(async()=>{await w(),await(i==null?void 0:i())},[w,i]);return{keysSortOrder:O,submitLoading:N,isModalRendered:p,isFormRendered:g,loading:M,addNewAddress:u,addressesList:_,addressId:T,handleRenderForm:j,handleRenderModal:h,removeAddress:v,onCloseBtnClick:V,setEditingAddressId:Z,closeNewAddressForm:b,redirectToAddressesRoute:C,handleOnSuccess:x,handleSelectAddressOption:P,selectedAddressOption:o}},lr=_e(({minifiedViewKey:e,hideActionFormButtons:s=!1,inputName:n,slots:t,title:d="",addressFormTitle:l="",defaultSelectAddressId:i="",showFormLoader:o=!1,onAddressData:c,forwardFormRef:p,className:f,showSaveCheckBox:g=!1,saveCheckBoxValue:y=!1,selectShipping:M=!1,selectBilling:L=!1,selectable:N=!1,withHeader:r=!0,minifiedView:u=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:T=!0,inputsDefaultValueSet:S,showShippingCheckBox:_=!0,showBillingCheckBox:q=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:B=!0,routeAddressesPage:w,onSuccess:Z,onError:P})=>{const j=ne({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:V,submitLoading:h,isModalRendered:v,isFormRendered:b,loading:C,addNewAddress:x,addressesList:m,addressId:I,handleRenderForm:z,handleRenderModal:F,removeAddress:H,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=kt({defaultSelectAddressId:i,minifiedView:u,routeAddressesPage:w,onSuccess:Z,onAddressData:c,selectShipping:M,selectBilling:L}),E=d||j.containerTitle;let W=null;if(N){const R=je(m,M,L)||[];let J;x?J=a("div",{className:Q(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",x]]),children:a(fe,{slots:t,hideActionFormButtons:s,formName:n,showFormLoader:o,isOpen:x,forwardFormRef:p,showSaveCheckBox:g,saveCheckBoxValue:y,shippingCheckBoxValue:O,billingCheckBoxValue:B,addressesFormTitle:l||j.differentAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:_,showBillingCheckBox:q,onCloseBtnClick:oe,onSuccess:re,onError:P,onChange:c})}):R.length?J=a(Fe,{selectable:N,minifiedView:u,addNewAddress:x,routeAddressesPage:ie}):J=null;const X=`generalLabel_${E.replace(/\s+/g,"")}`;W=G("div",{className:"account-addresses-wrapper--select-view",children:[a("span",{id:X,style:"display: none;",children:E}),R.map((U,ge)=>{const be=`${n}_${U.id}`,$e=`${be}_label`;return G(Te,{children:[a("input",{"data-testid":`radio-${ge+1}`,type:"radio",name:n,id:be,value:U.id,checked:ue===(U==null?void 0:U.id.toString()),onChange:Ge=>ce(Ge,U),"aria-labelledby":`${X} ${$e}`}),a("label",{id:$e,htmlFor:be,className:"account-addresses-wrapper__label",children:a(Me,{slots:t,selectable:N,selectShipping:M,selectBilling:L,minifiedView:u,addressData:U,keysSortOrder:V,loading:C})})]},U.id)}),a("input",{"aria-label":`${E} ${j.ariaLabelAddressPicker}`,"data-testid":"radio-0",type:"radio",name:n,id:`${n}_addressActions`,value:"0",checked:ue==="0",onChange:U=>ce(U,{}),tabindex:J?0:-1}),a("label",{htmlFor:`${n}_addressActions`,className:"account-addresses-wrapper__label",children:J})]})}else W=G(D,{children:[m.map(R=>a(Te,{children:I===R.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:t,isOpen:I===R.id&&b,addressFormId:I,inputsDefaultValueSet:R,addressesFormTitle:j.editAddressFormTitle,showShippingCheckBox:_,showBillingCheckBox:q,shippingCheckBoxValue:O,billingCheckBoxValue:B,onCloseBtnClick:te,onSuccess:re,onError:P})}):a(Me,{slots:t,minifiedView:u,addressData:R,keysSortOrder:V,loading:C,setAddressId:Le,handleRenderModal:u&&A||!u&&T?F:void 0,handleRenderForm:u&&A||!u&&T?z:void 0},R.id)},R.id)),a("div",{className:"account-addresses__footer",children:x?a(he,{variant:"secondary",children:a(fe,{slots:t,isOpen:x,addressesFormTitle:j.newAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:!!(m!=null&&m.length),showBillingCheckBox:!!(m!=null&&m.length),shippingCheckBoxValue:O,billingCheckBoxValue:B,onCloseBtnClick:oe,onSuccess:re,onError:P})}):a(Fe,{minifiedView:u,addNewAddress:x,routeAddressesPage:ie})})]});return G("div",{children:[r?a(tt,{title:E,divider:!u,className:u?"account-addresses-header":""}):null,G("div",{className:Q(["account-addresses-wrapper",f]),"data-testid":"addressesIdWrapper",children:[a(wt,{minifiedView:u,addressData:m==null?void 0:m.find(R=>R.id===I),keysSortOrder:V,submitLoading:h,open:v,closeModal:te,onRemoveAddress:H}),C?a(Pe,{testId:"addressSkeletonLoader",withCard:!1}):N?a(fe,{slots:t,hideActionFormButtons:s,formName:n,isOpen:!(m!=null&&m.length),forwardFormRef:p,showSaveCheckBox:g,saveCheckBoxValue:y,shippingCheckBoxValue:O,billingCheckBoxValue:B,inputsDefaultValueSet:S,showShippingCheckBox:_,showBillingCheckBox:q,onCloseBtnClick:oe,onSuccess:re,onError:P,onChange:c}):a(Ht,{isEmpty:!(m!=null&&m.length),typeList:"address",minifiedView:u}),W]})]})}),We={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},qt={...We,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ut={...We,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Pt=(e,s)=>s==null?void 0:s.map(n=>{const t={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(t,n.customUpperCode)){const l=t[n.customUpperCode];n.customUpperCode==="region"&&typeof l=="object"?d.defaultValue=l.regionCode&&l.regionId?`${l.regionCode},${l.regionId}`:l.region??l.regionCode:d.defaultValue=l}return d}),Oe=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(t=>{s.has(t.name)||s.set(t.name,"false"),t.checked&&s.set(t.name,"true")}),s&&typeof s.entries=="function"){const t=s.entries();if(t&&typeof t[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(t)))||{}}return{}},jt=({fields:e,addressId:s,countryOptions:n,disableField:t,regionOptions:d,isRequiredRegion:l,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:t}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:l,disabled:t}:c),Wt=(e,s="address")=>{const n=s==="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"],t={},d=[];return Object.keys(e).forEach(l=>{n.includes(l)?t[l]=e[l]:d.push({attribute_code:ze(l),value:e[l]})}),d.length>0&&(t.custom_attributesV2=d),t},Be=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],t=[],d={};for(const L in e){const N=e[L];n.includes(N)&&(d[L]=qe(N)),s.includes(L)&&t.push(N)}const{street:l,streetMultiline_2:i,streetMultiline_1:o,region:c,...p}=e,[f,g]=c?c.split(","):[void 0,void 0],y=g&&f?{regionId:+g,regionCode:f}:{region:f};return Wt({...p,...d,region:{...y},street:t})},Gt=(e,s)=>{const n={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const d=e[t];if(t==="region"&&d.regionId){const l=s.find(i=>(i==null?void 0:i.id)===d.regionId);l?n[t]={...d,text:l.text}:n[t]=d}else Array.isArray(d)?(n[t]=d[0]||"",d.slice(1).forEach((l,i)=>{n[`${t}Multiline_${i+2}`]=l})):n[t]=d}return n},Jt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Xt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:t,billingCheckBoxValue:d,shippingCheckBoxValue:l,showShippingCheckBox:i,showBillingCheckBox:o,inputsDefaultValueSet:c,onCloseBtnClick:p,onSuccess:f,onError:g,formName:y})=>{const[M,L]=$({text:"",type:"success"}),[N,r]=$(e??!1),[u,A]=$(t||""),[T,S]=$([]),[_,q]=$([]),[O,B]=$([]),[w,Z]=$([]),[P,j]=$([]),[V,h]=$(!1),[v,b]=$(!1),[C,x]=$(()=>{var W,R;const E=sessionStorage.getItem(`${y}_addressData`);return E?{countryCode:(R=(W=JSON.parse(E))==null?void 0:W.data)==null?void 0:R.countryCode}:c}),[m,I]=$(!1),[z,F]=$(!1),[H,te]=$(()=>{var R,J;const E=sessionStorage.getItem(`${y}_addressData`);return E?(J=(R=JSON.parse(E))==null?void 0:R.data)==null?void 0:J.saveAddressBook:n}),re=k(E=>{te(E.target.checked)},[]);ee(()=>{typeof e>"u"||r(e)},[e]),ee(()=>{ke(u?"customer_address_edit":"customer_register_address").then(E=>{S(E)})},[u]),ee(()=>{I(!0),lt().then(({availableCountries:E,countriesWithRequiredRegion:W,optionalZipCountries:R})=>{q(E),Z(W),j(R),I(!1)})},[]),ee(()=>{if(C!=null&&C.countryCode){I(!0),F(!0);const E=C==null?void 0:C.countryCode;it(E).then(W=>{B(W);const R=w.find(X=>X===E),J=P.find(X=>X===E);h(!!R),b(!J),I(!1),F(!1)})}},[C==null?void 0:C.countryCode,w,P]);const Le=k(()=>{L({text:"",type:"success"}),p==null||p()},[p]),oe=k(async(E,W)=>{if(!W)return null;r(!0);const R=Oe(E.target),J=Be(R);await ye(J).then(()=>{var X;f==null||f(),p==null||p(),(X=E==null?void 0:E.target)==null||X.reset()}).catch(X=>{L(U=>({...U,text:X.message,type:"error"})),g==null||g(X)}).finally(()=>{A(""),r(!1)})},[p,g,f]),ie=k(async(E,W)=>{if(!W)return;r(!0);const{saveAddressBook:R,...J}=Oe(E.target),X=Be(J);await ct(X).then(()=>{var U;f==null||f(),p==null||p(),(U=E==null?void 0:E.target)==null||U.reset()}).catch(U=>{L(ge=>({...ge,text:U.message,type:"error"})),g==null||g(U)}).finally(()=>{A(""),r(!1)})},[p,g,f]),ce=nt(()=>{if(!T.length)return[];const E={...qt,defaultValue:l,isHidden:s&&!H?!0:!i},W={...Ut,defaultValue:d,isHidden:s&&!H?!0:!o},R=[...T,E,W],J=sessionStorage.getItem(`${y}_addressData`),X=J?Gt(JSON.parse(J).data,O):{},U=Pt(Jt(X,c),R);return jt({fields:U,addressId:u,countryOptions:_,disableField:m,regionOptions:O,isRequiredRegion:V,isRequiredPostCode:v})},[T,l,s,H,i,d,o,y,O,c,u,_,m,V,v]),ue=k(E=>{x(W=>({...W,...E}))},[]);return{isWaitingForResponse:z,regionOptions:O,saveCheckBoxAddress:H,inLineAlert:M,addressId:u,submitLoading:N,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:Le,handleInputChange:ue}},Kt=e=>{var d;if(!e||!Array.isArray(e.customAttributes))return e??{};const s={};(d=e==null?void 0:e.customAttributes)==null||d.forEach(l=>{l.code&&Object.hasOwn(l,"value")&&(s[l.code]=l.value)});const{customAttributes:n,...t}=e;return{...t,...Ve(s,"camelCase",{})}},Yt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:t=!1,saveCheckBoxValue:d=!1,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,showShippingCheckBox:g=!0,showBillingCheckBox:y=!0,shippingCheckBoxValue:M=!0,billingCheckBoxValue:L=!0,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S})=>{const _=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:q,inLineAlert:O,addressId:B,submitLoading:w,normalizeFieldsConfig:Z,handleUpdateAddress:P,handleCreateAddress:j,handleOnCloseForm:V,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:C}=Xt({showFormLoader:n,addressFormId:p,inputsDefaultValueSet:Kt(f),shippingCheckBoxValue:M,billingCheckBoxValue:L,showShippingCheckBox:g,showBillingCheckBox:y,saveCheckBoxValue:d,showSaveCheckBox:t,onSuccess:A,onError:T,onCloseBtnClick:u,formName:s});return N?G("div",{className:Q(["account-address-form-wrapper",c]),children:[o?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:o}):null,O.text?a(rt,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:O.type,variant:"secondary",heading:O.text,icon:O.icon}):null,G(xt,{regionOptions:C,forwardFormRef:l,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:Z,onSubmit:r||(B?P:j),setInputChange:b,loading:w,showFormLoader:n,showSaveCheckBox:t,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,onChange:S,isWaitingForResponse:q,children:[B?a("input",{type:"hidden",name:"addressId",value:B,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:Q(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",t]]),children:i!=null&&i.AddressFormActions?a(me,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:P,handleCreateAddress:j,addressId:B}}):a(D,{children:t?null:G(D,{children:[a(de,{type:"button",onClick:V,variant:"secondary",disabled:w,children:_.secondaryButton}),a(de,{disabled:w,children:_.primaryButton})]})})})]})]}):null};export{fe as A,Pe as C,Ht as E,xt as F,Ot as S,lr as a,Ue as c,or as d,Oe as g,Wt as n};
3
+ import{jsx as a,Fragment as ee,jsxs as G}from"@dropins/tools/preact-jsx-runtime.js";import{classes as Q,Slot as me}from"@dropins/tools/lib.js";import{Field as le,Picker as Je,Input as Xe,InputDate as Ke,Checkbox as Re,TextArea as Ye,Card as he,Skeleton as we,SkeletonRow as K,Button as de,Tag as pe,Icon as He,Modal as Qe,ProgressSpinner as De,IllustratedMessage as et,Header as tt,InLineAlert as rt}from"@dropins/tools/components.js";import{useRef as st,useState as $,useEffect as te,useCallback as k,useMemo as nt}from"@dropins/tools/preact-hooks.js";import{n as Ve,o as ze,u as ye,c as ke,e as at,m as dt,j as ot,h as lt,i as it,d as ct}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as Y from"@dropins/tools/preact-compat.js";import{memo as _e,forwardRef as ut,useImperativeHandle as pt,useId as ft,useMemo as ve,useCallback as Ne}from"@dropins/tools/preact-compat.js";import{Fragment as Te}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:t,saveCheckBoxValue:d,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,billingCheckBoxValue:L,shippingCheckBoxValue:y,showBillingCheckBox:M,showShippingCheckBox:g,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S})=>a("div",{className:Q(["account-address-form"]),children:a(Yt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,shippingCheckBoxValue:y,billingCheckBoxValue:L,showShippingCheckBox:g,showBillingCheckBox:M,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S,forwardFormRef:l,showSaveCheckBox:t,saveCheckBoxValue:d})}),At=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ht=e=>/^\d+$/.test(e),mt=e=>/^[a-zA-Z0-9\s]+$/.test(e),gt=e=>/^[a-zA-Z0-9]+$/.test(e),Lt=e=>/^[a-zA-Z]+$/.test(e),bt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),Ct=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),yt=(e,s,n)=>{const t=new Date(e).getTime()/1e3;return!(isNaN(t)||t<0||s!==void 0&&t<s||n!==void 0&&t>n)},Ze=e=>!e||isNaN(Number(e))?"":new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],vt=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),Mt=(e,s,n)=>{const t=e.length;return t>=s&&t<=n},Ce=(e,s,n,t)=>{var O,B;const{requiredFieldError:d,lengthTextError:l,numericError:i,alphaNumWithSpacesError:o,alphaNumericError:c,alphaError:p,emailError:f,dateError:L,urlError:y,dateLengthError:M}=n,g=s==null?void 0:s.customUpperCode,N={[g]:""};if(t[g]&&delete t[g],s!=null&&s.required&&(!e||e==="false"))return{[g]:d};if(!(s!=null&&s.required)&&!e||!((O=s==null?void 0:s.validateRules)!=null&&O.length))return N;const r=At(s==null?void 0:s.validateRules),u=r.MIN_TEXT_LENGTH??1,A=r.MAX_TEXT_LENGTH??255,T=r.DATE_RANGE_MIN,S=r.DATE_RANGE_MAX;if(!Mt(e,+u,+A)&&!(T||S))return{[g]:l.replace("{min}",u).replace("{max}",A)};if(!yt(e,+T,+S)&&(T||S))return{[g]:M.replace("{min}",Ze(T)).replace("{max}",Ze(S))};const q={numeric:{validate:ht,error:i},"alphanum-with-spaces":{validate:mt,error:o},alphanumeric:{validate:gt,error:c},alpha:{validate:Lt,error:p},email:{validate:bt,error:f},date:{validate:Ct,error:L},url:{validate:vt,error:y}}[r.INPUT_VALIDATION];return q&&!q.validate(e)&&!((B=t[g])!=null&&B.length)?{[g]:q.error}:N},qe=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}},Et=["true","false","yes","on","off"],_t={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},$t=e=>{const s={},n={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const d=e[t],l=t.match(/^(.*)Multiline_(\d+)$/);if(l){const i=l[1],o=parseInt(l[2],10);n[i]||(n[i]=[]),n[i].push({index:o,value:d})}else Object.keys(e).filter(o=>o.startsWith(`${t}Multiline_`)).length>0?n[t]=[{index:1,value:d}]:s[t]=d}for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const d=n[t];d.sort((l,i)=>l.index-i.index),s[t]=d.map(l=>l.value)}return s},Nt=e=>{const s={},n=[];for(const t in e){const d=Et.includes(e[t])?qe(e[t]):e[t];Object.prototype.hasOwnProperty.call(e,t)&&(Object.prototype.hasOwnProperty.call(_t,t)?s[t]=d:n.push({code:ze(t),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Ve(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),t=Nt($t(n));if(!s)return t;const[d,l]=t.region?t.region.split(","):[];return{...t,region:{regionCode:d,...l&&{regionId:+l}}}},Ae=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((t,d)=>(d.name&&(t[d.name]=d.type==="checkbox"?d.checked:d.value),t),{})},Ie=(e,s)=>Object.keys(e).length?Object.keys(e).every(t=>t in s&&s[t]!==""):!1,Ue=e=>typeof e=="function",Tt=e=>e.reduce((s,{customUpperCode:n,required:t,defaultValue:d})=>(t&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),Se=e=>Object.keys(e).length>0,Zt=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:t,formName:d,isWaitingForResponse:l})=>{const i=ne({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"}),o=st(null),[c,p]=$({}),[f,L]=$({}),[y,M]=$({}),[g,N]=$(!0),[r,u]=$(!1),[A,T]=$(!1),[S,_]=$(!0),[q,O]=$(!1);te(()=>{const h=()=>{if(o.current){const b=window.getComputedStyle(o.current).getPropertyValue("grid-template-rows").split(" ").length,C=o.current.querySelector(".account-address-form--saveAddressBook");C&&(C.style.gridRow=String(b-1))}};return h(),window.addEventListener("resize",h),()=>{window.removeEventListener("resize",h)}},[e==null?void 0:e.length]);const B=k((h=!1)=>{let v=!0;const b={...f};let C=null;for(const[x,m]of Object.entries(c)){const I=e==null?void 0:e.find(F=>F.customUpperCode.includes(x)),H=Ce(m.toString(),I,i,b);H[x]&&(Object.assign(b,H),v=!1),C||(C=Object.keys(b).find(F=>b[F])||null)}if(h||L(b),C&&o.current&&!h){const x=o.current.elements.namedItem(C);x==null||x.focus()}return v},[f,e,c,i]),w=k((h,v,b,C)=>{const x={...Ae(o),[v]:h,...v.includes("countryCode")?{region:""}:{}},m={data:ae(x,!0),isDataValid:Ie(b,x)};O(m.isDataValid),B(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(m)),n==null||n(m,{},C)},[B,d,n]);te(()=>{if(e!=null&&e.length){const{initialData:h,errorList:v}=Tt(e);p(b=>({...h,...b})),L(v),M(v)}},[JSON.stringify(e)]),te(()=>{if(A)return;const h=Ae(o),v=sessionStorage.getItem(`${d}_addressData`);if(Se(c)&&Se(y)){let b={};const C=Ie(y,c);v?b=JSON.parse(v).data:b=ae(h,!0)??{},n==null||n({data:b,isDataValid:C},{},null),O(C),T(!0)}},[c,y]),te(()=>{var x;if(!S)return;const h=Ae(o),v=!!(h!=null&&h.countryCode),b=!!((x=h==null?void 0:h.region)!=null&&x.length);h&&v&&!b&&Ue(n)&&!l&&w(h==null?void 0:h.region,"region",y,null)},[S,g,e,o,n,w,y,r,l]);const Z=k((h,v)=>{const{name:b,value:C,type:x,checked:m}=h==null?void 0:h.target,I=x==="checkbox"?m:C;p(V=>{const D={...V,[b]:I};return b==="countryCode"&&(D.region="",N(!0),u(!1)),D}),t==null||t({[b]:I}),T(!0);const H=e==null?void 0:e.find(V=>V.customUpperCode.includes(b));let F=v?{...v}:{...f};if(H){const V=Ce(I.toString(),H,i,F);V&&Object.assign(F,V),L(F)}w(I,b,y,h)},[t,e,f,i,w,y,g]),P=k(h=>{const{name:v}=h==null?void 0:h.target,b=e==null?void 0:e.find(C=>C.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&_(!1),_(v==="countryCode")},[]),j=k((h,v)=>{const{name:b,value:C,type:x,checked:m}=h==null?void 0:h.target,I=x==="checkbox"?m:C,H=e==null?void 0:e.find(F=>F.customUpperCode===b);if(H){const F=v?{...v}:{...f},V=Ce(I.toString(),H,i,F);V&&Object.assign(F,V),L(F)}},[f,e,i]),z=k(h=>{h.preventDefault();const v=B();s==null||s(h,v)},[B,s]);return{isDataValid:q,formData:c,errors:f,formRef:o,handleInputChange:Z,onFocus:P,handleBlur:j,handleSubmit:z,handleValidationSubmit:B}};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 It=_e(({loading:e,values:s,fields:n=[],errors:t,className:d="",onChange:l,onBlur:i,onFocus:o,slots:c})=>{const p=`${d}__field`,f=(r,u)=>{if(!(c!=null&&c[`AddressFormInput_${r.code}`]))return;const A={inputName:r.customUpperCode,handleOnChange:l,handleOnBlur:i,handleOnFocus:o,errorMessage:u,errors:t,config:r};return a(me,{"data-testid":`addressFormInput_${r.code}`,name:`AddressFormInput_${r.code}`,slot:c[`AddressFormInput_${r.code}`],context:A},r.id)},L=(r,u,A)=>{var S;const T=((S=r.options.find(_=>_.isDefault))==null?void 0:S.value)??u??r.defaultValue;return a(ee,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e||r.disabled,children:a(Je,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,required:r==null?void 0:r.required,name:r.customUpperCode,floatingLabel:`${r.label} ${r.required?"*":""}`,placeholder:r.label,options:r.options,onBlur:i,onFocus:o,handleSelect:l,defaultValue:T,value:T})},r.id)})},y=(r,u,A)=>a(ee,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e,children:a(Xe,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u??r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:i,onFocus:o,onChange:l})},r.id)}),M=(r,u,A)=>a(ee,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e||r.disabled,children:a(Ke,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u||r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l,disabled:e||r.disabled})},r.id)}),g=(r,u,A)=>a(ee,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:(r==null?void 0:r.isHidden)??e,children:a(Re,{"aria-label":r.label,"aria-required":r.required?"true":"false","aria-hidden":r.isHidden,tabindex:r!=null&&r.isHidden?-1:0,id:r.code,name:r.customUpperCode,checked:u||r.defaultValue,placeholder:r.label,label:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l})},r.id)}),N=(r,u,A)=>a(ee,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e,children:a(Ye,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u??r.defaultValue,label:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l})},r.id)});return n.length?a(ee,{children:n.map(r=>{const u=t==null?void 0:t[r.customUpperCode],A=s==null?void 0:s[r.customUpperCode];switch(r.fieldType){case se.TEXT:return r.options.length?L(r,A,u):y(r,A,u);case se.MULTILINE:return y(r,A,u);case se.SELECT:return L(r,A,u);case se.DATE:return M(r,A,u);case se.BOOLEAN:return g(r,A,u);case se.TEXTAREA:return N(r,A,u);default:return null}})}):null}),Pe=({testId:e,withCard:s=!0})=>{const n=G(we,{"data-testid":e||"skeletonLoader",children:[a(K,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:Q(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},St=()=>G(we,{"data-testid":"addressFormLoader",children:[a(K,{variant:"heading",size:"medium"}),a(K,{variant:"empty",size:"medium"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large",fullWidth:!0}),a(K,{size:"large",fullWidth:!0,lines:3}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large",fullWidth:!0})]}),xt=_e(ut(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:t,name:d,loading:l,children:i,className:o="defaultForm",fieldsConfig:c,onSubmit:p,onChange:f,forwardFormRef:L,regionOptions:y,showSaveCheckBox:M,handleSaveCheckBoxAddress:g,saveCheckBoxAddress:N})=>{const r=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:u,formData:A,errors:T,formRef:S,handleInputChange:_,handleBlur:q,handleSubmit:O,handleValidationSubmit:B,onFocus:w}=Zt({fieldsConfig:c,onSubmit:p,onChange:f,setInputChange:s,regionOptions:y,formName:d,isWaitingForResponse:e});return pt(L,()=>{const Z=Ae(S);return{handleValidationSubmit:B,formData:ae(Z,!0),isDataValid:u}}),n||!(c!=null&&c.length)?a(St,{}):G("form",{className:Q(["account-form",o]),onSubmit:O,name:d,ref:S,children:[a(It,{className:o,loading:l,fields:c,onChange:_,onBlur:q,errors:T,values:A,onFocus:w,slots:t}),t!=null&&t.AddressFormInputs?a(me,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:t.AddressFormInputs,context:{formActions:{handleChange:_}}}):null,M?a("div",{className:"account-address-form--saveAddressBook",children:a(Re,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:r.saveAddressBook,checked:N,onChange:Z=>{_(Z),g==null||g(Z)}})}):null,i]})})),xe=(e,s,n={},t="editButton")=>{const d=t==="removeButton",l={shippingAndBilling:{edit:n.editAddressAriaLabelShippingAndBilling,remove:n.removeAddressAriaLabelShippingAndBilling},shipping:{edit:n.editAddressAriaLabelShipping,remove:n.removeAddressAriaLabelShipping},billing:{edit:n.editAddressAriaLabelBilling,remove:n.removeAddressAriaLabelBilling},default:{edit:n.editAddressAriaLabelDefault,remove:n.removeAddressAriaLabelDefault}};let i="default";return e&&s?i="shippingAndBilling":e?i="shipping":s&&(i="billing"),d?l[i].remove:l[i].edit},Me=({slots:e,selectable:s,selectShipping:n,selectBilling:t,variant:d="secondary",minifiedView:l,keysSortOrder:i,addressData:o,loading:c,setAddressId:p,handleRenderModal:f,handleRenderForm:L})=>{const y=ft(),M=l?"minifiedView":"fullSizeView",g=ne({actionRemove:`Account.${M}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${M}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${M}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${M}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${M}.Addresses.addressCard.defaultLabelText`,editAddressAriaLabelDefault:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.default`,editAddressAriaLabelShipping:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.shipping`,editAddressAriaLabelBilling:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.billing`,editAddressAriaLabelShippingAndBilling:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.shippingAndBilling`,removeAddressAriaLabelDefault:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.default`,removeAddressAriaLabelShipping:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.shipping`,removeAddressAriaLabelBilling:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.billing`,removeAddressAriaLabelShippingAndBilling:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.shippingAndBilling`}),N=g.cardLabelBilling.toLocaleUpperCase(),r=g.cardLabelShipping.toLocaleUpperCase(),u=g.defaultLabelText.toLocaleUpperCase(),A=ve(()=>{const Z={shippingLabel:r,billingLabel:N,hideShipping:!1,hideBilling:!1};return s?n&&!t?{shippingLabel:u,billingLabel:u,hideShipping:!1,hideBilling:!0}:t&&!n?{shippingLabel:u,billingLabel:u,hideShipping:!0,hideBilling:!1}:Z:Z},[N,u,r,t,n,s]),T=Ne(()=>{p==null||p(o==null?void 0:o.id),f==null||f()},[f,o==null?void 0:o.id,p]),S=Ne(()=>{p==null||p(o==null?void 0:o.id),L==null||L()},[L,o==null?void 0:o.id,p]),_=ve(()=>{if(!i)return[];const{region:Z,...P}=o,j={...P,...Z};return i.filter(({name:z})=>j[z]).map(z=>({name:z.name,orderNumber:z.orderNumber,value:j[z.name],label:z.label}))},[o,i]),{shippingLabel:q,billingLabel:O,hideShipping:B,hideBilling:w}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(Pe,{}):G(ee,{children:[G("div",{className:"account-address-card__action",children:[f?a(de,{type:"button",variant:"tertiary",onClick:T,"data-testid":"removeButton","aria-label":xe(o==null?void 0:o.defaultShipping,o==null?void 0:o.defaultBilling,g,"removeButton"),"aria-describedby":y,children:g.actionRemove}):null,L?a(de,{type:"button",variant:"tertiary",onClick:S,className:"account-address-card__action--editbutton","data-testid":"editButton","aria-label":xe(o==null?void 0:o.defaultShipping,o==null?void 0:o.defaultBilling,g,"editButton"),"aria-describedby":y,children:g.actionEdit}):null]}),a("div",{className:"account-address-card__description",id:y,children:e!=null&&e.AddressCard?a(me,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:_}}):a(ee,{children:_.map((Z,P)=>{const j=Z.label?`${Z.label}: ${Z==null?void 0:Z.value}`:Z==null?void 0:Z.value;return a("p",{"data-testid":`${Z.name}_${P}`,children:j},P)})})}),(o!=null&&o.defaultShipping||o!=null&&o.defaultBilling)&&!s?G("div",{className:"account-address-card__labels",children:[o!=null&&o.defaultShipping?a(pe,{label:r}):null,o!=null&&o.defaultBilling?a(pe,{label:N}):null]}):null,s?G("div",{className:"account-address-card__labels",children:[!B&&(o!=null&&o.defaultShipping)?a(pe,{label:q}):null,!w&&(o!=null&&o.defaultBilling)?a(pe,{label:O}):null]}):null]})})},Ft=e=>Y.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},Y.createElement("g",{id:"Large"},Y.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Y.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},Y.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"}),Y.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"})))),Ot=e=>Y.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},Y.createElement("g",{id:"Large"},Y.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Y.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},Y.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"})))),Bt=e=>Y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Y.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"})),Rt=e=>Y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Y.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"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:t,routeAddressesPage:d})=>{const l=t?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${l}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${l}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${l}.Addresses.differentAddressButton`}),o=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},p=t&&!n?i.viewAllAddressesButton:i.addNewAddressButton,f=e?i.differentAddressButton:p;return G(o,{...c,className:Q(["account-actions-address",["account-actions-address--viewall",t],["account-actions-address--address",!t],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:f}),a(He,{source:t&&!n?Ot:Ft,size:"32"})]})},wt=({minifiedView:e,keysSortOrder:s,addressData:n,open:t,submitLoading:d,onRemoveAddress:l,closeModal:i})=>{const o=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${o}.Addresses.removeAddressModal.title`,description:`Account.${o}.Addresses.removeAddressModal.description`,actionCancel:`Account.${o}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${o}.Addresses.removeAddressModal.actionConfirm`});return t?a("div",{className:"account-address-modal",children:G(Qe,{className:"account-address-modal--overlay",title:a("h3",{children:c.title}),size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(De,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),G("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:l,children:c.actionConfirm})]})]})}):null},Ht=({typeList:e,isEmpty:s,minifiedView:n,className:t})=>{const d=n?"minifiedView":"fullSizeView",l=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=ve(()=>{switch(e){case"address":return{icon:Bt,text:a("p",{children:l.addressesMessage})};case"orders":return{icon:Rt,text:a("p",{children:l.ordersListMessage})};default:return{icon:"",text:""}}},[e,l]);return!s||!e||!i.text?null:a(et,{className:Q(["account-empty-list",n?"account-empty-list--minified":"",t]),message:i.text,icon:a(He,{source:i.icon}),"data-testid":"emptyList"})},Vt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(f=>!!f)?{}:{region:{...i.region,regionId:0}};return!!await ye({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),t=s[s.length-1],d=n[0]||((t==null?void 0:t.id)!==e?t:null);return!d||!d.id?!1:!!await ye({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},zt=["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"],or=["email","firstname","lastname","middlename","gender","dob","prefix","suffix","fax"],je=(e,s,n)=>{if(s&&n||!s&&!n)return e;const t=e.slice();return s?t.sort((d,l)=>Number(l.defaultShipping)-Number(d.defaultShipping)):n?t.sort((d,l)=>Number(l.defaultBilling)-Number(d.defaultBilling)):e},Ee=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(Ee),kt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:t,minifiedView:d,routeAddressesPage:l,onSuccess:i})=>{const[o,c]=$(""),[p,f]=$(!1),[L,y]=$(!1),[M,g]=$(!1),[N,r]=$(!1),[u,A]=$(!1),[T,S]=$(""),[_,q]=$([]),[O,B]=$([]),w=k(async()=>{g(!0),Promise.all([ke("shortRequest"),at()]).then(m=>{const[I,H]=m;if(I){const F=I.map(({name:V,orderNumber:D,label:re})=>({name:dt(V),orderNumber:D,label:zt.includes(V)?null:re}));B(F)}if(H)if(d){const F=H.filter(D=>!!D.defaultShipping||!!D.defaultBilling),V=H[H.length-1];q(F.length?F:[V])}else q(H)}).finally(()=>{g(!1)})},[d]);te(()=>{w()},[w]),te(()=>{var m;if(_.length)if(n===0)A(!0),c("0");else{const I=_.find(F=>+F.id===n)||je(_,e,s)[0],H={data:ae(I),isDataValid:!Ee(I)};c(n.toString()||((m=I==null?void 0:I.id)==null?void 0:m.toString())),t==null||t(H)}},[_,n,t,s,e]);const Z=k(m=>{S(m),A(!1)},[]),P=k((m,I)=>{const H=(m==null?void 0:m.target).value,F=(m==null?void 0:m.target).nextSibling;c(H);const V={data:ae(I),isDataValid:!Ee(ae(I))};t==null||t(V),A(H==="0"),F&&(F.focus(),window.scrollBy(0,100))},[t]),j=k(()=>{y(!0)},[]),z=k(()=>{S(""),y(!1),f(!1)},[]),h=k(()=>{f(!0)},[]),v=k(async()=>{r(!0),await Vt(T,_),ot(+T).then(()=>{w(),z()}).finally(()=>{r(!1)})},[_,T,z,w]),b=k(()=>{A(!1)},[]),C=k(()=>{Ue(l)&&d&&!u?window.location.href=l():(A(!0),S(""))},[u,l,d]),x=k(async()=>{await w(),await(i==null?void 0:i())},[w,i]);return{keysSortOrder:O,submitLoading:N,isModalRendered:p,isFormRendered:L,loading:M,addNewAddress:u,addressesList:_,addressId:T,handleRenderForm:j,handleRenderModal:h,removeAddress:v,onCloseBtnClick:z,setEditingAddressId:Z,closeNewAddressForm:b,redirectToAddressesRoute:C,handleOnSuccess:x,handleSelectAddressOption:P,selectedAddressOption:o}},lr=_e(({minifiedViewKey:e,hideActionFormButtons:s=!1,inputName:n,slots:t,title:d="",addressFormTitle:l="",defaultSelectAddressId:i="",showFormLoader:o=!1,onAddressData:c,forwardFormRef:p,className:f,showSaveCheckBox:L=!1,saveCheckBoxValue:y=!1,selectShipping:M=!1,selectBilling:g=!1,selectable:N=!1,withHeader:r=!0,minifiedView:u=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:T=!0,inputsDefaultValueSet:S,showShippingCheckBox:_=!0,showBillingCheckBox:q=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:B=!0,routeAddressesPage:w,onSuccess:Z,onError:P})=>{const j=ne({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:z,submitLoading:h,isModalRendered:v,isFormRendered:b,loading:C,addNewAddress:x,addressesList:m,addressId:I,handleRenderForm:H,handleRenderModal:F,removeAddress:V,onCloseBtnClick:D,handleOnSuccess:re,setEditingAddressId:ge,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=kt({defaultSelectAddressId:i,minifiedView:u,routeAddressesPage:w,onSuccess:Z,onAddressData:c,selectShipping:M,selectBilling:g}),E=d||j.containerTitle;let W=null;if(N){const R=je(m,M,g)||[];let J;x?J=a("div",{className:Q(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",x]]),children:a(fe,{slots:t,hideActionFormButtons:s,formName:n,showFormLoader:o,isOpen:x,forwardFormRef:p,showSaveCheckBox:L,saveCheckBoxValue:y,shippingCheckBoxValue:O,billingCheckBoxValue:B,addressesFormTitle:l||j.differentAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:_,showBillingCheckBox:q,onCloseBtnClick:oe,onSuccess:re,onError:P,onChange:c})}):R.length?J=a(Fe,{selectable:N,minifiedView:u,addNewAddress:x,routeAddressesPage:ie}):J=null;const X=`generalLabel_${E.replace(/\s+/g,"")}`;W=G("div",{className:"account-addresses-wrapper--select-view",children:[a("span",{id:X,style:"display: none;",children:E}),R.map((U,Le)=>{const be=`${n}_${U.id}`,$e=`${be}_label`;return G(Te,{children:[a("input",{"data-testid":`radio-${Le+1}`,type:"radio",name:n,id:be,value:U.id,checked:ue===(U==null?void 0:U.id.toString()),onChange:Ge=>ce(Ge,U),"aria-labelledby":`${X} ${$e}`}),a("label",{id:$e,htmlFor:be,className:"account-addresses-wrapper__label",children:a(Me,{slots:t,selectable:N,selectShipping:M,selectBilling:g,minifiedView:u,addressData:U,keysSortOrder:z,loading:C})})]},U.id)}),a("input",{"aria-label":`${E} ${j.ariaLabelAddressPicker}`,"data-testid":"radio-0",type:"radio",name:n,id:`${n}_addressActions`,value:"0",checked:ue==="0",onChange:U=>ce(U,{}),tabindex:J?0:-1}),a("label",{htmlFor:`${n}_addressActions`,className:"account-addresses-wrapper__label",children:J})]})}else W=G(ee,{children:[m.map(R=>a(Te,{children:I===R.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:t,isOpen:I===R.id&&b,addressFormId:I,inputsDefaultValueSet:R,addressesFormTitle:j.editAddressFormTitle,showShippingCheckBox:_,showBillingCheckBox:q,shippingCheckBoxValue:O,billingCheckBoxValue:B,onCloseBtnClick:D,onSuccess:re,onError:P})}):a(Me,{slots:t,minifiedView:u,addressData:R,keysSortOrder:z,loading:C,setAddressId:ge,handleRenderModal:u&&A||!u&&T?F:void 0,handleRenderForm:u&&A||!u&&T?H:void 0},R.id)},R.id)),a("div",{className:"account-addresses__footer",children:x?a(he,{variant:"secondary",children:a(fe,{slots:t,isOpen:x,addressesFormTitle:j.newAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:!!(m!=null&&m.length),showBillingCheckBox:!!(m!=null&&m.length),shippingCheckBoxValue:O,billingCheckBoxValue:B,onCloseBtnClick:oe,onSuccess:re,onError:P})}):a(Fe,{minifiedView:u,addNewAddress:x,routeAddressesPage:ie})})]});return G("div",{children:[r?a(tt,{title:E,divider:!u,className:u?"account-addresses-header":""}):null,G("div",{className:Q(["account-addresses-wrapper",f]),"data-testid":"addressesIdWrapper",children:[a(wt,{minifiedView:u,addressData:m==null?void 0:m.find(R=>R.id===I),keysSortOrder:z,submitLoading:h,open:v,closeModal:D,onRemoveAddress:V}),C?a(Pe,{testId:"addressSkeletonLoader",withCard:!1}):N?a(fe,{slots:t,hideActionFormButtons:s,formName:n,isOpen:!(m!=null&&m.length),forwardFormRef:p,showSaveCheckBox:L,saveCheckBoxValue:y,shippingCheckBoxValue:O,billingCheckBoxValue:B,inputsDefaultValueSet:S,showShippingCheckBox:_,showBillingCheckBox:q,onCloseBtnClick:oe,onSuccess:re,onError:P,onChange:c}):a(Ht,{isEmpty:!(m!=null&&m.length),typeList:"address",minifiedView:u}),W]})]})}),We={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},qt={...We,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ut={...We,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Pt=(e,s)=>s==null?void 0:s.map(n=>{const t={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(t,n.customUpperCode)){const l=t[n.customUpperCode];n.customUpperCode==="region"&&typeof l=="object"?d.defaultValue=l.regionCode&&l.regionId?`${l.regionCode},${l.regionId}`:l.region??l.regionCode:d.defaultValue=l}return d}),Oe=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(t=>{s.has(t.name)||s.set(t.name,"false"),t.checked&&s.set(t.name,"true")}),s&&typeof s.entries=="function"){const t=s.entries();if(t&&typeof t[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(t)))||{}}return{}},jt=({fields:e,addressId:s,countryOptions:n,disableField:t,regionOptions:d,isRequiredRegion:l,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:t}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:l,disabled:t}:c),Wt=(e,s="address")=>{const n=s==="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"],t={},d=[];return Object.keys(e).forEach(l=>{n.includes(l)?t[l]=e[l]:d.push({attribute_code:ze(l),value:e[l]})}),d.length>0&&(t.custom_attributesV2=d),t},Be=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],t=[],d={};for(const g in e){const N=e[g];n.includes(N)&&(d[g]=qe(N)),s.includes(g)&&t.push(N)}const{street:l,streetMultiline_2:i,streetMultiline_1:o,region:c,...p}=e,[f,L]=c?c.split(","):[void 0,void 0],y=L&&f?{regionId:+L,regionCode:f}:{region:f};return Wt({...p,...d,region:{...y},street:t})},Gt=(e,s)=>{const n={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const d=e[t];if(t==="region"&&d.regionId){const l=s.find(i=>(i==null?void 0:i.id)===d.regionId);l?n[t]={...d,text:l.text}:n[t]=d}else Array.isArray(d)?(n[t]=d[0]||"",d.slice(1).forEach((l,i)=>{n[`${t}Multiline_${i+2}`]=l})):n[t]=d}return n},Jt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Xt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:t,billingCheckBoxValue:d,shippingCheckBoxValue:l,showShippingCheckBox:i,showBillingCheckBox:o,inputsDefaultValueSet:c,onCloseBtnClick:p,onSuccess:f,onError:L,formName:y})=>{const[M,g]=$({text:"",type:"success"}),[N,r]=$(e??!1),[u,A]=$(t||""),[T,S]=$([]),[_,q]=$([]),[O,B]=$([]),[w,Z]=$([]),[P,j]=$([]),[z,h]=$(!1),[v,b]=$(!1),[C,x]=$(()=>{var W,R;const E=sessionStorage.getItem(`${y}_addressData`);return E?{countryCode:(R=(W=JSON.parse(E))==null?void 0:W.data)==null?void 0:R.countryCode}:c}),[m,I]=$(!1),[H,F]=$(!1),[V,D]=$(()=>{var R,J;const E=sessionStorage.getItem(`${y}_addressData`);return E?(J=(R=JSON.parse(E))==null?void 0:R.data)==null?void 0:J.saveAddressBook:n}),re=k(E=>{D(E.target.checked)},[]);te(()=>{typeof e>"u"||r(e)},[e]),te(()=>{ke(u?"customer_address_edit":"customer_register_address").then(E=>{S(E)})},[u]),te(()=>{I(!0),lt().then(({availableCountries:E,countriesWithRequiredRegion:W,optionalZipCountries:R})=>{q(E),Z(W),j(R),I(!1)})},[]),te(()=>{if(C!=null&&C.countryCode){I(!0),F(!0);const E=C==null?void 0:C.countryCode;it(E).then(W=>{B(W);const R=w.find(X=>X===E),J=P.find(X=>X===E);h(!!R),b(!J),I(!1),F(!1)})}},[C==null?void 0:C.countryCode,w,P]);const ge=k(()=>{g({text:"",type:"success"}),p==null||p()},[p]),oe=k(async(E,W)=>{if(!W)return null;r(!0);const R=Oe(E.target),J=Be(R);await ye(J).then(()=>{var X;f==null||f(),p==null||p(),(X=E==null?void 0:E.target)==null||X.reset()}).catch(X=>{g(U=>({...U,text:X.message,type:"error"})),L==null||L(X)}).finally(()=>{A(""),r(!1)})},[p,L,f]),ie=k(async(E,W)=>{if(!W)return;r(!0);const{saveAddressBook:R,...J}=Oe(E.target),X=Be(J);await ct(X).then(()=>{var U;f==null||f(),p==null||p(),(U=E==null?void 0:E.target)==null||U.reset()}).catch(U=>{g(Le=>({...Le,text:U.message,type:"error"})),L==null||L(U)}).finally(()=>{A(""),r(!1)})},[p,L,f]),ce=nt(()=>{if(!T.length)return[];const E={...qt,defaultValue:l,isHidden:s&&!V?!0:!i},W={...Ut,defaultValue:d,isHidden:s&&!V?!0:!o},R=[...T,E,W],J=sessionStorage.getItem(`${y}_addressData`),X=J?Gt(JSON.parse(J).data,O):{},U=Pt(Jt(X,c),R);return jt({fields:U,addressId:u,countryOptions:_,disableField:m,regionOptions:O,isRequiredRegion:z,isRequiredPostCode:v})},[T,l,s,V,i,d,o,y,O,c,u,_,m,z,v]),ue=k(E=>{x(W=>({...W,...E}))},[]);return{isWaitingForResponse:H,regionOptions:O,saveCheckBoxAddress:V,inLineAlert:M,addressId:u,submitLoading:N,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:ge,handleInputChange:ue}},Kt=e=>{var d;if(!e||!Array.isArray(e.customAttributes))return e??{};const s={};(d=e==null?void 0:e.customAttributes)==null||d.forEach(l=>{l.code&&Object.hasOwn(l,"value")&&(s[l.code]=l.value)});const{customAttributes:n,...t}=e;return{...t,...Ve(s,"camelCase",{})}},Yt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:t=!1,saveCheckBoxValue:d=!1,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,showShippingCheckBox:L=!0,showBillingCheckBox:y=!0,shippingCheckBoxValue:M=!0,billingCheckBoxValue:g=!0,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S})=>{const _=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:q,inLineAlert:O,addressId:B,submitLoading:w,normalizeFieldsConfig:Z,handleUpdateAddress:P,handleCreateAddress:j,handleOnCloseForm:z,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:C}=Xt({showFormLoader:n,addressFormId:p,inputsDefaultValueSet:Kt(f),shippingCheckBoxValue:M,billingCheckBoxValue:g,showShippingCheckBox:L,showBillingCheckBox:y,saveCheckBoxValue:d,showSaveCheckBox:t,onSuccess:A,onError:T,onCloseBtnClick:u,formName:s});return N?G("div",{className:Q(["account-address-form-wrapper",c]),children:[o?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:o}):null,O.text?a(rt,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:O.type,variant:"secondary",heading:O.text,icon:O.icon}):null,G(xt,{regionOptions:C,forwardFormRef:l,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:Z,onSubmit:r||(B?P:j),setInputChange:b,loading:w,showFormLoader:n,showSaveCheckBox:t,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,onChange:S,isWaitingForResponse:q,children:[B?a("input",{type:"hidden",name:"addressId",value:B,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:Q(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",t]]),children:i!=null&&i.AddressFormActions?a(me,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:P,handleCreateAddress:j,addressId:B}}):a(ee,{children:t?null:G(ee,{children:[a(de,{type:"button",onClick:z,variant:"secondary",disabled:w,children:_.secondaryButton}),a(de,{disabled:w,children:_.primaryButton})]})})})]})]}):null};export{fe as A,Pe as C,Ht as E,xt as F,Ot as S,lr as a,Ue as c,or as d,Oe as g,Wt as n};
@@ -172,7 +172,7 @@ export declare const mockOrdersListResponse: {
172
172
  items: ({
173
173
  status: string;
174
174
  quantityOrdered: number;
175
- product_name: string;
175
+ product_name: undefined;
176
176
  id: string;
177
177
  product: {
178
178
  small_image: {
@@ -191,6 +191,17 @@ export declare const mockOrdersListResponse: {
191
191
  url: string;
192
192
  };
193
193
  };
194
+ } | {
195
+ status: string;
196
+ quantityOrdered: number;
197
+ product_name: string;
198
+ id: string;
199
+ product: {
200
+ small_image: {
201
+ url: string;
202
+ };
203
+ };
204
+ quantityInvoiced?: undefined;
194
205
  })[];
195
206
  total: {
196
207
  grand_total: {
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as s,jsxs as l,Fragment as $}from"@dropins/tools/preact-jsx-runtime.js";import{classes as k,Slot as U}from"@dropins/tools/lib.js";import{S as K,c as Q,E as X,C as Z}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as R,Icon as V,Price as rr,ContentGrid as tr,Image as W,Header as sr,Picker as er,Pagination as ar}from"@dropins/tools/components.js";import{useText as D}from"@dropins/tools/i18n.js";import{useState as y,useEffect as Y,useMemo as cr,useCallback as j}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as nr}from"../chunks/getOrderHistoryList.js";import{g as or}from"../chunks/getStoreConfig.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";import"../fragments.js";const m={size:"32",stroke:"2"},G=({minifiedView:a,orderNumber:c,orderToken:r,routeOrdersList:e,routeOrderDetails:u})=>{const n=a?"minifiedView":"fullSizeView",i=D({viewAllOrdersButton:`Account.${n}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${n}.OrdersList.ariaLabelLink`});return e?s("a",{className:k(["account-orders-list-action",["account-orders-list-action--minifiedView",a]]),"data-testid":"ordersListActionButtonMinifiedView",href:e(),children:s(R,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:l("div",{className:"account-orders-list-action__card-wrapper",children:[s("p",{children:i.viewAllOrdersButton}),s(V,{source:K,...m})]})})}):s("a",{"aria-label":`${i.ariaLabelLink} ${c??r}`,href:Q(u)?u(c,r):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:s(V,{source:K,...m})})},dr=()=>{const[a,c]=y(window.innerWidth<768);return Y(()=>{const r=()=>{c(window.innerWidth<768)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),a},ir=({placeholderImage:a,minifiedView:c,item:r,withThumbnails:e,children:u,slots:n,routeTracking:i,routeOrderProduct:p,routeReturnDetails:f,...b})=>{var g,I,_,x,N,M,P,O,z,w,T,v;const o=c?"minifiedView":"fullSizeView",h=D({orderNumber:`Account.${o}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${o}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${o}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${o}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${o}.OrdersList.OrdersListCard.orderDate`}),d=dr(),S=Q(p);return l(R,{variant:"secondary",...b,className:k(["account-orders-list-card",["account-orders-list-card--full",((g=r==null?void 0:r.items)==null?void 0:g.length)>6]]),children:[s("div",{className:"account-orders-list-card__content",children:n!=null&&n.OrdersListCard?s(U,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):l($,{children:[s("div",{children:r==null?void 0:r.status}),l("p",{children:[h.deliveryDateText," ",r==null?void 0:r.orderDate]}),l("p",{children:[h.orderNumber," ",r.number]}),(I=r==null?void 0:r.shipments)==null?void 0:I.map(t=>{var L;return(L=t==null?void 0:t.tracking)==null?void 0:L.map(A=>{const C=i==null?void 0:i(A);return l("p",{"data-testid":A.number,children:[s("span",{children:`${h.carrier} ${A.carrier.toLocaleUpperCase()} `}),C?s("a",{href:C,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:A.number}):s("span",{className:"account-orders-list-card__content--track_number",children:A.number})]},t.id)})}),r!=null&&r.returns&&((_=r.returns)!=null&&_.length)?l("p",{"data-testid":r.number,children:[l("span",{children:[h.returnsText," "]}),(x=r==null?void 0:r.returns)==null?void 0:x.map(t=>s("span",{"data-testid":t.number,children:l("a",{href:(f==null?void 0:f({orderNumber:r.number,orderToken:r.token,returnNumber:t.number}))??"#",className:"account-orders-list-card__content--return_number",children:[t.number," "]})},t.uid))]},r.id):null,s("p",{children:s(rr,{amount:((M=(N=r==null?void 0:r.total)==null?void 0:N.grandTotal)==null?void 0:M.value)??0,currency:(O=(P=r==null?void 0:r.total)==null?void 0:P.grandTotal)==null?void 0:O.currency,weight:"normal",size:"medium"})}),l("p",{"data-testid":"itemsAmount",children:[(z=r==null?void 0:r.items)!=null&&z.length?(w=r==null?void 0:r.items)==null?void 0:w.reduce((t,L)=>{const A=(L==null?void 0:L.quantityOrdered)||0;return t+A},0):0," ",h.itemsAmount]}),(T=r==null?void 0:r.items)==null?void 0:T.map((t,L)=>{if(L>=0&&L<10)return l("p",{className:"account-orders-list-card__content--product-name",children:[l("span",{className:"account-orders-list-card__content--quantity",children:[(t==null?void 0:t.quantityOrdered)>1?t==null?void 0:t.quantityOrdered:null," "]}),t==null?void 0:t.productName.replaceAll("-"," ")]},`${L}_${t.id}`);if(L===11)return s("p",{children:"..."},"ellipsis")})]})}),e&&((v=r==null?void 0:r.items)!=null&&v.length)?s(tr,{maxColumns:d?3:9,emptyGridContent:s($,{}),className:k(["account-orders-list-card__images",["account-orders-list-card__images-3",d]]),"data-testid":"ordersListCardImages",children:r.items.map((t,L)=>{var H,q,B,F,J;const A=(B=(q=(H=t==null?void 0:t.product)==null?void 0:H.smallImage)==null?void 0:q.url)!=null&&B.length?(J=(F=t==null?void 0:t.product)==null?void 0:F.smallImage)==null?void 0:J.url:a,C=(t==null?void 0:t.productName)??"";return S?s("a",{href:(p==null?void 0:p(t))??"",target:"_blank",rel:"noreferrer",children:s(W,{src:A,width:65,height:65,alt:C})},t.id+L):s(W,{src:A,width:65,height:65,alt:C},t.id+L)})}):null,s("div",{className:"account-orders-list-card__actions",children:u})]})},lr=({ordersInMinifiedView:a,minifiedView:c,pageSize:r,selectedDate:e,selectedPage:u,handleSetFirstOrderDate:n})=>{const[i,p]=y([]),[f,b]=y({totalPages:1,currentPage:1,pageSize:1}),[o,h]=y(!1),[d,S]=y("");return Y(()=>{or().then(g=>{S(g.baseMediaUrl)})},[]),Y(()=>{h(!0),nr(c?a:r,e,u).then(g=>{!g||!g.items||(b(g.pageInfo),p(g.items),n==null||n(g.dateOfFirstOrder))}).finally(()=>{h(!1)})},[n,c,a,r,e,u]),{loading:o,orderHistoryListItems:i,pageInfo:f,placeholderImage:d}},E=(a,c=1)=>{const r=new Date,e=new Date(r);switch(a){case"sixMonthsAgo":{e.setMonth(e.getMonth()-c);break}case"oneYearAgo":{e.setFullYear(e.getFullYear()-c);break}default:return""}return{from:e==null?void 0:e.toISOString().split("T")[0],to:`${r==null?void 0:r.toISOString().split("T")[0]} 23:59:59`}},ur=a=>{const c=[],r=new Date().getFullYear();for(let e=a;e<=r-1;e++)c.push({value:`{"from":"${e}-01-01","to":"${e+1}-01-01 23:59:59"}`,text:e.toString()});return c},hr=()=>{const a=D({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[c,r]=y(),[e,u]=y(JSON.stringify(E("sixMonthsAgo",6))),[n,i]=y(1);Y(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[n]);const p=cr(()=>{const o=[{value:JSON.stringify(E("sixMonthsAgo",6)),text:a.pastSixMonths},{value:JSON.stringify(E("oneYearAgo",1)),text:a.currentYear},{value:"viewAll",text:a.viewAll}];if(c){const d=new Date(c).getFullYear();o==null||o.splice(2,0,...ur(d))}return o},[a,c]),f=j(o=>{r(o)},[]),b=j(o=>{const d=o.target.value;u(d),i(1)},[]);return{selectableDateList:p,selectedDate:e,selectedPage:n,handleSelectDate:b,setSelectedPage:i,handleSetFirstOrderDate:f}},gr=({className:a,withHeader:c=!0,minifiedView:r=!1,withThumbnails:e=!0,withFilter:u=!0,ordersInMinifiedView:n=1,pageSize:i=10,routeOrdersList:p,routeOrderDetails:f,routeReturnDetails:b,routeTracking:o,routeOrderProduct:h,slots:d})=>{const S=r?"minifiedView":"fullSizeView",g=D({containerTitle:`Account.${S}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${S}.OrdersList.dateOrderPlaced`}),{selectableDateList:I,selectedDate:_,handleSelectDate:x,selectedPage:N,setSelectedPage:M,handleSetFirstOrderDate:P}=hr(),{pageInfo:O,loading:z,orderHistoryListItems:w,placeholderImage:T}=lr({minifiedView:r,pageSize:i,ordersInMinifiedView:n,selectedDate:_,selectedPage:N,handleSetFirstOrderDate:P});return l("div",{children:[c?s(sr,{"aria-label":g.containerTitle,role:"region",title:g.containerTitle,divider:!r,className:r?"account-orders-list-header":""}):null,l("div",{className:k(["account-orders-list",a]),children:[!r&&u?l("div",{className:"account-orders-list__date-select",children:[s("span",{children:g.dateOrderPlaced}),s(er,{value:_,name:"orderDatePicker",options:I,handleSelect:x})]}):null,z?s($,{children:Array.from(Array(O==null?void 0:O.pageSize).keys()).map(v=>s(Z,{testId:"orderSkeletonLoader",withCard:!1},v))}):s($,{children:w.length?s($,{children:w.map((v,t)=>s(ir,{placeholderImage:T,routeTracking:o,routeOrderProduct:h,routeReturnDetails:b,minifiedView:r,item:v,withThumbnails:e,slots:d,children:d!=null&&d.OrdersListAction?s(U,{"data-testid":`ordersListActionSlot_${t}`,name:"OrdersListAction",slot:d==null?void 0:d.OrdersListAction,context:{orderHistoryListItem:v}}):s(G,{minifiedView:r,orderNumber:v.number,orderToken:v.token,routeOrderDetails:f})},t))}):s(X,{isEmpty:!w.length,typeList:"orders",minifiedView:r})}),!r&&(O==null?void 0:O.totalPages)>1?s(ar,{totalPages:O==null?void 0:O.totalPages,currentPage:N,onChange:M}):null,r?s(G,{minifiedView:r,routeOrdersList:p}):null]})]})},kr=({className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:u,ordersInMinifiedView:n,pageSize:i,routeOrdersList:p,routeOrderDetails:f,routeReturnDetails:b,routeTracking:o,routeOrderProduct:h,slots:d})=>s("div",{className:k(["account-orders-list",a]),"data-testid":"ordersListId",children:s(gr,{className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:u,ordersInMinifiedView:n,pageSize:i,routeOrdersList:p,routeOrderDetails:f,routeReturnDetails:b,routeTracking:o,routeOrderProduct:h,slots:d})});export{kr as OrdersList,kr as default};
3
+ import{jsx as t,jsxs as l,Fragment as x}from"@dropins/tools/preact-jsx-runtime.js";import{classes as k,Slot as m}from"@dropins/tools/lib.js";import{S as B,c as j,E as Q,C as R}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as G,Icon as F,Image as J,Price as X,ContentGrid as Z,Header as rr,Picker as tr,Pagination as er}from"@dropins/tools/components.js";import{useText as H}from"@dropins/tools/i18n.js";import{useState as y,useEffect as E,useMemo as U,useCallback as K}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as ar}from"../chunks/getOrderHistoryList.js";import{g as sr}from"../chunks/getStoreConfig.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";import"../fragments.js";const V={size:"32",stroke:"2"},W=({minifiedView:n,orderNumber:c,orderToken:r,routeOrdersList:a,routeOrderDetails:u})=>{const s=n?"minifiedView":"fullSizeView",i=H({viewAllOrdersButton:`Account.${s}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${s}.OrdersList.ariaLabelLink`});return a?t("a",{className:k(["account-orders-list-action",["account-orders-list-action--minifiedView",n]]),"data-testid":"ordersListActionButtonMinifiedView",href:a(),children:t(G,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:l("div",{className:"account-orders-list-action__card-wrapper",children:[t("p",{children:i.viewAllOrdersButton}),t(F,{source:B,...V})]})})}):t("a",{"aria-label":`${i.ariaLabelLink} ${c??r}`,href:j(u)?u(c,r):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:t(F,{source:B,...V})})},nr=()=>{const[n,c]=y(window.innerWidth<768);return E(()=>{const r=()=>{c(window.innerWidth<768)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),n},cr=({placeholderImage:n,minifiedView:c,item:r,withThumbnails:a,children:u,slots:s,routeTracking:i,routeOrderProduct:g,routeReturnDetails:f,...b})=>{var M,w,P,N,z,T,O,Y,_,D,v,C;const o=c?"minifiedView":"fullSizeView",h=H({orderNumber:`Account.${o}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${o}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${o}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${o}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${o}.OrdersList.OrdersListCard.orderDate`}),d=nr(),S=j(g),L=U(()=>((r==null?void 0:r.items)??[]).map((e,p)=>{var $,q;const A={title:(e==null?void 0:e.productName)??"",src:((q=($=e==null?void 0:e.product)==null?void 0:$.smallImage)==null?void 0:q.url)||n,alt:(e==null?void 0:e.productName)??"",width:65,height:65,loading:"eager"};return t(m,{name:"OrderItemImage",slot:s==null?void 0:s.OrderItemImage,context:{data:e,defaultImageProps:A},children:S?t("a",{href:(g==null?void 0:g(e))??"",target:"_blank",rel:"noreferrer",children:t(J,{...A})}):t(J,{...A})},`${p}_${e.id}`)}),[S,r.items,n,g,s==null?void 0:s.OrderItemImage]);return l(G,{variant:"secondary",...b,className:k(["account-orders-list-card",["account-orders-list-card--full",((M=r==null?void 0:r.items)==null?void 0:M.length)>6]]),children:[t("div",{className:"account-orders-list-card__content",children:s!=null&&s.OrdersListCard?t(m,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:s==null?void 0:s.OrdersListCard,context:{orderHistoryListItem:r}}):l(x,{children:[t("div",{children:r==null?void 0:r.status}),l("p",{children:[h.deliveryDateText," ",r==null?void 0:r.orderDate]}),l("p",{children:[h.orderNumber," ",r.number]}),(w=r==null?void 0:r.shipments)==null?void 0:w.map(e=>{var p;return(p=e==null?void 0:e.tracking)==null?void 0:p.map(A=>{const $=i==null?void 0:i(A);return l("p",{"data-testid":A.number,children:[t("span",{children:`${h.carrier} ${A.carrier.toLocaleUpperCase()} `}),$?t("a",{href:$,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:A.number}):t("span",{className:"account-orders-list-card__content--track_number",children:A.number})]},e.id)})}),r!=null&&r.returns&&((P=r.returns)!=null&&P.length)?l("p",{"data-testid":r.number,children:[l("span",{children:[h.returnsText," "]}),(N=r==null?void 0:r.returns)==null?void 0:N.map(e=>t("span",{"data-testid":e.number,children:l("a",{href:(f==null?void 0:f({orderNumber:r.number,orderToken:r.token,returnNumber:e.number}))??"#",className:"account-orders-list-card__content--return_number",children:[e.number," "]})},e.uid))]},r.id):null,t("p",{children:t(X,{amount:((T=(z=r==null?void 0:r.total)==null?void 0:z.grandTotal)==null?void 0:T.value)??0,currency:(Y=(O=r==null?void 0:r.total)==null?void 0:O.grandTotal)==null?void 0:Y.currency,weight:"normal",size:"medium"})}),l("p",{"data-testid":"itemsAmount",children:[(_=r==null?void 0:r.items)!=null&&_.length?(D=r==null?void 0:r.items)==null?void 0:D.reduce((e,p)=>{const A=(p==null?void 0:p.quantityOrdered)||0;return e+A},0):0," ",h.itemsAmount]}),(v=r==null?void 0:r.items)==null?void 0:v.map((e,p)=>{if(p>=0&&p<10)return l("p",{className:"account-orders-list-card__content--product-name",children:[l("span",{className:"account-orders-list-card__content--quantity",children:[(e==null?void 0:e.quantityOrdered)>1?e==null?void 0:e.quantityOrdered:null," "]}),e==null?void 0:e.productName.replaceAll("-"," ")]},`${p}_${e.id}`);if(p===11)return t("p",{children:"..."},"ellipsis")})]})}),a&&((C=r==null?void 0:r.items)!=null&&C.length)?t(Z,{maxColumns:d?3:9,emptyGridContent:t(x,{}),className:k(["account-orders-list-card__images",["account-orders-list-card__images-3",d]]),"data-testid":"ordersListCardImages",children:L}):null,t("div",{className:"account-orders-list-card__actions",children:u})]})},or=({ordersInMinifiedView:n,minifiedView:c,pageSize:r,selectedDate:a,selectedPage:u,handleSetFirstOrderDate:s})=>{const[i,g]=y([]),[f,b]=y({totalPages:1,currentPage:1,pageSize:1}),[o,h]=y(!1),[d,S]=y("");return E(()=>{sr().then(L=>{S(L.baseMediaUrl)})},[]),E(()=>{h(!0),ar(c?n:r,a,u).then(L=>{!L||!L.items||(b(L.pageInfo),g(L.items),s==null||s(L.dateOfFirstOrder))}).finally(()=>{h(!1)})},[s,c,n,r,a,u]),{loading:o,orderHistoryListItems:i,pageInfo:f,placeholderImage:d}},I=(n,c=1)=>{const r=new Date,a=new Date(r);switch(n){case"sixMonthsAgo":{a.setMonth(a.getMonth()-c);break}case"oneYearAgo":{a.setFullYear(a.getFullYear()-c);break}default:return""}return{from:a==null?void 0:a.toISOString().split("T")[0],to:`${r==null?void 0:r.toISOString().split("T")[0]} 23:59:59`}},dr=n=>{const c=[],r=new Date().getFullYear();for(let a=n;a<=r-1;a++)c.push({value:`{"from":"${a}-01-01","to":"${a+1}-01-01 23:59:59"}`,text:a.toString()});return c},ir=()=>{const n=H({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[c,r]=y(),[a,u]=y(JSON.stringify(I("sixMonthsAgo",6))),[s,i]=y(1);E(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[s]);const g=U(()=>{const o=[{value:JSON.stringify(I("sixMonthsAgo",6)),text:n.pastSixMonths},{value:JSON.stringify(I("oneYearAgo",1)),text:n.currentYear},{value:"viewAll",text:n.viewAll}];if(c){const d=new Date(c).getFullYear();o==null||o.splice(2,0,...dr(d))}return o},[n,c]),f=K(o=>{r(o)},[]),b=K(o=>{const d=o.target.value;u(d),i(1)},[]);return{selectableDateList:g,selectedDate:a,selectedPage:s,handleSelectDate:b,setSelectedPage:i,handleSetFirstOrderDate:f}},lr=({className:n,withHeader:c=!0,minifiedView:r=!1,withThumbnails:a=!0,withFilter:u=!0,ordersInMinifiedView:s=1,pageSize:i=10,routeOrdersList:g,routeOrderDetails:f,routeReturnDetails:b,routeTracking:o,routeOrderProduct:h,slots:d})=>{const S=r?"minifiedView":"fullSizeView",L=H({containerTitle:`Account.${S}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${S}.OrdersList.dateOrderPlaced`}),{selectableDateList:M,selectedDate:w,handleSelectDate:P,selectedPage:N,setSelectedPage:z,handleSetFirstOrderDate:T}=ir(),{pageInfo:O,loading:Y,orderHistoryListItems:_,placeholderImage:D}=or({minifiedView:r,pageSize:i,ordersInMinifiedView:s,selectedDate:w,selectedPage:N,handleSetFirstOrderDate:T});return l("div",{children:[c?t(rr,{"aria-label":L.containerTitle,role:"region",title:L.containerTitle,divider:!r,className:r?"account-orders-list-header":""}):null,l("div",{className:k(["account-orders-list",n]),children:[!r&&u?l("div",{className:"account-orders-list__date-select",children:[t("span",{children:L.dateOrderPlaced}),t(tr,{value:w,name:"orderDatePicker",options:M,handleSelect:P})]}):null,Y?t(x,{children:Array.from(Array(O==null?void 0:O.pageSize).keys()).map(v=>t(R,{testId:"orderSkeletonLoader",withCard:!1},v))}):t(x,{children:_.length?t(x,{children:_.map((v,C)=>t(cr,{placeholderImage:D,routeTracking:o,routeOrderProduct:h,routeReturnDetails:b,minifiedView:r,item:v,withThumbnails:a,slots:d,children:d!=null&&d.OrdersListAction?t(m,{"data-testid":`ordersListActionSlot_${C}`,name:"OrdersListAction",slot:d==null?void 0:d.OrdersListAction,context:{orderHistoryListItem:v}}):t(W,{minifiedView:r,orderNumber:v.number,orderToken:v.token,routeOrderDetails:f})},C))}):t(Q,{isEmpty:!_.length,typeList:"orders",minifiedView:r})}),!r&&(O==null?void 0:O.totalPages)>1?t(er,{totalPages:O==null?void 0:O.totalPages,currentPage:N,onChange:z}):null,r?t(W,{minifiedView:r,routeOrdersList:g}):null]})]})},Nr=({className:n,withHeader:c,minifiedView:r,withThumbnails:a,withFilter:u,ordersInMinifiedView:s,pageSize:i,routeOrdersList:g,routeOrderDetails:f,routeReturnDetails:b,routeTracking:o,routeOrderProduct:h,slots:d})=>t("div",{className:k(["account-orders-list",n]),"data-testid":"ordersListId",children:t(lr,{className:n,withHeader:c,minifiedView:r,withThumbnails:a,withFilter:u,ordersInMinifiedView:s,pageSize:i,routeOrdersList:g,routeOrderDetails:f,routeReturnDetails:b,routeTracking:o,routeOrderProduct:h,slots:d})});export{Nr as OrdersList,Nr as default};
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-account", "version": "1.0.4", "@dropins/elsie": "~0.41.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-account", "version": "1.0.5", "@dropins/elsie": "~0.42.0", "license": "SEE LICENSE IN LICENSE.md"}
@@ -1,6 +1,7 @@
1
1
  import { SlotProps } from '@dropins/tools/types/elsie/src/lib';
2
2
  import { HTMLAttributes } from 'preact/compat';
3
3
  import { OrderDetails, OrderItem, ShipmentsTracingModel } from '../data/models';
4
+ import { ImageProps } from '@dropins/tools/types/elsie/src/components';
4
5
 
5
6
  export interface OrdersListActionContext {
6
7
  orderHistoryListItem: OrderDetails;
@@ -15,6 +16,10 @@ export interface OrdersListProps extends HTMLAttributes<HTMLDivElement> {
15
16
  slots?: {
16
17
  OrdersListAction?: SlotProps<OrdersListActionContext>;
17
18
  OrdersListCard?: SlotProps<OrdersListCardContext>;
19
+ OrderItemImage?: SlotProps<{
20
+ data: OrderItem;
21
+ defaultImageProps: ImageProps;
22
+ }>;
18
23
  };
19
24
  routeOrdersList?: () => string;
20
25
  routeOrderDetails?: () => string;
@@ -38,6 +43,10 @@ export interface OrdersListCardProps extends HTMLAttributes<HTMLDivElement> {
38
43
  withThumbnails: boolean;
39
44
  slots?: {
40
45
  OrdersListCard?: SlotProps<OrdersListCardContext>;
46
+ OrderItemImage?: SlotProps<{
47
+ data: OrderItem;
48
+ defaultImageProps: ImageProps;
49
+ }>;
41
50
  };
42
51
  routeTracking?: (shipping: ShipmentsTracingModel) => string;
43
52
  routeOrderProduct?: (product: OrderItem) => string;