1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["shopping-list-modal.plugin"],{857:t=>{var e=function(t){var e;return!!t&&"object"==typeof t&&"[object RegExp]"!==(e=Object.prototype.toString.call(t))&&"[object Date]"!==e&&t.$$typeof!==r},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(t,e){return!1!==e.clone&&e.isMergeableObject(t)?a(Array.isArray(t)?[]:{},t,e):t}function s(t,e,r){return t.concat(e).map(function(t){return i(t,r)})}function n(t){return Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[])}function o(t,e){try{return e in t}catch(t){return!1}}function a(t,r,l){(l=l||{}).arrayMerge=l.arrayMerge||s,l.isMergeableObject=l.isMergeableObject||e,l.cloneUnlessOtherwiseSpecified=i;var c,d,u=Array.isArray(r);return u!==Array.isArray(t)?i(r,l):u?l.arrayMerge(t,r,l):(d={},(c=l).isMergeableObject(t)&&n(t).forEach(function(e){d[e]=i(t[e],c)}),n(r).forEach(function(e){(!o(t,e)||Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))&&(o(t,e)&&c.isMergeableObject(r[e])?d[e]=(function(t,e){if(!e.customMerge)return a;var r=e.customMerge(t);return"function"==typeof r?r:a})(e,c)(t[e],r[e],c):d[e]=i(r[e],c))}),d)}a.all=function(t,e){if(!Array.isArray(t))throw Error("first argument should be an array");return t.reduce(function(t,r){return a(t,r,e)},{})},t.exports=a},49:(t,e,r)=>{r.d(e,{Z:()=>s});var i=r(140);class s{static isNode(t){return"object"==typeof t&&null!==t&&(t===document||t===window||t instanceof Node)}static hasAttribute(t,e){if(!s.isNode(t))throw Error("The element must be a valid HTML Node!");return"function"==typeof t.hasAttribute&&t.hasAttribute(e)}static getAttribute(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!1===s.hasAttribute(t,e))throw Error('The required property "'.concat(e,'" does not exist!'));if("function"!=typeof t.getAttribute){if(r)throw Error("This node doesn't support the getAttribute function!");return}return t.getAttribute(e)}static getDataAttribute(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2],n=e.replace(/^data(|-)/,""),o=i.Z.toLowerCamelCase(n,"-");if(!s.isNode(t)){if(r)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===t.dataset){if(r)throw Error("This node doesn't support the dataset attribute!");return}let a=t.dataset[o];if(void 0===a){if(r)throw Error('The required data attribute "'.concat(e,'" does not exist on ').concat(t,"!"));return a}return i.Z.parsePrimitive(a)}static querySelector(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!s.isNode(t))throw Error("The parent node is not a valid HTML Node!");let i=t.querySelector(e)||!1;if(r&&!1===i)throw Error('The required element "'.concat(e,'" does not exist in parent node!'));return i}static querySelectorAll(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!s.isNode(t))throw Error("The parent node is not a valid HTML Node!");let i=t.querySelectorAll(e);if(0===i.length&&(i=!1),r&&!1===i)throw Error('At least one item of "'.concat(e,'" must exist in parent node!'));return i}static getFocusableElements(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return t.querySelectorAll('\n input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n select:not([tabindex^="-"]):not([disabled]),\n textarea:not([tabindex^="-"]):not([disabled]),\n button:not([tabindex^="-"]):not([disabled]),\n a[href]:not([tabindex^="-"]):not([disabled]),\n [tabindex]:not([tabindex^="-"]):not([disabled])\n ')}static getFirstFocusableElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(t)[0]}static getLastFocusableElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=this.getFocusableElements(t);return e[e.length-1]}}},937:(t,e,r)=>{r.d(e,{Z:()=>o});var i=r(266),s=r(49);let n=Object.freeze(new class{replaceFromMarkup(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t;"string"==typeof i&&(i=this._createMarkupFromString(i)),"string"==typeof e&&(e=[e]),this._replaceSelectors(i,e,r)}replaceElement(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return("string"==typeof t&&(t=s.Z.querySelectorAll(document,t,r)),"string"==typeof e&&(e=s.Z.querySelectorAll(document,e,r)),t instanceof NodeList&&e instanceof NodeList&&e.length>t.length)?(i.Z.iterate(e,e=>{i.Z.iterate(t,t=>{t.innerHTML&&t.className===e.className&&(e.innerHTML=t.innerHTML)})}),!0):t instanceof NodeList?(i.Z.iterate(t,(t,r)=>{t.innerHTML&&(e[r].innerHTML=t.innerHTML)}),!0):e instanceof NodeList?(i.Z.iterate(e,e=>{t.innerHTML&&(e.innerHTML=t.innerHTML)}),!0):!!e&&!!t&&!!t.innerHTML&&(e.innerHTML=t.innerHTML,!0)}_replaceSelectors(t,e,r){i.Z.iterate(e,e=>{let i=s.Z.querySelectorAll(t,e,r),n=s.Z.querySelectorAll(document,e,r);this.replaceElement(i,n,r)})}_createMarkupFromString(t){return this._domParser.parseFromString(t,"text/html")}constructor(){this._domParser=new DOMParser}});class o{static replaceFromMarkup(t,e,r){n.replaceFromMarkup(t,e,r)}static replaceElement(t,e,r){return n.replaceElement(t,e,r)}}},266:(t,e,r)=>{r.d(e,{Z:()=>i});
1class i{static iterate(t,e){if(t instanceof Map||Array.isArray(t))return t.forEach(e);if(t instanceof FormData){for(var r of t.entries())e(r[1],r[0]);return}if(t instanceof NodeList)return t.forEach(e);if(t instanceof HTMLCollection)return Array.from(t).forEach(e);if(t instanceof Object)return Object.keys(t).forEach(r=>{e(t[r],r)});throw Error("The element type ".concat(typeof t," is not iterable!"))}}},140:(t,e,r)=>{r.d(e,{Z:()=>i});class i{static ucFirst(t){return t.charAt(0).toUpperCase()+t.slice(1)}static lcFirst(t){return t.charAt(0).toLowerCase()+t.slice(1)}static toDashCase(t){return t.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(t,e){let r=i.toUpperCamelCase(t,e);return i.lcFirst(r)}static toUpperCamelCase(t,e){return e?t.split(e).map(t=>i.ucFirst(t.toLowerCase())).join(""):i.ucFirst(t.toLowerCase())}static parsePrimitive(t){try{return/^\d+(.|,)\d+$/.test(t)&&(t=t.replace(",",".")),JSON.parse(t)}catch(e){return t.toString()}}}},293:(t,e,r)=>{r.d(e,{Z:()=>l});var i=r(857),s=r.n(i),n=r(49),o=r(140);class a{publish(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=new CustomEvent(t,{detail:e,cancelable:r});return this.el.dispatchEvent(i),i}subscribe(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this,s=t.split("."),n=r.scope?e.bind(r.scope):e;if(r.once&&!0===r.once){let e=n;n=function(r){i.unsubscribe(t),e(r)}}return this.el.addEventListener(s[0],n),this.listeners.push({splitEventName:s,opts:r,cb:n}),!0}unsubscribe(t){let e=t.split(".");return this.listeners=this.listeners.reduce((t,r)=>([...r.splitEventName].sort().toString()===e.sort().toString()?this.el.removeEventListener(r.splitEventName[0],r.cb):t.push(r),t),[]),!0}reset(){return this.listeners.forEach(t=>{this.el.removeEventListener(t.splitEventName[0],t.cb)}),this.listeners=[],!0}get el(){return this._el}set el(t){this._el=t}get listeners(){return this._listeners}set listeners(t){this._listeners=t}constructor(t=document){this._el=t,t.$emitter=this,this._listeners=[]}}class l{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(t){let e=o.Z.toDashCase(this._pluginName),r=n.Z.getDataAttribute(this.el,"data-".concat(e,"-config"),!1),i=n.Z.getAttribute(this.el,"data-".concat(e,"-options"),!1),a=[this.constructor.options,this.options,t];r&&a.push(window.PluginConfigManager.get(this._pluginName,r));try{i&&a.push(JSON.parse(i))}catch(t){throw console.error(this.el),Error('The data attribute "data-'.concat(e,'-options" could not be parsed to json: ').concat(t.message))}return s().all(a.filter(t=>t instanceof Object&&!(t instanceof Array)).map(t=>t||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(t){return t||(t=this.constructor.name),t}constructor(t,e={},r=!1){if(!n.Z.isNode(t))throw Error("There is no valid element given.");this.el=t,this.$emitter=new a(this.el),this._pluginName=this._getPluginName(r),this.options=this._mergeOptions(e),this._initialized=!1,this._registerInstance(),this._init()}}},107:(t,e,r)=>{r.d(e,{Z:()=>i});class i{get(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",i=this._createPreparedRequest("GET",t,r);return this._sendRequest(i,null,e)}post(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(e,i);let s=this._createPreparedRequest("POST",t,i);return this._sendRequest(s,e,r)}delete(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(e,i);let s=this._createPreparedRequest("DELETE",t,i);return this._sendRequest(s,e,r)}patch(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(e,i);let s=this._createPreparedRequest("PATCH",t,i);return this._sendRequest(s,e,r)}
1abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(t){this._errorHandlingInternal=t}_registerOnLoaded(t,e){e&&(!0===this._errorHandlingInternal?(t.addEventListener("load",()=>{e(t.responseText,t)}),t.addEventListener("abort",()=>{console.warn("the request to ".concat(t.responseURL," was aborted"))}),t.addEventListener("error",()=>{console.warn("the request to ".concat(t.responseURL," failed with status ").concat(t.status))}),t.addEventListener("timeout",()=>{console.warn("the request to ".concat(t.responseURL," timed out"))})):t.addEventListener("loadend",()=>{e(t.responseText,t)}))}_sendRequest(t,e,r){return this._registerOnLoaded(t,r),t.send(e),t}_getContentType(t,e){return t instanceof FormData&&(e=!1),e}_createPreparedRequest(t,e,r){return this._request=new XMLHttpRequest,this._request.open(t,e),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),r&&this._request.setRequestHeader("Content-type",r),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}},327:(t,e,r)=>{r.d(e,{Z:()=>n});var i=r(363);let s="element-loader-backdrop";class n extends i.Z{static create(t){t.classList.add("has-element-loader"),n.exists(t)||(n.appendLoader(t),setTimeout(()=>{let e=t.querySelector(".".concat(s));e&&e.classList.add("element-loader-backdrop-open")},1))}static remove(t){t.classList.remove("has-element-loader");let e=t.querySelector(".".concat(s));e&&e.remove()}static exists(t){return t.querySelectorAll(".".concat(s)).length>0}static getTemplate(){return'\n <div class="'.concat(s,'">\n <div class="loader" role="status">\n <span class="').concat("visually-hidden",'">Loading...</span>\n </div>\n </div>\n ')}static appendLoader(t){t.insertAdjacentHTML("beforeend",n.getTemplate())}}},363:(t,e,r)=>{r.d(e,{Z:()=>o});var i=r(266);let s="loader",n={BEFORE:"before",INNER:"inner"};class o{create(){if(!this.exists()){if(this.position===n.INNER){this.parent.innerHTML=o.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),o.getTemplate())}}remove(){let t=this.parent.querySelectorAll(".".concat(s));i.Z.iterate(t,t=>t.remove())}exists(){return this.parent.querySelectorAll(".".concat(s)).length>0}_getPosition(){return this.position===n.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'<div class="'.concat(s,'" role="status">\n <span class="').concat("visually-hidden",'">Loading...</span>\n </div>')}static SELECTOR_CLASS(){return s}constructor(t,e=n.BEFORE){this.parent=t instanceof Element?t:document.body.querySelector(t),this.position=e}}},625:(t,e,r)=>{r.r(e),r.d(e,{default:()=>a});var i=r(293),s=r(107),n=r(327),o=r(937);class a extends i.Z{init(){this.httpClient=new s.Z,this.form=this.el.querySelector(this.options.selectors.form),this.cancelButton=this.el.querySelector(this.options.selectors.cancelButton),this.closeButton=this.el.querySelector(this.options.selectors.closeButton),this.nameInput=this.el.querySelector(this.options.selectors.nameInput),this.ajaxContainer=this.el.closest(this.options.selectors.ajaxContainerSelector),this._registerEvents()}_registerEvents(){this.el.addEventListener("hidden.bs.modal",this._resetForm.bind(this)),this.el.addEventListener("shown.bs.modal",this._initialForm.bind(this)),this.form&&(this._resetForm(),this.form.addEventListener("submit",this._onFormSubmit.bind(this))),this.cancelButton&&this.cancelButton.addEventListener("click",this._onCancelButtonClick.bind(this)),this.closeButton&&this.closeButton.addEventListener("click",this._onCancelButtonClick.bind(this))}_onFormSubmit(t){var e,r,i,s,o;t.preventDefault(),t.stopPropagation();let a=(e=this.nameInput)===null||void 0===e?void 0:e.value,l=this.form.checkValidity(),c=document.querySelectorAll(this.options.selectors.productItemsSelector),d=this.el.dataset.productId?"div[class*='".concat(this.options.selectors.addProductActionContainer,"-").concat(this.el.dataset.productId,"']"):this.options.selectors.addProductActionContainer;if(this.addProductActionContainer=document.querySelector(d),this.buyBoxEl=this.el.closest(this.options.selectors.buyBoxSelector),this.productId=this.options.productId||this.el.dataset.productId,this.isDeleteMethod="delete"===this.options.method,!this.isDeleteMethod&&(!1===l||!(null==a?void 0:a.trim().length))){this.form.classList.add(this.options.selectors.validatedClass);return}this.addProductActionContainer&&this.addProductActionContainer.classList.add("loading"),bootstrap.Modal.getInstance(this.el)&&bootstrap.Modal.getInstance(this.el).hide(),this.ajaxContainer&&n.Z.create(this.ajaxContainer);let u={};this.productId&&(u[this.productId]={id:this.productId,quantity:1}),c&&c.length>
10&&c.forEach(t=>{var e,r;let i=t.querySelector("input[type='checkbox']");(!i||i.checked)&&(u[t.dataset.id]={id:t.dataset.id,quantity:parseInt((r=(e=t.querySelector(this.options.selectors.quantitySelector))===null||void 0===e?void 0:e.value)!==null&&void 0!==r?r:1)})}),this.buyBoxEl&&this.productId&&(u[this.productId]={id:this.productId,quantity:parseInt((i=(r=this.buyBoxEl.querySelector(this.options.selectors.quantitySelector))===null||void 0===r?void 0:r.value)!==null&&void 0!==i?i:1)});let h={name:a,lineItems:u,forwardTo:(s=this.options.forwardTo)!==null&&void 0!==s&&s};this.isDeleteMethod&&(h={ids:this._isJSONString(this.el.dataset.listId)?this._formatListIds(this.el.dataset.listId):this.el.dataset.listId.split(","),forwardTo:(o=this.options.forwardTo)!==null&&void 0!==o&&o,forwardParameters:{id:this.options.shoppingListId}}),this.httpClient[this.options.method](this.el.dataset.listAction||"".concat(window.router["frontend.account.shopping-list.create"]),JSON.stringify(h),t=>{this._modalCallback(t,a)})}_modalCallback(t,e){if(this.addProductActionContainer&&this.addProductActionContainer.classList.remove("loading"),this.options.productId&&document.$emitter.publish("ShoppingList/addDropdownItem",e),this.isDeleteMethod&&this.options.shoppingListId&&!t){window.location.href=window.router["frontend.account.shopping-lists"];return}if(!this.options.noReload)return window.location.reload();this.ajaxContainer&&n.Z.remove(this.ajaxContainer),t&&(o.Z.replaceFromMarkup(t,this.options.selectors.replaceElementSelector,!1),window.PluginManager.initializePlugins()),this.options.elementReplacement&&(this.el.dataset.listAction||this.httpClient.get(window.router["frontend.account.shopping-lists.dropdown"],this._dropdownCallback.bind(this)),o.Z.replaceFromMarkup(this.options.elementReplacement,this.options.selectors.replaceElementSelector,!1)),this.el.dataset.productId&&this._animationHandler("added",e)}_dropdownCallback(t){t&&(document.querySelector(this.options.selectors.dropdownContainerSelector).innerHTML=t)}_onCancelButtonClick(){this._resetForm()}_resetForm(){var t,e;(t=this.form)===null||void 0===t||t.classList.remove(this.options.selectors.validatedClass),(e=this.form)===null||void 0===e||e.reset(),delete this.el.dataset.listId,delete this.el.dataset.listName,delete this.el.dataset.listAction,delete this.el.dataset.productId}_initialForm(){var t;(t=this.nameInput)===null||void 0===t||t.focus(),this.el.dataset.listName&&(this.nameInput.value=this.el.dataset.listName,this.nameInput.placeholder=this.el.dataset.listName)}_isJSONString(t){try{return JSON.parse(t),!0}catch(t){return!1}}_formatListIds(t){return[...new Map(JSON.parse(t)).keys()]}_animationHandler(t,e){let r=document.querySelector(this.options.selectors.shoppingListAddProductLabel);r&&(r.textContent=e),this.addProductActionContainer&&(this.addProductActionContainer.classList.add(t),setTimeout(()=>{this.addProductActionContainer.classList.remove(t)},1e3))}}}}]);
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.