{"version":3,"file":"n-ups-c0a24b39.js","sources":["../../../client/src/javascripts/customer_pages/_shelf-category/url-query-parser.js","../../../client/src/javascripts/customer_pages/_shelf-category/n-ups.jsx"],"sourcesContent":["// -----------------------------------------------------------\n// UrlQueryParser\n// -----------------------------------------------------------\n// Why yes, this was written in CoffeeScript!\nconst UrlQueryParser = (function () {\n let decodeValue;\n\n function UrlQueryParser(url) {\n let i, len, ref, ref1, pair;\n\n if (url == null && typeof location !== 'undefined') {\n url = decodeURI(location.href);\n }\n this.hashParts = {};\n ref1 = ((ref = url.split('?')[1]) != null ? ref.split('&') : void 0) || [];\n for (i = 0, len = ref1.length; i < len; i++) {\n if (pair = ref1[i]) {\n pair = pair.split('=');\n this.hashParts[decodeURIComponent(pair[0])] = pair[1] || '';\n }\n }\n }\n\n UrlQueryParser.prototype.filters = function () {\n const result = {};\n const ref = this.hashParts;\n\n for (let key in ref) {\n if (!(key.indexOf('_') !== 0 && key !== 'delivery-options' && key !== 'search')) {\n continue;\n }\n result[key] = decodeValue(ref[key]);\n }\n\n return result;\n };\n\n UrlQueryParser.prototype.search = function () {\n const ref = this.hashParts;\n\n for (let key in ref) {\n if (key === 'search') {\n return decodeValue(ref[key])[0];\n }\n }\n };\n\n UrlQueryParser.prototype.delivery = function () {\n const ref = this.hashParts;\n\n for (let key in ref) {\n if (key === 'delivery-options') {\n return decodeValue(ref[key], true);\n }\n }\n };\n\n UrlQueryParser.prototype.startState = function () {\n const result = {};\n const ref = this.hashParts;\n\n for (let key in ref) {\n if (!(key.indexOf('_') === 0)) {\n continue;\n }\n key = key.substring(1);\n result[key] = decodeValue(ref[key], key === 'page')[0];\n }\n\n return result;\n };\n\n decodeValue = function (value, shouldParseInt) {\n const ref = value.split('|');\n const results = [];\n\n for (let i = 0, len = ref.length; i < len; i++) {\n const s = ref[i];\n const value = decodeURIComponent(s);\n results.push(shouldParseInt ? parseInt(value, 10) : value);\n }\n\n return results;\n };\n\n return UrlQueryParser;\n}());\n\nexport default UrlQueryParser;\n","'use strict';\n\n// Import Libraries\nimport React, { useEffect, useState } from 'react';\nimport classNames from 'classnames';\nimport UrlQueryParser from './url-query-parser';\n\n// -----------------------------------------------------------\n// NUps\n// -----------------------------------------------------------\n\nconst NUps = ({collection, onUrlFiltersChange}) => {\n const [loaded, setloaded] = useState(false);\n useEffect(() => {\n loadImages();\n }, []);\n\n const handleClick = (e, url) => {\n const a = document.createElement('a');\n a.href = url;\n if (a.pathname === location.pathname && a.search) {\n // link is to the current page\n e.preventDefault();\n\n const urlQueryParser = new UrlQueryParser(a.href);\n onUrlFiltersChange(urlQueryParser.filters());\n }\n };\n\n const attachSlick = () => {\n $('.n-ups > div').slick({\n // generic settings\n arrows: false,\n infinite: true,\n speed: 300,\n dots: collection.length > 10,\n\n\n // xl - wide desktops\n slidesToShow: 10,\n slidesToScroll: 10,\n\n responsive: [{\n // lg - desktops\n breakpoint: 1200,\n settings: {\n slidesToShow: 8,\n slidesToScroll: 8,\n dots: collection.length > 8,\n }\n }, {\n // md - tablets\n breakpoint: 992,\n settings: {\n slidesToShow: 3,\n slidesToScroll: 3,\n dots: collection.length > 3,\n }\n }, {\n // sm - new phones\n breakpoint: 768,\n settings: {\n slidesToShow: 3,\n slidesToScroll: 3,\n dots: collection.length > 3,\n }\n }, {\n // xs - old phones\n breakpoint: 576,\n settings: {\n slidesToShow: 3,\n slidesToScroll: 3,\n dots: collection.length > 3,\n }\n }]\n });\n };\n\n const loadImages = async () => {\n const promises = [];\n promises.push((collection || []).forEach((item, i) => {\n return new Promise((resolve, reject) => {\n const image = new Image();\n image.crossOrigin = 'use-credentials';\n image.onload = () => { \n resolve\n };\n image.onerror = reject;\n image.src = item.image;\n });\n }));\n await Promise.all(promises);\n setloaded(true);\n attachSlick();\n };\n\n if (!loaded) return null;\n\n return (\n
\n
\n {\n (collection || []).map((item, i) => (\n handleClick(e, item.url)}\n >\n \n
{item.title}
\n \n ))\n }\n
\n
\n );\n};\n\nexport default NUps;\n"],"names":["UrlQueryParser","decodeValue","url","i","len","ref","ref1","pair","result","key","value","shouldParseInt","results","s","NUps","collection","onUrlFiltersChange","loaded","setloaded","useState","useEffect","loadImages","handleClick","e","a","urlQueryParser","attachSlick","promises","item","resolve","reject","image","classNames","React"],"mappings":"uFAIA,MAAMA,EAAkB,UAAY,CAClC,IAAIC,EAEJ,SAASD,EAAeE,EAAK,CAC3B,IAAIC,EAAGC,EAAKC,EAAKC,EAAMC,EAOvB,IALIL,GAAO,MAAQ,OAAO,SAAa,MACrCA,EAAM,UAAU,SAAS,IAAI,GAE/B,KAAK,UAAY,GACjBI,IAASD,EAAMH,EAAI,MAAM,GAAG,EAAE,CAAC,IAAM,KAAOG,EAAI,MAAM,GAAG,EAAI,SAAW,GACnEF,EAAI,EAAGC,EAAME,EAAK,OAAQH,EAAIC,EAAKD,KAClCI,EAAOD,EAAKH,CAAC,KACfI,EAAOA,EAAK,MAAM,GAAG,EACrB,KAAK,UAAU,mBAAmBA,EAAK,CAAC,CAAC,CAAC,EAAIA,EAAK,CAAC,GAAK,GAG9D,CAED,OAAAP,EAAe,UAAU,QAAU,UAAY,CAC7C,MAAMQ,EAAS,CAAA,EACTH,EAAM,KAAK,UAEjB,QAASI,KAAOJ,EACRI,EAAI,QAAQ,GAAG,IAAM,GAAKA,IAAQ,oBAAsBA,IAAQ,WAGtED,EAAOC,CAAG,EAAIR,EAAYI,EAAII,CAAG,CAAC,GAGpC,OAAOD,CACX,EAEER,EAAe,UAAU,OAAS,UAAY,CAC5C,MAAMK,EAAM,KAAK,UAEjB,QAASI,KAAOJ,EACd,GAAII,IAAQ,SACV,OAAOR,EAAYI,EAAII,CAAG,CAAC,EAAE,CAAC,CAGtC,EAEET,EAAe,UAAU,SAAW,UAAY,CAC9C,MAAMK,EAAM,KAAK,UAEjB,QAASI,KAAOJ,EACd,GAAII,IAAQ,mBACV,OAAOR,EAAYI,EAAII,CAAG,EAAG,EAAI,CAGzC,EAEET,EAAe,UAAU,WAAa,UAAY,CAChD,MAAMQ,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