{"version":3,"file":"index.es.min.js","sources":["../../../packages/helpers/src/props.helpers.js","../../../packages/helpers/src/refs.helpers.js","../../../packages/helpers/src/utils.ts","../../../packages/design-system/src/constants.mjs","../../../packages/helpers/src/viewport.helpers.ts","../../../packages/helpers/src/impolicy.js","../../../packages/design-system/src/ui_elements/bubble/js/constants.js","../../../packages/design-system/src/ui_elements/bubble/bubble.js"],"sourcesContent":["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","const createRefs = component => [...component.querySelectorAll('[data-ref]')].reduce(extract, {})\n\nconst extract = (refs, $ref) => {\n    const { ref } = $ref.dataset\n\n    // Check if ref is of type array\n    const refArray = ref.match(/(\\w+)\\[(.+)\\]/)\n\n    if (refArray !== null) {\n        return getRefArray(refs, $ref, refArray)\n    } else {\n        return { ...refs, [$ref.dataset.ref]: $ref }\n    }\n}\n\nconst getRefArray = (refs, $ref, [, name, index]) => {\n    if (refs[name] === undefined) {\n        refs[name] = []\n    }\n    refs[name][index] = $ref\n    return refs\n}\n\nexport default createRefs\n","export { waitForSelector } from './waitForSelector'\n\nexport const constants = {\n    LEFT: 37,\n    UP: 38,\n    RIGHT: 39,\n    DOWN: 40,\n    ESC: 27,\n    SPACE: 32,\n    ENTER: 13,\n    TAB: 9\n}\n\nexport function capitalize(s = '') {\n    return s[0].toUpperCase() + s.slice(1)\n}\n\nexport const convertToCamelCase = (str: string): string => {\n    const arr = str.match(/[a-z]+|\\d+/gi)\n    if (!arr) { return str }\n    return arr.map((m, i) => {\n        let low = m.toLowerCase()\n        if (i !== 0) {\n            low = low.split('').map((s, k) => (k === 0 ? s.toUpperCase() : s)).join(\"\")\n        }\n        return low\n    }).join(\"\")\n}\n\nexport function slug(s = '') {\n    return s\n        .toLowerCase()\n        .trim()\n        .replace(/\\s+/g, '-') // Replace spaces with -\n        .replace(/[^\\w-]+/g, '') // Remove all non-word chars\n        .replace(/--+/g, '-') // Replace multiple - with single -\n}\n\nexport function pxToEm(target: number, stripedInnerFontSize = 1) {\n    return target / 14 / stripedInnerFontSize + 'em'\n}\n\nexport function percent(target: number) {\n    return target + '%'\n}\n\nexport function parseHTML(str: string) {\n    const tmp = document.implementation.createHTMLDocument('')\n    tmp.body.innerHTML = str\n    return tmp.body.childNodes\n}\n\nexport function stripHTML(str: string) {\n    const tmp = document.implementation.createHTMLDocument('')\n    tmp.body.innerHTML = str\n    return (tmp.body.textContent ?? \"\").replace(RegExp('[\\\\s|\\'|\"]', 'g'), '')\n}\n\nexport function makeId(length: number) {\n    var result = ''\n    var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\n    var charactersLength = characters.length\n    for (var i = 0; i < length; i++) {\n        result += characters.charAt(Math.floor(Math.random() * charactersLength))\n    }\n    return result\n}\n\nexport function makeHash(str: string) {\n    var hash = 0,\n        i,\n        chr\n    if (!str) {\n        return hash\n    }\n    for (i = 0; i < str.length; i++) {\n        chr = str.charCodeAt(i)\n        hash = (hash << 5) - hash + chr\n        hash |= 0 // Convert to 32bit integer\n    }\n    return 'id-' + hash\n}\n\nexport function getHashLink(link: string) {\n    let linkHash = link\n    let linkNoHash = link\n    if (link.indexOf('#') !== -1) {\n        linkNoHash = link.replace('#', '')\n    } else {\n        linkHash = '#' + link\n    }\n\n    return { linkNoHash, linkHash }\n}\n\nexport function lazyLoad(node: Element, attribute: string, value: any, url: string) {\n    const CLASSNAME_OUT_OF_SCREEN = 'lazy-load'\n    const CLASSNAME_IN_SCREEN = 'lazy-loaded'\n    const CLASSNAME_ON_ERROR = 'lazy-loaded-error'\n\n    const isOldIOS = () => {\n        var agent = window.navigator.userAgent,\n            start = agent.indexOf('OS ')\n        if ((agent.indexOf('iPhone') > -1 || agent.indexOf('iPad') > -1) && start > -1) {\n            return window.Number(agent.substr(start + 3, 3).replace('_', '.')) < 14\n        }\n        return false\n    }\n\n    const inViewPort = (attribute: string, value: any) => {\n        node.setAttribute(attribute, value)\n\n        const cb = () => node.classList.add(CLASSNAME_IN_SCREEN)\n\n        if (url) {\n            const img = new Image()\n            img.src = url\n            img.onload = cb\n            img.onerror = () => {\n                cb()\n                node.classList.add(CLASSNAME_ON_ERROR)\n                throw new Error(`Image ${url} cannot be loaded`)\n            }\n\n            return\n        }\n\n        cb()\n    }\n\n    if (/Trident\\/|MSIE/.test(window.navigator.userAgent) || isOldIOS()) {\n        inViewPort(attribute, value)\n    } else {\n        if ('IntersectionObserver' in window) {\n            node.classList.add(CLASSNAME_OUT_OF_SCREEN)\n            let lazyBackgroundObserver = new IntersectionObserver(function (entries) {\n                entries.forEach(function (entry) {\n                    if (entry.isIntersecting) {\n                        inViewPort(attribute, value)\n                        lazyBackgroundObserver.unobserve(entry.target)\n                    }\n                })\n            })\n            lazyBackgroundObserver.observe(node)\n        } else {\n            inViewPort(attribute, value)\n        }\n    }\n}\n\nexport function lazyLoadCallback(node: Element, cb: () => void) {\n    const isOldIOS = () => {\n        var agent = window.navigator.userAgent,\n            start = agent.indexOf('OS ')\n        if ((agent.indexOf('iPhone') > -1 || agent.indexOf('iPad') > -1) && start > -1) {\n            return window.Number(agent.substr(start + 3, 3).replace('_', '.')) < 14\n        }\n        return false\n    }\n\n    if (/Trident\\/|MSIE/.test(window.navigator.userAgent) || isOldIOS()) {\n        cb()\n    } else {\n        if ('IntersectionObserver' in window) {\n            let lazyBackgroundObserver = new IntersectionObserver(\n                function (entries) {\n                    entries.forEach(function (entry) {\n                        if (entry.isIntersecting) {\n                            cb()\n                            lazyBackgroundObserver.unobserve(entry.target)\n                        }\n                    })\n                },\n                { rootMargin: '150% 0px' }\n            )\n            lazyBackgroundObserver.observe(node)\n        }\n    }\n}\n\n// Debounce\nexport function debounce<T>(func: (v: T) => void, time = 100) {\n    let timer: number\n    return function (event: T) {\n        if (timer) {\n            window.clearTimeout(timer)\n        }\n        timer = window.setTimeout(func, time, event)\n    }\n}\n\n// isIE - to check for internet explorer\nexport function isIE() {\n    let ua = window.navigator.userAgent,\n        isIE = /MSIE|Trident/.test(ua)\n\n    return isIE\n}\n\n// Load external script\nexport const loadExternalScript = ({\n    src,\n    callback = null,\n    async = false,\n    defer = false,\n    module = false,\n    id = ''\n}: {\n    src: string;\n    callback: null | GlobalEventHandlers[\"onload\"]\n    module: boolean,\n    defer: boolean,\n    async: boolean,\n    id: string\n}) => {\n    const script = document.createElement('script')\n    script.type = module ? 'module' : 'text/javascript'\n    script.src = src\n    id ? (script.id = id) : false // add id attribute only if passed\n    if (typeof callback === 'function') {\n        script.onload = callback\n    }\n    script.async = async\n    script.defer = defer\n    document.body.appendChild(script)\n}\n\n// Load external css\nexport const loadExternalCss = ({ src }: { src: string }) => {\n    const script = document.createElement('link')\n    script.rel = 'stylesheet'\n    script.href = src\n    document.body.appendChild(script)\n}\n// Lazy load vendor script\nexport const lazyLoadVendorScript = (handler, el) => {\n    const observer = new IntersectionObserver(handler)\n    observer.observe(el)\n}\n\n/**\n * Replaces variable inside a given string\n * Each variable have to be enclosed between stChr and enChr\n * The values have to be contained in the vars object, they key must match\n * example :\n * txt : 'See {resultsLength} Results'\n * vars : {resultsLength:'30'}\n * stChr : '{'\n * enChr : '}'\n *\n * will return : 'See 30 Results'\n *\n * @param {string} txt\n * @param {object} vars\n * @param {string} stChr\n * @param {string} enChr\n */\nexport function interpolate(txt: string, vars: Record<string, null | undefined | string>, stChr: string, enChr: string) {\n    let curIdx = 0\n\n    while (txt) {\n        const stIdx = txt.indexOf(stChr, curIdx)\n        if (stIdx === -1) {\n            break\n        }\n        const enIdx = txt.indexOf(enChr, stIdx + 1)\n        if (enIdx === -1) {\n            break\n        }\n        const hashId = txt.substring(stIdx + stChr.length, enIdx)\n        if (vars[hashId] != null) {\n            txt = txt.substr(0, stIdx) + vars[hashId] + txt.substr(enIdx + enChr.length)\n            curIdx = stIdx\n        } else {\n            curIdx = enIdx\n        }\n    }\n    return txt\n}\n\n/**\n * Find in container element, add height to equal size of element\n * @param container css path where my element is contain e.g. `.c-container`\n * @param el css path of elements to equalized\n */\nexport const equalHeight = (containerSelector: string, el: string, elementScope: HTMLElement) => {\n    const container = elementScope.querySelector<HTMLElement>(containerSelector)\n    if (!container) {\n        return\n    }\n\n    const items = container.querySelectorAll<HTMLElement>(el)\n    let max = -1\n\n    for (let i = 0; i < [...items].length; i++) {\n        const item = [...items][i]\n        let h = item.offsetHeight\n        max = h > max ? h : max\n    }\n\n    if (max <= 0) {\n        return\n    }\n\n    for (let i = 0; i < [...items].length; i++) {\n        const item = [...items][i]\n        item.style.height = `${max}px`\n    }\n}\n\nexport const stringifyCurlyQuote = (data: {}) => JSON.stringify(data).replace(\"'\", '’')\n\nexport const stringifyForAttribute = (data = {}) => {\n    return escapeHtml(JSON.stringify(data))\n}\n\n/**\n * This function is included instead of sanitizeString because for\n * inserting HTML into innerHTML we need to make sure all HTML\n * entities are escaped.\n */\nexport const escapeHtml = (text: string) => {\n    const map = {\n        '&': '&amp;',\n        '<': '&lt;',\n        '>': '&gt;',\n        '\"': '&quot;',\n        \"'\": '&#039;'\n    } as { [s: string]: string }\n\n    return text.replace(/[&<>\"']/g, (m) => map[m])\n}\n\n/**\n * Because setting attributes escapes more than the characters above and then preact also \n * escapes text we need a more complete way of unescaping all html entities (not just the ones\n * above)\n */\nconst domParser = new DOMParser()\nexport const unescapeHtml = (text: string) => {\n    return domParser.parseFromString(text, \"text/html\").body.textContent\n}\n\nexport const sanitizeString = (data: {}) => {\n    if (!data) {\n        return ''\n    }\n\n    return data.toString().replace(/\"/g, '&quot;').replace(/'/g, '&apos;')\n}\n\nexport const stripTags = (s: string) => {\n    return (s || '').replace(/(<([^>]+)>)/gi, '')\n}\n\nexport const setAttributes = (element: Element, attrs: Record<string, any>) => {\n    for (let key in attrs) {\n        element.setAttribute(key, attrs[key])\n    }\n    return element\n}\n\nexport const getMetaContent = (metaName: string) => {\n    const metaTag = document.querySelector(`meta[name=${metaName}]`)\n    if (!metaTag) {\n        return ''\n    }\n    return metaTag.getAttribute('content')\n}\n\nexport const isObjectEmpty = (obj: {}) => {\n    return Object.keys(obj).length === 0\n}\n","export const MAX_WIDTH_CONTAINER = 1160\n\nexport const BREAKPOINT_XL = 1920\nexport const BREAKPOINT_TABLET = 1024\nexport const BREAKPOINT_L = 996\nexport const BREAKPOINT_M = 768\nexport const BREAKPOINT_S = 750\nexport const BREAKPOINT_XS = 375\n\nexport const CTA_PRIMARY = 'primary'\nexport const CTA_PRIMARY_TRANSPARENT = 'primary_transparent'\nexport const CTA_SUBTLE = 'subtle'\nexport const CTA_LINK = 'link'\nexport const CTA_LINK_UNDERLINE = 'link-underline'\nexport const CTA_LINK_GOLD = 'link-gold'\nexport const CTA_LINK_ADD_TO_CART_SMALL = 'AddToCart_small'\nexport const CTA_LINK_ADD_TO_CART_LARGE = 'AddToCart_large'\n\nexport const EVENT_TAB_CHANGE = 'EVENT_TAB_CHANGE'\n\nexport const EVENT_VIDEO = 'WEB_COMPONENT_VIDEO'\nexport const EVENT_POPIN_OPEN = 'WEB_COMPONENT_POPIN_OPEN'\nexport const EVENT_POPIN_OPENED = 'WEB_COMPONENT_POPIN_OPENED'\nexport const EVENT_POPIN_CLOSE = 'WEB_COMPONENT_POPIN_CLOSE'\nexport const EVENT_POPIN_CLOSED = 'WEB_COMPONENT_POPIN_CLOSED'\nexport const EVENT_POPIN_CLOSE_CLICK = 'WEB_COMPONENT_POPIN_CLOSE_CLICK'\nexport const EVENT_POPIN_KEY_DOWN = 'keydown'\nexport const EVENT_POPIN_FORM_TOGGLE_TITLE = 'WEB_COMPONENT_POPIN_FORM_TOGGLE_TITLE'\nexport const EVENT_CTA_CLICK = 'WEB_COMPONENT_CTA_CLICK'\nexport const EVENT_HERO_REORDER_OPEN = 'WEB_COMPONENT_HERO_REORDER_OPEN'\nexport const EVENT_HERO_REORDER_CLOSE = 'WEB_COMPONENT_HERO_REORDER_CLOSE'\nexport const EVENT_QUICKVIEW_OPEN = 'WEB_COMPONENT_QUICKVIEW_OPEN'\nexport const EVENT_QS_OPEN = 'WEB_COMPONENT_QS_OPEN'\nexport const EVENT_QS_OPENED = 'WEB_COMPONENT_QS_OPENED'\nexport const EVENT_QS_CLOSE = 'WEB_COMPONENT_QS_CLOSE'\nexport const EVENT_QS_CLOSED = 'WEB_COMPONENT_QS_CLOSED'\nexport const EVENT_QS_CLOSE_CLICK = 'WEB_COMPONENT_QS_CLOSE_CLICK'\nexport const EVENT_QS_KEY_DOWN = 'keydown'\nexport const EVENT_ADD_TO_CART = 'WEB_COMPONENT_ADD_TO_CART'\nexport const EVENT_CART_UPDATED = 'WEB_COMPONENT_CART_UPDATED'\nexport const EVENT_VIDEO_TOGGLE = 'WEB_COMPONENT_VIDEO_TOGGLE'\nexport const VIDEO_ON_HOVER = 'VIDEO_ON_HOVER'\nexport const VIDEO_ON_OUT = 'VIDEO_ON_OUT'\nexport const EVENT_DETAIL_OPEN = 'WEB_COMPONENT_DETAIL_OPEN'\nexport const EVENT_SLIDER_READY = 'WEB_COMPONENT_SLIDER_READY'\nexport const EVENT_SLIDE_CHANGE = 'WEB_COMPONENT_SLIDE_CHANGE'\nexport const EVENT_OVERLAY_OPEN = 'WEB_COMPONENT_OVERLAY_OPEN'\nexport const EVENT_OVERLAY_CLOSE = 'WEB_COMPONENT_OVERLAY_CLOSE'\nexport const EVENT_OVERLAY_CLICKED = 'WEB_COMPONENT_OVERLAY_CLICKED'\nexport const EVENT_OPEN_PRODUCT_AR_CLICKED = 'OPEN_PRODUCT_AR_CLICKED'\nexport const EVENT_SORT_BY_CHANGE = 'WEB_COMPONENT_SORT_BY_CHANGE'\nexport const EVENT_BUBBLE_SELECTED = 'EVENT_BUBBLE_SELECTED'\nexport const EVENT_RECO_TOOL_OPTION_CLICKED = 'EVENT_RECO_TOOL_OPTION_CLICKED'\nexport const WEB_COMPONENT_PROJECTS_LOADED = 'WEB_COMPONENT_PROJECTS_LOADED'\nexport const WEB_COMPONENT_ANCHOR_LOADED = 'WEB_COMPONENT_ANCHOR_LOADED'\n\nexport const EVENT_SWIPED_UP = 'swiped-up'\nexport const EVENT_SWIPED_DOWN = 'swiped-down'\nexport const EVENT_SWIPED_LEFT = 'swiped-left'\nexport const EVENT_SWIPED_RIGHT = 'swiped-right'\n\nexport const EVENT_HEADER_POSITION_CHANGED = 'EVENT_HEADER_POSITION_CHANGED'\n\nexport const keys = { ESC: 'Escape' }\n\nexport const ADD_TO_CART_MODIFIER_MINI = 'mini'\nexport const ADD_TO_CART_MODIFIER_DEFAULT = ADD_TO_CART_MODIFIER_MINI\n\nexport const COFFEE_ORIGINAL = 'original'\nexport const COFFEE_VERTUO = 'vertuo'\nexport const COFFEE_PRO = 'pro'\nexport const COFFEE_OL = 'OL'\nexport const COFFEE_VL = 'VL'\nexport const INTENSITY_MAX_OL = 14\nexport const INTENSITY_MAX_VL = 12\nexport const DEFAULT_BUBBLE_ICON = ''\n\nexport const NUMBER_PRODUCTS_SLIDER = 8\nexport const NUMBER_FEATURES_PDP = 8\n\nexport const ALIGNMENT = ['center', 'left', 'right']\nexport const POSITION = ['top', 'right', 'bottom', 'left']\nexport const TRANSLATION_ADD_TO_CART = 'Add to cart'\nexport const TRANSLATION_UPDATE_BASKET = 'Update basket'\n\nexport const TIME_INSTANT = 1\nexport const TIME_FAST = 300\nexport const TIME_MEDIUM = 600\nexport const TIME_SLOW = 1200\n\nexport const APP_APPLE_LINK = 'https://apps.apple.com/us/app/nespresso/id342879434'\nexport const APP_ANDROID_LINK =\n    'https://play.google.com/store/apps/details?id=com.nespresso.activities'\nexport const APP_HUAWEI_LINK = 'https://appgallery.huawei.com/app/C102571517'\n\nexport const SRC_PAGE_PLP = 'plp'\nexport const SRC_PAGE_PDP = 'pdp'\n\nexport const PLP_TYPE_COFFEE = 'coffee'\nexport const PLP_TYPE_MACHINE = 'machine'\nexport const PLP_TYPE_ACCESSORY = 'accessory'\nexport const CALLEO_API_DOMAIN = 'https://www.contact.nespresso.com/'\n\n// SCSS RELATED\n// Todo : should be shared by JS and SCSS\nexport const BROWSER_CONTEXT = 16 // 1rem = 16px\nexport const COLOR_WHITE_1000 = '#FFFFFF' // Do not change for #FFF shortcut, it will break slider-natural gradients !\n\nexport const CONTRAST_DARK = 'dark'\nexport const CONTRAST_LIGHT = 'light'\n\nexport const B2B_CONTACT_FORM_POPIN_ID = 'b2b-contact-form-popin-id'\nexport const B2B_CONTACT_FORM_POPIN_SRC_SKU_MAIN_INFO = 'sku-main-info'\n\nexport const B2B_CONTACT_FORM_POPIN_SRC_SKU_MAIN_INFO_AUTO = 'sku-main-info-auto'\n\nexport const ASPECT_RATIO_16_9 = '16/9'\nexport const ASPECT_RATIO_1_1 = '1/1'\n\nexport const NESPRESSO_PRODUCTION_DOMAIN = 'https://www.nespresso.com'\nexport const NESPRESSO_ROLLOUT_DOMAIN = 'https://nc2-env-rollout.nespresso.com'\n","import { BREAKPOINT_M, BREAKPOINT_TABLET } from '@kissui/design-system'\n\nconst viewport = () => {\n    const lt = (ref: number) => {\n        return window.innerWidth < ref\n    }\n\n    return {\n        get is() {\n            const { innerWidth: vw, devicePixelRatio } = window\n            return {\n                mobile: vw < BREAKPOINT_M,\n                mobile_tablet: vw < BREAKPOINT_TABLET,\n                tablet: vw >= BREAKPOINT_M && vw < BREAKPOINT_TABLET,\n                desktop: vw >= BREAKPOINT_TABLET && devicePixelRatio <= 1,\n                retina: vw >= BREAKPOINT_TABLET && devicePixelRatio > 1\n            }\n        },\n        lt\n    }\n}\n\nconst helper = viewport()\n\nexport default helper\n","import viewportHelper from './viewport.helpers'\n\n/**\n * Resize image on the fly by Akamai\n * https://dsu-confluence.nestle.biz/x/06kaCQ\n * https://dsu-confluence.nestle.biz/display/EUXUI/Performance?preview=/152742355/152761429/IMPoliciesExtract-31072020.docx\n * @param {''|'carouselBannerNarrowMedium'|'carouselBannerWide'|'horizontalBannerNarrow'|'landscapeRecipeDetails'|'large'|'medium'|'portraitRecipeDetails'|'productPdpMainDefault'|'productPdpMain'|'productPdpSafeZone'|'product'|'recipeCard'|'registrationTechChoiceMediumLarge'|'resize_crop'|'small'} policy - IM Policy coming from Akamaï\n * @param {24|150|320|640|1024|2048|5000} width - IM Width size of the image\n * @returns {string} - Rules apply in a query string parameter\n */\nexport const getImpolicy = (policy = 'product', width = 160) => {\n    const rules = []\n\n    if (policy) {\n        rules.push(`impolicy=${policy}`)\n    }\n\n    if (width) {\n        rules.push(`imwidth=${width}`)\n    }\n\n    return `?${rules.join('&')}`\n}\n\n/**\n * Ask the right resolution depending on breakpoint, returns the closest one\n * No need to give a retina resolution, Akamai will return Retina automatically (you need to give the normal resolution)\n * @param {''|'medium'} policy - IM Policy coming from Akamaï, default is medium because it have the largest batch of resolutions\n * @param {''|'375'} mobileWidth - Mobile image width to be served  | 375 default is full mobile screen width\n * @param {''|'1024'} tabletWidth - Tablet image width to be served | 1024 default is full tablet landscape screen width\n * @param {''|'1920'} desktopWidth - Desktop image width to be served | 1024 default is full tablet landscape screen width\n * @returns {string} - Rules to concatenate to your image url\n */\nexport const getResponsiveImpolicy = (\n    policy = 'medium',\n    mobileWidth = '375',\n    tabletWidth = '1024',\n    desktopWidth = '1920',\n    retinaWidth = '3840'\n) => {\n    if (viewportHelper.is.mobile) {\n        return getImpolicy(policy, mobileWidth)\n    } else if (viewportHelper.is.tablet) {\n        return getImpolicy(policy, tabletWidth)\n    } else if (viewportHelper.is.desktop) {\n        return getImpolicy(policy, desktopWidth)\n    } else {\n        return getImpolicy(policy, retinaWidth)\n    }\n}\n","export const STATE_DEFAULT = 'default'\nexport const STATE_SELECTED = 'selected'\nexport const STATE_DISABLED = 'disabled'\n","import createProps from '@kissui/helpers/src/props.helpers'\nimport createRefs from '@kissui/helpers/src/refs.helpers'\nimport { lazyLoad, getHashLink } from '@kissui/helpers/src/utils'\nimport { getResponsiveImpolicy } from '@kissui/helpers/src/impolicy'\n\nimport { STATE_SELECTED, STATE_DISABLED } from './js/constants'\n\nclass Bubble extends HTMLElement {\n    constructor() {\n        super()\n        this.classList.add('nb-bubble')\n    }\n\n    static get observedAttributes() {\n        return ['state']\n    }\n\n    attributeChangedCallback(name) {\n        if (name === 'state') {\n            this.setState()\n        }\n    }\n\n    connectedCallback() {\n        this.props = createProps(this.attributes)\n        this.render()\n        this.refs = createRefs(this)\n        this.initLazyLoad()\n    }\n\n    initLazyLoad() {\n        let { src = '', src_retina = '' } = this.props.visual\n        const { visual } = this.refs\n\n        // If src_retina is not provided by markets, then takes the src as default\n        if (src_retina === '') {\n            src_retina = src\n        }\n\n        src_retina += getResponsiveImpolicy('small', '144', '160', '80', '160')\n        src_retina += '&imdensity=1'\n\n        if (visual && src_retina) {\n            lazyLoad(visual, 'src', `${src_retina}`, src_retina)\n        }\n    }\n\n    render() {\n        const { label, link, state, a11y_scrollto = 'Scroll to' } = this.props\n        const { linkNoHash, linkHash } = getHashLink(link)\n\n        this.innerHTML = `\n            ${\n                state === STATE_DISABLED\n                    ? this.renderVisual()\n                    : `<a href=\"${linkHash}\" data-href=\"${linkNoHash}\" aria-label='${a11y_scrollto} ${label}'>\n                ${this.renderVisual()}\n            </a>`\n            }\n\n            ${this.renderLabel()}\n        `\n\n        this.link = this.querySelector('a')\n        this.label = this.querySelector('span')\n        state && this.setAttribute('state', state)\n        this.setTheme()\n    }\n\n    setState() {\n        const state = this.getAttribute('state')\n\n        if (state === STATE_SELECTED) {\n            this.link.setAttribute('aria-selected', 'true')\n            this.label.classList.add('t-xs-700-sl')\n            this.label.classList.remove('t-xs-500-sl')\n        } else {\n            if (state !== STATE_DISABLED) {\n                this.link.removeAttribute('aria-selected')\n            }\n\n            this.label.classList.remove('t-xs-700-sl')\n            this.label.classList.add('t-xs-500-sl')\n        }\n    }\n\n    setTheme() {\n        const { theme } = this.props\n\n        if (theme && theme !== '') {\n            this.style.setProperty('--placeholder-background', theme)\n        }\n    }\n\n    renderVisual() {\n        let { src = '', src_retina = '' } = this.props.visual\n        const { state } = this.props\n\n        if (src === '' && src_retina === '') {\n            return ''\n        }\n\n        // Image is decorative, we can have alt=\"\" and aria-hidden should be true\n        return `<img src=\"\" alt=\"\" aria-hidden=\"true\" data-ref=\"visual\" ${\n            state === STATE_DISABLED ? 'class=\"is-disabled\"' : ''\n        }/>`\n    }\n\n    renderLabel() {\n        const { label, state } = this.props\n\n        if (!label) {\n            return\n        }\n\n        return `<span class=\"t-xs-500-sl ${\n            state === STATE_DISABLED ? 'is-disabled' : ''\n        }\">${label}</span>`\n    }\n}\n\ncustomElements.get('nb-bubble') || customElements.define('nb-bubble', Bubble)\n\nexport default Bubble\n"],"names":["getData","attributes","find","attribute","nodeName","createProps","data","props","filter","reduce","all","attr","nodeValue","isNil","JSON","parse","error","console","log","obj","createRefs","component","querySelectorAll","extract","refs","$ref","ref","dataset","refArray","match","getRefArray","name","index","undefined","getHashLink","link","linkHash","linkNoHash","indexOf","replace","lazyLoad","node","value","url","CLASSNAME_OUT_OF_SCREEN","CLASSNAME_IN_SCREEN","CLASSNAME_ON_ERROR","isOldIOS","agent","window","navigator","userAgent","start","Number","substr","inViewPort","setAttribute","cb","classList","add","img","Image","src","onload","onerror","Error","test","lazyBackgroundObserver","IntersectionObserver","entries","forEach","entry","isIntersecting","unobserve","target","observe","DOMParser","BREAKPOINT_TABLET","BREAKPOINT_M","viewport","is","innerWidth","vw","devicePixelRatio","mobile","mobile_tablet","tablet","desktop","retina","lt","helper","getImpolicy","policy","width","rules","push","join","getResponsiveImpolicy","mobileWidth","tabletWidth","desktopWidth","retinaWidth","viewportHelper","STATE_SELECTED","STATE_DISABLED","Bubble","HTMLElement","constructor","observedAttributes","attributeChangedCallback","setState","connectedCallback","render","initLazyLoad","src_retina","visual","label","state","a11y_scrollto","innerHTML","renderVisual","renderLabel","querySelector","setTheme","getAttribute","remove","removeAttribute","theme","style","setProperty","customElements","get","define"],"mappings":"AAAA,MAAMA,IAAUC,CAAAA,MAAcA,EAAWC,KAAKC,CAAAA,MAAaA,EAAUC,aAAa,MAAM,GAElFC,IAAcJ,CAAAA,MAAc;AAC9B,QAAMK,IAAON,EAAQ,CAAC,GAAGC,CAAU,CAAC,GAC9BM,IAAQ,CAAC,GAAGN,CAAU,EACvBO,OAAOL,CAAAA,MAAaA,EAAUC,aAAa,MAAM,EACjDK,OAAO,CAACC,GAAKC,OACH;AAAA,IAAE,GAAGD;AAAAA,IAAK,CAACC,EAAKP,QAAQ,GAAGO,EAAKC;AAAAA,MACxC,CAAE,CAAA;AAET,MAAIC,EAAMP,CAAI;AACV,WAAOC;AAGX,MAAI;AACA,WAAO;AAAA,MAAE,GAAGA;AAAAA,MAAO,GAAGO,KAAKC,MAAMT,EAAKM,SAAS;AAAA;EAClD,SAAQI,GAAO;AACZC,YAAQC,IAAI,kBAAkBF,GAAOV,GAAMM,SAAS;AAAA,EACxD;AACJ,GAEMC,IAAQM,CAAAA,MAA4BA,KAAQ,MCrB5CC,IAAaC,CAAAA,MAAa,CAAC,GAAGA,EAAUC,iBAAiB,YAAY,CAAC,EAAEb,OAAOc,GAAS,CAAA,CAAE,GAE1FA,IAAUA,CAACC,GAAMC,MAAS;AAC5B,QAAM;AAAA,IAAEC,KAAAA;AAAAA,MAAQD,EAAKE,SAGfC,IAAWF,EAAIG,MAAM,eAAe;AAE1C,SAAID,MAAa,OACNE,EAAYN,GAAMC,GAAMG,CAAQ,IAEhC;AAAA,IAAE,GAAGJ;AAAAA,IAAM,CAACC,EAAKE,QAAQD,GAAG,GAAGD;AAAAA;AAE9C,GAEMK,IAAcA,CAACN,GAAMC,GAAM,CAAA,EAAGM,GAAMC,CAAK,OACvCR,EAAKO,CAAI,MAAME,WACfT,E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