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c8E,GAC9CR,EAAcrD,WAAWuE,YAAYlB,EAAc,GAE3D,EAwDAoB,CAAe,CACXjB,SACAH,gBACApE,eACAwD,iBACAG,WACAF,kBACAG,YACAY,uBACAC,uBACAC,sCAEJP,EAASC,GACTV,SAAgDA,GAAQ,EG1K1D+B,CAAc,CACZxG,YACAqE,iBAAkB,8BAClBC,qBAAsB,iCACtBC,eAAgB,yBAChBC,gBAAiB,0BACjBzC,aAAc,8BACd2C,SAAU+B,IACmBA,EAAOC,MAAKvF,GAASA,EAAME,UAAY4C,KAEnC3B,SAASS,iBAAiB,sBAClCC,SAAQgB,IAC7B,MAAM2C,EAAQ3C,EAAa6B,QAAQE,WAAU,GAC7C/B,EAAalC,WAAWC,aAAa4E,EAAO3C,EAAa,GACzD,GAEJ,EAKFD,EAAe,G","sources":["webpack://openforms/./node_modules/django-cookie-consent/lib/cookiebar.js","webpack://openforms/./src/openforms/js/utils/dom.js","webpack://openforms/./src/openforms/js/components/auth-mode.js","webpack://openforms/./src/openforms/js/public.js"],"sourcesContent":["/**\n * Cookiebar functionality, as a TS/JS module.\n *\n * About modules: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\n *\n * The code is organized here in a way to make the templates work with Django's page\n * cache. This means that anything user-specific (so different django session and even\n * cookie consent cookies) cannot be baked into the templates, as that breaks caches.\n *\n * The cookie bar operates on the following principles:\n *\n * - The developer using the library includes the desired template in their django\n *   templates, using the HTML <template> element. This contains the content for the\n *   cookie bar.\n * - The developer is responsible for loading some Javascript that loads this script.\n * - The main export of this script needs to be called (showCookieBar), with the\n *   appropriate options.\n * - The options include the backend URLs where the retrieve data, which selectors/DOM\n *   nodes to use for various functionality and the hooks to tap into the accept/decline\n *   life-cycle.\n * - When a user accepts or declines (all) cookies, the call to the backend is made via\n *   a fetch request, bypassing any page caches and preventing full-page reloads.\n */\n;\nconst DEFAULT_FETCH_HEADERS = {\n    'X-Cookie-Consent-Fetch': '1'\n};\n/**\n * A simple wrapper around window.fetch that understands the django-cookie-consent\n * backend endpoints.\n *\n * @private - while exported, use at your own risk. This class is not part of the\n * public API covered by SemVer.\n */\nexport class FetchClient {\n    constructor(statusUrl, csrfHeaderName) {\n        this.statusUrl = statusUrl;\n        this.csrfHeaderName = csrfHeaderName;\n        this.cookieStatus = null;\n    }\n    async getCookieStatus() {\n        if (this.cookieStatus === null) {\n            const response = await window.fetch(this.statusUrl, {\n                method: 'GET',\n                credentials: 'same-origin',\n                headers: DEFAULT_FETCH_HEADERS,\n            });\n            this.cookieStatus = await response.json();\n        }\n        // type checker sanity check\n        if (this.cookieStatus === null) {\n            throw new Error('Unexpectedly received null cookie status');\n        }\n        return this.cookieStatus;\n    }\n    ;\n    async saveCookiesStatusBackend(urlProperty, cookieGroups) {\n        const cookieStatus = await this.getCookieStatus();\n        const url = cookieStatus[urlProperty];\n        if (!url) {\n            throw new Error(`Missing url for ${urlProperty} - was the cookie status not loaded properly?`);\n        }\n        const formData = new FormData();\n        for (const group of cookieGroups) {\n            formData.append('cookie_groups', group.varname);\n        }\n        await window.fetch(url, {\n            method: 'POST',\n            body: formData,\n            credentials: 'same-origin',\n            headers: Object.assign(Object.assign({}, DEFAULT_FETCH_HEADERS), { [this.csrfHeaderName]: cookieStatus.csrftoken })\n        });\n    }\n}\n/**\n * Read the JSON script node contents and parse the content as JSON.\n *\n * The result is the list of available/configured cookie groups.\n * Use the status URL to get the accepted/declined status for an individual user.\n */\nexport const loadCookieGroups = (selector) => {\n    const node = document.querySelector(selector);\n    if (!node) {\n        throw new Error(`No cookie groups (script) tag found, using selector: '${selector}'`);\n    }\n    return JSON.parse(node.innerText);\n};\nconst doInsertBefore = (beforeNode, newNode) => {\n    const parent = beforeNode.parentNode;\n    if (parent === null)\n        throw new Error('Reference node doesn\\'t have a parent.');\n    parent.insertBefore(newNode, beforeNode);\n};\n/**\n * Register the accept/decline event handlers.\n *\n * Note that we can't just set the decline or accept cookie purely client-side, as the\n * cookie possibly has the httpOnly flag set.\n */\nconst registerEvents = ({ client, cookieBarNode, cookieGroups, acceptSelector, onAccept, declineSelector, onDecline, acceptedCookieGroups: accepted, declinedCookieGroups: declined, notAcceptedOrDeclinedCookieGroups: undecided, }) => {\n    const acceptNode = cookieBarNode.querySelector(acceptSelector);\n    if (acceptNode) {\n        acceptNode.addEventListener('click', event => {\n            event.preventDefault();\n            const acceptedGroups = filterCookieGroups(cookieGroups, accepted.concat(undecided));\n            onAccept === null || onAccept === void 0 ? void 0 : onAccept(acceptedGroups, event);\n            // trigger async action, but don't wait for completion\n            client.saveCookiesStatusBackend('acceptUrl', acceptedGroups);\n            cookieBarNode.parentNode.removeChild(cookieBarNode);\n        });\n    }\n    const declineNode = cookieBarNode.querySelector(declineSelector);\n    if (declineNode) {\n        declineNode.addEventListener('click', event => {\n            event.preventDefault();\n            const declinedGroups = filterCookieGroups(cookieGroups, declined.concat(undecided));\n            onDecline === null || onDecline === void 0 ? void 0 : onDecline(declinedGroups, event);\n            // trigger async action, but don't wait for completion\n            client.saveCookiesStatusBackend('declineUrl', declinedGroups);\n            cookieBarNode.parentNode.removeChild(cookieBarNode);\n        });\n    }\n};\n/**\n * Filter the cookie groups down to a subset of specified varnames.\n */\nconst filterCookieGroups = (cookieGroups, varNames) => {\n    return cookieGroups.filter(group => varNames.includes(group.varname));\n};\n// See https://github.com/microsoft/TypeScript/issues/283\nfunction cloneNode(node) {\n    return node.cloneNode(true);\n}\nexport const showCookieBar = async (options = {}) => {\n    const { templateSelector = '#cookie-consent__cookie-bar', cookieGroupsSelector = '#cookie-consent__cookie-groups', acceptSelector = '.cookie-consent__accept', declineSelector = '.cookie-consent__decline', insertBefore = null, onShow, onAccept, onDecline, statusUrl = '', csrfHeaderName = 'X-CSRFToken', // Django's default, can be overridden with settings.CSRF_HEADER_NAME\n     } = options;\n    const cookieGroups = loadCookieGroups(cookieGroupsSelector);\n    // no cookie groups -> abort, nothing to do\n    if (!cookieGroups.length)\n        return;\n    const templateNode = document.querySelector(templateSelector);\n    if (!templateNode) {\n        throw new Error(`No (template) element found for selector '${templateSelector}'.`);\n    }\n    // insert before a given node, if specified, or append to the body as default behaviour\n    const doInsert = insertBefore === null\n        ? (cookieBarNode) => document.querySelector('body').appendChild(cookieBarNode)\n        : typeof insertBefore === 'string'\n            ? (cookieBarNode) => {\n                const referenceNode = document.querySelector(insertBefore);\n                if (referenceNode === null)\n                    throw new Error(`No element found for selector '${insertBefore}'.`);\n                doInsertBefore(referenceNode, cookieBarNode);\n            }\n            : (cookieBarNode) => doInsertBefore(insertBefore, cookieBarNode);\n    if (!statusUrl)\n        throw new Error('Missing status URL option, did you forget to pass the `statusUrl` option?');\n    const client = new FetchClient(statusUrl, csrfHeaderName);\n    const cookieStatus = await client.getCookieStatus();\n    // calculate the cookie groups to invoke the callbacks. We deliberately fire those\n    // without awaiting so that our cookie bar is shown/hidden as soon as possible.\n    const { acceptedCookieGroups, declinedCookieGroups, notAcceptedOrDeclinedCookieGroups } = cookieStatus;\n    const acceptedGroups = filterCookieGroups(cookieGroups, acceptedCookieGroups);\n    if (acceptedGroups.length)\n        onAccept === null || onAccept === void 0 ? void 0 : onAccept(acceptedGroups);\n    const declinedGroups = filterCookieGroups(cookieGroups, declinedCookieGroups);\n    if (declinedGroups.length)\n        onDecline === null || onDecline === void 0 ? void 0 : onDecline(declinedGroups);\n    // there are no (more) cookie groups to accept, don't show the bar\n    if (!notAcceptedOrDeclinedCookieGroups.length)\n        return;\n    // grab the contents from the template node and add them to the DOM, optionally\n    // calling the onShow callback\n    const childToClone = templateNode.content.firstElementChild;\n    if (childToClone === null)\n        throw new Error('The cookie bar template element may not be empty.');\n    const cookieBarNode = cloneNode(childToClone);\n    registerEvents({\n        client,\n        cookieBarNode,\n        cookieGroups,\n        acceptSelector,\n        onAccept,\n        declineSelector,\n        onDecline,\n        acceptedCookieGroups,\n        declinedCookieGroups,\n        notAcceptedOrDeclinedCookieGroups,\n    });\n    doInsert(cookieBarNode);\n    onShow === null || onShow === void 0 ? void 0 : onShow();\n};\n","const onLoaded = callback => {\n  if (document.readyState !== 'loading') {\n    callback();\n  } else {\n    document.addEventListener('DOMContentLoaded', event => callback());\n  }\n};\n\nexport {onLoaded};\n","import {onLoaded} from 'utils/dom';\n\nconst onModeSelect = event => {\n  const {value: mode, checked} = event.target;\n  if (!checked) return;\n\n  const nodesToHide = document.querySelectorAll(`.auth-mode:not(.auth-mode--${mode})`);\n  nodesToHide.forEach(node => {\n    node.classList.remove('auth-mode--active');\n    node.querySelectorAll('input').forEach(input => (input.value = ''));\n  });\n\n  const nodesToShow = document.querySelectorAll(`.auth-mode.auth-mode--${mode}`);\n  nodesToShow.forEach(node => node.classList.add('auth-mode--active'));\n};\n\nconst init = () => {\n  const radios = document.querySelectorAll('#registrator-subject [name=\"mode\"]');\n  if (!radios.length) return;\n\n  radios.forEach(node => {\n    node.addEventListener('change', onModeSelect);\n    node.dispatchEvent(new Event('change'));\n  });\n};\n\nonLoaded(init);\n","import {showCookieBar} from 'django-cookie-consent';\n\nimport 'components/auth-mode';\nimport {onLoaded} from 'utils/dom';\n\n// connect the \"Print this page\" link element to a handler\nconst registerPrintHandler = () => {\n  const node = document.getElementById('print-button');\n  if (!node) return;\n  node.addEventListener('click', event => {\n    event.preventDefault();\n    window.print();\n  });\n};\n\nconst initCookieBar = () => {\n  const templateNode = document.getElementById('cookie-consent__cookie-bar');\n  if (!templateNode) return;\n\n  const {varName, statusUrl} = templateNode.dataset;\n  showCookieBar({\n    statusUrl,\n    templateSelector: '#cookie-consent__cookie-bar',\n    cookieGroupsSelector: '#cookie-consent__cookie-groups',\n    acceptSelector: '.cookie-notice__accept',\n    declineSelector: '.cookie-notice__decline',\n    insertBefore: '#cookie-consent__cookie-bar',\n    onAccept: groups => {\n      const isAnalyticsEnabled = groups.find(group => group.varname === varName);\n      if (!isAnalyticsEnabled) return;\n      const analyticsTemplateNodes = document.querySelectorAll('.analytics-scripts');\n      analyticsTemplateNodes.forEach(templateNode => {\n        const clone = templateNode.content.cloneNode(true);\n        templateNode.parentNode.insertBefore(clone, templateNode);\n      });\n    },\n  });\n};\n\nconst init = () => {\n  registerPrintHandler();\n  initCookieBar();\n};\n\nonLoaded(init);\n"],"names":["DEFAULT_FETCH_HEADERS","FetchClient","constructor","statusUrl","csrfHeaderName","this","cookieStatus","getCookieStatus","response","window","fetch","method","credentials","headers","json","Error","saveCookiesStatusBackend","urlProperty","cookieGroups","url","formData","FormData","group","append","varname","body","Object","assign","csrftoken","doInsertBefore","beforeNode","newNode","parent","parentNode","insertBefore","filterCookieGroups","varNames","filter","includes","onLoaded","callback","document","readyState","addEventListener","event","onModeSelect","value","mode","checked","target","querySelectorAll","forEach","node","classList","remove","input","add","init","radios","length","dispatchEvent","Event","registerPrintHandler","getElementById","preventDefault","print","initCookieBar","templateNode","varName","dataset","async","options","templateSelector","cookieGroupsSelector","acceptSelector","declineSelector","onShow","onAccept","onDecline","selector","querySelector","JSON","parse","innerText","loadCookieGroups","doInsert","cookieBarNode","appendChild","referenceNode","client","acceptedCookieGroups","declinedCookieGroups","notAcceptedOrDeclinedCookieGroups","acceptedGroups","declinedGroups","childToClone","content","firstElementChild","cloneNode","accepted","declined","undecided","acceptNode","concat","removeChild","declineNode","registerEvents","showCookieBar","groups","find","clone"],"sourceRoot":""}