{"version":3,"sources":["webpack:///./src/feature/gtm-ecomm-detail/gtm-ecomm-detail.js","webpack:///./node_modules/core-js/modules/es.object.get-prototype-of.js"],"names":["GtmEcommDetail","element","initDomCache","data","dataset","impression","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","push","subscribe","window","dataLayer","productElement","document","querySelectorAll","headingPriceElements","getElementsByClassName","dynamicPriceElement","querySelector","innerHTML","replace","length","parseFloat","totalPrice","BaseFeature","$","fails","toObject","nativeGetPrototypeOf","CORRECT_PROTOTYPE_GETTER","stat","forced","sham","getPrototypeOf","it"],"mappings":"g8CAEMA,E,YACL,WAAYC,GAAS,a,4FAAA,UACpB,wBAAMA,KACDA,QAAUA,EACf,EAAKC,eACL,EAAKC,KAAOF,EAAQG,QAAQC,WAAaC,KAAKC,MAAMN,EAAQG,QAAQC,YAAc,KAClF,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,YACPC,UAAW,CACVC,SAAU,GACVC,MAAO,EACPC,MAAO,CACN,CACCC,QAAS,GACTC,UAAW,GACXC,MAAO,EACPC,WAAY,GACZC,cAAe,GACfC,aAAc,GACdd,SAAU,OAMd,EAAKe,cAAgB,EAAKZ,UAAUE,UACpC,EAAKW,OAhCe,E,8RAmCd,WACNC,KAAKF,cAAcT,SAAW,MAC9BW,KAAKF,cAAcR,MAAQ,EAFrB,IAGCW,EAHD,EAGeD,KAAKd,UAAUE,UAAUG,MAHxC,MAINS,KAAKE,iBAAmBD,EACxBD,KAAKE,iBAAiBT,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AAQ,IAAK,IAAIA,QAAQ,IAAK,IAAIA,QAAQ,IAAK,KAChGnB,KAAKE,iBAAiBT,UAAYkB,GACxBG,EAAqBM,OAAS,IACxCnC,EAAmB6B,EAAqB,GAAGI,UAAUC,QAAQ,IAAK,IAAIA,QAAQ,IAAK,IAAIA,QAAQ,IAAK,MAGrGnB,KAAKf,iBAAmBA,EAKxBe,KAAKf,iBAAmBoC,WAAWrB,KAAKf,mBAEd,IAAtBe,KAAKhB,aACRgB,KAAKE,iBAAiBT,UAAYkB,EAClCX,KAAKF,cAAcR,MAAQU,KAAKf,iBAChCe,KAAKE,iBAAiBR,MAAQM,KAAKf,qBAC7B,CACNe,KAAKE,iBAAiBR,MAAQM,KAAKf,iBACnC,IAAMqC,EAAatB,KAAKE,iBAAiBR,MAAQM,KAAKE,iBAAiBnB,SACvEiB,KAAKd,UAAUE,UAAUE,MAAQgC,EAGlCb,OAAOC,UAAUH,KAAKP,KAAKd,iB,oCAxIDqC,GA6IdvD,a,oBC/If,IAAIwD,EAAI,EAAQ,GACZC,EAAQ,EAAQ,GAChBC,EAAW,EAAQ,GACnBC,EAAuB,EAAQ,IAC/BC,EAA2B,EAAQ,IAMvCJ,EAAE,CAAEnB,OAAQ,SAAUwB,MAAM,EAAMC,OAJRL,GAAM,WAAcE,EAAqB,MAIJI,MAAOH,GAA4B,CAChGI,eAAgB,SAAwBC,GACtC,OAAON,EAAqBD,EAASO","file":"14-0a40f9d3.pkg.js","sourcesContent":["import BaseFeature from '../../foundation/base/base';\r\n\r\nclass GtmEcommDetail extends BaseFeature {\r\n\tconstructor(element) {\r\n\t\tsuper(element);\r\n\t\tthis.element = element;\r\n\t\tthis.initDomCache();\r\n\t\tthis.data = element.dataset.impression ? JSON.parse(element.dataset.impression) : 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: 'view_item',\r\n\t\t\tecommerce: {\r\n\t\t\t\tcurrency: '',\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\tthis.ecommerceHead.currency = 'DKK';\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.log(this.ecommData);\r\n\r\n\t\tthis.log('GA4 view_item');\r\n\t\tthis.push();\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 cardProductPrice = 'm-variant-card__value';\r\n\t\t\tconst heroProductPrice = 'm-product-hero__price a-heading';\r\n\t\t\tlet headingPriceElements = document.getElementsByClassName(footerProductPrice);\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(heroProductPrice);\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\t// if (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 GtmEcommDetail;\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"],"sourceRoot":""}