{"version":3,"file":"index.es.min.js","sources":["../../../packages/helpers/src/dataLayer.js","../../../packages/helpers/src/cremaDataHelper.js","../../../packages/helpers/src/props.helpers.js","../../../packages/components/src/card-logos/cardLogos.js"],"sourcesContent":["export const getDataLayer = () => {\n    return window[window?.padlNamespace]?.dataLayer\n}\n\nexport const getMarketCode = () => {\n    const dataLayer = getDataLayer()\n    if (!dataLayer) {\n        return 'ch'\n    }\n\n    return dataLayer.app.app.market.toLocaleLowerCase()\n}\n\nexport const getLangCode = () => {\n    const dataLayer = getDataLayer()\n    if (!dataLayer) {\n        return 'en'\n    }\n\n    return getDataLayer().page.page.pageInfo.language.toLocaleLowerCase()\n}\n\nexport const getSegmentCode = () => {\n    const dataLayer = getDataLayer()\n    if (!dataLayer) {\n        return 'B2C'\n    }\n\n    return getDataLayer().page.page.pageInfo.segmentBusiness\n}\n\nexport const isLoggedIn = () => {\n    const dataLayer = getDataLayer()\n    if (!dataLayer || !dataLayer.user) {\n        return false\n    }\n\n    return dataLayer.user.isLoggedIn\n}\n\nexport const interpolateMarketLang = (string, market, lang) => {\n    return string.replace('{market}', market).replace('{lang}', lang)\n}\n","import { getMarketCode } from './dataLayer'\n\nconst LABEL_CATEGORY_NAME = 'cat/capsule-range-label'\nconst LABEL_CATEGORY_NAME_MACHINE = 'cat/machine-range-label'\nexport const RANGE_CATEGORY_NAME = 'cat/capsule-range'\nconst FAIR_TRADE_CATEGORY_NAME = 'cat/capsule-range-fair-trade'\nconst VERTUO_NEXT_CATEGORY_NAME = 'cat/capsule-attribute-only-vertuo-next'\nconst ORGANIC_EU_CATEGORY_NAME = 'capsule-attribute-organic-eu'\nconst RAINFOREST_CATEGORY_NAME = 'capsule-attribute-rainforest'\nconst SUSTAINABILITY_CATEGORY_NAME = 'capsule-attribute-sustainability'\nconst ARABICA_CATEGORY_NAME = 'capsule-attribute-arabica'\nconst PRODUCT_HIGHLIGHT_CATEGORY_NAME = 'cat/capsule-attribute-highlight'\nconst TECHNOLOGY_CATEGORY_IDENTIFIER = '/machineTechno/'\n\nconst COMMON_URL = 'https://www.nespresso.com/shared_res/agility/commons/img/icons/'\n\nexport const FAIR_TRADE_IMG = COMMON_URL + 'fairTrade.svg'\nexport const ORGANIC_LOGO_IMG_EU = COMMON_URL + 'logo-organic-eu.svg'\nexport const ORGANIC_LOGO_IMG_US = COMMON_URL + 'logo-organic-us.svg'\nexport const ORGANIC_LOGO_IMG_CA = COMMON_URL + 'logo-organic-ca.svg'\nexport const ORGANIC_LOGO_IMG_BR = COMMON_URL + 'logo-organic-br.svg'\nexport const ORGANIC_LOGO_IMG_JP = COMMON_URL + 'logo-organic-jp.svg'\nexport const ORGANIC_LOGO_IMG_BE = COMMON_URL + 'logo-organic-be.png'\n\nexport const VERTUONEXT_LOGO_IMG = COMMON_URL + 'logo-only-vertuo-next.svg'\nexport const RAINFOREST_LOGO_IMG = COMMON_URL + 'logo-rainforest.svg'\nexport const SUSTAINABILITY_LOGO_IMG = COMMON_URL + 'logo-sustainability.svg'\nexport const Q_CERTIFICATION_ARABICA_LOGO_IMG = COMMON_URL + 'q_grade_certification_arabica.svg'\nexport const DESIGN_AWARD_2021_IMG = COMMON_URL + 'design_award_2021.svg'\n\nexport const LOGO_IMG_MAP = {\n    fair_trade: FAIR_TRADE_IMG,\n    is_organic: getOrganicLogo(),\n    only_vertuo_next: VERTUONEXT_LOGO_IMG,\n    is_q_certified_arabica: Q_CERTIFICATION_ARABICA_LOGO_IMG,\n    is_rainforest: RAINFOREST_LOGO_IMG,\n    is_sustainable: SUSTAINABILITY_LOGO_IMG,\n    is_design_award_2021: DESIGN_AWARD_2021_IMG\n}\n\nexport function getOrganicLogo() {\n    let organicLogoImg = ORGANIC_LOGO_IMG_EU\n\n    switch (getMarketCode()) {\n        case 'us':\n            organicLogoImg = ORGANIC_LOGO_IMG_US\n            break\n        case 'ca':\n            organicLogoImg = ORGANIC_LOGO_IMG_CA\n            break\n        case 'br':\n            organicLogoImg = ORGANIC_LOGO_IMG_BR\n            break\n        case 'jp':\n            organicLogoImg = ORGANIC_LOGO_IMG_JP\n            break\n        case 'be':\n            organicLogoImg = ORGANIC_LOGO_IMG_BE\n            break\n    }\n\n    return organicLogoImg\n}\n\n/**\n * retrieves the list of categories of type Vertuo Next\n * @param {category[]} categories\n */\nexport function getVertuoNext(categories) {\n    return categories.find(category => isVertuoNext(category))\n}\n\n/**\n * returns true when the category is product vertuo next\n * @param {category} category\n */\nfunction isVertuoNext(category) {\n    return getCategoryRegEx(VERTUO_NEXT_CATEGORY_NAME).test(category.id)\n}\n\n/**\n * retrieves the list of categories of type organic EU\n * @param {category[]} categories\n */\nexport function getOrganicEu(categories) {\n    return categories.find(category => isOrganicEu(category))\n}\n\n/**\n * returns true when the category is product organic EU\n * @param {category} category\n */\nfunction isOrganicEu(category) {\n    return getCategoryRegEx(ORGANIC_EU_CATEGORY_NAME).test(category.id)\n}\n\n/**\n * retrieves the list of categories of type rainforest\n * @param {category[]} categories\n */\nexport function getRainforest(categories) {\n    return categories.find(category => isRainforest(category))\n}\n\n/**\n * returns true when the category is rainforest\n * @param {category} category\n */\nfunction isRainforest(category) {\n    return getCategoryRegEx(RAINFOREST_CATEGORY_NAME).test(category.id)\n}\n\n/**\n * retrieves the list of categories of type sustainability\n * @param {category[]} categories\n */\nexport function getSustainability(categories) {\n    return categories.find(category => isSustainability(category))\n}\n\n/**\n * retrieves the list of categories of type arabica\n * @param {category[]} categories\n */\nexport function getArabica(categories) {\n    return categories.find(category => isArabica(category))\n}\n\n/**\n * returns true when the category is arabica\n * @param {category} category\n */\nfunction isArabica(category) {\n    return getCategoryRegEx(ARABICA_CATEGORY_NAME).test(category.id)\n}\n\n/**\n * returns true when the category is sustainability\n * @param {category} category\n */\nfunction isSustainability(category) {\n    return getCategoryRegEx(SUSTAINABILITY_CATEGORY_NAME).test(category.id)\n}\n\n/**\n * retrieves the list of categories of type label\n * @param {category[]} categories\n */\nexport function getLabels(categories) {\n    return categories.filter(category => isLabel(category))\n}\n\n/**\n * retrieves the list of categories of type label\n * @param {category[]} categories\n */\nexport function getProductHighlight(categories) {\n    return categories.find(category => isProductHighlight(category))\n}\n/**\n * retrieves the list of categories of type label\n * @param {category[]} categories\n */\nexport function getFairTrade(categories) {\n    return categories.find(category => isFairTrade(category))\n}\n\n/**\n * returns a regex to match the tail (global) of a given local category ID\n * @param {string} categoryIdTail : should contain the end of the category ID\n */\nexport function getCategoryRegEx(categoryIdTail) {\n    return new RegExp(categoryIdTail.replace(/\\//g, '\\\\/'))\n}\n\n/**\n * returns true when the category is child of the label category (is type label)\n * @param {category} category\n */\nfunction isLabel(category) {\n    return (\n        getCategoryRegEx(LABEL_CATEGORY_NAME).test(category.id) ||\n        getCategoryRegEx(LABEL_CATEGORY_NAME_MACHINE).test(category.id)\n    )\n}\n\n/**\n * returns true when the category is product highlight\n * @param {category} category\n */\nfunction isProductHighlight(category) {\n    return getCategoryRegEx(PRODUCT_HIGHLIGHT_CATEGORY_NAME).test(category.id)\n}\n/**\n * returns true when the category is fair trade\n * @param {category} category\n */\nfunction isFairTrade(category) {\n    return getCategoryRegEx(FAIR_TRADE_CATEGORY_NAME).test(category.id)\n}\n\n/**\n * returns true when the category is child of the range category (is type range)\n * @param {category} category\n */\nexport function isRange(category) {\n    return category.superCategories.some(superCategory =>\n        getCategoryRegEx(RANGE_CATEGORY_NAME).test(superCategory)\n    )\n}\n\nexport function getTechnologyName(productData, categories) {\n    if (!productData || !productData.technologies || !productData.technologies.length) {\n        return null\n    }\n\n    const techno = productData.technologies[0]\n    const categoryNameAsSubstring = techno.substring(\n        techno.indexOf(TECHNOLOGY_CATEGORY_IDENTIFIER) + TECHNOLOGY_CATEGORY_IDENTIFIER.length\n    )\n    const category = categories?.find(cat => cat.id === techno)\n\n    // Backward compatibility, return name as substring if the list of categories are not available\n    return category?.name || categoryNameAsSubstring\n}\n\nexport function isCategoryHidden(categoryId) {\n    let hideCategory = false\n    // To enable AB testing: exclude categories which are to be hidden\n    if (\n        window.PLP_HIDE_CATEGORIES?.length &&\n        window.PLP_HIDE_CATEGORIES.findIndex(c => categoryId.indexOf(c) >= 0) >= 0\n    ) {\n        hideCategory = true\n    }\n\n    // To enable AB testing: exclude categories except those which are to be shown\n    if (window.PLP_ONLY_SHOW_CATEGORIES?.length) {\n        // Default to hide\n        hideCategory = true\n        if (window.PLP_ONLY_SHOW_CATEGORIES.findIndex(c => categoryId.indexOf(c) >= 0) >= 0) {\n            hideCategory = false\n        }\n    }\n    return hideCategory\n}\n","const getData = attributes => attributes.find(attribute => attribute.nodeName === 'data')\n\nconst createProps = attributes => {\n    const data = getData([...attributes])\n    const props = [...attributes]\n        .filter(attribute => attribute.nodeName !== 'data')\n        .reduce((all, attr) => {\n            return { ...all, [attr.nodeName]: attr.nodeValue }\n        }, {})\n\n    if (isNil(data)) {\n        return props\n    }\n\n    try {\n        return { ...props, ...JSON.parse(data.nodeValue) }\n    } catch (error) {\n        console.log('ERROR: No data', error, data?.nodeValue)\n    }\n}\n\nconst isNil = obj => obj === undefined || obj === null\n\nexport const parseBool = value => (!value || value === 'false' ? false : true)\n\nexport default createProps\n","import { LOGO_IMG_MAP } from '@kissui/helpers/src/cremaDataHelper'\nimport createProps from '@kissui/helpers/src/props.helpers'\n\nclass CardLogos extends HTMLElement {\n    constructor() {\n        super()\n        this.props = {}\n    }\n\n    connectedCallback() {\n        this.props = createProps(this.attributes)\n        this.render()\n    }\n\n    render() {\n        // individual props for each logo is there for retro compatibility\n        // logos is the prop that we should use going forward to add any logo\n        let { direction = 'row', logos } = this.props\n        let fair_trade\n        let alt_fair_trade\n        let is_organic\n        let alt_organic\n        let only_vertuo_next\n        let alt_vertuo_next\n        let is_rainforest\n        let alt_rainforest\n        let is_sustainable\n        let alt_sustainable\n        let is_q_certified_arabica\n        let alt_q_certification_arabica\n\n        this.classList.add(\n            `${direction === 'column' ? 'direction-column' : 'direction-' + direction}`\n        )\n\n        let logos_list = []\n        if (logos == null) {\n            fair_trade = this.props?.fair_trade\n            alt_fair_trade = this.props?.alt_fair_trade\n            is_organic = this.props?.is_organic\n            alt_organic = this.props?.alt_organic\n            only_vertuo_next = this.props?.only_vertuo_next\n            alt_vertuo_next = this.props?.alt_vertuo_next\n            is_rainforest = this.props?.is_rainforest\n            alt_rainforest = this.props?.alt_rainforest\n            is_sustainable = this.props?.is_sustainable\n            alt_sustainable = this.props?.alt_sustainable\n            is_q_certified_arabica = this.props?.is_q_certified_arabica\n            alt_q_certification_arabica = this.props?.alt_q_certification_arabica\n        } else if (logos.length === undefined) {\n            // Logos exists but is not an array, this is the old format\n            fair_trade = logos?.fair_trade\n            alt_fair_trade = logos?.alt_fair_trade\n            is_organic = logos?.is_organic\n            alt_organic = logos?.alt_organic\n            only_vertuo_next = logos?.only_vertuo_next\n            alt_vertuo_next = logos?.alt_vertuo_next\n            is_rainforest = logos?.is_rainforest\n            alt_rainforest = logos?.alt_rainforest\n            is_sustainable = logos?.is_sustainable\n            alt_sustainable = logos?.alt_sustainable\n            is_q_certified_arabica = logos?.is_q_certified_arabica\n            alt_q_certification_arabica = logos?.alt_q_certification_arabica\n        } else if (logos.length) {\n            logos_list = [...logos]\n        }\n\n        // here we fill logos with logos taken from individual props\n        ;[\n            [fair_trade, 'fair_trade', alt_fair_trade, logos_list],\n            [is_organic, 'is_organic', alt_organic, logos_list],\n            [only_vertuo_next, 'only_vertuo_next', alt_vertuo_next, logos_list],\n            [is_rainforest, 'is_rainforest', alt_rainforest, logos_list],\n            [is_sustainable, 'is_sustainable', alt_sustainable, logos_list],\n            [\n                is_q_certified_arabica,\n                'is_q_certified_arabica',\n                alt_q_certification_arabica,\n                logos_list\n            ]\n        ].forEach(param => this.appendLogo.apply(this, param))\n\n        this.innerHTML = logos_list\n            .map(logo => `<img src=\"${LOGO_IMG_MAP[logo.name]}\" alt=\"${logo.alt}\" loading=\"lazy\">`)\n            .join('')\n    }\n\n    appendLogo(param, name, alt, list) {\n        if (!!param && !this.hasLogo(list, name)) {\n            list.push({ name, alt })\n        }\n    }\n\n    hasLogo(logosList, logoName) {\n        return logosList.some(logo => logo.name === logoName)\n    }\n}\n\ncustomElements.get('nb-card-logos') || customElements.define('nb-card-logos', CardLogos)\n\nexport default CardLogos\n"],"names":["getMarketCode","dataLayer","window","padlNamespace","app","market","toLocaleLowerCase","COMMON_URL","ORGANIC_LOGO_IMG_EU","ORGANIC_LOGO_IMG_US","ORGANIC_LOGO_IMG_CA","ORGANIC_LOGO_IMG_BR","ORGANIC_LOGO_IMG_JP","ORGANIC_LOGO_IMG_BE","VERTUONEXT_LOGO_IMG","RAINFOREST_LOGO_IMG","SUSTAINABILITY_LOGO_IMG","Q_CERTIFICATION_ARABICA_LOGO_IMG","DESIGN_AWARD_2021_IMG","LOGO_IMG_MAP","fair_trade","is_organic","organicLogoImg","getOrganicLogo","only_vertuo_next","is_q_certified_arabica","is_rainforest","is_sustainable","is_design_award_2021","isNil","obj","CardLogos","HTMLElement","constructor","this","props","connectedCallback","attributes","data","find","attribute","nodeName","getData","filter","reduce","all","attr","nodeValue","JSON","parse","error","console","log","createProps","render","alt_fair_trade","alt_organic","alt_vertuo_next","alt_rainforest","alt_sustainable","alt_q_certification_arabica","direction","logos","classList","add","logos_list","undefined","length","forEach","param","appendLogo","apply","innerHTML","map","logo","name","alt","join","list","hasLogo","push","logosList","logoName","some","customElements","get","define"],"mappings":"AAAO,MAIMA,EAAgBA,KACzB,MAAMC,EAJCC,OAAOA,QAAQC,gBAAgBF,UAKtC,OAAKA,EAIEA,EAAUG,IAAIA,IAAIC,OAAOC,oBAHrB,IAAA,ECOTC,EAAa,kEAGNC,EAAsBD,EAAa,sBACnCE,EAAsBF,EAAa,sBACnCG,EAAsBH,EAAa,sBACnCI,EAAsBJ,EAAa,sBACnCK,EAAsBL,EAAa,sBACnCM,EAAsBN,EAAa,sBAEnCO,EAAsBP,EAAa,4BACnCQ,EAAsBR,EAAa,sBACnCS,EAA0BT,EAAa,0BACvCU,EAAmCV,EAAa,oCAChDW,EAAwBX,EAAa,wBAErCY,EAAe,CACxB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