{"version":3,"sources":["webpack://crc/webpack/bootstrap","webpack://crc/./src/utils/elements.js","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","curry","prefix","container","className","getElementsByClassName","text","elem","document","createElement","textContent","insertBefore","firstChild","obj","Array","isArray","forEach","appendChild","HTMLElement","span","innerHTML","parentNode","removeChild","reverse","appendImage","url","alt","srcset","logo","Image","src","dimensions","width","height","svgWrapper","canvas","getTagSize","node","classList","visibleElement","arrayFind","arrayFrom","children","element","ownerDocument","defaultView","getWindowFromElement","getComputedStyle","getPropertyValue","size","contains","toUpperCase","getActiveTags","querySelector","subHeadline","disclaimer","Message","useXProps","amount","currency","buyerCountry","style","offer","payerId","clientId","merchantId","version","env","onClick","onReady","onHover","onMarkup","resize","useServerData","markup","meta","parentStyles","warnings","setServerData","dimensionsRef","useRef","buttonRef","handleHover","useLayoutEffect","styles","activeTags","current","messageRequestId","useDidUpdateLayoutEffect","buttonWidth","offsetWidth","buttonHeight","offsetHeight","useDidUpdateEffect","query","objectEntries","message_request_id","buyer_country","credit_type","payer_id","client_id","merchant_id","filter","Boolean","reduce","acc","val","encodeURIComponent","JSON","stringify","request","window","location","origin","then","type","ref","onMouseOver","onFocus","aria-label","display","background","padding","border","outline","textAlign","align","fontFamily","fontSize","setupMessage","render","body"],"mappings":"uBACE,SAASA,EAAqBC,GAQ7B,IAPA,IAMIC,EAAUC,EANVC,EAAWH,EAAK,GAChBI,EAAcJ,EAAK,GACnBK,EAAi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C,OAA3B,qCAAsEnB,GAASoB,MAAK,YAAc,YAAX9K,EAAW,EAAXA,KAC1F0I,EAAc,CACVJ,OAAM,SAAEtI,EAAKsI,QAAP,EAAiBA,EACvBC,KAAI,SAAEvI,EAAKuI,MAAP,EAAeA,EAEnBC,aAAY,SAAExI,EAAKwI,cAAP,EAAuBA,EACnCC,SAAQ,SAAEzI,EAAKyI,UAAP,EAAmBA,SAGpC,CAACnB,EAAQC,EAAUC,EAAcgD,KAAKC,UAAUhD,GAAQC,EAAOC,EAASC,EAAUC,IAGjF,sBACIkD,KAAK,SACLC,IAAKnC,EACLb,QA3EY,WACO,mBAAZA,GACPA,EAAQ,CAAEO,UA0EV0C,YAAanC,EACboC,QAASpC,EACTqC,aAAW,wBACX1D,MAAO,CACH2D,QAAS,QACTC,WAAY,cACZC,QAAS,EACTC,OAAQ,OACRC,QAAS,OACTC,WAAgB,MAALhE,GAAA,SAAAA,EAAOvD,WAAP,IAAawH,QAAS,OACjCC,WAAY,UACZC,SAAU,WAEd5G,UAAWsD,KCjHhB,SAASuD,EAAT,GAAgE,IAAxCvD,EAAwC,EAAxCA,OAAQC,EAAgC,EAAhCA,KAAMC,EAA0B,EAA1BA,aAAcC,EAAY,EAAZA,SACvDqD,YACI,YAAC,IAAD,KACI,YAAC,IAAD,CAAoB9L,KAAM,CAAEsI,SAAQC,OAAMC,eAAcC,aACpD,YAAC,EAAD,QAGRrE,SAAS2H","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([155,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';\nimport arrayFlatMap from 'core-js-pure/stable/array/flat-map';\nimport arrayIncludes from 'core-js-pure/stable/array/includes';\nimport stringStartsWith from 'core-js-pure/stable/string/starts-with';\nimport { ZalgoPromise } from 'zalgo-promise/src';\n\nimport { curry } from './functional';\nimport { objectMerge, flattenedToObject } from './objects';\n\nexport const getWindowFromElement = node => node?.ownerDocument?.defaultView;\n\nexport const getTopWindow = () => {\n try {\n // Try to access body which will throw an error if cross domain\n return window.top.document.body && window.top;\n } catch (err) {\n return undefined;\n }\n};\n\n/**\n * Check if object is an HTMLElement instance\n * @param {HTMLElement} el Element to check\n * @returns {Boolean} Is an HTMLElement\n */\nexport function isElement(el) {\n return typeof HTMLElement === 'object'\n ? el instanceof HTMLElement\n : el && typeof el === 'object' && el !== null && el.nodeType === 1 && typeof el.nodeName === 'string';\n}\n\n/**\n * Return options object from valid container data attributes\n * @param {HTMLElement} container Container element with data attributes\n * @returns {Object} Options object\n */\nexport function getInlineOptions(container) {\n // Allows for data attributes dependent on camel casing to function properly.\n const attributeNameOverride = {\n buyercountry: 'buyerCountry',\n merchantid: 'merchantId',\n fontfamily: 'fontFamily',\n fontsource: 'fontSource',\n onclick: 'onClick',\n onapply: 'onApply',\n onrender: 'onRender',\n 'style-text-fontfamily': 'style-text-fontFamily',\n 'style-text-fontsource': 'style-text-fontSource'\n };\n\n const inlineEventHandlers = ['onclick', 'onapply', 'onrender'];\n\n const getOptionValue = (name, value) => {\n if (stringStartsWith(value, '[')) {\n try {\n return flattenedToObject(name, JSON.parse(value.replace(/'/g, '\"')));\n } catch (err) {} // eslint-disable-line no-empty\n }\n return flattenedToObject(name, value);\n };\n\n const dataOptions = arrayFrom(container.attributes)\n .filter(({ nodeName }) => stringStartsWith(nodeName, 'data-pp-'))\n .reduce((accumulator, { nodeName, nodeValue }) => {\n if (nodeValue) {\n const attributeName = nodeName.replace('data-pp-', '');\n const value = arrayIncludes(inlineEventHandlers, attributeName)\n ? // eslint-disable-next-line no-new-func\n new Function(nodeValue)\n : nodeValue;\n\n return objectMerge(\n accumulator,\n getOptionValue(attributeNameOverride[attributeName] ?? attributeName, value)\n );\n }\n\n return accumulator;\n }, {});\n\n if (\n !container.firstElementChild ||\n container.firstElementChild.tagName !== 'SCRIPT' ||\n container.firstElementChild.getAttribute('type') !== 'text/template'\n ) {\n return dataOptions;\n }\n\n // For custom banners with inline markup\n const markup = container.firstElementChild.textContent.trim();\n container.removeChild(container.firstElementChild);\n\n return objectMerge(dataOptions, { style: { markup } });\n}\n\n/**\n * Search for the first element of specified class name\n * @param {HTMLElement} container Container to search for element\n * @param {String} className Base element class name without prefix\n * @returns {HTMLElement} Matched element\n */\nexport const getElement = curry(\n (prefix, container, className) => container.getElementsByClassName(`${prefix}__${className}`)[0]\n);\n\n/**\n * Create a new style element and prepend it to the container\n * @param {HTMLElement} container Container element to prepend new style\n * @param {String} text Text content of the style element\n * @returns {void}\n */\nexport const prependStyle = curry((container, text) => {\n const elem = document.createElement('style');\n elem.textContent = text;\n container.insertBefore(elem, container.firstChild);\n});\n\n/**\n * Append text data into the container element\n * @param {HTMLElement} container Container element to append text\n * @param {any} obj Various inputs representing text to be appended\n * @returns {void}\n */\nexport const appendText = curry((container, obj) => {\n if (Array.isArray(obj)) {\n obj.forEach(elem => container.appendChild(elem));\n } else if (obj instanceof HTMLElement) {\n container.appendChild(obj);\n } else if (typeof obj === 'string') {\n const span = document.createElement('span');\n span.innerHTML = obj;\n container.appendChild(span);\n } else if (obj === false) {\n container.parentNode.removeChild(container);\n }\n});\n\n/**\n * Append text data into the container element\n * @param {HTMLElement} container Container element to append text\n * @param {any} obj Various inputs representing text to be appended\n * @returns {void}\n */\nexport const prependText = curry((container, obj) => {\n if (Array.isArray(obj)) {\n [...obj].reverse().forEach(elem => container.insertBefore(elem, container.firstChild));\n } else if (obj instanceof HTMLElement) {\n container.insertBefore(obj, container.firstChild);\n } else if (typeof obj === 'string') {\n const span = document.createElement('span');\n span.innerHTML = obj;\n container.insertBefore(span, container.firstChild);\n } else if (obj === false) {\n container.parentNode.removeChild(container);\n }\n});\n\n/**\n * Append a new image into the container element\n * @param {HTMLElement} container Container element to append image\n * @param {String} url Image src attribute\n * @param {String} alt Image alt attribute\n * @param {String} srcset Image srcset attribute\n * @returns {void}\n */\nexport const appendImage = curry((container, url, alt = 'PayPal Credit', srcset = '') => {\n if (Array.isArray(url)) {\n url.forEach(logo => appendImage(container, logo, alt));\n } else if (typeof url === 'string') {\n const logo = new Image();\n logo.alt = alt;\n logo.className = 'message__logo';\n logo.src = url;\n\n if (srcset) {\n logo.srcset = srcset;\n }\n\n container.appendChild(logo);\n } else if (typeof url === 'object') {\n const {\n src,\n dimensions: [width, height]\n } = url;\n\n const logo = new Image();\n logo.src = src;\n logo.alt = alt;\n\n const svgWrapper = document.createElement('div');\n svgWrapper.className = 'message__logo message__logo--svg';\n\n const canvas = document.createElement('canvas');\n canvas.height = height;\n canvas.width = width;\n\n svgWrapper.appendChild(logo);\n svgWrapper.appendChild(canvas);\n container.appendChild(svgWrapper);\n } else {\n container.parentNode.removeChild(container);\n }\n}, 2); // Need to manually set curry arity because of default parameters and transpiling\n\n/**\n * Ensure element is ready to be worked with. Necessary since\n * creating an iframe is asynchronous\n * @param {HTMLElement} element HTML Element\n * @returns {Promise} Promise resolves when element is ready\n */\nexport const waitForElementReady = element =>\n new ZalgoPromise(resolve => {\n if (element.tagName === 'IFRAME' && element.contentWindow.document.readyState !== 'complete') {\n element.addEventListener('load', resolve);\n } else {\n resolve();\n }\n });\n\n/**\n * Check if an element is within the current viewport\n * @param {HTMLElement} container DOM element\n * @returns {boolean} Visible or not visible\n */\nexport function isInViewport(container) {\n const containerRect = container.getBoundingClientRect();\n const containerWindow = getWindowFromElement(container);\n\n const bannerY = (containerRect.top + containerRect.bottom) / 2;\n const bannerX = (containerRect.left + containerRect.right) / 2;\n\n if (bannerY > containerWindow.innerHeight || bannerY < 0) {\n return false;\n }\n if (bannerX > containerWindow.innerWidth || bannerX < 0) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Check if an element is visually hidden on a page\n * @param {HTMLElement} container DOM element\n * @returns {boolean} Hidden or not hidden\n */\nexport function isHidden(container) {\n const containerWindow = getWindowFromElement(container);\n\n if (typeof containerWindow.getComputedStyle === 'function') {\n const containerStyles = containerWindow.getComputedStyle(container);\n if (\n containerStyles.getPropertyValue('display') === 'none' ||\n containerStyles.getPropertyValue('visibility') === 'hidden' ||\n containerStyles.getPropertyValue('clip') !== 'auto'\n )\n return true;\n }\n\n const containerRect = container.getBoundingClientRect();\n if (\n containerRect.left > containerWindow.document.body.scrollWidth ||\n containerRect.right < 0 ||\n containerRect.top > containerWindow.document.body.scrollHeight ||\n containerRect.bottom < 0\n )\n return true;\n\n return container.offsetWidth === 0 || container.offsetHeight === 0;\n}\n\nexport function getAllBySelector(selector) {\n if (typeof selector === 'string') {\n return arrayFrom(document.querySelectorAll(selector));\n }\n\n if (isElement(selector)) {\n return [selector];\n }\n\n if (Array.isArray(selector) && selector.every(isElement)) {\n return arrayFlatMap(selector, getAllBySelector);\n }\n\n return [];\n}\n\nexport const elementContains = (parentEl, childEl) => {\n if (\n (parentEl?.nodeType !== Node.ELEMENT_NODE && !(parentEl instanceof Window)) ||\n childEl?.nodeType !== Node.ELEMENT_NODE\n ) {\n return false;\n }\n\n const parentBounds =\n parentEl instanceof Window\n ? {\n top: 0,\n left: 0,\n bottom: parentEl.innerHeight,\n right: parentEl.innerWidth\n }\n : parentEl.getBoundingClientRect();\n const childBounds = childEl.getBoundingClientRect();\n\n return (\n parentBounds.top <= childBounds.top &&\n parentBounds.bottom >= childBounds.bottom &&\n parentBounds.left <= childBounds.left &&\n parentBounds.right >= childBounds.right\n );\n};\n\nexport const getRoot = baseElement => {\n const elementWindow = getWindowFromElement(baseElement);\n\n const domPath = [];\n {\n let el = baseElement;\n // Loop up the DOM tree to the root html node\n while (el?.parentNode.nodeType === Node.ELEMENT_NODE) {\n domPath.push(el.parentNode);\n el = el.parentNode;\n }\n }\n\n const root = arrayFind(domPath.reverse(), (el, index, elements) => {\n // We are searching for the element that contains the page scrolling.\n // Some merchant sites will use height 100% on elements such as html and body\n // that cause the intersection observer to hide elements below the fold.\n const height = el.offsetHeight;\n const child = elements[index + 1];\n\n return (\n // window.innerHeight has a variable value on mobile based on the URL bar so\n // we are looking for the element that is larger than the window\n // TODO: This could potentially provide a false positive if a merchant is using height 100vh\n height > elementWindow.innerHeight ||\n // Ensure that the selected root is the larger of the parent\n // and contains the child otherwise there may not be a proper page wrapper\n // e.g. https://www.acwholesalers.com\n (child && child.offsetHeight < height && elementContains(el.parentNode, el))\n );\n });\n\n // If the root element is entirely within the viewport then return undefined\n // so that the viewport is used as the root. This helps with position fixed\n // containers that may have content outside of the root element.\n return elementContains(elementWindow, root) ? undefined : root;\n};\n","import arrayFind from 'core-js-pure/stable/array/find';\nimport arrayFrom from 'core-js-pure/stable/array/from';\n\nimport { getWindowFromElement } from './elements';\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 =>\n getWindowFromElement(node)\n .getComputedStyle(element)\n .getPropertyValue('display') !== 'none'\n );\n\n if (!visibleElement) {\n return '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 buyerCountry,\n style,\n offer,\n payerId,\n clientId,\n merchantId,\n version,\n env,\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 buyer_country: buyerCountry,\n style,\n credit_type: offer,\n payer_id: payerId,\n client_id: clientId,\n merchant_id: merchantId,\n version,\n env\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, buyerCountry, 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":""}