{"version":3,"file":"index.es.min.js","sources":["../../../packages/helpers/src/props.helpers.js","../../../packages/components/src/intensity/intensity.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","import createProps from '@kissui/helpers/src/props.helpers'\n\nclass Intensity 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 const { intensity_label = 'Intensity', a11y_intensity_max, max_intensity } = this.props\n const intensity = parseInt(this.props.intensity)\n\n if (!intensity || isNaN(intensity)) {\n return ''\n }\n\n const a11yIntensityMax = a11y_intensity_max?.replace('{max_intensity}', max_intensity)\n\n this.innerHTML = `\n <p>\n <span class=\"sr-only\">${intensity_label} ${intensity} ${a11yIntensityMax}</span>\n <div class=\"t-xs-500-sl\" aria-hidden=\"true\">${intensity_label}</div>\n ${this.renderIntensityMin(intensity)}\n <div class=\"t-xs-700-sl\" aria-hidden=\"true\">${intensity}</div>\n ${this.renderIntensityMax(intensity)}\n </p>\n `\n }\n\n renderIntensityMin(intensity) {\n const min_intensity = 0\n\n return new Array(Math.max(intensity, 0) - min_intensity)\n .fill('<span class=\"bar filled\"></span>')\n .join('')\n }\n\n renderIntensityMax(intensity) {\n let { max_intensity } = this.props\n if (!max_intensity || max_intensity === 'undefined') {\n max_intensity = 14\n }\n\n return new Array(parseInt(max_intensity) - Math.min(intensity, parseInt(max_intensity)))\n .fill('<span class=\"bar\"></span>')\n .join('')\n }\n}\n\ncustomElements.get('nb-intensity') || customElements.define('nb-intensity', Intensity)\n\nexport default Intensity\n"],"names":["isNil","obj","Intensity","HTMLElement","constructor","this","props","connectedCallback","attributes","data","find","attribute","nodeName","getData","filter","reduce","all","attr","nodeValue","JSON","parse","error","console","log","createProps","render","intensity_label","a11y_intensity_max","max_intensity","intensity","parseInt","isNaN","a11yIntensityMax","replace","innerHTML","renderIntensityMin","renderIntensityMax","Array","Math","max","min_intensity","fill","join","min","customElements","get","define"],"mappings":"AAAA,MAqBMA,EAAQC,GAAoC,MAARA,ECnB1C,MAAMC,UAAkBC,YACpBC,WAAAA,WAEIC,KAAKC,MAAQ,EACjB,CAEAC,iBAAAA,GACIF,KAAKC,MDPOE,CAAAA,IACVC,MAAAA,EAHMD,CAAAA,GAAcA,EAAWE,MAAKC,GAAoC,SAAvBA,EAAUC,WAGpDC,CAAQ,IAAIL,IACnBF,EAAQ,IAAIE,GACbM,QAAOH,GAAoC,SAAvBA,EAAUC,WAC9BG,QAAO,CAACC,EAAKC,KACH,IAAKD,EAAK,CAACC,EAAKL,UAAWK,EAAKC,aACxC,CAAE,GAET,GAAIlB,EAAMS,GACCH,OAAAA,EAGP,IACO,MAAA,IAAKA,KAAUa,KAAKC,MAAMX,EAAKS,WACzC,OAAQG,GACLC,QAAQC,IAAI,iBAAkBF,EAAOZ,GAAMS,UAC/C,GCTiBM,CAAYnB,KAAKG,YAC9BH,KAAKoB,QACT,CAEAA,MAAAA,GACU,MAAEC,gBAAAA,EAAkB,YAAaC,mBAAAA,EAAoBC,cAAAA,GAAkBvB,KAAKC,MAC5EuB,EAAYC,SAASzB,KAAKC,MAAMuB,WAElC,IAACA,GAAaE,MAAMF,GACb,MAAA,GAGX,MAAMG,EAAmBL,GAAoBM,QAAQ,kBAAmBL,GAExEvB,KAAK6B,UAAY,4DAEeR,KAAmBG,KAAaG,yEACVN,4BAC5CrB,KAAK8B,mBAAmBN,mEACoBA,4BAC5CxB,KAAK+B,mBAAmB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