{"version":3,"sources":["webpack:///./src/feature/gtm-ecomm-add/gtm-ecomm-add.js","webpack:///./node_modules/core-js/modules/es.object.get-prototype-of.js","webpack:///./node_modules/core-js/modules/es.array.slice.js"],"names":["GtmEcommAdd","element","initDomCache","data","dataset","add","JSON","parse","button","dom","action","form","closest","submitted","variant","quantity","dynamicPrice","unitPriceExclVat","ecommData","event","ecommerce","currency","value","items","item_id","item_name","price","item_brand","item_category","item_variant","ecommerceHead","init","this","productObj","ecommDataProduct","addEventListener","e","target","log","eventCallback","submit","preventDefault","stopPropagation","push","subscribe","window","dataLayer","productElement","document","querySelectorAll","headingPriceElements","getElementsByClassName","dynamicPriceElement","querySelector","innerHTML","replace","length","at","slice","parseFloat","totalPrice","BaseFeature","$","fails","toObject","nativeGetPrototypeOf","CORRECT_PROTOTYPE_GETTER","stat","forced","sham","getPrototypeOf","it","isObject","isArray","toAbsoluteIndex","toLength","toIndexedObject","createProperty","arrayMethodHasSpeciesSupport","SPECIES","wellKnownSymbol","nativeSlice","max","Math","proto","start","end","Constructor","result","n","O","k","fin","undefined","constructor","Array","prototype","call"],"mappings":"s8CAEMA,E,YACL,WAAYC,GAAS,a,4FAAA,UACpB,wBAAMA,KAEDA,QAAUA,EACf,EAAKC,eACL,EAAKC,KAAOF,EAAQG,QAAQC,IAAMC,KAAKC,MAAMN,EAAQG,QAAQC,KAAO,KACpE,EAAKG,OAAS,EAAKC,IAAIC,OACvB,EAAKC,KAAOV,EAAQW,QAAQ,QAC5B,EAAKC,WAAY,EACjB,EAAKC,QAAU,EAAKL,IAAIK,QACxB,EAAKC,SAAW,EAAKN,IAAIM,SACzB,EAAKC,cAAe,EACpB,EAAKC,iBAAmB,EACxB,EAAKC,UAAY,CAChBC,MAAO,cACPC,UAAW,CACVC,SAAU,MACVC,MAAO,EACPC,MAAO,CACN,CACCC,QAAS,GACTC,UAAW,GACXC,MAAO,EACPC,WAAY,GACZC,cAAe,GACfC,aAAc,GACdd,SAAU,OAMd,EAAKe,cAAgB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ructor(element) {\r\n\t\tsuper(element);\r\n\r\n\t\tthis.element = element;\r\n\t\tthis.initDomCache();\r\n\t\tthis.data = element.dataset.add ? JSON.parse(element.dataset.add) : null;\r\n\t\tthis.button = this.dom.action;\r\n\t\tthis.form = element.closest('form');\r\n\t\tthis.submitted = false;\r\n\t\tthis.variant = this.dom.variant;\r\n\t\tthis.quantity = this.dom.quantity;\r\n\t\tthis.dynamicPrice = false;\r\n\t\tthis.unitPriceExclVat = 0;\r\n\t\tthis.ecommData = {\r\n\t\t\tevent: 'add_to_cart',\r\n\t\t\tecommerce: {\r\n\t\t\t\tcurrency: 'DKK',\r\n\t\t\t\tvalue: 0.0,\r\n\t\t\t\titems: [\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\titem_id: '',\r\n\t\t\t\t\t\titem_name: '',\r\n\t\t\t\t\t\tprice: 0.0,\r\n\t\t\t\t\t\titem_brand: '',\r\n\t\t\t\t\t\titem_category: '',\r\n\t\t\t\t\t\titem_variant: '',\r\n\t\t\t\t\t\tquantity: '',\r\n\t\t\t\t\t},\r\n\t\t\t\t],\r\n\t\t\t},\r\n\t\t};\r\n\r\n\t\tthis.ecommerceHead = this.ecommData.ecommerce;\r\n\t\tthis.init();\r\n\t}\r\n\r\n\tinit() {\r\n\t\t// this.ecommerceHead.currency = this.data.currency;\r\n\t\tthis.ecommerceHead.value = 0.0;\r\n\t\tconst [productObj] = this.ecommData.ecommerce.items;\r\n\t\tthis.ecommDataProduct = productObj;\r\n\t\tthis.ecommDataProduct.item_name = this.data.item_name;\r\n\t\tthis.ecommDataProduct.item_id = this.data.item_id;\r\n\t\tthis.ecommDataProduct.price = 0.0;\r\n\t\tthis.ecommDataProduct.item_brand = this.data.item_brand;\r\n\t\tthis.ecommDataProduct.item_category = this.data.item_category;\r\n\t\tthis.ecommDataProduct.item_variant = this.data.item_variant;\r\n\r\n\t\tif (this.variant) {\r\n\t\t\tthis.ecommDataProduct.variant = this.variant.value;\r\n\t\t\tthis.variant.addEventListener('change', (e) => {\r\n\t\t\t\tthis.ecommDataProduct.item_variant = e.target.value;\r\n\t\t\t\tthis.log('change', e.target.value);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.quantity) {\r\n\t\t\tthis.ecommDataProduct.quantity = this.quantity.value;\r\n\t\t\tthis.quantity.addEventListener('change', (e) => {\r\n\t\t\t\tif (!this.dynamicPrice) {\r\n\t\t\t\t\tthis.ecommDataProduct.quantity = e.target.value;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.log('change', e.target.value);\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\tthis.ecommDataProduct.quantity = 1;\r\n\t\t}\r\n\r\n\t\tthis.ecommData.eventCallback = () => {\r\n\t\t\t// This check prevents IE/Edge from submitting twice\r\n\t\t\tif (!this.submitted) {\r\n\t\t\t\tthis.log('************** ecomm callback');\r\n\t\t\t\tthis.form.submit();\r\n\t\t\t\tthis.submitted = true;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tthis.log(this.ecommData);\r\n\r\n\t\tthis.form.addEventListener('submit', (e) => {\r\n\t\t\te.preventDefault();\r\n\t\t\te.stopPropagation();\r\n\r\n\t\t\tthis.log(e.target);\r\n\r\n\t\t\tthis.log('gtm-ecomm-add click');\r\n\r\n\t\t\tthis.push();\r\n\t\t});\r\n\r\n\t\tthis.subscribe('dynamicPrice.change', () => {\r\n\t\t\tthis.ecommDataProduct.quantity = 1;\r\n\t\t\tthis.log('dynamicPrice change', this.ecommDataProduct.quantity);\r\n\t\t});\r\n\r\n\t\tthis.subscribe('dynamicPrice.init', (data) => {\r\n\t\t\t/**\r\n\t\t\t\tIf the price is dynamically calculated set true\r\n\t\t\t*/\r\n\t\t\tthis.dynamicPrice = data;\r\n\t\t});\r\n\t}\r\n\r\n\tpush() {\r\n\t\tif (window.dataLayer) {\r\n\t\t\t// unit price\r\n\t\t\tlet unitPriceExclVat = 0;\r\n\r\n\t\t\tconst footerProductText = 'div.m-product-pos-bar__content h3';\r\n\t\t\tconst cardProductText = 'div.m-variant-card__description h2';\r\n\t\t\tconst heroProductText = 'div.m-product-hero__content h1';\r\n\t\t\tconst productElement = document.querySelectorAll(\r\n\t\t\t\theroProductText,\r\n\t\t\t\tcardProductText,\r\n\t\t\t\tfooterProductText);\r\n\r\n\t\t\tconst footerProductPrice = 'm-product-pos-bar__price a-heading a-heading--level-3';\r\n\t\t\tconst heroProductPrice = 'm-product-hero__price a-heading';\r\n\t\t\tconst cardProductPrice = 'm-variant-card__value';\r\n\t\t\tlet headingPriceElements = document.getElementsByClassName(heroProductPrice);\r\n\t\t\tif (headingPriceElements === null) {\r\n\t\t\t\theadingPriceElements = document.getElementsByClassName(cardProductPrice);\r\n\t\t\t\tif (headingPriceElements === null) {\r\n\t\t\t\t\theadingPriceElements = document.getElementsByClassName(footerProductPrice);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tconst dynamicPriceElement = document.querySelector('[data-js=\\'product-dynamic-price__priceExclVat\\']');\r\n\t\t\tif (dynamicPriceElement) {\r\n\t\t\t\tunitPriceExclVat = dynamicPriceElement.innerHTML.replace('.', '').replace('-', '').replace(',', '.');\r\n\t\t\t\tthis.ecommDataProduct.item_name = productElement;\r\n\t\t\t} else if (headingPriceElements.length > 0) {\r\n\t\t\t\tunitPriceExclVat = headingPriceElements[0].innerHTML.replace('.', '').replace('-', '').replace(',', '.');\r\n\t\t\t}\r\n\r\n\t\t\tthis.unitPriceExclVat = unitPriceExclVat;\r\n\r\n\t\t\tif (this.unitPriceExclVat.at(-1) === '.') {\r\n\t\t\t\tthis.unitPriceExclVat = this.unitPriceExclVat.slice(0, -1);\r\n\t\t\t}\r\n\t\t\tthis.unitPriceExclVat = parseFloat(this.unitPriceExclVat);\r\n\r\n\t\t\tif (this.dynamicPrice === true) {\r\n\t\t\t\tthis.ecommDataProduct.item_name = productElement;\r\n\t\t\t\tthis.ecommerceHead.value = this.unitPriceExclVat;\r\n\t\t\t\tthis.ecommDataProduct.price = this.unitPriceExclVat;\r\n\t\t\t} else {\r\n\t\t\t\tthis.ecommDataProduct.price = this.unitPriceExclVat;\r\n\t\t\t\tconst totalPrice = this.ecommDataProduct.price * this.ecommDataProduct.quantity;\r\n\t\t\t\tthis.ecommData.ecommerce.value = totalPrice;\r\n\t\t\t}\r\n\r\n\t\t\twindow.dataLayer.push(this.ecommData);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport default GtmEcommAdd;\r\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar toObject = require('../internals/to-object');\nvar nativeGetPrototypeOf = require('../internals/object-get-prototype-of');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });\n\n// `Object.getPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.getprototypeof\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {\n getPrototypeOf: function getPrototypeOf(it) {\n return nativeGetPrototypeOf(toObject(it));\n }\n});\n\n","'use strict';\nvar $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar isArray = require('../internals/is-array');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar createProperty = require('../internals/create-property');\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar SPECIES = wellKnownSymbol('species');\nvar nativeSlice = [].slice;\nvar max = Math.max;\n\n// `Array.prototype.slice` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.slice\n// fallback for not array-like ES3 strings and DOM objects\n$({ target: 'Array', proto: true, forced: !arrayMethodHasSpeciesSupport('slice') }, {\n slice: function slice(start, end) {\n var O = toIndexedObject(this);\n var length = toLength(O.length);\n var k = toAbsoluteIndex(start, length);\n var fin = toAbsoluteIndex(end === undefined ? length : end, length);\n // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible\n var Constructor, result, n;\n if (isArray(O)) {\n Constructor = O.constructor;\n // cross-realm fallback\n if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {\n Constructor = undefined;\n } else if (isObject(Constructor)) {\n Constructor = Constructor[SPECIES];\n if (Constructor === null) Constructor = undefined;\n }\n if (Constructor === Array || Constructor === undefined) {\n return nativeSlice.call(O, k, fin);\n }\n }\n result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));\n for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);\n result.length = n;\n return result;\n }\n});\n"],"sourceRoot":""}