1import{v as i,T as $,N as f,ck as m,y,C as g}from"./storefrontApp.5Jl33SLO.min.js";import{b as v,$ as l,w as _,f as n,d as I,e as d,t as b}from"./chunk-vendor-lit.NvY0u02.js";import{S as C}from"./chunk-storefront_base_lit_element.BngXaMu.js";import{t as p}from"./chunk-translations_directive.GYGOaCp.js";import{S}from"./chunk-storefront_settings_constants.DIF02Gz.js";import"./chunk-vendor-di.Bh23gdA.js";import"./chunk-vendor-rxjs.Dp7kflo.js";import"./chunk-vendor-lodash.CWHFt7Z.js";import"./chunk-vendor-phoenix.cdKS79L.js";var F=Object.defineProperty,c=(h,e,t,r)=>{for(var o=void 0,s=h.length-1,u;s>=0;s--)(u=h[s])&&(o=u(e,t,o)||o);return o&&F(e,t,o),o};class a extends C{constructor(){super(),this._zipInputRef=v(),this._formId=`form-${i()}`,this._fieldIds={name:`name-${i()}`,surname:`surname-${i()}`,phone:`phone-${i()}`,coname:`coname-${i()}`,nip:`nip-${i()}`,other_address:`other_address-${i()}`,zip:`zip-${i()}`,city:`city-${i()}`,state:`state-${i()}`,country:`country-${i()}`},this.addressId=0,this.formFields={},this.showDefault1="0",this.showDefault2="0",this.default1="0",this.default2="0",this._selectedCountry="",this._allCountries=[],this._storefrontSettings=this.getApiSync(S.api),this._translationApi=this.getApiSync($.api)}static{this.moduleName="address-form"}connectedCallback(){super.connectedCallback();const e=this._storefrontSettings.getSkinSettings().locale.replace("_","-"),t=e.slice(-2).toUpperCase();this._selectedCountry=this.formFields.country?.value||t,this._storefrontSettings.selectCountries$().subscribe(r=>{this._allCountries=r.map(o=>({value:o.isocode,content:this._translationApi.translate(o.name),selected:o.isocode===this._selectedCountry})).sort((o,s)=>o.content.localeCompare(s.content,e))})}_toggleZipFieldMaskBasedOnSelectedCountry(){const e=this._zipInputRef.value;this._selectedCountry==="PL"?e?.enableMask():e?.disableMask()}_onCountryChange(e){const r=e.target.selectedOptions[0]?.value;r&&(this._selectedCountry=r,this._toggleZipFieldMaskBasedOnSelectedCountry())}_getField(e){return this.formFields[e]||null}_getFieldErrors(e){return e.error?Array.isArray(e.error)?e.error:typeof e.error=="object"?Object.values(e.error).filter(t=>typeof t=="string"):[]:[]}_renderInputField(e){const t=this._getField(e);if(!t)return l``;const r=this._getFieldErrors(t),o=e==="phone"?"tel":"text",s=this._fieldIds[e]||"";return l` 2 <control-connector 3 validationMode="change" 4 ?required="${t.obligatory}" 5 class="control" 6 > 7 <h-control> 8 <h-control-label class="control__label"> 9 <label 10 class="label ${t.obligatory?"label_required":""}" 11 for="${s}" 12 > 13 ${n(t.obligatory,()=>l`<span 14 class="label__asterisk" 15 aria-hidden="true" 16 >*</span 17 >`)} 18 ${t.label} 19 </label> 20 </h-control-label> 21 22 <h-control-content class="control"> 23 <h-control-element class="control__element"> 24 <h-input 25 controlId="${s}" 26 controlName="${t.name}" 27 ?required="${t.obligatory}" 28 type="${o}" 29 > 30 <h-input-control 31 value="${t.value||""}" 32 ?required="${t.obligatory}" 33 aria-describedby="${t.hint?`${s}-hint`:_}" 34 ></h-input-control> 35 </h-input> 36 </h-control-element> 37 38 ${n(r.length>0,()=>l` 39 <ul 40 class="form-errors"
41 aria-live="polite" 42 > 43 ${r.map(u=>l`<li class="form-errors__error">${u}</li>`)} 44 </ul> 45 `)} 46 <control-errors></control-errors> 47 ${n(t.hint,()=>l` 48 <p 49 id="${s}-hint" 50 class="p_xs color_tertiary" 51 > 52 ${t.hint} 53 </p> 54 `)} 55 </h-control-content> 56 </h-control> 57 </control-connector> 58 `}_renderZipField(){const e=this._getField("zip");if(!e)return l``;const t=this._getFieldErrors(e),r=this._fieldIds.zip||"";return l` 59 <control-connector 60 validationMode="change" 61 ?required="${e.obligatory}" 62 class="control" 63 > 64 <h-control> 65 <h-control-label class="control__label"> 66 <label 67 class="label ${e.obligatory?"label_required":""}" 68 for="${r}" 69 > 70 ${n(e.obligatory,()=>l`<span 71 class="label__asterisk" 72 aria-hidden="true" 73 >*</span 74 >`)} 75 ${e.label} 76 </label> 77 </h-control-label> 78 79 <h-control-content class="control"> 80 <h-control-element class="control__element"> 81 <h-input 82 controlId="${r}" 83 controlName="${e.name}" 84 ?required="${e.obligatory}" 85 type="text" 86 > 87 <h-input-control 88 @connected="${()=>this._toggleZipFieldMaskBasedOnSelectedCountry()}" 89 value="${e.value||""}" 90 mask-disabled="${this._selectedCountry!=="PL"?!0:_}" 91 mask="__-___" 92 pattern="^(\\d{2})(-)(\\d{3})$" 93 valid-pattern="00-000" 94 ?required="${e.obligatory}" 95 ${I(this._zipInputRef)} 96 aria-describedby="${e.hint?`${r}-hint`:_}" 97 ></h-input-control> 98 </h-input> 99 </h-control-element> 100 101 ${n(t.length>0,()=>l` 102 <ul 103 class="form-errors" 104 aria-live="polite" 105 > 106 ${t.map(o=>l`<li class="form-errors__error">${o}</li>`)} 107 </ul> 108 `)} 109 <control-errors></control-errors> 110 ${n(e.hint&&this._selectedCountry==="PL",()=>l` 111 <p 112 id="${r}-hint" 113 class="p_xs color_tertiary" 114 > 115 ${e.hint} 116 </p> 117 `)} 118 </h-control-content> 119 </h-control> 120 </control-connector> 121 `}_renderCountrySelect(){const e=this._getField("country");if(!e)return l``;const t=this._getFieldErrors(e),r=this._fieldIds.country||"";return l` 122 <control-connector 123 class="control" 124 ?required="${e.obligatory}" 125 > 126 <h-control> 127 <h-control-label class="control__label"> 128 <label 129 class="select__title label ${e.obligatory?"label_required":""}" 130 for="${r}" 131 id="${r}-label" 132 > 133 ${n(e.obligatory,()=>l`<span 134 class="label__asterisk" 135 aria-hidden="true" 136 >*</span 137 >`)} 138 ${e.label} 139 </label> 140 </h-control-label> 141 142 <h-control-content class="control"> 143 <h-control-element class="control__element"> 144 <h-select 145 class="select" 146 control-name="${e.name}" 147 control-id="${r}" 148 assistive-title-id="${r}-label" 149 no-deselect 150 .optionsList="${this._allCountries}" 151 ?required="${e.obligatory}" 152 @change="${this._onCountryChange}" 153 > 154 <h-select-toggler 155 class="select-toggler" 156 aria-labelledby="${r}-label" 157 aria-describedby="${e.hint?`${r}-hint`:_}" 158 ></h-select-toggler> 159 </h-select> 160 </h-control-element> 161 ${n(t.length>0,()=>l` 162 <ul 163 class="form-errors"
164 aria-live="polite" 165 > 166 ${t.map(o=>l`<li class="form-errors__error">${o}</li>`)} 167 </ul> 168 `)} 169 <control-errors></control-errors> 170 ${n(e.hint,()=>l` 171 <p 172 id="${r}-hint" 173 class="p_xs color_tertiary" 174 > 175 ${e.hint} 176 </p> 177 `)} 178 </h-control-content> 179 </h-control> 180 </control-connector> 181 `}_renderCheckbox(e,t,r,o="1"){const s=`${e}_${this._formId}`;return l` 182 <control-connector class="control"> 183 <h-control> 184 <h-control-content class="control"> 185 <h-control-element class="control__element"> 186 <div class="checkbox"> 187 <div class="checkbox__control"> 188 <input 189 type="checkbox" 190 id="${s}" 191 name="${e}" 192 value="${o}" 193 autocomplete="off" 194 class="checkbox__input" 195 ?checked="${r}" 196 aria-invalid="false" 197 /> 198 <label 199 class="checkbox__label" 200 for="${s}" 201 ></label> 202 </div> 203 <div class="checkbox__content"> 204 <label 205 class="label" 206 for="${s}" 207 > 208 ${t} 209 </label> 210 </div> 211 </div> 212 </h-control-element> 213 <control-errors></control-errors> 214 </h-control-content> 215 </h-control> 216 </control-connector> 217 `}render(){return l` 218 <reactive-form> 219 <form 220 class="control" 221 id="${this._formId}" 222 method="post" 223 data-turbo="false" 224 > 225 <div 226 class="form__additional-info mt-xs-0" 227 aria-hidden="true" 228 > 229 <i> 230 ${p("Required fields are marked with")} - 231 <span class="form__additional-info_secondary">*</span> 232 </i> 233 </div> 234 235 ${this._renderInputField("name")} ${this._renderInputField("surname")} ${this._renderInputField("phone")} 236 ${this._renderInputField("coname")} ${this._renderInputField("nip")} ${this._renderCountrySelect()} 237 ${this._renderInputField("other_address")} ${this._renderZipField()} ${this._renderInputField("city")} 238 ${this._renderInputField("state")} 239 ${n(this.showDefault1==="1",()=>this._renderCheckbox("default1",this._translationApi.translate("Set as default address"),this.default1==="1","1"))} 240 ${n(this.showDefault2==="1",()=>this._renderCheckbox("default2",this._translationApi.translate("Set as default delivery address"),this.default2==="1","1"))} 241 242 <input 243 type="hidden" 244 name="addressform" 245 value="1" 246 /> 247 248 <div class="grid__row"> 249 <div class="grid__col grid__col_xs-grow"> 250 <button 251 type="submit" 252 name="button1" 253 value="button1" 254 class="btn btn_secondary btn_full-width" 255 > 256 <h-icon 257 icon-name="icon-arrow-left" 258 css-classes="btn__icon btn__icon_left" 259 ></h-icon> 260 ${p("Back")} 261 </button> 262 </div> 263 264 <div class="grid__col grid__col_xs-grow"> 265 <button 266 type="submit" 267 name="button2" 268 value="button2" 269 class="btn btn_primary btn_full-width" 270 > 271 ${n(this.addressId>0,()=>p("Save"),()=>p("Add"))} 272 </button> 273 </div> 274 </div> 275 </form> 276 </reactive-form> 277 `}}c([d({type:Number,attribute:"address-id"})],a.prototype,"addressId");c([d({type:Object,attribute:"form-fields"})],a.prototype,"formFields");c([d({type:String,attribute:"show-default1"})],a.prototype,"showDefault1");c([d({type:String,attribute:"show-default2"})],a.prototype,"showDefault2");c([d({type:String})],a.prototype,"default1");c([d({type:String})],a.prototype,"default2");c([b()],a.prototype,"_selectedCountry");c([b()],a.prototype,"_allCountries");class R extends f{static{this.featureName=m.feature}static{this.dependencies=[y.feature]}
277async init(){return{cores:[{type:g,instance:[a]}]}}}export{R as AddressFormInitializer};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.