{"version":3,"file":"gtm.service-Dwwk4JyT.js","sources":["../../../Frontend/src/vue/helpers/text.helper.ts","../../../Frontend/src/vue/services/gtm.service.ts"],"sourcesContent":["import {HexColor} from \"~/types/HexColor\";\r\n\r\n/**\r\n * Slugify a string\r\n * \r\n * @param input The string to slugify.\r\n * @return The slugified string.\r\n */\r\nexport const slugify = (input: string) => {\r\n return input.toLowerCase().replace(/[^a-zA-Z0-9\\w]/g, '-');\r\n};\r\n\r\n/**\r\n * Gets the most visible text color for a given background color.\r\n * This will be black for lighter colors and white for darker colors to ensure readability.\r\n * \r\n * @param backgroundColor The background color to get the text color for. Must be a hex color.\r\n * @return The most visible text color for the given background color, either black or white. Defaults to black if the background color is not valid.\r\n */\r\nexport const getVisibleTextColor = (backgroundColor: HexColor) => {\r\n const isHexColor = /^#[0-9A-F]{6}$/i.test(backgroundColor);\r\n if (!isHexColor) {\r\n console.error(\"Invalid color, defaulting to black\")\r\n return \"#000000\";\r\n }\r\n\r\n const red = parseInt(backgroundColor.substring(1, 3), 16);\r\n const green = parseInt(backgroundColor.substring(3, 5), 16);\r\n const blue = parseInt(backgroundColor.substring(5, 7), 16);\r\n \r\n const isLightColor = (red * 0.299 + green * 0.587 + blue * 0.114) > 186;\r\n return isLightColor\r\n ? \"#000000\"\r\n : \"#FFFFFF\";\r\n}\r\n\r\n/**\r\n * Find and replace a string with a substitute in a text.\r\n * \r\n * @param text The text to search in.\r\n * @param find The string to find.\r\n * @param replace The string to replace the found string with.\r\n * @param replaceAll (Optional) Whether to replace all occurrences of the found string. Defaults to true.\r\n */\r\nexport const findAndReplace = (text: string, find: string, replace: string, replaceAll = true) => {\r\n const flags = replaceAll ? 'g' : '';\r\n const regex = new RegExp(find, flags);\r\n return text.replace(regex, replace);\r\n}","// Must be done so that TypeScript knows that there is a global dataLayer object\r\ndeclare const window: Window & { [key: string]: any }\r\n\r\n/**\r\n * Add an event to the dataLayer, which Google Tag Manager uses to track events.\r\n * \r\n * @param event The name of the event\r\n * @param data The data to send with the event\r\n */\r\nexport const addToDataLayer = (event: string, data: any = null) => {\r\n window.dataLayer = window.dataLayer || [];\r\n \r\n const ecommerceEvents = ['view_item_list', 'view_item', 'select_item', 'checkout_begin', 'add_payment_info', 'add_shipping_info', 'purchase'];\r\n\r\n let eventObject = {\r\n 'event': event,\r\n };\r\n \r\n if (data !== null) {\r\n eventObject = {\r\n ...eventObject,\r\n ...data\r\n };\r\n }\r\n \r\n if (ecommerceEvents.includes(event)) {\r\n window.dataLayer.push({ ecommerce: null });\r\n }\r\n \r\n window.dataLayer.push(eventObject);\r\n}\r\n\r\nexport const gtag = (...args: any) => {\r\n window.dataLayer = window.dataLayer || [];\r\n window.dataLayer.push({...args});\r\n}"],"names":["slugify","input","getVisibleTextColor","backgroundColor","red","green","blue","findAndReplace","text","find","replace","replaceAll","flags","regex","addToDataLayer","event","data","ecommerceEvents","eventObject","gtag","args"],"mappings":"AAQa,MAAAA,EAAWC,GACbA,EAAM,YAAc,EAAA,QAAQ,kBAAmB,GAAG,EAUhDC,EAAuBC,GAA8B,CAE9D,GAAI,CADe,kBAAkB,KAAKA,CAAe,EAErD,eAAQ,MAAM,oCAAoC,EAC3C,UAGX,MAAMC,EAAM,SAASD,EAAgB,UAAU,EAAG,CAAC,EAAG,EAAE,EAClDE,EAAQ,SAASF,EAAgB,UAAU,EAAG,CAAC,EAAG,EAAE,EACpDG,EAAO,SAASH,EAAgB,UAAU,EAAG,CAAC,EAAG,EAAE,EAGzD,OADsBC,EAAM,KAAQC,EAAQ,KAAQC,EAAO,KAAS,IAE9D,UACA,SACV,EAUaC,EAAiB,CAACC,EAAcC,EAAcC,EAAiBC,EAAa,KAAS,CACxF,MAAAC,EAAQD,EAAa,IAAM,GAC3BE,EAAQ,IAAI,OAAOJ,EAAMG,CAAK,EAC7B,OAAAJ,EAAK,QAAQK,EAAOH,CAAO,CACtC,ECvCaI,EAAiB,CAACC,EAAeC,EAAY,OAAS,CACxD,OAAA,UAAY,OAAO,WAAa,CAAA,EAEjC,MAAAC,EAAkB,CAAC,iBAAkB,YAAa,cAAe,iBAAkB,mBAAoB,oBAAqB,UAAU,EAE5I,IAAIC,EAAc,CACd,MAASH,CAAA,EAGTC,IAAS,OACKE,EAAA,CACV,GAAGA,EACH,GAAGF,CAAA,GAIPC,EAAgB,SAASF,CAAK,GAC9B,OAAO,UAAU,KAAK,CAAE,UAAW,IAAM,CAAA,EAGtC,OAAA,UAAU,KAAKG,CAAW,CACrC,EAEaC,EAAO,IAAIC,IAAc,CAC3B,OAAA,UAAY,OAAO,WAAa,CAAA,EACvC,OAAO,UAAU,KAAK,CAAC,GAAGA,CAAK,CAAA,CACnC"}