{"version":3,"sources":["webpack://crc/webpack/bootstrap","webpack://crc/./src/utils/activeTags.js","webpack://crc/./src/components/message/Message.jsx","webpack://crc/./src/components/message/index.js"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","executeModules","i","resolves","length","Object","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","deferredModules","apply","checkDeferredModules","result","deferredModule","fulfilled","j","splice","__webpack_require__","s","installedModules","1","exports","module","l","m","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","p","jsonpArray","self","this","oldJsonpFunction","slice","getTagSize","node","classList","visibleElement","arrayFind","arrayFrom","children","element","window","getComputedStyle","getPropertyValue","size","contains","toUpperCase","getActiveTags","container","querySelector","subHeadline","disclaimer","Message","useXProps","amount","currency","style","offer","payerId","clientId","merchantId","onClick","onReady","onHover","onMarkup","resize","useServerData","markup","meta","parentStyles","warnings","setServerData","dimensionsRef","useRef","width","height","buttonRef","handleHover","useLayoutEffect","styles","activeTags","current","messageRequestId","useDidUpdateLayoutEffect","buttonWidth","offsetWidth","buttonHeight","offsetHeight","useDidUpdateEffect","query","objectEntries","message_request_id","credit_type","payer_id","client_id","merchant_id","filter","Boolean","reduce","acc","val","encodeURIComponent","JSON","stringify","request","location","origin","then","type","ref","onMouseOver","onFocus","aria-label","display","background","padding","border","outline","textAlign","fontFamily","fontSize","innerHTML","setupMessage","render","document","body"],"mappings":"uBACE,SAASA,EAAqBC,GAQ7B,IAPA,IAMIC,EAAUC,EANVC,EAAWH,EAAK,GAChBI,EAAcJ,EAAK,GACnBK,EAAiBL,EAAK,GAIHM,EAAI,EAAGC,EAAW,GACpCD,EAAIH,EAASK,OAAQF,KAEtBG,IAAiBC,eAAeC,KAAKC,EADxCV,EAAUC,EAASG,KACkDM,EAAgBV,IACpFK,EAASM,KAAKD,EAAgBV,GAAS,IAExCU,EAAgBV,GAAW,EAE5B,IAAID,KAAYG,GACZK,IA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T,OAAQW,MAI9DE,aAAmB,WACf,IAAMC,EAAQC,IAAc,CACxBC,mBAAoBvB,EAAKc,iBACzB5B,SACAC,WACAC,QACAoC,YAAanC,EACboC,SAAUnC,EACVoC,UAAWnC,EACXoC,YAAanC,IAEZoC,QAAO,mBAAaC,QAAb,SACPC,QACG,SAACC,EAAD,OAAYC,EAAZ,YACOD,EADP,aACqBE,mBAAkC,iBAARD,EAAmBE,KAAKC,UAAUH,GAAOA,KACxF,IAEHpE,MAAM,GAEXwE,YAAQ,MAAU/D,OAAOgE,SAASC,OAA3B,qCAAsEjB,GAASkB,MAAK,YAAc,YAAXvI,EAAW,EAAXA,KAC1FmG,EAAc,CACVJ,OAAM,SAAE/F,EAAK+F,QAAP,EAAiBA,EACvBC,KAAI,SAAEhG,EAAKgG,MAAP,EAAeA,EAEnBC,aAAY,SAAEjG,EAAKiG,cAAP,EAAuBA,EACnCC,SAAQ,SAAElG,EAAKkG,UAAP,EAAmBA,SAGpC,CAAChB,EAAQC,EAAU+C,KAAKC,UAAU/C,GAAQC,EAAOC,EAASC,EAAUC,IAGnE,sBACIgD,KAAK,SACLC,IAAKjC,EACLf,QAxEY,WACO,mBAAZA,GACPA,EAAQ,CAAEO,UAuEV0C,YAAajC,EACbkC,QAASlC,EACTmC,aAAW,wBACXxD,MAAO,CACHyD,QAAS,QACTC,WAAY,cACZC,QAAS,EACTC,OAAQ,OACRC,QAAS,OACTC,UAAW,OACXC,WAAY,UACZC,SAAU,WAEdC,UAAWtD,KC3GhB,SAASuD,EAAT,GAAgE,IAAxCvD,EAAwC,EAAxCA,OAAQC,EAAgC,EAAhCA,KAAMC,EAA0B,EAA1BA,aAAcC,EAAY,EAAZA,SACvDqD,YACI,YAAC,IAAD,KACI,YAAC,IAAD,CAAoBvJ,KAAM,CAAE+F,SAAQC,OAAMC,eAAcC,aACpD,YAAC,EAAD,QAGRsD,SAASC","file":"smart-credit-message.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t1: 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \tvar jsonpArray = (typeof self !== 'undefined' ? self : this)[\"webpackJsonpcrc\"] = (typeof self !== 'undefined' ? self : this)[\"webpackJsonpcrc\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// add entry module to deferred list\n \tdeferredModules.push([148,0]);\n \t// run deferred modules when ready\n \treturn checkDeferredModules();\n","import arrayFind from 'core-js-pure/stable/array/find';\nimport arrayFrom from 'core-js-pure/stable/array/from';\n\n// Map class name of visible element to size tag.\nconst toTagSize = classList => {\n const sizes = ['xsmall', 'small', 'medium', 'large', 'xlarge'];\n\n // Match on first tag contained in classList, ignoring other values.\n const tag = arrayFind(sizes, size => classList.contains(`tag--${size}`)) || 'NONE';\n\n return tag.toUpperCase();\n};\n\nconst getTagSize = node => {\n // Provide NONE as value for section in payload if not shown\n if (!node) {\n return 'NONE';\n }\n\n const visibleElement = arrayFind(\n arrayFrom(node.children),\n element => window.getComputedStyle(element).getPropertyValue('display') !== 'none'\n );\n\n // Get the tag size of the element shown\n return toTagSize(visibleElement.classList);\n};\n\nexport function getActiveTags(container) {\n if (!container) {\n return `headline:NONE::subheadline:NONE::disclaimer:NONE`;\n }\n\n const [headline, subHeadline, disclaimer] = [\n container.querySelector('.message__headline'),\n container.querySelector('.message__subheadline'),\n container.querySelector('.message__disclaimer')\n ];\n\n return `headline:${getTagSize(headline)}::subheadline:${getTagSize(subHeadline)}::disclaimer:${getTagSize(\n disclaimer\n )}`;\n}\n","/** @jsx h */\nimport objectEntries from 'core-js-pure/stable/object/entries';\nimport { h } from 'preact';\nimport { useLayoutEffect, useRef } from 'preact/hooks';\n\nimport { request, getActiveTags } from '../../utils';\nimport { useXProps, useServerData, useDidUpdateEffect, useDidUpdateLayoutEffect } from './lib';\n\nconst Message = () => {\n const {\n amount,\n currency,\n style,\n offer,\n payerId,\n clientId,\n merchantId,\n onClick,\n onReady,\n onHover,\n onMarkup,\n resize\n } = useXProps();\n const { markup, meta, parentStyles, warnings, setServerData } = useServerData();\n const dimensionsRef = useRef({ width: 0, height: 0 });\n const buttonRef = useRef();\n\n const handleClick = () => {\n if (typeof onClick === 'function') {\n onClick({ meta });\n }\n };\n\n const handleHover = () => {\n if (typeof onHover === 'function') {\n onHover({ meta });\n }\n };\n\n useLayoutEffect(() => {\n if (typeof onMarkup === 'function') {\n onMarkup({ meta, styles: parentStyles, warnings });\n }\n }, [parentStyles, warnings, markup]);\n\n useLayoutEffect(() => {\n if (typeof onReady === 'function') {\n onReady({ meta, activeTags: getActiveTags(buttonRef.current) });\n }\n }, [meta.messageRequestId]);\n\n useDidUpdateLayoutEffect(() => {\n const buttonWidth = buttonRef.current.offsetWidth;\n const buttonHeight = buttonRef.current.offsetHeight;\n\n // Zoid will not fire a resize event if the markup has the same dimensions meaning the render event\n // in the overflow observer will not fire. This forces the resize event to fire for every render\n // so that the render complete logs will always fire\n if (dimensionsRef.current.width === buttonWidth && dimensionsRef.current.height === buttonHeight) {\n resize({ width: buttonWidth, height: buttonHeight });\n } else {\n dimensionsRef.current = { width: buttonWidth, height: buttonHeight };\n }\n });\n\n useDidUpdateEffect(() => {\n const query = objectEntries({\n message_request_id: meta.messageRequestId,\n amount,\n currency,\n style,\n credit_type: offer,\n payer_id: payerId,\n client_id: clientId,\n merchant_id: merchantId\n })\n .filter(([, val]) => Boolean(val))\n .reduce(\n (acc, [key, val]) =>\n `${acc}&${key}=${encodeURIComponent(typeof val === 'object' ? JSON.stringify(val) : val)}`,\n ''\n )\n .slice(1);\n\n request('GET', `${window.location.origin}/credit-presentment/renderMessage?${query}`).then(({ data }) => {\n setServerData({\n markup: data.markup ?? markup,\n meta: data.meta ?? meta,\n // Respect empty string value in order to remove styles when switch from flex to text layout\n parentStyles: data.parentStyles ?? parentStyles,\n warnings: data.warnings ?? warnings\n });\n });\n }, [amount, currency, JSON.stringify(style), offer, payerId, clientId, merchantId]);\n\n return (\n \n );\n};\n\nexport default Message;\n","/** @jsx h */\nimport { h, render } from 'preact';\n\nimport { XPropsProvider, ServerDataProvider } from '../lib';\nimport Message from './Message';\n\nexport function setupMessage({ markup, meta, parentStyles, warnings }) {\n render(\n \n \n \n \n ,\n document.body\n );\n}\n"],"sourceRoot":""}