{"version":3,"file":"nrkno-masthead-render.min.js","sources":["../node_modules/@nrk/core-toggle/core-toggle.cjs.js","../node_modules/@nrk/core-icons/core-icons.mjs","../node_modules/@nrk/nrkno-login-connector/connector.js","../nrkno-masthead-banners.js","../nrkno-masthead-initialize.js","../nrkno-masthead.js"],"sourcesContent":["'use strict';\n\nvar name = \"@nrk/core-toggle\";\nvar version = \"2.2.2\";\n\nvar IS_BROWSER = typeof window !== 'undefined';\nvar IS_ANDROID = IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed\nvar IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform));\nvar HAS_EVENT_OPTIONS = (function (has) {\n if ( has === void 0 ) has = false;\n\n try { window.addEventListener('test', null, { get passive () { has = true; } }); } catch (e) {}\n return has\n})();\n\n/**\n* addEvent\n* @param {String} uuid An unique ID of the event to bind - ensurnes single instance\n* @param {String} type The type of event to bind\n* @param {Function} handler The function to call on event\n* @param {Boolean|Object} options useCapture or options object for addEventListener. Defaults to false\n*/\nfunction addEvent (uuid, type, handler, options) {\n if ( options === void 0 ) options = false;\n\n if (typeof window === 'undefined' || window[uuid = uuid + \"-\" + type]) { return } // Ensure single instance\n if (!HAS_EVENT_OPTIONS && typeof options === 'object') { options = Boolean(options.capture); } // Fix unsupported options\n var node = (type === 'resize' || type === 'load') ? window : document;\n node.addEventListener(window[uuid] = type, handler, options);\n}\n\n/**\n* dispatchEvent - with infinite loop prevention\n* @param {Element} elem The target object\n* @param {String} name The source object(s)\n* @param {Object} detail Detail object (bubbles and cancelable is set to true)\n* @return {Boolean} Whether the event was canceled\n*/\nvar IGNORE = 'prevent_recursive_dispatch_maximum_callstack';\nfunction dispatchEvent (element, name, detail) {\n if ( detail === void 0 ) detail = {};\n\n var ignore = \"\" + IGNORE + name;\n var event;\n\n if (element[ignore]) { return true } // We are already processing this event, so skip sending a new one\n else { element[ignore] = true; } // Add name to dispatching ignore\n\n if (typeof window.CustomEvent === 'function') {\n event = new window.CustomEvent(name, { bubbles: true, cancelable: true, detail: detail });\n } else {\n event = document.createEvent('CustomEvent');\n event.initCustomEvent(name, true, true, detail);\n }\n // IE reports incorrect event.defaultPrevented\n // but correct return value on element.dispatchEvent\n var result = element.dispatchEvent(event);\n element[ignore] = null; // Remove name from dispatching ignore\n\n return result // Follow W3C standard for return value\n}\n\n/**\n* getUUID\n* @return {String} A generated unique ID\n*/\nfunction getUUID (el) {\n return Date.now().toString(36) + Math.random().toString(36).slice(2, 5)\n}\n\n/**\n* queryAll\n* @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element\n* @return {Element[]} Array of elements\n*/\nfunction queryAll (elements, context) {\n if ( context === void 0 ) context = document;\n\n if (elements) {\n if (elements.nodeType) { return [elements] }\n if (typeof elements === 'string') { return [].slice.call(context.querySelectorAll(elements)) }\n if (elements.length) { return [].slice.call(elements) }\n }\n return []\n}\n\nvar UUID = (\"data-\" + name + \"-\" + version).replace(/\\W+/g, '-'); // Strip invalid attribute characters\nvar ARIA = IS_ANDROID ? 'data' : 'aria'; // Andriod has a bug and reads only label instead of content\nvar KEYS = { ESC: 27 };\n\nfunction toggle (toggles, open) {\n var options = typeof open === 'object' ? open : { open: open };\n if (IS_IOS) { document.documentElement.style.cursor = 'pointer'; } // Fix iOS events for closing popups (https://stackoverflow.com/a/16006333/8819615)\n\n return queryAll(toggles).map(function (toggle) {\n var content = getContentElement(toggle);\n var isOpen = toggle.getAttribute('aria-expanded') === 'true';\n var open = typeof options.open === 'boolean' ? options.open : (options.open === 'toggle' ? !isOpen : isOpen);\n var popup = String((options.hasOwnProperty('popup') ? options.popup : toggle.getAttribute(UUID)) || false);\n\n if (options.value) { toggle.innerHTML = options.value; } // Set innerHTML before updating aria-label\n if (popup !== 'false' && popup !== 'true') { toggle.setAttribute('aria-label', ((toggle.textContent) + \", \" + popup)); } // Only update aria-label if popup-mode\n\n toggle.setAttribute(UUID, popup); // aria-haspopup triggers forms mode in JAWS, therefore store in uuid\n toggle.setAttribute('aria-controls', content.id = content.id || getUUID());\n content.setAttribute((ARIA + \"-labelledby\"), toggle.id = toggle.id || getUUID());\n setOpen(toggle, open);\n return toggle\n })\n}\n\nfunction getContentElement (toggle) {\n return document.getElementById(toggle.getAttribute('aria-controls')) || toggle.nextElementSibling\n}\n\naddEvent(UUID, 'keydown', function (event) {\n if (event.keyCode !== KEYS.ESC) { return }\n for (var el = event.target; el; el = el.parentElement) {\n var toggle = (el.id && document.querySelector((\"[aria-controls=\\\"\" + (el.id) + \"\\\"]\"))) || el;\n\n if (toggle.getAttribute(UUID) !== 'false' && toggle.getAttribute('aria-expanded') === 'true') {\n event.preventDefault(); // Prevent leaving maximized window in Safari\n toggle.focus();\n return setOpen(toggle, false)\n }\n }\n}, true); // Use capture to enable checking defaultPrevented (from ESC key) in parents\n\naddEvent(UUID, 'click', function (ref) {\n var target = ref.target;\n var defaultPrevented = ref.defaultPrevented;\n\n if (defaultPrevented) { return false } // Do not toggle if someone run event.preventDefault()\n\n for (var el = target, item = (void 0); el; el = el.parentElement) {\n var toggle = item && el.id && document.querySelector((\"[\" + UUID + \"][aria-controls=\\\"\" + (el.id) + \"\\\"]\"));\n if ((el.nodeName === 'BUTTON' || el.nodeName === 'A') && !el.hasAttribute(UUID)) { item = el; } // interactive element clicked\n if (toggle) {\n dispatchEvent(toggle, 'toggle.select', {\n relatedTarget: getContentElement(toggle),\n currentTarget: item,\n value: item.textContent.trim()\n });\n break\n }\n }\n\n queryAll((\"[\" + UUID + \"]\")).forEach(function (toggle) {\n var open = toggle.getAttribute('aria-expanded') === 'true';\n var popup = toggle.getAttribute(UUID) !== 'false';\n var content = getContentElement(toggle);\n\n if (toggle.contains(target)) { setOpen(toggle, !open); } // Click on toggle\n else if (popup && open) { setOpen(toggle, content.contains(target)); } // Click in content or outside\n });\n});\n\nfunction setOpen (toggle, open) {\n var content = getContentElement(toggle);\n var isOpen = toggle.getAttribute('aria-expanded') === 'true';\n var willOpen = typeof open === 'boolean' ? open : (open === 'toggle' ? !isOpen : isOpen);\n var isUpdate = isOpen === willOpen || dispatchEvent(toggle, 'toggle', { relatedTarget: content, isOpen: isOpen, willOpen: willOpen });\n var nextOpen = isUpdate ? willOpen : toggle.getAttribute('aria-expanded') === 'true'; // dispatchEvent can change attributes\n var focus = !isOpen && nextOpen && content.querySelector('[autofocus]');\n\n if (focus) { setTimeout(function () { return focus && focus.focus(); }); } // Move focus on next render (if element stil exists)\n\n toggle.setAttribute('aria-expanded', nextOpen);\n content[nextOpen ? 'removeAttribute' : 'setAttribute']('hidden', '');\n}\n\nmodule.exports = toggle;\n","export const nrk360 = ''\nexport const nrk404 = ''\nexport const nrkArrowDropdown = ''\nexport const nrkArrowLeftLong = ''\nexport const nrkArrowLeft = ''\nexport const nrkArrowRightLong = ''\nexport const nrkArrowRight = ''\nexport const nrkArticle = ''\nexport const nrkBack = ''\nexport const nrkBellActive = ''\nexport const nrkBell = ''\nexport const nrkBookmarkActive = ''\nexport const nrkBookmark = ''\nexport const nrkBroadcast = ''\nexport const nrkCalendar = ''\nexport const nrkCategory = ''\nexport const nrkCheckActive = ''\nexport const nrkCheck = ''\nexport const nrkChevronDown = ''\nexport const nrkChevronLeft = ''\nexport const nrkChevronRight = ''\nexport const nrkChevronUp = ''\nexport const nrkCloseActive = ''\nexport const nrkClose = ''\nexport const nrkComment = ''\nexport const nrkDice1Active = ''\nexport const nrkDice1 = ''\nexport const nrkDice2Active = ''\nexport const nrkDice2 = ''\nexport const nrkDice3Active = ''\nexport const nrkDice3 = ''\nexport const nrkDice4Active = ''\nexport const nrkDice4 = ''\nexport const nrkDice5Active = ''\nexport const nrkDice5 = ''\nexport const nrkDice6Active = ''\nexport const nrkDice6 = ''\nexport const nrkDownload = ''\nexport const nrkDuration = ''\nexport const nrkEllipsisActive = ''\nexport const nrkEllipsis = ''\nexport const nrkFullscreenActive = ''\nexport const nrkFullscreen = ''\nexport const nrkGallery = ''\nexport const nrkGeoActive = ''\nexport const nrkGeo = ''\nexport const nrkGeopointActive = ''\nexport const nrkGeopoint = ''\nexport const nrkGlobe = ''\nexport const nrkHardwareCamera = ''\nexport const nrkHardwareComputer = ''\nexport const nrkHardwareGame = ''\nexport const nrkHardwareLaptop = ''\nexport const nrkHardwareMobile = ''\nexport const nrkHardwarePrinter = ''\nexport const nrkHardwareRadio = ''\nexport const nrkHardwareSmartSpeaker = ''\nexport const nrkHardwareSmartWatch = ''\nexport const nrkHardwareSpeaker = ''\nexport const nrkHardwareTablet = ''\nexport const nrkHardwareTv = ''\nexport const nrkHardwareWatch = ''\nexport const nrkHeartActive = ''\nexport const nrkHeart = ''\nexport const nrkHelp = ''\nexport const nrkHomeActive = ''\nexport const nrkHome = ''\nexport const nrkInfo = ''\nexport const nrkLatestNewsActive = ''\nexport const nrkLatestNews = ''\nexport const nrkLink = ''\nexport const nrkList = ''\nexport const nrkLockActive = ''\nexport const nrkLock = ''\nexport const nrkLogoMgp = ''\nexport const nrkLogoNrk1Colorblack = ''\nexport const nrkLogoNrk1Colorgrey = ''\nexport const nrkLogoNrk1Colorwhite = ''\nexport const nrkLogoNrk1 = ''\nexport const nrkLogoNrk2Colorblack = ''\nexport const nrkLogoNrk2Colorgrey = ''\nexport const nrkLogoNrk2Colorwhite = ''\nexport const nrkLogoNrk2 = ''\nexport const nrkLogoNrk3Colorblack = ''\nexport const nrkLogoNrk3Colorgrey = ''\nexport const nrkLogoNrk3Colorwhite = ''\nexport const nrkLogoNrk3 = ''\nexport const nrkLogoNrkAlltidNyheter = ''\nexport const nrkLogoNrkFolkemusikk = ''\nexport const nrkLogoNrkJazz = ''\nexport const nrkLogoNrkKlassisk = ''\nexport const nrkLogoNrkMp3Symbol = ''\nexport const nrkLogoNrkMp3 = ''\nexport const nrkLogoNrkNyheterSymbolBlackwhite = ''\nexport const nrkLogoNrkNyheterSymbolColor = ''\nexport const nrkLogoNrkNyheterSymbol = ''\nexport const nrkLogoNrkNyheter = ''\nexport const nrkLogoNrkP1Pluss = ''\nexport const nrkLogoNrkP1 = ''\nexport const nrkLogoNrkP13Radioresepsjonen = ''\nexport const nrkLogoNrkP13 = ''\nexport const nrkLogoNrkP2 = ''\nexport const nrkLogoNrkP3NationalRapShow = ''\nexport const nrkLogoNrkP3Symbol = ''\nexport const nrkLogoNrkP3Urort = ''\nexport const nrkLogoNrkP3X = ''\nexport const nrkLogoNrkP3 = ''\nexport const nrkLogoNrkRadio = ''\nexport const nrkLogoNrkSapmi = ''\nexport const nrkLogoNrkSportSymbolBlackwhite = ''\nexport const nrkLogoNrkSportSymbolColor = ''\nexport const nrkLogoNrkSportSymbol = ''\nexport const nrkLogoNrkSport = ''\nexport const nrkLogoNrkSuperSentrert = ''\nexport const nrkLogoNrkSuperSymbol = ''\nexport const nrkLogoNrkSuper = ''\nexport const nrkLogoNrkTegnspraakColorblack = ''\nexport const nrkLogoNrkTegnspraakColorgrey = ''\nexport const nrkLogoNrkTegnspraakColorwhite = ''\nexport const nrkLogoNrkTegnspraak = ''\nexport const nrkLogoNrkTv = ''\nexport const nrkLogoNrk = ''\nexport const nrkLogoYrBlackwhite = ''\nexport const nrkLogoYrColor = ''\nexport const nrkLogoYr = ''\nexport const nrkLongreadActive = ''\nexport const nrkLongread = ''\nexport const nrkLyn = ''\nexport const nrkMat = ''\nexport const nrkMedia404Notfound = ''\nexport const nrkMediaAirplayActive = ''\nexport const nrkMediaAirplay = ''\nexport const nrkMediaChromecast1 = ''\nexport const nrkMediaChromecast2 = ''\nexport const nrkMediaChromecast3 = ''\nexport const nrkMediaChromecastActive = ''\nexport const nrkMediaChromecast = ''\nexport const nrkMediaCompleted = ''\nexport const nrkMediaDirekteActive = ''\nexport const nrkMediaDirekte = ''\nexport const nrkMediaDirektetvActive = ''\nexport const nrkMediaDirektetv = ''\nexport const nrkMediaFfw15sec = ''\nexport const nrkMediaFfw30sec = ''\nexport const nrkMediaFfw = ''\nexport const nrkMediaNext = ''\nexport const nrkMediaNy = ''\nexport const nrkMediaPause = ''\nexport const nrkMediaPictureInPictureActive = ''\nexport const nrkMediaPictureInPicture = ''\nexport const nrkMediaPlayFail = ''\nexport const nrkMediaPlay = ''\nexport const nrkMediaPrevious = ''\nexport const nrkMediaProgramguideActive = ''\nexport const nrkMediaProgramguide = ''\nexport const nrkMediaRwd15sec = ''\nexport const nrkMediaRwd30sec = ''\nexport const nrkMediaRwd = ''\nexport const nrkMediaSoundwave = ''\nexport const nrkMediaStop = ''\nexport const nrkMediaSubtitlesActive = ''\nexport const nrkMediaSubtitlesUnavailable = ''\nexport const nrkMediaSubtitles = ''\nexport const nrkMediaTheaterActive = ''\nexport const nrkMediaTheater = ''\nexport const nrkMediaTilgjengelighetGeoblocked = ''\nexport const nrkMediaTilgjengelighetIkkelengertilgjengelig = ''\nexport const nrkMediaTilgjengelighetKommer = ''\nexport const nrkMediaVolume1 = ''\nexport const nrkMediaVolume2 = ''\nexport const nrkMediaVolume3 = ''\nexport const nrkMediaVolumeMuted = ''\nexport const nrkMening = ''\nexport const nrkMinus = ''\nexport const nrkMoreActive = ''\nexport const nrkMore = ''\nexport const nrkNote1Off = ''\nexport const nrkNote1 = ''\nexport const nrkNote2 = ''\nexport const nrkOffline = ''\nexport const nrkOpenInNew = ''\nexport const nrkPerson = ''\nexport const nrkPlus = ''\nexport const nrkPoll = ''\nexport const nrkReload = ''\nexport const nrkReorder = ''\nexport const nrkSearchActive = ''\nexport const nrkSearch = ''\nexport const nrkSettingsActive = ''\nexport const nrkSettings = ''\nexport const nrkSomeEmail = ''\nexport const nrkSomeEmbed = ''\nexport const nrkSomeFacebook = ''\nexport const nrkSomeGoogle = ''\nexport const nrkSomeInstagram = ''\nexport const nrkSomePinterest = ''\nexport const nrkSomeShareIos = ''\nexport const nrkSomeShare = ''\nexport const nrkSomeSnapchat = ''\nexport const nrkSomeTommelnedActive = ''\nexport const nrkSomeTommelned = ''\nexport const nrkSomeTommeloppActive = ''\nexport const nrkSomeTommelopp = ''\nexport const nrkSomeTwitter = ''\nexport const nrkSomeYoutube = ''\nexport const nrkSpinner = ''\nexport const nrkStarActive = ''\nexport const nrkStar = ''\nexport const nrkTilgjengelighetHorbarhet = ''\nexport const nrkTilgjengelighetLydtekst = ''\nexport const nrkTilgjengelighetSynstolking = ''\nexport const nrkTilgjengelighetTegnspraak = ''\nexport const nrkTilgjengelighet = ''\nexport const nrkTrashActive = ''\nexport const nrkTrash = ''\nexport const nrkUpload = ''\nexport const nrkUserLoggedinActive = ''\nexport const nrkUserLoggedin = ''\nexport const nrkUserNotloggedinActive = ''\nexport const nrkUserNotloggedin = ''\nexport const nrkWarning = ''","/**\n * Connect takes a callback that will be called after retrieving the users session\n * @example\n * connect((user, session) => {\n * if (user) {\n * console.log(`${user.name} is logged in`)\n * } else {\n * session.login({abortPath: '%2Fminside'})\n * }\n * })\n */\nexport function connect(callback) {\n const key = 'onLoginReady';\n // Add callback queue placeholder if needed\n if (window[key] === undefined) {\n window[key] = function () {\n (window[key].q = window[key].q || []).push(arguments);\n };\n }\n\n // load script if needed\n loadOnce('/logginn.js');\n\n // add callback\n window[key](callback);\n}\n\n/**\n * loadOnce loads the given script IFF it is not already present in the DOM.\n * @param {string} src URL for script\n * @returns {undefined}\n */\nfunction loadOnce(src) {\n const hasScript = document.querySelector(`script[src=\"${src}\"]`);\n\n if (hasScript) {\n return;\n }\n\n const script = document.createElement('script');\n script.async = true;\n script.src = src;\n\n document.head.appendChild(script);\n}\n","import { nrkClose } from '@nrk/core-icons';\n\nexport function initializeLoginBanner(window, userName, showCookieBanner) {\n const canReplaceState = window.history && window.history.replaceState\n const loginBanner = document.body.insertAdjacentElement('afterbegin', document.createElement('div'))\n\n loginBanner.className = 'nrk-masthead__info-banner nrk-masthead__info-banner--login'\n if (showCookieBanner) {\n loginBanner.style = 'display: none;'\n }\n loginBanner.innerHTML = `Hei, du er nå logget på NRK.no fordi du allerede er logget på med din NRK-profil på denne enheten`\n loginBanner\n .querySelector('button')\n .addEventListener('click', () => loginBanner.parentElement.removeChild(loginBanner))\n loginBanner.querySelector('.nrk-masthead__semibold').textContent = `Hei ${userName}` // Use textContent for security\n\n if (canReplaceState) {\n const href = window.location.href.replace(/autoLogin=true&?/, '').replace(/[?|&]$/, '')\n window.history.replaceState(window.history.state, document.title, href)\n }\n}\n\n\n\nexport function initializeCookieBanner(cookieName) {\n const cookieDialog = document.body.insertAdjacentElement('afterbegin', document.createElement('div'))\n\n cookieDialog.className = 'nrk-masthead__info-banner nrk-masthead__info-banner--cookie'\n cookieDialog.innerHTML = `Vi bruker informasjonskapsler for å forbedre brukeropplevelsen. Besøk vår informasjonsside for mer detaljer, eller finn lenken i bunnen av NRK.no.`\n cookieDialog.querySelector('button').addEventListener('click', () => {\n cookieDialog.parentElement.removeChild(cookieDialog)\n const loginBanner = document.querySelector('.nrk-masthead__info-banner--login')\n if (loginBanner) {\n loginBanner.removeAttribute('style')\n }\n const expirationDate = new Date()\n expirationDate.setTime(expirationDate.getTime() + 1000 * 24 * 60 * 60 * 1000)\n document.cookie = `${cookieName}=1; expires=${expirationDate.toUTCString()}; path=/;`\n })\n}\n\nwindow.initializeCookieBanner = initializeCookieBanner;\n\nwindow.initializeLoginBanner = initializeLoginBanner;","import coreToggle from '@nrk/core-toggle'\nimport { nrkUserLoggedin } from '@nrk/core-icons'\nimport { connect } from '@nrk/nrkno-login-connector'\nimport { initializeCookieBanner, initializeLoginBanner } from './nrkno-masthead-banners'\n\nexport function initialize() {\n if (typeof document === 'undefined') return\n registerMBLScript()\n\n coreToggle('.nrk-masthead__bars, .nrk-masthead__more', { popup: true })\n\n const loginLinks = document.querySelectorAll('.nrk-masthead__user a')\n const loginLinksArray = Array.from(loginLinks)\n\n const cookieInfoCookieName = 'nrkno-cookie-information'\n const darkmodeCookieName = 'nrkno-darkmode'\n const allCookies = document.cookie.split(';')\n\n const isApp = window.location.search.indexOf('header=off') > 0\n let showCookieBanner = isApp ? false : true\n allCookies.forEach((cookie) => {\n if (cookie.trim().substring(0, cookieInfoCookieName.length) === cookieInfoCookieName) {\n showCookieBanner = false\n }\n if (cookie.trim().substring(0, darkmodeCookieName.length) === darkmodeCookieName) {\n handleDarkmodeCookie(cookie)\n }\n })\n\n if (loginLinksArray && loginLinksArray.length > 0) {\n connect((user) => {\n if (user) {\n loginLinksArray.forEach((loginLink) => {\n loginLink.href = 'https://www.nrk.no/minside'\n const span = document.createElement('span')\n span.textContent = user.name\n loginLink.innerHTML = nrkUserLoggedin\n loginLink.appendChild(span)\n })\n const isAutoLogin = window.location.search.indexOf('autoLogin=true') >= 0\n\n if (isAutoLogin) {\n initializeLoginBanner(window, user.name, showCookieBanner)\n }\n }\n loginLinksArray.forEach((loginLink) => {\n loginLink.removeAttribute('hidden')\n })\n })\n }\n\n if (showCookieBanner) {\n initializeCookieBanner(cookieInfoCookieName)\n }\n\n handleJumpToContent()\n}\n/**\n * Find, if any, the disabled jumpAnchor and \"enable\" it.\n */\nfunction handleJumpToContent() {\n const jumpAnchor = document.querySelector('#nrk-masthead__jump-anchor[class~=\"nrk-masthead__jump-anchor--disabled\"]')\n\n if (!jumpAnchor) {\n return\n }\n\n const mainElement = getMainElement()\n if (!mainElement) {\n // retry incase dom not loaded yet\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', handleJumpToContent)\n }\n return\n }\n\n if (!mainElement.id) {\n mainElement.id = 'innhold'\n }\n\n jumpAnchor.setAttribute('href', `#${mainElement.id}`)\n jumpAnchor.classList.remove('nrk-masthead__jump-anchor--disabled')\n jumpAnchor.classList.add('nrk-masthead__jump-anchor--enabled')\n // no-op if listener has not been added\n document.removeEventListener('DOMContentLoaded', handleJumpToContent)\n}\n\n/**\n * @returns {Element | undefined} the `main` element or the _best-effort_ main element.\n */\nfunction getMainElement() {\n const mainElement = document.querySelector('main, [role=\"main\"], #innhold')\n\n if (mainElement) {\n return mainElement\n }\n\n const bestEffortMainElement = document.querySelector('nrkno-player, article a, a > figure')\n\n if (!bestEffortMainElement) {\n return\n }\n\n if (bestEffortMainElement.tagName === 'FIGURE') {\n // return the parent/`a` tag\n return bestEffortMainElement.parentElement\n }\n\n return bestEffortMainElement\n}\n\n// Appends MBL Script to so that page views are tracked\nfunction registerMBLScript() {\n const mblScript = document.createElement('script')\n mblScript.type = 'text/javascript'\n mblScript.src = 'https://log.medietall.no/analytics.js'\n mblScript.async = true\n\n document.head.appendChild(mblScript)\n}\n\n// Check for darkmode cookie and set correct html-class\nfunction handleDarkmodeCookie (cookie) {\n const value = cookie.substring(cookie.indexOf('=') + 1)\n // If darkmode cookie is \"on\", or if it's \"auto\" and the use has darkmode preference set in the OS/browser\n const prefersDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;\n if (value && (value === 'on' || (value === 'auto' && prefersDarkMode))) {\n if (!document.documentElement.className.includes('darkmode')) {\n document.documentElement.classList.add('darkmode')\n }\n // NTB Livesport sets darkmode differently:\n const dataTheme = document.documentElement.getAttribute('data-theme')\n if (dataTheme && dataTheme === 'light') {\n document.documentElement.setAttribute('data-theme', 'dark')\n document.documentElement.style.colorScheme = 'dark'\n }\n }\n}\n","import {\n nrkLogoNrk,\n nrkChevronDown,\n nrkUserNotloggedin,\n nrkSearch\n} from '@nrk/core-icons'\n\n/**\n * @typedef {Object} MastheadOptions\n * @property {boolean} [dark=false]\n * @property {boolean} [login=true]\n * @property {boolean} [search=true]\n * @property {boolean} [minimal=false]\n * @property {string} [nonce]\n * @property {JumpAnchorManualOptions | JumpAnchorAutoOptions | false} [jumpAnchor=false]\n */\n\n/**\n * @typedef {Object} JumpAnchorAutoOptions\n * @property {'auto'} strategy\n * @property {never} [jumpToId='']\n */\n\n/**\n * @typedef {Object} JumpAnchorManualOptions\n * @property {'manual'} strategy\n * @property {`#${string}`} jumpToId MUST include `#`\n */\n\n/**\n * Masthead\n * @param {MastheadOptions} [options]\n * @returns {string} raw html markup\n */\nexport function Masthead (options) {\n const { dark = false, login = true, search = true, minimal = false, jumpAnchor = false } = options || {}\n\n let hideMasthead = false\n let isFrontPage = false\n\n if (typeof window !== 'undefined') {\n const searchParams = new URLSearchParams(window.location.search)\n isFrontPage = window.location.origin === 'https://www.nrk.no' && window.location.pathname === '/'\n const headerParam = searchParams.get('header')\n hideMasthead = headerParam === 'off'\n }\n\n return /*html*/ `
\n ${getJumpAnchor(jumpAnchor)}\n \n
\n ${nrkLogoNrk}\n
\n
\n \n\n \n ${\n login\n ? `
\n \n
`\n : ''\n }\n \n
`\n}\n\n/**\n * Returns a jump to content anchor.\n * Note that strategy `auto` requires JavaScript.\n * @param {JumpAnchorManualOptions | JumpAnchorAutoOptions | false} options\n * @returns {string}\n */\nfunction getJumpAnchor (options) {\n if (!options) {\n return ''\n }\n\n if (options.strategy === 'auto') {\n return 'Hopp til innhold'\n }\n\n return `Hopp til innhold`\n}\n"],"names":["IS_BROWSER","window","IS_ANDROID","test","navigator","userAgent","IS_IOS","String","platform","HAS_EVENT_OPTIONS","has","addEventListener","passive","e","addEvent","uuid","type","handler","options","Boolean","capture","document","IGNORE","dispatchEvent","element","name","detail","event","ignore","CustomEvent","bubbles","cancelable","createEvent","initCustomEvent","result","getUUID","el","Date","now","toString","Math","random","slice","queryAll","elements","context","nodeType","call","querySelectorAll","length","UUID","replace","ARIA","KEYS","getContentElement","toggle","getElementById","getAttribute","nextElementSibling","setOpen","open","content","isOpen","willOpen","nextOpen","relatedTarget","focus","querySelector","setTimeout","setAttribute","keyCode","target","parentElement","id","preventDefault","ref","defaultPrevented","item","nodeName","hasAttribute","currentTarget","value","textContent","trim","forEach","popup","contains","coreToggle_cjs","toggles","documentElement","style","cursor","map","hasOwnProperty","innerHTML","nrkClose","nrkUserNotloggedin","connect","callback","const","key","undefined","q","push","arguments","src","script","createElement","async","head","appendChild","loadOnce","initializeLoginBanner","userName","showCookieBanner","canReplaceState","history","replaceState","loginBanner","body","insertAdjacentElement","className","removeChild","href","location","state","title","initializeCookieBanner","cookieName","cookieDialog","removeAttribute","expirationDate","setTime","getTime","cookie","toUTCString","handleJumpToContent","jumpAnchor","mainElement","bestEffortMainElement","tagName","getMainElement","classList","remove","add","removeEventListener","readyState","dark","login","search","minimal","let","hideMasthead","isFrontPage","searchParams","URLSearchParams","origin","pathname","get","strategy","mblScript","coreToggle","loginLinks","loginLinksArray","Array","from","cookieInfoCookieName","darkmodeCookieName","allCookies","split","indexOf","substring","prefersDarkMode","matchMedia","matches","includes","dataTheme","colorScheme","handleDarkmodeCookie","user","loginLink","span"],"mappings":"iDAEA,IAGIA,EAA+B,oBAAXC,OACpBC,EAAaF,GAAc,aAAaG,KAAKC,UAAUC,WACvDC,EAASN,GAAc,mBAAmBG,KAAKI,OAAOH,UAAUI,WAChEC,EAAoB,SAAWC,QACpB,IAARA,IAAiBA,GAAM,GAE5B,IAAMT,OAAOU,iBAAiB,OAAQ,KAAM,CAAMC,cAAaF,GAAM,CAAO,GAAM,CAAC,MAAOG,GAAK,CAC/F,OAAOH,CACR,CALuB,GAcxB,SAASI,EAAUC,EAAMC,EAAMC,EAASC,SACrB,IAAZA,IAAqBA,GAAU,GAEd,oBAAXjB,QAA0BA,OAAOc,EAAOA,EAAO,IAAMC,MAC3DP,GAAwC,iBAAZS,IAAwBA,EAAUC,QAAQD,EAAQE,WAC9D,WAATJ,GAA8B,SAATA,EAAmBf,OAASoB,UACxDV,iBAAiBV,OAAOc,GAAQC,EAAMC,EAASC,GACtD,CASA,IAAII,EAAS,+CACb,SAASC,EAAeC,EAASC,EAAMC,QACrB,IAAXA,IAAoBA,EAAS,CAAE,GAEpC,IACIC,EADAC,EAAS,GAAKN,EAASG,EAG3B,GAAID,EAAQI,GAAW,OAAO,EACvBJ,EAAQI,IAAU,EAES,mBAAvB3B,OAAO4B,YAChBF,EAAQ,IAAI1B,OAAO4B,YAAYJ,EAAM,CAAEK,SAAS,EAAMC,YAAY,EAAML,OAAQA,KAEhFC,EAAQN,SAASW,YAAY,gBACvBC,gBAAgBR,GAAM,GAAM,EAAMC,GAI1C,IAAIQ,EAASV,EAAQD,cAAcI,GAGnC,OAFAH,EAAQI,GAAU,KAEXM,CACT,CAMA,SAASC,EAASC,GAChB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