1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[71900],{1369(e,t,r){r.d(t,{A:()=>a});var s=r(1452);class o{constructor(){this._storage={}}setItem(e,t){return this._storage[e]=t}getItem(e){return Object.prototype.hasOwnProperty.call(this._storage,e)?this._storage[e]:null}removeItem(e){return delete this._storage[e]}key(e){return Object.values(this._storage)[e]||null}clear(){return this._storage={}}}class i{constructor(){this._storage=null,this._chooseStorage(),this._validateStorage()}_chooseStorage(){return i._isSupported("localStorage")?this._storage=window.localStorage:i._isSupported("sessionStorage")?this._storage=window.sessionStorage:s.A.isSupported()?this._storage=s.A:this._storage=new o}static _isSupported(e){try{let t="__storage_test";return window[e].setItem(t,"1"),window[e].removeItem(t),!0}catch(e){return!1}}_validateStorage(){if("function"!=typeof this._storage.setItem)throw Error('The storage must have a "setItem" function');if("function"!=typeof this._storage.getItem)throw Error('The storage must have a "getItem" function');if("function"!=typeof this._storage.removeItem)throw Error('The storage must have a "removeItem" function');if("function"!=typeof this._storage.key)throw Error('The storage must have a "key" function');if("function"!=typeof this._storage.clear)throw Error('The storage must have a "clear" function')}getStorage(){return this._storage}}let a=Object.freeze(new i).getStorage()},1900(e,t,r){r.r(t),r.d(t,{default:()=>a});var s=r(4335),o=r(1369);let i="customerComment";class a extends s.A{static #e=this.options={customerId:null,storageKey:"checkoutCustomerStorage"};init(){this.options.customerId&&(this._form="FORM"===this.el.tagName?this.el:this.el.form??document.getElementById(this.el.getAttribute("form")),this._form&&(this._fieldDefinitions=this._getFieldDefinitions(),this._fields=this._resolveFields(),this._clearCurrentCustomerData=this._clearCurrentCustomerData.bind(this),this._restoreCurrentCustomerData(),this._registerEvents()))}_registerEvents(){this._fields.forEach(e=>{e.events.forEach(t=>{e.element.addEventListener(t,()=>this._updateField(e))})}),this._form.addEventListener("submit",this._clearCurrentCustomerData),this._form.addEventListener("reset",this._clearCurrentCustomerData)}_restoreCurrentCustomerData(){let e=this._getCurrentCustomerData();this._fields.forEach(t=>
1{t.writeValue(t.element,e[t.key]??null)})}_getFieldDefinitions(){return[{key:i,resolveElement:()=>this._getFormElementByName(i),events:["input","change"],normalizeValue:e=>"string"==typeof e?e:null,readValue:e=>""===e.value?null:e.value,writeValue:(e,t)=>{"string"==typeof t&&(e.value=t)}},{key:"tos",resolveElement:()=>this._getFormElementByName("tos"),events:["change"],normalizeValue:e=>!0===e||null,readValue:e=>!!e.checked||null,writeValue:(e,t)=>{e.checked=!0===t}}]}_resolveFields(){return this._fieldDefinitions.reduce((e,t)=>{let r=t.resolveElement();return r&&e.push({...t,element:r}),e},[])}_updateField(e){this._updateCurrentCustomerData(t=>{let r=e.readValue(e.element);if(null===r){delete t[e.key];return}t[e.key]=r})}_clearCurrentCustomerData(){let e=this._getStoredCustomers();this.options.customerId in e&&(delete e[this.options.customerId],this._setStoredCustomers(e))}_updateCurrentCustomerData(e){let t=this._getStoredCustomers(),r=this._getCurrentCustomerData(t);e(r),0===Object.keys(r).length?delete t[this.options.customerId]:t[this.options.customerId]=r,this._setStoredCustomers(t)}_getCurrentCustomerData(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._getStoredCustomers();return this._normalizeCustomerData(e[this.options.customerId])??{}}_getStoredCustomers(){return this._getParsedStorage(this.options.storageKey).customers}_getParsedStorage(e){let t=o.A.getItem(e);if("string"!=typeof t||""===t)return{customers:{},valid:!1};try{let e=JSON.parse(t);if(e&&"object"==typeof e&&!Array.isArray(e))return{customers:this._normalizeStoredCustomers(e),valid:!0}}catch(e){}return{customers:{},valid:!1}}_normalizeStoredCustomers(e){return Object.entries(e).reduce((e,t)=>{let[r,s]=t,o=this._normalizeCustomerData(s);return o&&Object.keys(o).length>0&&(e[r]=o),e},{})}_normalizeCustomerData(e){return!e||"object"!=typeof e||Array.isArray(e)?null:this._fieldDefinitions.reduce((t,r)=>{let s=r.normalizeValue(e[r.key]);return null!==s&&(t[r.key]=s),t},{})}_getFormElementByName(e){return Array.from(document.getElementsByName(e)).find(e=>e.form===this._form)??null}_setStoredCustomers(e){if(0===Object.keys(e).length){o.A.removeItem(this.options.storageKey);return}o.A.setItem(this.options.storageKey,JSON.stringify(e))}}}}]);
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.