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AO,OAAO,IACnC,UAAW,CAAE,MAAO,OAAO,OAAO,MAKxC,GAAI,GAAM,EAAK,EAAkB,CAAE,KAAM,MAGzC,IAAe","file":"scripts/9480.702b466c86c7254bc89f.js","sourcesContent":["import { Component } from '@verndale/core';\nimport Cookies from 'js-cookie';\n\nconst COOKIES_EVENT = 'cookies:ready';\n\nclass TfaForm extends Component {\n setupDefaults() {\n this.dom = {\n el: this.el\n };\n\n this.src = this.el.dataset.src;\n this.title = this.el.dataset.title;\n this.height = this.el.dataset.height;\n this.width = this.el.dataset.width;\n this.fields = JSON.parse(this.el.dataset.fields);\n this.redirectUrl = this.el.dataset.redirectUrl;\n this.loaded = false;\n this.cookiesReady = false;\n\n if (window.cookiesReady) {\n this.cookiesReady = true;\n this.initIframe();\n }\n }\n\n addListeners() {\n if (!this.cookiesReady) {\n window.addEventListener(COOKIES_EVENT, this.initIframe.bind(this));\n }\n }\n\n initSkeleton() {\n // we will create a skeleton here for the iframe form until is loaded\n\n const skeletonDiv = document.createElement('div');\n skeletonDiv.setAttribute('class', 'skeleton-form__tfa');\n skeletonDiv.setAttribute(\n 'style',\n `width: ${this.width}; height: ${this.height};`\n );\n\n const skeletonForm = document.createElement('div');\n skeletonForm.setAttribute('class', 'skeleton__form');\n\n for (let i = 0; i < 6; i++) {\n const skeletonFieldContainer = document.createElement('div');\n const skeletonLabel = document.createElement('div');\n const skeletonField = document.createElement('div');\n\n skeletonLabel.setAttribute('class', 'skeleton skeleton__label');\n skeletonField.setAttribute('class', 'skeleton skeleton__field');\n\n skeletonFieldContainer.setAttribute('class', 'skeleton__field-container');\n\n skeletonFieldContainer.appendChild(skeletonLabel);\n skeletonFieldContainer.appendChild(skeletonField);\n\n skeletonForm.appendChild(skeletonFieldContainer);\n }\n\n const skeletonSubmit = document.createElement('div');\n skeletonSubmit.setAttribute('class', 'skeleton skeleton__submit');\n skeletonForm.appendChild(skeletonSubmit);\n\n skeletonDiv.appendChild(skeletonForm);\n\n this.dom.el.appendChild(skeletonDiv);\n }\n\n initIframe() {\n if (typeof window.setURLCookie === 'function') {\n if (Cookies.get('transactionid')) window.setURLCookie(true);\n else window.setURLCookie(false);\n }\n\n let queryString = '';\n\n this.fields.forEach(field => {\n const cookieValue = Cookies.get(field.cookie);\n if (cookieValue) {\n queryString += `&${field.parameter}=${cookieValue}`;\n }\n });\n\n const url = queryString ? `${this.src}?${queryString.slice(1)}` : this.src;\n\n this.iframe = document.createElement('iframe');\n this.iframe.setAttribute('src', url);\n this.iframe.setAttribute('title', this.title);\n this.iframe.setAttribute('width', this.width);\n this.iframe.setAttribute('height', this.height);\n this.iframe.setAttribute('frameborder', '0');\n this.iframe.setAttribute('scrolling', 'yes');\n this.iframe.setAttribute('style', 'border: none;');\n this.iframe.style.display = 'none';\n\n this.dom.el.appendChild(this.iframe);\n\n if (this.redirectUrl) {\n this.iframe.addEventListener('load', this.handleIframeLoad.bind(this));\n setTimeout(() => {\n if (!this.loaded) {\n this.dom.el.querySelector('.skeleton-form__tfa').style.display =\n 'none';\n this.iframe.style.display = 'block';\n }\n }, 2000);\n }\n\n this.initSkeleton();\n }\n\n handleIframeLoad() {\n if (this.loaded) {\n window.location.href = this.redirectUrl;\n }\n\n // if the iframe is loaded, we will set the loaded flag to true and hide the skeleton\n this.loaded = true;\n this.dom.el.querySelector('.skeleton-form__tfa').style.display = 'none';\n this.iframe.style.display = 'block';\n }\n}\n\nexport default TfaForm;\n","/*! js-cookie v3.0.1 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (key, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n key = encodeURIComponent(key)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n key + '=' + converter.write(value, key) + stringifiedAttributes)\n }\n\n function get (key) {\n if (typeof document === 'undefined' || (arguments.length && !key)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var foundKey = decodeURIComponent(parts[0]);\n jar[foundKey] = converter.read(value, foundKey);\n\n if (key === foundKey) {\n break\n }\n } catch (e) {}\n }\n\n return key ? jar[key] : jar\n }\n\n return Object.create(\n {\n set: set,\n get: get,\n remove: function (key, attributes) {\n set(\n key,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport default api;\n"],"sourceRoot":""}